-
Notifications
You must be signed in to change notification settings - Fork 34
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
Cut PWM above speed limit (fixes E09) #104
Conversation
That's right, duty cycle goes to zero at the end of the deceleration ramp. |
I see. I didn't think this would be an issue, as at high speed the ramp is typically fast
Let me split the second PR, because it might be relevant to the change you want to make in "moto goes alone" logic. |
I saw that you prefer the deceleration ramp to 100%, I thought so too, then I changed my mind. |
Yes, I definitely I want the torque be reduced together with pedal torque. This is crucial on technical climbs, when a bit too much torque lifts up the front wheel and you need quick reaction to respond to that. I fell into spiky bushes before because of shmitt trigger filtering and bike was pushing forward a little too long and I went out of balance . :D But as I said, around the speed limit, the ramp will be usually 100% anyway for you too, due to speed mapping TSDZ2-Smart-EBike-1/src/ebike_app.c Lines 637 to 641 in ad782fd
So I don't think it would be noticeable to set the PWM to zero. Later we can add proper time based current target ramping. |
I was wrong. The speed limit is not abrupt. For now I removed map function optimizations. I will add it in a separate PR. |
88f2797
to
da4d918
Compare
Without it pwm is set high by one of the assist function leading to diagnostic errors. Use 8bit addition and multiplication.
…for inverted range similar to map_ui8, map_ui8/16, fix div by zero edge case map_ui16: uint16 argument types, Tests - hypothesis framework, covers whole range of values (cherry picked from commit 3f2058d)
Ok, so I used that change for some time now. I used it together with the interpolation ( Without map fixes it probably would work too, but unit tests show precision issues against floating point calculation: In any case, again, I don't see a reason not to implement this change:.
|
I was thinking about releasing a beta with the E09 fix, but every time I looked at your pull requests I found something changed, and this confused me and made me wait.
Looking at the code changes they seem ok, can you confirm that it is ok? |
|
I was suspecting the issue was E09 instead of E07 lately. After using your last change 81b813c I was indeed getting the E09 error.
After adding this modification, E07/E09 errors didn't appear.
The change should be done regardless of the errors anyway.
Rationale:
Speed limit function doesn't limit the PWM
ui8_duty_cycle_target
. (The PWM is actually set to max value by the assist function during speed limitation.)I think, as result, motor is not disabled and the only thing stopping the duty cycle from being increased is
ui8_adc_battery_current_filtered > ui8_controller_adc_battery_current_target
in motor.c. Whenever the current is 0, the pwm will be increased until the current is non-zero. During that time, the motor can accelerate a little bit and triggerERROR_MOTOR_CHECK
, notERROR_BATTERY_OVERCURRENT
.