Skip to content

Commit e1d5476

Browse files
author
jenkie
committed
Modified speed calculation for slow speeds
Calculates the upper limit of the speed based on the time elapsed since the last speed_change event. If this upper limit is slower than the last real measurement, this slower speed is used.
1 parent e7b52ed commit e1d5476

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ void loop()
635635
spd=1;
636636
}
637637

638+
//live speed update when there is no speed_change interrupt-----------------------------------------------------------------
639+
long wheeltime_temp=(millis()-last_wheel_time)*wheel_magnets; //current upper limit of the speed based on last measurement
640+
if (wheeltime_temp>wheel_time) //is current upper limit slower than last real measurement?
641+
spd = 3600*wheel_circumference/wheeltime_temp;
642+
638643
//Power control-------------------------------------------------------------------------------------------------------------
639644
power_throttle = throttle_stat / 1023.0 * curr_power_max; //power currently set by throttle
640645

0 commit comments

Comments
 (0)