maximusdm said:
Hi mbrusa,
I plan to add the overrun fix to the LCD3 version.
LE: I noticed in lcd3 thread taht you already did it

. But my question still stands.
I noticed that in case of STANDARD_MODE there is
Code:
// for overrun problem
ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 4));
and in case of ADVANCED_MODE there is
Code:
// for overrun problem
ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 2));
Can you please explain?
Thanks,
Max.
Hi maximusdm
If you only ask this question I think you understand the rest of the change.
Synthesizing.
To minimize the overrun time I had to add another control method for stationary pedals, and above all I had to put all the code in motor.c inside the PWM cycle function that runs every 64us (first, part of the code was in ebike_app.c which runs every 0.1 sec).
"ui16_cadence_sensor_ticks" is the number of pulses, at the PWM frequency, between one step of the cadence sensor and the next, and is inversely proportional to the speed.
"ui16_cadence_sensor_ticks_counter" is the counter of these impulses, when the pedal stops the counter does not immediately reset, continues to count.
When it reaches the value of "ui16_cadence_sensor_ticks_stop" the padals are considered stationary.
"ui16_cadence_sensor_ticks_stop" is calculated with the last valid value of "ui16_cadence_sensor_ticks" by adding an extra number of pulses.
To establish how proportionally the number of extra pulses must be, I have not made any calculations, I have obtained the optimal values experimentally.
Optimal value detected in standard mode
"ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 4));"
equivalent to (ui16_cadence_sensor_ticks * 1.06)
Optimal value detected in advanced mode
"ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 2));"
equivalent to (ui16_cadence_sensor_ticks * 1.25)
The calculation factor of the extra pulses is different in the two modes because the value of "ui16_cadence_sensor_ticks" is different, at the same speed, in advanced mode it is on average the half of the standard one.
I want to highlight that by increasing the calculated value of "ui16_cadence_sensor_ticks_stop", increases the overrun time, decreasing it lacks startup assistance.
I had reports of too fast stops and a case of lack startup assistance.
For this reason, in the next full version I will slightly increase the calculated values.
"ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 3)));" in standard mode,
"ui16_cadence_sensor_ticks_stop = (ui16_cadence_sensor_ticks + (ui16_cadence_sensor_ticks >> 1));" in advanced mode,
or maybe I'll add editable parameters in the config.h file.