I really appreciate your work.jbalat said:Just some testing on the inverse ramp factor to reduce lag
[youtube]UXVxzXzJDbc[/youtube]
casainho said:I really appreciate your work.
After your notes and reports, I think I did learn a new things. First, I do not agree that we should just reduce the PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP, as I believe it should be worst for the gears and other mechanical parts.
I think it can be done like this:
1. we should implement a current ramp and not a duty_cycle ramp. I think now as duty_cycle representing motor rotor speed and the current representing the torque.
2. implement: current ramp AND PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP at a lower value maybe like 10
3. Let´s say we set our target current to 10 amps and the current ramp increases 1 amp per each 0.1 second, so after 1 second the motor ends at 10 amps but the current/torque stress on gears and mechanical parts increase with the ramp from 0 to 10 in 1 second.
4. At the first step on 0.1 second, the current ramp controller will set current to 1 amp and duty-cycle will jump very fast on that 0.1 second to get 1 amp and that should make motor rotate very fast to the desired final speed and engage the gears but using that low current... -- I think the result is what we all would like to have: fast response but not with an abrupt torque!!!
gaber said:How have you guys wired in your brake wires? I understand how to do it schematically (thanks to the wiki, but am curious where you’ve spliced them in and what kind of connectors. Looking to capitalize on the group think instead of reinventing the wheel.
casainho said:1. we should implement a current ramp and not a duty_cycle ramp.
uint32_t PI_control(uint16_t pv, uint16_t setpoint, uint8_t uint_PWM_Enable) {
float float_p;
static float float_i;
static float float_dc = 0;
float_p = ((float) setpoint - (float) pv) * flt_s_pid_gain_p;
float_i += ((float) setpoint - (float) pv) * flt_s_pid_gain_i;
if (float_i > 255)float_i = 255;
if (float_i < 0)float_i = 0;
if (float_p + float_i > float_dc + 5) {
float_dc += 5;
} else if (float_p + float_i < float_dc - 5) {
float_dc -= 5;
} else {
float_dc = float_p + float_i;
}
if (float_dc > 255)float_dc = 255;
if (float_dc < 0)float_dc = 0;
return ((uint32_t) (float_dc));
}
I am not a big fan of PI controllers, I prefer the ramp approach. If I find more value over ramp for PI, I will implement it. Do you know an advantage of using a PI controller (for this current controller) over a ramp?stancecoke said:Why don't you use a PI-controller for the battery current, like we do in the Kunteng project? With this you can adjust the response time very easily with the parameters Gain_P and Gain_I...casainho said:1. we should implement a current ramp and not a duty_cycle ramp.
Ah, I see. But I don´t like that approach having current controller on slow loop, I really prefer it on fast loop and on motor.c. Users are playing on ebike_app.c and that way are not making issues with the current controller, that I think otherwise would result in burned motor controllers.stancecoke said:With our experience, you don't need an extra control in the fast loop.
Fantastic! Keep up the good work! Sure I'll test and release it sooncasainho said:Assist level and start power boost now work as a factor of rider pedal human power
I implemented it and it is so nice to look at LCD3 and see the motor exactly assist you, for instance, 200% of your generated pedal human power, if you did set the assist level to 2.0.
On LCD3 odometer field you can now see:
1. pedal torque (in Nm);
2. pedal energy power (in Watts).
The 1. uses as input the force applied to the pedals (torque sensor signal) and 2. multiplies 1. to pedal cadence. Because of this, the startup power boost assist level scale factor uses 1. and regular assist level scale factor uses 2.
This code is available here: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/pull/47
Soon I hope that EndelessCadence can review/test it and make a new firmware release that includes some nice new developments!!
casainho said:But I don´t like that approach having current controller on slow loop
I prefer to have current controller on fast loop but it is not about speed. I remember from Dave Wilson videos that for industrial FOC motor control they do PI controller for current on the fast loop, so maybe 100x faster than what you are doing. But I think we do not need the so fast response from our motors (that is why our microcontrollers are so slow and cheap, could not do PI on fast loop) and so I decided to do fast/dirty/bitbang on fast loop instead of slow PI on slow loop.stancecoke said:Perhaps you can do a similar log with you implementation, to see if there is any difference in the lag between current target and recent current. My log is with 50Hz slow loop frequency.casainho said:But I don´t like that approach having current controller on slow loop
- odometer data were group on some logic groups
- now the odometer number os shown on wheel speed field, blinking for some seconds, everytime we change the odometer filed or subfield
- now we can use combination of click + long click for UP and DOWN buttons. This UP button combination on odometer field will cycle to next odometer sub field (that is shown as number on wheel speed field). The DOWN combination, at Total Trip Distance, after some seconds, will reset this value
casainho said:Assist level and start power boost now work as a factor of rider pedal human power
I implemented it and it is so nice to look at LCD3 and see the motor exactly assist you, for instance, 200% of your generated pedal human power, if you did set the assist level to 2.0.
On LCD3 odometer field you can now see:
1. pedal torque (in Nm);
2. pedal energy power (in Watts).
The 1. uses as input the force applied to the pedals (torque sensor signal) and 2. multiplies 1. to pedal cadence. Because of this, the startup power boost assist level scale factor uses 1. and regular assist level scale factor uses 2.
This code is available here: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/pull/47
Soon I hope that EndelessCadence can review/test it and make a new firmware release that includes some nice new developments!!
gaber said:How have you guys wired in your brake wires? I understand how to do it schematically (thanks to the wiki), but am curious where you’ve spliced them in and with what connectors. Looking to capitalize on the group think instead of reinventing the wheel.
gaber said:gaber said:How have you guys wired in your brake wires? I understand how to do it schematically (thanks to the wiki), but am curious where you’ve spliced them in and with what connectors. Looking to capitalize on the group think instead of reinventing the wheel.
Any input from you LCD3 ebrake users? I plan on finishing up my wiring this afternoon.
I'm planning to cut the VLCD5 display cable up near the cockpit and solder the (what will be short) male LCD3 connector to the VLCD5 connector cable.
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 20
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 20
// Target: ramp 5 amps per second
// every second has 15625 PWM cycles interrupts
// 1 ADC battery current step --> 0.625 amps
// 5 / 0.625 = 8 (we need to do 8 steps ramp up per second)
// 15625 / 8 = 1953
#define ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP 1953
/****************************************************************************/
// Implement ramp up ADC battery current
if (ui8_adc_target_battery_max_current > ui8_controller_adc_battery_max_current)
{
if (ui16_counter_adc_battery_current_ramp_up++ >= ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP)
{
ui16_counter_adc_battery_current_ramp_up = 0;
ui8_controller_adc_battery_max_current++;
}
}
else if (ui8_adc_target_battery_max_current < ui8_controller_adc_battery_max_current)
{
// we are not doing a ramp down here, just reducing to the target value
ui8_controller_adc_battery_max_current = ui8_adc_target_battery_max_current;
}
/****************************************************************************/
casainho said:I really appreciate your work.jbalat said:Just some testing on the inverse ramp factor to reduce lag
[youtube]UXVxzXzJDbc[/youtube]
After your notes and reports, I think I did learn a new things. First, I do not agree that we should just reduce the
PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP, as I believe it should be worst for the gears and other mechanical parts.
I think it can be done like this:
1. we should implement a current ramp and not a duty_cycle ramp. I think now as duty_cycle representing motor rotor speed and the current representing the torque.
2. implement: current ramp AND PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP at a lower value maybe like 10
3. Let´s say we set our target current to 10 amps and the current ramp increases 1 amp per each 0.1 second, so after 1 second the motor ends at 10 amps but the current/torque stress on gears and mechanical parts increase with the ramp from 0 to 10 in 1 second.
4. At the first step on 0.1 second, the current ramp controller will set current to 1 amp and duty-cycle will jump very fast on that 0.1 second to get 1 amp and that should make motor rotate very fast to the desired final speed and engage the gears but using that low current... -- I think the result is what we all would like to have: fast response but not with an abrupt torque!!!
Does not help if you duplicate your messages, posting them on different threads.haiyi911 said:Hi,casainho.
when i downloaded the kt-lcd3 FW and stancecoke'FW successfully,the motor run normally,
lcd3 canbe turned on,but not be turned off,and the UP/DOWN button is useless.
the display showed that liked the picture and no change.
Don't know about that 2 points. Maybe you or others can develop them and try. For me it is not a priority.vscope said:hi casainho,
i would suggest to use the wheelspeed as a factor for the ramp up. since when on speed faster ramp up is no such a problem for gears compared when wheelspeed is low. so not use a constant but a var multiplied with wheelspeed should give a quick response when its mostly needed, when on higher speed and save the gears on startup and low speed...
one more thing. i would like to have a boost mode without boost from standing still. so boost only when wheelspeed bigger than eg 8kmh.
so gears are save but still benefit of boost when riding fast. maybe that would be usefull for others too.