Skip to content
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

Motor goes alone fixes #106

Merged
merged 4 commits into from
Aug 9, 2024
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
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