Skip to content

Commit 1c93b5a

Browse files
authored
Force using first one revolution of hall signal (#78)
1 parent 7af4ef3 commit 1c93b5a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tfrog-motordriver/controlPWM.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,19 @@ void FIQ_PWMPeriod()
621621
}
622622
}
623623

624-
// ホール素子は高速域では信頼できない
624+
hall_pos = hall_pos % ENC0_BUF_MAX;
625+
626+
// Rely hall signal only if the velocity is under the threshold.
627+
// Force using all measurement result if it is first time of measurement.
625628
if (_abs(motor[i].vel1) > motor_param[i].vel_rely_hall &&
626-
!saved_param.rely_hall)
629+
!saved_param.rely_hall &&
630+
motor[i].enc0_buf[hall_pos] != ENC0_BUF_UNKNOWN)
627631
continue;
628632

629633
// Compensate hall signal delay
630634
enc0 -= motor[i].vel1 * motor_param[i].hall_delay_factor / 32768;
631635

632636
// Fill enc0_buf and calculate average
633-
hall_pos = hall_pos % ENC0_BUF_MAX;
634637
motor[i].enc0_buf[hall_pos] = enc0;
635638
motor[i].enc0_buf_updated = 1;
636639
}

0 commit comments

Comments
 (0)