Skip to content

Commit fbe5af1

Browse files
authored
Fix static hall error detection condition (#108)
1 parent 8d52cfc commit fbe5af1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tfrog-motordriver/controlPWM.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ void FIQ_PWMPeriod()
427427
(hall[i] & 0x07) == 0)
428428
{
429429
// Stop motor control if static hall signal error is continued for more than 3 PWM cycle interrups.
430-
if (driver_state.error.hall[i] <= 12)
430+
if (driver_state.error.hall_static[i] <= 3)
431431
{
432-
driver_state.error.hall[i] += 6;
432+
driver_state.error.hall_static[i]++;
433433
}
434-
if (driver_state.error.hall[i] > 12)
434+
if (driver_state.error.hall_static[i] > 3)
435435
{
436436
if ((motor[i].error_state & ERROR_HALL_SEQ) == 0)
437437
{
@@ -441,6 +441,7 @@ void FIQ_PWMPeriod()
441441
}
442442
continue;
443443
}
444+
driver_state.error.hall_static[i] = 0;
444445

445446
u = v = w = 0;
446447
halldiff = (hall[i] ^ _hall[i]) & 0x07;

tfrog-motordriver/controlVelocity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ typedef struct _DriverState
168168
uint8_t low_voltage;
169169
uint8_t hall[2];
170170
uint8_t hallenc[2];
171+
uint8_t hall_static[2];
171172
} error;
172173
enum
173174
{

0 commit comments

Comments
 (0)