-
Notifications
You must be signed in to change notification settings - Fork 15
Walk assist mode #7
Comments
Not on/off because it is dangerous. |
I'm experimenting with this, it almost works already and it's quite easy to implement. But, how can I get the motor to run slow enough? It still feels too fast for my liking. @casainho do you have some good ideas? |
How are you implementing it?? I would try to use a PI controller as I did on KT motor controller Firmware -- see ebike_app.c file on that project: // PI controller for wheel speed |
Thanks! I experimented using the wheel speed but is it just me or is the wheel speed unreliable at these low speeds (6 km/h)? Will try the PI controller. |
Motor won't run using the code below. Also the case when I bypass the PI controller and just set a fixed duty cycle. Am I missing some kind of enable flag or state? What does the motor controller need exactly besides max_current and duty_cycle?
I've initialized the PI controller using the default parameters of main.h |
I think you need to use the PI controller output value!! The output should be the current value to after setup on ebike_app_set_target_adc_battery_max_current (). The idea is that you have as input the speed variable and the output the current value. See that you need to setup correctly the P and I coefficients. |
Thanks! I've experimented again tonight. I've tried your suggestion (using the current controller) before but decided to retry it tonight. Same issue unfortunately: the minimum current for ebike_app_set_target_adc_battery_max_current () is 1 right? With this value the motor and wheel is spinning way too fast. That's why I was experimenting with the duty cycle... Regarding the PI controller, isn't the update rate of 10Hz too slow? I'm calling the PI controller from the ebike_app which is called every 100 ms if I'm correct. Maybe we should move it to the motor controller (called every 4ms)? I also have my doubts about the implementation of the PI controller, there is no delta time factor and the resolution is quite low? Btw, I have a simple low pass filter (debounce) for walk assist implemented in the display, this allows a short interruption of the button down event. |
@casainho can you clarify on ebike_app_set_target_adc_battery_max_current () and how we can get a better resolution? |
// each 1 unit = 0.625 amps Better resolution would be to use ui8_adc_battery_current but with a 10 bits ADC resolution (see motor.c): I decided to use 8 bits because the STM8 is 8 bits and also when we loose resolution from 10 bits to 8 bits, we are low pass filtering, which I think is important because the raw 10 bits signal should be noisy. Maybe, the best option here is for you to control directly the target duty_cycle with motor_set_pwm_duty_cycle_target (255);. I would keep the code just the same but reduce target duty_cycle from 255, when I want a lower speed.... |
If that matters, I think the 6kmh walk assist of the original TSDZ2 firmware doesn't really care about the actual speed. So, maybe it would be an idea to implement it simply by a constant (maximum) motor rpm together with a very limited maximum power? |
At 6km/h, my 26 inchs wheel takes 1.24 seconds to make one rotation, which I think is slow as input variable to control. I think we can increase motor current/pwm duty-cycle and when wheel speed is equal or over 6km/h, we can store the motor speed value that equals to wheel speed of 6km/h (like 10km/h motor rotating at 100 erps, so (6 * 10) /100 = 60 erps, we would control the motor erps to be 60. And in fact, we already control motor max erps to be 525, so maybe we could change the motor max speed erps value to the lower value we need for walk assist and them the speed controller is already done?? |
No description provided.
The text was updated successfully, but these errors were encountered: