Brake resistor and decel voltage/current

I use LiFePo cells from electronic vehicle for my hoverboard motors. The batteries are far from ideal state but they work yet. To avoid any catastrophic damage of cells I would like to measure the voltage and current going to the batteries during deceleration of motors.

  1. Are there any variables which I can read from oDrive?

  2. Currently I have 4.4Ohm brake resistor connected to oDrive. Is it more safe to use brake resistor even if the power coming form batteries? Or it is absolutely unnecessary?

  3. What measures or calculations should I take into consideration in this situation

Thanks for the help in advance!

Hi James,

You can monitor the voltage at odrv0.vbus_voltage and the current drawn (regen is negative) for each axis on odrv0.axis0.motor.current_control.Ibus. You can sum the Ibus for each axis to get the total.

If you hook up a brake resistor and give ODrive the correct setting (odrv0.config.brake_resistance), it will dump ALL regen current into the resistor, and send none to the battery. If you do not plug in the resistor and set odrv0.config.brake_resistance = 0, it will regen all. If you hook it up and you set it to half the actual value, it will dump half and regen the other half.

1 Like

If I am understanding correctly, the following code should be able to regen up to 8 amps, and dump anything beyond 8 amps into the 2 Ohm resistor that comes with the ODrive:

void regenBrake()
{
    float axis0current;
    float axis1current;

    Serial2 << "r odrv0.axis0.motor.current_control.Ibus" << '\n';
    while (Serial2.available)
    {
        axis0current = Serial2.read();        
    }
    
    Serial2 << "r odrv0.axis1.motor.current_control.Ibus" << '\n';
    while (Serial2.available)
    {
        axis1current = Serial2.read();        
    }

    float totalCurrent = axis0current + axis1current;
    float resistance = 2; //ohms
    float maxChargeCurrent = -8; //amps current draw

    if (totalCurrent < maxChargeCurrent)
    {        
        float currentFactor = 1 - ( maxChargeCurrent / totalCurrent);
        Serial2 << "w odrv0.config.brake_resistance " << (resistance * currentFactor) << '\n';
    }
    else
    {
        Serial2 << "w odrv0.config.brake_resistance " << 0 << '\n';
    }
}

Is that correct?

So the ratio of power dissipated in the brake resistor vs power sent back to the battery is set via the ‘brake_resistance’ parameter, but how does that actually work practically speaking? Does it mean that if, for example, I calculate Vemf to be max 19V for my application, that:

  • settting the brake_resistance to the actual resistor value will result in no positive voltage spike on DCBUS?
  • setting it to half the actual resistnace value would result in a spike of 19V /2 or 9.5V?
  • setting it to 0 will result in the full 19V spike?

I’m asking particularly about the voltage because my battery supplier said that even transients above the rated battery voltage weren’t acceptable, so I’m thinking the only way I can make use of regen is by adjusting the brake_resistance value in function of the battery voltage, i.e. no regen when the battery is fully charged, and set the resistance value so that Vemf gets the bus voltage close to the max battery voltage (with a bit of safety margin).

The ODrive calculates the total bus current. If that bus current is positive (going INTO the drive), then it sets the duty cycle of the aux output:

V = IR
V = Ibus * brake_resistance
DC% = V / Vbus

Not ideal and there’s more robust ways of handling it but it functions for now :slight_smile: