From baa23afbd39949f73d5b7c67686ff3cc9ca8f4dc Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 6 Oct 2023 13:10:39 +0200 Subject: [PATCH] industry/foc/openloop: don't use direction argument, instead use signed velocity otherwise, when dir=-1 and the velocity value is negative, the output from velocity is in the opposite direction than the intended one --- industry/foc/fixed16/foc_ang_openloop.c | 6 ++++-- industry/foc/float/foc_ang_openloop.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/industry/foc/fixed16/foc_ang_openloop.c b/industry/foc/fixed16/foc_ang_openloop.c index 64f8194b8..8744f2da5 100644 --- a/industry/foc/fixed16/foc_ang_openloop.c +++ b/industry/foc/fixed16/foc_ang_openloop.c @@ -258,9 +258,11 @@ static int foc_angle_ol_run_b16(FAR foc_angle_b16_t *h, DEBUGASSERT(h->data); ol = h->data; - /* Update open-loop */ + /* Update open-loop. + * NOTE: we don't use dir argument here, instead we use signed velocity. + */ - motor_openloop_b16(&ol->data, in->vel, in->dir); + motor_openloop_b16(&ol->data, in->vel, 1); tmp = motor_openloop_angle_get_b16(&ol->data); diff --git a/industry/foc/float/foc_ang_openloop.c b/industry/foc/float/foc_ang_openloop.c index 44122025a..d33f30169 100644 --- a/industry/foc/float/foc_ang_openloop.c +++ b/industry/foc/float/foc_ang_openloop.c @@ -259,9 +259,11 @@ static int foc_angle_ol_run_f32(FAR foc_angle_f32_t *h, DEBUGASSERT(h->data); ol = h->data; - /* Update open-loop */ + /* Update open-loop. + * NOTE: we don't use dir argument here, instead we use signed velocity. + */ - motor_openloop(&ol->data, in->vel, in->dir); + motor_openloop(&ol->data, in->vel, 1.0f); /* Get open-loop angle */