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 ¨startup¨ delay/lag at medium/high pedal cadence #9
Comments
checked the code again maybe the problem is in this piece of code _ui8_pas_cadence_rpm = ui8_pas_cadence_rpm; |
Thanks! Maybe it's best if you start with a clear description of the problem first. This way it will be easier to fix and verify if it's fixed too. I'll look into this when the changes from the improve_power branch are merged into master. |
It must be the 2 second lag. As I mentioned in the post there is hardly any lag when you begin to peddle from stop which means the cadence measurement is almost instant. |
Thanks. I think we can remove this. Measurement isn't the problem and it's plenty fast enough. From a safety point of view I think something like this is only needed from a stop. The bug could be related to the boost feature. |
Since I remember, that lag/delay works as a hysteresis and I think is needed (that is why I implemented like that). If we stop pedaling, makes sense that at least we stop for at least a minimum amount of time - if 2 seconds is to much, I think we can reduce maybe for 1 second. See here about hysteresis: |
casainho. i will try to compile the code by myself and see what different STATE_STARTUP_PEDALLING timings will change and report back. however i cant find a location where can i download the 0.12 src files... |
i reviewed the torque_sensor_read() again. |
I'm worried about removing lines of code without e-brakes. EDIT 16/10 |
the problem is that torque_sensor_read will return in every state torque sensor is set to ui8_torque_sensor_raw i think i would make sense to have the security logic in the torque_sensor_read () function and use only ui8_torque_sensor in the ebike_control_motor function. i did some changes yesterday. ui8_state_machine is never used for power reasons... |
Thanks! I appreciate your help! I agree that it's quite a mess. We should also pass variables to functions instead of having all global variables which can become confusing. See the improve_power branch where I already did some organizing of the code. |
i would remove all that extra code from torque_sensor_read and cadence read and have one gloabal security function called at the the end of ebike_control_motor before motor_set_pwm_duty_cycle_target . this checks like brake set, speed, cadence checks torque sensor. at the moment these security checks are all over the place. if you want i can go over it when 0.14 is released. |
Sure! Let's do this together when 0.14 is released which also includes some restructuring. Keep in mind that we need to test this thoroughly and we should ask beta testers when possible, especially for these kind of security changes. At this moment I focus on stabilizing and restructuring the firmware instead of new features. There are still quite a few bugs... |
good plan. |
I'm so excited for this bug to be fixed/minimized. Due to my riding style, it's almost made me switch to the original + LCD3. |
casainho wrote: ↑Thu Oct 25, 2018 3:26 am For the ones that are interested in helping solve this issue, please help by looking at the following values on LCD3: The idea is to see how that values changes when the issue happen, like stop pedaling and then pedal again and look at that values. How do they change when the issue happen? |
jbalat wrote: ↑ This brings me to my next idea. |
casainho wrote: ↑ I got the same feeling as you on my tests. First, looking at firmware I don´t see a reason for a delay (except the one I will mention). On hardware, there is a delay for the torque sensor signal, that seems to be low pass filtered quite a bit (compared to other torque sensor I worked with) - this delays happen when increasing or decreasing (when start pedaling AND when stop pedaling).
What I think is happening is that motor takes time (delay) to increase from 0 speed to final speed that will equal to the rider actual cadence/wheel speed. The higher the ebike speed on 1., the longer the time (delay) the electric motor will take to achieve the final speed. Can we increase the motor speed acceleration to try reduce that delay? // *************************************************************************** // // Choose PWM ramp up/down step (higher value will make the motor acceleration slower) The brave ones can try to reduce the value of #define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 75 but be warned that faster motor acceleration/faster motor energy increase/faster motor torque increase may be harder for the system (motor controller, gears, battery, etc) and we don´t know what can go wrong!! |
I have been testing the new inverse ramp value of 25 and the lag is now greatly reduced. While this approach works I propose that we can apply a small amount of power at all times (say 20w) while the wheel speed is greater than zero. This will not only prevent lag since the motor will already be at speed when you start pedalling again but it should reduce backlash noise in the gears too. Whether we can use this to automatically assist the bike for walk mode is something that can also be investigated. |
Solved on 0.16. |
I checked the code and i think i found the problem for the lag.
Reproduce ->
pedalling -> then stop pedalling -> then pedalling again -> lag.... -> motor kicks in
i checked the code and i think i found the problem in: torque_sensor_read
if STATE_NO_PEDALLING and torque sensor > 0 the wheelspeed must also be checked,
so i should not do the 2 seconds STATE_STARTUP_PEDALLING when allready at speed.
when wheelspeed > X kmh instant change to STATE_PEDALLING
2 seconds lag is really too much.
hope you understand what i mean.
i marked the code changes in bold below
void torque_sensor_read (void)
{
// map value from 0 up to 255
// map value from 0 up to 255
ui8_torque_sensor_raw = (uint8_t) (map (
UI8_ADC_TORQUE_SENSOR,
(uint8_t) ui8_adc_torque_sensor_min_value,
(uint8_t) ui8_adc_torque_sensor_max_value,
(uint8_t) 0,
(uint8_t) 255));
switch (ui8_tstr_state_machine)
{
// ebike is stopped, wait for throttle signal
case STATE_NO_PEDALLING:
if ((ui8_torque_sensor_raw > 0) &&
(!brake_is_set()))
{
if(ui16_wheel_speed_x10 > 10){
ui8_tstr_state_machine = STATE_PEDALLING;
} else {
ui8_tstr_state_machine = STATE_STARTUP_PEDALLING;
}
break;
}
// bike is moving but user doesn't pedal, disable torque sensor signal because user can be resting the feet on the pedals
if ((ui8_tstr_state_machine == STATE_PEDALLING) && (ui8_pas_cadence_rpm == 0))
{
ui8_torque_sensor = 0;
}
else
{
ui8_torque_sensor = ui8_torque_sensor_raw;
}
}
The text was updated successfully, but these errors were encountered: