Skip to content

Commit

Permalink
Quicker speed decay when slowing down
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Nov 11, 2023
1 parent c49b0a5 commit ca636cf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/controller/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,10 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
// save current PAS state
ui8_pas_state_old = ui8_pas_state;
}
if (ui16_cadence_calc_counter > ui16_cadence_sensor_ticks) {
// next pulse later than previous - start decaying the speed
ui16_cadence_sensor_ticks = ui16_cadence_calc_counter;
}

if (++ui16_cadence_stop_counter > ui16_cadence_sensor_ticks_counter_min) {
// pedals stop detected
Expand Down Expand Up @@ -943,6 +947,10 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
}
}
}
if (ui16_wheel_speed_sensor_ticks_counter > ui16_wheel_speed_sensor_ticks) {
//strat decaying the speed if thte pulse is coming later than last time
ui16_wheel_speed_sensor_ticks = ui16_wheel_speed_sensor_ticks_counter;
}
}

// increment and also limit the ticks counter
Expand Down

0 comments on commit ca636cf

Please sign in to comment.