industry/foc: force angle observers output to zero if motor stopped

this prevents junk data from the observer when the motor is stopped
This commit is contained in:
raiden00pl 2023-10-10 13:15:49 +02:00 committed by Alan Carvalho de Assis
parent fe7f217497
commit 768d5b29f1
4 changed files with 36 additions and 0 deletions

View File

@ -281,6 +281,15 @@ static int foc_angle_onfo_run_b16(FAR foc_angle_b16_t *h,
DEBUGASSERT(h->data);
ob = h->data;
if (in->vel == 0)
{
/* Do nothing if motor stopped */
out->type = FOC_ANGLE_TYPE_ELE;
out->angle = 0;
return OK;
}
/* Normalize the d-q voltage to get the d-q modulation
* voltage
*/

View File

@ -268,6 +268,15 @@ static int foc_angle_osmo_run_b16(FAR foc_angle_b16_t *h,
DEBUGASSERT(h->data);
ob = h->data;
if (in->vel == 0)
{
/* Do nothing if motor stopped */
out->type = FOC_ANGLE_TYPE_ELE;
out->angle = 0;
return OK;
}
/* Update observer */
motor_aobserver_smo_b16(&ob->o, &in->state->iab, &in->state->vab,

View File

@ -280,6 +280,15 @@ static int foc_angle_onfo_run_f32(FAR foc_angle_f32_t *h,
DEBUGASSERT(h->data);
ob = h->data;
if (in->vel == 0.0f)
{
/* Do nothing if motor stopped */
out->type = FOC_ANGLE_TYPE_ELE;
out->angle = 0.0f;
return OK;
}
/* Normalize the d-q voltage to get the d-q modulation voltage */
v_dq_mod.d = in->state->vdq.d * in->state->mod_scale;

View File

@ -268,6 +268,15 @@ static int foc_angle_osmo_run_f32(FAR foc_angle_f32_t *h,
DEBUGASSERT(h->data);
ob = h->data;
if (in->vel == 0.0f)
{
/* Do nothing if motor stopped */
out->type = FOC_ANGLE_TYPE_ELE;
out->angle = 0.0f;
return OK;
}
/* Update observer */
motor_aobserver_smo(&ob->o, &in->state->iab, &in->state->vab,