From eeacbdde3a1d648c89a49ce3e7b821dda7ce268e Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Wed, 8 Nov 2023 18:42:33 +0100 Subject: [PATCH] examples/foc: get velocity from observer if sensored mode --- examples/foc/foc_motor_b16.c | 6 +++++- examples/foc/foc_motor_f32.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c index 8bc0f5173..dcfe80b0a 100644 --- a/examples/foc/foc_motor_b16.c +++ b/examples/foc/foc_motor_b16.c @@ -1230,7 +1230,7 @@ static int foc_motor_vel_get(FAR struct foc_motor_b16_s *motor) UNUSED(vout); motor->vel_el = motor->vel.set; -#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) +#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) && defined(CONFIG_EXAMPLES_FOC_SENSORLESS) if (motor->openloop_now == FOC_OPENLOOP_DISABLED) { /* Get electrical velocity from observer if we are in closed-loop */ @@ -1243,6 +1243,10 @@ static int foc_motor_vel_get(FAR struct foc_motor_b16_s *motor) motor->vel_el = motor->vel.set; } +#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) && defined(CONFIG_EXAMPLES_FOC_SENSORED) + /* Get electrical velocity from observer in sensored mode */ + + motor->vel_el = motor->vel_obs; #else /* Need electrical velocity source here - raise assertion */ diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c index 11fd3d6eb..11b816ffb 100644 --- a/examples/foc/foc_motor_f32.c +++ b/examples/foc/foc_motor_f32.c @@ -1217,7 +1217,7 @@ static int foc_motor_vel_get(FAR struct foc_motor_f32_s *motor) UNUSED(vout); motor->vel_el = motor->vel.set; -#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) +#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) && defined(CONFIG_EXAMPLES_FOC_SENSORLESS) if (motor->openloop_now == FOC_OPENLOOP_DISABLED) { /* Get electrical velocity from observer if we are in closed-loop */ @@ -1230,6 +1230,10 @@ static int foc_motor_vel_get(FAR struct foc_motor_f32_s *motor) motor->vel_el = motor->vel.set; } +#elif defined(CONFIG_EXAMPLES_FOC_VELOBS) && defined(CONFIG_EXAMPLES_FOC_SENSORED) + /* Get electrical velocity from observer in sensored mode */ + + motor->vel_el = motor->vel_obs; #else /* Need electrical velocity source here - raise assertion */