vedderb / bldc

The VESC motor control firmware
2.18k stars 1.35k forks source link

Add regen cutoff to prevent overcharging the battery during braking #607

Closed nitrousnrg closed 1 year ago

nitrousnrg commented 1 year ago

This change helps ensure that the battery remains in good condition, prolongs its overall lifespan and avoids hazardous scenarios of overcharge.

A soft cutoff for the regenerative braking is implemented, in which start and end thresholds should be set in VESC Tool. The end threshold should be set such that the cells don't exceed 4.2v in a typical Li-Ion battery.

The default values follow the default max voltage that was being used. This means that in setups with operating voltages above ~60V, these new fields with the default values will completely disable regenerative braking until the motor config is updated accordingly for the correct battery voltage.

The code is easy to test with power supplies, as it can now brake the motor without tripping an overvoltage. It was also tested with a 60v battery.

This commit needs its companion commit on vesc tool code, I'll make that PR now

vedderb commented 1 year ago

I think it is best to change the defaults to something high like 1000 and 1100 V, so that you always have braking if you don't change the parameters. A lot of people rely on the braking as their primary brake (which is a bad idea), so I don't want to surprise them with a non-existent brake after a firmware update.

Also, in practice I have never seen an issue with overcharging a battery with regenerative braking but I have seen many situations where an inconsistent or disabled brake would cause a dangerous situation. I worry less about wearing out the battery slightly faster than not having a brake.

Another potential issue with this setting is that people probably don't realize that it will completely disable the brake when the battery is full. That is one of the most common misunderstandings - that it is not possible to brake using the motor without charging the battery in the process.

nitrousnrg commented 1 year ago

Sure, I'll move the defaults to 1000+v, I had the same concern which is why I did bring it up.

For some time I stayed in a home at the top of a hill with a Tesla rental. In the downhill it charged the battery 2 to 3% if it was not fully charged, and if it left the place fully charged it would reduce regen pretty dramatically. From a user perspective it sucks but its a safety matter.

tonymillion commented 1 year ago

To jump in, I use an e-scooter with VESC and its usually the BMS's job to limit reverse charging, I've noticed it on a full battery where regen kicks in first, then drops out leading to the scooter freewheeling until I pull the brakes harder.

If anything, I would request this be put behind a Boolean to completely disable it, lest it adds another failure point which could lead to a bad accident.

I see the advantage if the battery is being used without a good quality balancing BMS but I (hope) thats not the usual case (for accident & potential fire safety)

nitrousnrg commented 1 year ago

To jump in, I use an e-scooter with VESC and its usually the BMS's job to limit reverse charging, I've noticed it on a full battery where regen kicks in first, then drops out leading to the scooter freewheeling until I pull the brakes harder.

Yes, most BMS's will protect from overcharging, but the protection actuation is sharp and sudden. Not to mention if it happens in freezing temps and you have to reach in panic for the mechanical brakes on a red light. We can have a more predictable behavior if the controller is aware of the limits to avoid a hard BMS trip, like every EV does. I would even show a warning message "Regenerative Braking Temporarily Reduced"

If anything, I would request this be put behind a Boolean to completely disable it, lest it adds another failure point which could lead to a bad accident.

I think the 1000V default setting that I committed earlier today is enough.