stancecoke said:
honya96 said:
The biggest problems I saw allready on table is the pwm rampup and down set to 25 and also if set to 2 takes like 5 seconds atleast to get to full speed or down to zero.
That's only a problem on the table. The current is controlled to be zero if you release the throttle. If there is no load, the current is near zero and the control loop reduces the duty cycle very slowly due to small delta between target and actual value. The ramp parameters can't help a this point.
Stancecoke, I remember you told about let the current controller do it's job.
I am now facing this thing, with my direct drive motor. Here is the code when when I apply regular brakes:
Code:
// Brake signal
void EXTI_PORTA_IRQHandler(void) __interrupt(EXTI_PORTA_IRQHANDLER)
{
if (brake_is_set())
{
motor_controller_set_state (MOTOR_CONTROLLER_STATE_BRAKE); // enable brake state
motor_set_regen_current_max (ADC_MOTOR_REGEN_CURRENT_MAX); // enable the strongest possible ebrake/regen
motor_set_pwm_duty_cycle_target (0); // target 0 PWM duty_cycle and the motor will stop/block
ebike_app_cruise_control_stop ();
}
else
{
motor_controller_reset_state (MOTOR_CONTROLLER_STATE_BRAKE); // disable brake state, this will make throttle to setup the new value for target PWM duty_cycle
motor_set_regen_current_max (0); // disable ebrake/regen
}
}
So, when applying brakes on geared motor motor, the motor should stop fast while the bicycle wheel will rotate freely because of the clutch inside the geared motor. When releasing brakes, the throttle will accelerate the motor and will engage on the bicycle wheel (at his current speed) thanks to the clutch.
On a direct drive motor, the motor will brake and reduce is speed at a rate depending on the max regen current and also the speed and mass of the bicycle + rider.
NOTE: On the Regen ebrake like coast brakes, the regen current is increased/decreased depending on the pedals backwards movement and that way the rider can control the rate of reduce speed / brake.
When releasing brakes, the throttle will accelerate again the motor (will increase target PWM duty_cycle).
The throttle and brakes control the target PWM duty_cycle and the real PWM duty_cycle, is then controlled by the motor current and motor regen current controllers. When we put target PWM duty_cycle = 0, we are braking the motor and it will brake faster with an higher regen current. When we put target PWM duty_cycle = 255, we are accelerating the motor and it will accelerate faster with an higher defined motor current.
What about when we have defined 0 regen current + max motor current on a direct drive motor? From my experience, the controllers will try to keep the motor PWM duty_cycle constant, if I am currently at 20km/h on a flat land and stop pedaling (throttle = 0 --> target PWM duty_cycle = 0), the motor will not brake nor accelerate and I can feel the motor pushing, which is very strange...
What about if instead of flat, I start on a slight descent? -- the bicycle will even accelerate fast, because motor will push it forward... really unpleasant experience (the PWM duty_cycle keeps constant but now the bicycle would need an lower value to keep his speed).
-- what to do here??
I think we need to define regen current to some low value and not 0, so every time I stop pedal, the motor will brake slowly (reduce his PWM duty_cycle) and I will not feel the motor keep pushing and instead I will need to keep pedaling. A to strong regen current and should also feel strange... I think I experienced this with the original firmware.
What do you guys think?? I think we can try keep the same firmware for both direct drive and geared motors, but the result is clear different.