pgrady3 / EasyController3

A simple BLDC motor controller, and the evolution of the EasyController2
MIT License
70 stars 4 forks source link

Regenerative Braking #3

Closed pirdain closed 2 months ago

pirdain commented 1 year ago

Hey, it says in the Readme that Regenerative Braking was added in the EasyController3 and is an upgrade over the EasyController2, but I'm unable to find any support in the Hardware or Software regarding it. I believe an external circuit would be added to support regenerative braking and supplying current back to the battery pack at the required voltage and this may or may not require some additions in the software (for the basic functionality at least).

If anyone has figured out how to incorporate Regenerative Braking into this project please let me know.

Cheers.

pgrady3 commented 1 year ago

Hi Pirdain,

It's just a software change, and if you set the desired current value negative, the control loop will modulate the duty cycle to make current will flow backwards into the battery. No hardware change is required. However, I haven't tested this yet.

Sorry for the wait, I'm working on the updated 3.1 version that will have this feature enabled and tested.

Patrick

pgrady3 commented 1 year ago

To elaborate a bit more, the existing hardware can do regen. I made sure the current-shunt amplifier can read negative currents specifically for this use case. If the duty cycle is set below the motor's current speed, current will flow backwards into the battery since the controller essentially acts like a boost converter. I know this is possible because I have observed it when I operate the controller in duty-cycle mode.

The existing code (the current control loop) is smart enough to control the duty cycle to achieve a negative current. However, there are a few edge cases that have to be considered in the code. For example, if the current control loop gets stuck at zero duty cycle, the current shunt will also read zero and the control loop will get stuck. Also, there has to be some protection to avoid injecting too much power into the batteries.

If you're confident, you can feel free to try to add this to the code yourself. I hope to add this feature and thoroughly test it for version 3.1.

pirdain commented 1 year ago

Hey Patrick,

Thanks for the quick response. I'll test this with my motor and get back with the results.

Also I had another question, how do I calculate the Capacitance value for the Capacitor Bank. Did you follow some formula for it. The provided value is as per a lower wattage motor, 1 kW. The motor in my circuit is around 5 - 6 kW.

I understand that the Issue is for Regenerative Braking and this would need another issue altogether, but still any input is appreciated.

Kind Regards, Pirdain

pgrady3 commented 1 year ago

Hey Pirdain,

Choosing these bypass capacitors is a very empirical process. I'd recommend finding a comparable 5 kW controller, and just copying the capacitance value from that. Alternatively, you could design in 5x more capacitance, and solder in different values depending on what you find when testing.

Patrick

bmentink commented 3 months ago

Just a point regarding managing regen energy. If the current limit to the battery is set too low, or the battery won't accept any more current (fully charged), the regen voltage may still rise to a damaging level. One way around that is to dump to an external high power resistor in that situation.

Maybe that could be added to version4 ;)

pgrady3 commented 2 months ago

Yes, some controllers have a shunt resistor for these kinds of applications. I think this is mostly used for industrial BLDC servos, where dumping energy back into the bus is unacceptable.

On most vehicle applications (what this controller is really built for), you apply the mechanical brakes if the controller can't regen. And usually, the battery's stored energy is much larger than the kinetic energy of the vehicle, so over-charging the battery isn't a concern.

However, you're welcome to add more features to the design!

bmentink commented 2 months ago

Hi Patrick,

I am making great progress with sensorless addition to easycontroller3. The zero-cross detection is achieved with simple (two resistors and a fet) components per phase. I have used a majority filter function in software to clean it up, works great between 18v and 48v, no hardware filtering at all, just straight into the ADC.

Attached is a scope shot.

Cheers, Bernard

On Thu, Apr 11, 2024 at 5:53 PM Patrick Grady @.***> wrote:

Yes, some controllers have a shunt resistor for these kinds of applications. I think this is mostly used for industrial BLDC servos, where dumping energy back into the bus is unacceptable.

On most vehicle applications (what this controller is really built for), you apply the mechanical brakes if the controller can't regen. And usually, the battery's stored energy is much larger than the kinetic energy of the vehicle, so over-charging the battery isn't a concern.

However, you're welcome to add more features to the design!

— Reply to this email directly, view it on GitHub https://github.com/pgrady3/EasyController3/issues/3#issuecomment-2048972513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNHVB6H5RMULJJMF66RMF3Y4YQOTAVCNFSM6AAAAAA2BNQDYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYHE3TENJRGM . You are receiving this because you commented.Message ID: @.***>

bmentink commented 1 month ago

Hi Patrick,

I have finally managed to get an implementation of sensorless operation working on your board. It works reliably over a voltage range of 12v to 48v with no hardware changes needed to support different voltages, I can just ramp up the bench power supply to whatever voltage. And it starts up reliably , even under load.

I can't stop the motor by loading the shaft with my hand, but will need real load testing.

The hardware involved is 3 small signal fet',s a bunch of resistors and the CD4051 mux .. (finally got that working correctly) so would not be much to add to the bottom of the board.

At the moment, for development, I have totally re-written your software to support this mode, and I have yet to add back current/torque control. (Also it is written in Forth, not C, because it was fast to test out code for development) When I am totally happy with it I could port it back to C ...

Just thought I would keep you up to date with the development.

Cheers, Bernie

On Fri, Apr 19, 2024 at 3:50 PM Bernard Mentink @.***> wrote:

Hi Patrick,

I am making great progress with sensorless addition to easycontroller3. The zero-cross detection is achieved with simple (two resistors and a fet) components per phase. I have used a majority filter function in software to clean it up, works great between 18v and 48v, no hardware filtering at all, just straight into the ADC.

Attached is a scope shot.

Cheers, Bernard

On Thu, Apr 11, 2024 at 5:53 PM Patrick Grady @.***> wrote:

Yes, some controllers have a shunt resistor for these kinds of applications. I think this is mostly used for industrial BLDC servos, where dumping energy back into the bus is unacceptable.

On most vehicle applications (what this controller is really built for), you apply the mechanical brakes if the controller can't regen. And usually, the battery's stored energy is much larger than the kinetic energy of the vehicle, so over-charging the battery isn't a concern.

However, you're welcome to add more features to the design!

— Reply to this email directly, view it on GitHub https://github.com/pgrady3/EasyController3/issues/3#issuecomment-2048972513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNHVB6H5RMULJJMF66RMF3Y4YQOTAVCNFSM6AAAAAA2BNQDYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYHE3TENJRGM . You are receiving this because you commented.Message ID: @.***>