I am attempting to understand how the brake resistor is activated.
According to the v3.5 schematic, a pair of mosfets is used to connect the brake resistor to the DC bus voltage.
According to the firmware, in low level.cpp, brake_duty = brake_current * odrv.config_.brake_resistance / vbus_voltage. So, when the brake mosfets are on, a current of V_bus / R_brake flows through the braking resistor. To generate the required brake_current, I believe this logic assumes that the current flowing through the brake resistor comes from the motor. That is, I think this assumes the battery current is ~0 when the brake resistor is on.
Why is this? What is to stop current from flowing from the motor to the battery when the braking resistor is connected. Or, what is to stop current from flowing from the battery through the braking resistor?
I tried to make a simulation of a braking motor. I model the motor as a current source and the battery as a voltage source in series with a resistor. Depending on the value of the resistors, current may flow from the battery through the brake resistor. Or, current may flow from the “motor” to the battery even when the brake resistor is connected.
Technically nothing. But if we do “Kirchoff’s Current Law” at the bus node and we can show that if we do the math precisely, the motor current in (shown as a current source in your schematic) and the brake resistor current out (V=IR) are equal. Therefore there must not be current flowing into or out of the battery. If we apply too much or too little voltage to the brake resistor, then current will have to start being sourced or sinked to the battery.
One thing you’re missing is the capacitance in the DC bus, which can store energy in the form of higher DC bus voltage. Your circuit currently has no “real” energy storage devices (since your battery is a voltage source and doesn’t change) which means you’re not capturing any transient response, only steady-state. The transient response is why we created the dc_bus_overvoltage_ramp. This is a simple Proportional Control loop that measures the bus voltage and adds additional duty cycle (voltage) to the brake resistor according to the error between the dc bus threshold voltage and the actual dc bus voltage.
In other words, as the motor dumps energy into the bus, if we don’t turn that energy into heat in the brake resistor, it will be captured either by the DC link capacitance or the battery. This energy shows up as an increase in voltage on the bus. As the voltage rises, we measure it and ask the brake resistor to use more energy, so that we compensate for modeling errors in our system.
Did this circuit work for anyone, I am trying to make one for a different controller and want to include a braking circuit for it, pls help make one, thanks in advance