Skip to content

Commit

Permalink
Merge pull request emmebrusa#106 from dzid26/goes_alone
Browse files Browse the repository at this point in the history
Motor goes alone fixes
  • Loading branch information
emmebrusa authored Aug 9, 2024
2 parents ac89880 + b1cc802 commit cb44428
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "STM8 Build & Flash",
"preLaunchTask": "Build & Flash",
"postDebugTask": "OpenOCD reset target",
"name": "STM8-gdb",
"request": "launch",
Expand Down
7 changes: 4 additions & 3 deletions src/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
// - ramp up/down PWM duty_cycle and/or field weakening angle value

// check if to decrease, increase or maintain duty cycle
if ((ui8_g_duty_cycle > ui8_controller_duty_cycle_target)
|| (ui8_adc_battery_current_filtered > ui8_controller_adc_battery_current_target)
if ( (ui8_controller_duty_cycle_target < ui8_g_duty_cycle)
|| (ui8_controller_adc_battery_current_target < ui8_adc_battery_current_filtered)
|| (ui8_adc_motor_phase_current > ui8_adc_motor_phase_current_max)
|| (ui16_hall_counter_total < (HALL_COUNTER_FREQ / MOTOR_OVER_SPEED_ERPS))
|| (ui16_adc_voltage < ui16_adc_voltage_cut_off)
Expand All @@ -817,7 +817,8 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
}
}
}
else if (ui8_g_duty_cycle < ui8_controller_duty_cycle_target) {
else if ((ui8_controller_duty_cycle_target > ui8_g_duty_cycle)
&& (ui8_controller_adc_battery_current_target > ui8_adc_battery_current_filtered)) {
// reset duty cycle ramp down counter (filter)
ui8_counter_duty_cycle_ramp_down = 0;

Expand Down

0 comments on commit cb44428

Please sign in to comment.