-
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
Smooth Start feature and cleanups, closes #63 #73
base: master
Are you sure you want to change the base?
Conversation
I gave this firmware a quick go and it feels very nice. I haven't tried startup assist w/o pedalling much before, but with that enabled plus smooth startup I'm finding trackstands and wheelies easy, and it's much nicer pulling off from a standstill which will make traffic lights on the commute better |
I am glad you like it. Track stand was a disaster before. Which motor version are you running? |
I do, thanks! My only remaining gripes with the motor are the power dropoff with high cadences (I guess the motor is hitting max RPM?), and the delay when pushing the pedals from zero load. Maybe you know the reasons for this, I'm going to investigate the code |
To improve torque at a high cadence, definitely try the Field weakening option. It's not very efficient though, so don't do too much pedaling in that high cadence region. Regarding the delay. It happens when the bike has a non-zero speed. When you start to pedal, the crank can rotate up to 360deg / 20 clutch teeth * gear ratio, which is around 15 deg or so depending on the gear. During those 15 degrees, the cadence is already significant, but there is no torque reported by the sensor until the cassette engages. Once there is torque, the motor starts to accelerate - but it doesn't transmit any torque until its speed matches crank speed. Mechanically, you could improve by installing one of those mountain bike quick engagement freewheels. But there are software improvements possible as well, and they go like this:
The first feature should be simple and I wanted to implement it on top of the Smooth Start. |
The field weakening option is fantastic! I should have tried that earlier The delay I feel is subtle, I am pretty sure it is the motor rather than the transmission slop as the transmission slop I am used to from normal bikes - I can feel it most when rolling at a slow speed in a slightly high gear and then immediately loading the pedals (with a little hop), it is ~0.5 seconds until I hear the motor spin and feel the pull In any case it's not related to this PR, but thank you for answering my questions :-) |
You right. I lost my train of thought a bit with the cassette freewheel. By observing for pedal movement and accelerating the motor immediately, the delay can be reduced. (1) |
I've been riding with this every day to work and I've had no issues in general I've bought a DM-02 for a second bike so I'll have that to compare against soon :-) Unfortunately the firmware is closed source for now and I don't think it's as refined |
This still works. Make sure your weight is mostly supported by the seat when turning on the display while riding. |
24fe1ba improves speed calculation and partially solves #71. After this commit, the speed decays almost immediately (if the next pulse didn't arrive after the same period as the last one) and it typically goes 9, 7, 6, 5, 4, 0 kph.- in a matter of a couple of seconds as well. That is what is visible on the display anyway. |
I removed this last commit, as I haven't tested it enough and I found an issue with too sudden wheel speed increase on first pulse causing torque drop and walk mode interruptions for some reason. |
@dzid26 I tried in Power and Hybrid modes. I don't know what to think, it will be due to a different response of the 36V motor with 36V battery, or to a mechanical difference, sprocket/chainring ratio. |
Indeed, it doesn't sound like what I experience at all.
|
For reference, this is my config which has been working very well: |
Sorry for shortened, AWP = Assist without padaling. With your modification, even with 100, 100, 120, there is little assistance at the start, for the first 4-5 turns of the pedal, up to normal speed. More than the motor voltage, it could be the motor/battery voltage ratio, you use 48/52, I use 36/36, but I also tried 36/48 and the motor is much more reactive, you have to dose the push on the pedals so as not to make the bike wheelie. As regards the sprocket/chainring ratio, I didn't explain myself, I meant the number of teeth of the chainring, I consider the standard 42T unusable on the trails, then I tried the 34T for a year, then on both bikes I mounted the 30T, with 29" wheels is the best solution ever. |
Nooo, don't use it without AWP. It defeats the purpose. It's all about removing that initial delay. #63
When you click the Smooth Start checkbox in Java, AWP gets enabled automatically. Beyond this automation, the recommended settings are provided in the manual: I think you mean that the ratio of the first gear matters. Yes. - Of course, unlike the taller ratios, I cannot try the shorter ratios that I have for the first gear. But I think my setup is very reasonable for MTB. For what it's worth, I have 44t in the front, 50t in the rear, and 26" wheel. I can climb hills that I couldn't without the motor. I will switch to 42 front in the future, as I too rarely use the top gear. Anyway, my cadence is good even on steep hills, but that's also a function of rider weight, motor current, and rider strength. Ok, so back to the actual problem. Are you sure your AWP is enabled and the threshold set to 120? Could it be that it's not cleared in the EEPROM? I don't need to tell you - you are the expert. If that's confirmed, you could just try a different SMOOTH_START_PEDAL_FACTOR and recompile. Increase it 2x, to notice the change. Just to reiterate, the torque should feel quite subtle at the beginning (slow cadence) - you lay your leg on the pedals and you should feel just a little torque even in low gears. Only if you push much harder or go faster, does it transition to full support. |
Rebased. |
I've now seen new pull requests. |
Based on your description, it doesn't seems you are experiencing the same thing as I do. I still don't know if you ever disabled Assist without pedaling. It looked to me last time that this was the cause of the abrupt start. Also, we may have different expectations from the ebike behavior. One practical test is whether you can reliably track stand on it without motor throwing you out of balance (e.g. https://www.youtube.com/watch?v=TNQEJueTpdI). With the current target control, I don't think it is possible to achieve it. Basically, by the time current sensor sees any current, it is already too much torque. (Perhaps the issue of low resolution of the current feedback is exacerbated on the 48V motor). Thus low torque control can only be done by controlling duty cycle directly - in the open loop.. Also it is implemented in a way that for large force the duty cycle is not limited anymore and you'd get full assistance (even at 0rpm cadence). It's a pity that it didn't work for you. |
@emmebrusa This effect can be somewhat reduced by enabling Startup Boost which causes current command to appear earlier and thus it is also limited to a lower level by the Smooth Start and is overall more smooth. |
26a3a2e
to
5e09233
Compare
Actually, the issue with power assist was that the current target was rounded to zero for low cadence values. Although I don't know why power assist mode even exists. It reduces to a "torque gain as function of cadence". I recommend Torque mode (or eMTB) for most consistent assistance. |
Maybe that's why we don't understand each other, I use and recommend Power mode. |
Why do you prefer to have more assist the faster you pedal? Or the opposite question - If you like a lot of torque gain at high cadence, why not also at low cadence? My rationale for torque mode is that it provides always the same assist - so the ebike still feels like a bicycle but lighter. In any case, power assist jerk is gone after the 68f23fc, if you want to try it. |
I don't agree with this statement of yours, it's the Power mode that is more like a bicycle. I'll tell you my experience. |
d5335ac maxes out Additionally forced push moving the logic into a function: |
Removed |
fix: allow for inverted range similar to map_ui8
Added PWM bit shift constant
Smooth torque aplication on startup. Slightly reduce duty cycle ramping by starting from a small non-zero value Created BEMF calculation Hold last bemf value when FOC is active. Smooth start: added BEMF reduction factor Smooth start: fixed walk assist - special case Smooth start: also for the throttle Removed pedal filtering to slightly reduce delay Added wheel speed dependency for cadence modes.
fixes low cadence, zero torque issue
Fixes small jerk during Smooth Startup.
Changes:
Smooth start
Why Smooth Start is great - summary for the layman:
This feature uses direct duty cycle control instead of low-resolution current control for greater torque accuracy at low speeds.
The level of Smooth Start torque is entirely determined by raw pedal input (or throttle) at low speed. Then the torque gradually increases when the speed increase (or if pedal force exceeded half of the maximum force). This helps avoid sudden jerks or jolts, leading to a smoother and more controlled acceleration. Smooth and controlled acceleration enhances the user's confidence and contributes to overall safety. The function gives riders a feel that they are using a bicycle and not a motorcycle when starting the ride. Inadvertently, this adds to the overall safety of the system and protects the hardware from damage.
Smooth Startup control allows to relax of other global torque rate limitations and reduce delay in the motor's response to inputs, ensuring quicker and more immediate acceleration. This enhances confidence for mountain biking, particularly when riding on loose or steep terrain, where riders may be susceptible to losing their balance.
Independence from other settings at low speed: The initial rate at which torque is increased is consistent across different assist levels or pedal ADC mapping. This ensures predictability and allows the rider to learn their e-bike response.
The torque ramping feature deactivates when cadence, wheel speed, or pedal pressure reaches internally hardcoded thresholds. Thresholds have been calibrated to allow a smooth transition from the startup torque to full motor assistance (determined by the assist level).
Consequently, this feature can be used with all assist levels and other modifiers. Even functions that previously were very jerky (e.g. torque mode), now are ridable thanks to initial torque modulation.
Recommended Settings for Motor Acceleration and Deceleration: The text suggests specific values for motor acceleration (likely for ramping up torque) and deceleration (likely for slowing down the motor's output). The values "exactly 120 and 100" are provided as optimal settings for achieving the best response from the system.
Assistance settings tab:
Remarks regarding Voltage targets choice:
Duty% = (V_target+B_bemf)/V_Bat
Other:
CADENCE_SENSOR_STANDARD_MODE_SCHMITT_TRIGGER_THRESHOLD
. This setting is evil and reduces rider safety on complicated terrains. This feature will make the bike go when you need to stop. I crashed because of it when climbing a hill and that's why it's hardcoded to 0.(Sure, for cargo bikes, it doesn't matter, but for cargo bikes nothing matters, so who cares. If someone wants an unsafe feature, they can change it back in the code.)