Skip to content

Ignore singleshot hall signal error #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions tfrog-motordriver/controlPWM.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,11 @@ void FIQ_PWMPeriod()
//if( halldiff == 3 || halldiff >= 5 ) printf( "ENC error: %x->%x\n\r", _hall[i], hall[i] );
// ホール素子信号が全相1、全相0のとき
// ホース素子信号が2ビット以上変化したときはエラー
if (driver_state.error.hall[i] < 128)

// Skip next one error to avoid counting another edge of this error.
if (driver_state.error.hall[i] < 12)
driver_state.error.hall[i] += 12;

if (driver_state.error.hall[i] > 12)
{
// エラー検出後、1周以内に再度エラーがあれば停止
Expand Down Expand Up @@ -538,8 +541,23 @@ void FIQ_PWMPeriod()
// In worst case, initial encoder origin can have offset of motor_param[i].enc_rev/12.
if (_abs(err) > motor_param[i].enc_rev / 6)
{
motor[i].error_state |= ERROR_HALL_ENC;
printf("PWM:enc-hall err (%d)\n\r", err);
// Skip next one error to avoid counting another edge of this error.
if (driver_state.error.hallenc[i] < 12)
driver_state.error.hallenc[i] += 12;

if (driver_state.error.hallenc[i] > 12)
{
// Enter error stop mode if another error occurs within one revolution
motor[i].error_state |= ERROR_HALL_ENC;
printf("PWM:enc-hall err (%d)\n\r", err);
}
// Don't apply erroneous absolute angle
continue;
}
else
{
if (driver_state.error.hallenc[i] > 0)
driver_state.error.hallenc[i]--;
}
}

Expand Down
1 change: 1 addition & 0 deletions tfrog-motordriver/controlVelocity.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ typedef struct _DriverState
{
unsigned char low_voltage;
unsigned char hall[2];
unsigned char hallenc[2];
} error;
enum
{
Expand Down
6 changes: 6 additions & 0 deletions tfrog-motordriver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ int main()
driver_state.error.low_voltage = 0;
driver_state.error.hall[0] = 0;
driver_state.error.hall[1] = 0;
driver_state.error.hallenc[0] = 0;
driver_state.error.hallenc[1] = 0;

printf("Velocity Control init\n\r");
// Configure velocity control loop
Expand Down Expand Up @@ -704,6 +706,8 @@ int main()
driver_state.error.low_voltage = 0;
driver_state.error.hall[0] = 0;
driver_state.error.hall[1] = 0;
driver_state.error.hallenc[0] = 0;
driver_state.error.hallenc[1] = 0;
driver_state.ifmode = 0;
driver_state.watchdog = 0;
// Driver loop
Expand Down Expand Up @@ -761,6 +765,8 @@ int main()
}
driver_state.error.hall[0] = 0;
driver_state.error.hall[1] = 0;
driver_state.error.hallenc[0] = 0;
driver_state.error.hallenc[1] = 0;
motor[0].error_state |= ERROR_WATCHDOG;
motor[1].error_state |= ERROR_WATCHDOG;
printf("Watchdog - init parameters\n\r");
Expand Down