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 Oct 27, 2023
1 parent cf69065 commit 24fe1ba
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 @@ -893,6 +893,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 @@ -944,6 +948,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 24fe1ba

Please sign in to comment.