# ODrive cuts out when braking

I have the 56V Odrive, a 24V power supply and a very big (2kW) 4.7Ohm braking resistor.

• I power up Odrive, calibrate, and set it to Torque Control mode. I have tried this with torques of 0.1Nm, 1Nm and 10Nm.

• I then spin the motor against the torque it was trying to apply. I am spinning at maybe 1800rpm. The braking resistor never even perceptibly warms up.

• however, the ODrive randomly cuts out (LED dies, device appears disconnected from Windows.) At first it felt like this happened intermittently, or even just after sudden speed changes (more often when spinning suddenly stopped than when it started). But in my recent tries it’s happened pretty much instantly every time.

• The ODrive turns back on with seemingly no harm done. But since in its mind it’s just been turned on, I can’t read what the error was.

Does anyone have any ideas?

The LED is powered directly by the 5V supply from the integrated buck converter on the M0 drv8301 chip. If it ever goes off, it indicates an issue with either the DRV chip or the power supply.
It’s possible that your power supply is going into overvoltage lock-out because the ODrive is not using the brake resistor enough, and so is feeding current back to the power supply.

What firmware version are you running? What is your brake resistor config? (odrv0.config)
Make sure that you have set the brake resistance to 4.7 in the config, as the default for the 56V board is 2 Ohm.
Try setting dc_bus_overvoltage_ramp_start to exactly or very slightly above nominal vbus_voltage, and dc_bus_overvoltage_ramp_end and dc_bus_overvoltage_trip_level to whatever your PSU can handle before it trips.
Then set enable_dc_bus_overvoltage_ramp to True. This lets the ODrive behave as a bus voltage clamp.

Running firmware version 0.5.1, and the odrv0.config.brake_resistance value was set to 4.7.

I have just tried your suggestion, here’s what the relevant bit of odrv0.config now reads:

max_regen_current = 0.0 (float)
brake_resistance = 4.699999809265137 (float)
dc_bus_undervoltage_trip_level = 8.0 (float)
dc_bus_overvoltage_trip_level = 27.0 (float)
enable_dc_bus_overvoltage_ramp = True (bool)
dc_bus_overvoltage_ramp_start = 24.0 (float)
dc_bus_overvoltage_ramp_end = 27.0 (float)
dc_max_positive_current = inf (float)
dc_max_negative_current = -9.999999974752427e-07 (float)


I span it up and, as before, the torque suddenly cut out. This time though the light stayed on and I can actually read an error message. Progress!

This is the error message:

In [1]: dump_errors(odrv0,True)
axis0
axis: Error(s):
AXIS_ERROR_BRAKE_RESISTOR_DISARMED
AXIS_ERROR_MOTOR_DISARMED
motor: Error(s):
MOTOR_ERROR_DC_BUS_OVER_REGEN_CURRENT
fet_thermistor: no error
motor_thermistor: no error
encoder: no error
controller: no error
axis1
axis: Error(s):
AXIS_ERROR_BRAKE_RESISTOR_DISARMED
motor: Error(s):
MOTOR_ERROR_DC_BUS_OVER_REGEN_CURRENT
fet_thermistor: no error
motor_thermistor: no error
encoder: no error
controller: no error


I’m not quite sure what to make of this. I’m not sure what “regen current” is referring to. I have max_regen_current = 0.0 in the config, so shouldn’t all current be sent straight to the resistor?

Do I need to change that dc_max_negative_current  value in the config? I am nervous about doing things I don’t understand.

“regen current” is the current it can send back to the supply (ie >0 only if connected to a battery).
dc_max_negative_current = 0 (or a very low number) means that the ODrive will trip off and give this error if it ever sends any current back to the power supply. Previously, I’d guess it wasn’t hitting this error in time before the power supply itself tripped.

It’s possible that the brake resistor or VBUS voltage sensor is out of tolerance slightly. Try increasing the configured resistance to 5 Ohms.

I have tried setting brake_resistance = 5 and it doesn’t make any difference.

Given that I probably shouldn’t mess with dc_max_negative_current , I’m not sure what else there is I can tweak.

EDIT: okay, I’ve just re-done the test while continuously printing vbus_voltage to the screen.

Voltage started at 23.9V, and rose to 30V before falling down to 5V.

In this test the previous error came back, where the ODrive disconnected and the LED went off.

Now I am not sure if the previous fix ever really fixed the problem, or if it did and then changing brake_resistance to an incorrect value somehow exposed it again.

EDIT 2: I think it never really fixed the problem. I have just set the resistance back to 4.7 and re-tried. This time the voltage got to 37V before the power supply tripped.

I can confirm it is the power supply tripping, since I measure 23.9V across its terminals before starting the test, and 0V afterwards until it gets turned off and on again.

So this leaves me a bit better acquainted with what some of the ODrive’s settings are doing, but otherwise back to square one.

How can I stop the bus voltage from rising? Isn’t that tied straight to the motor’s rpm, via the KV value? Is the braking resistor supposed to bring it down, or does it have no effect on voltage?

Also note that at 24V, V^2/R is only 122W even when it is fully ‘on’.!

If you connect the resistor directly across the 24V supply, it will burn only 122W. The ODrive can’t get rid of more power than that!

Try a 0.5 Ohm resistor if you need to get rid of 1kW at 24V, or 0.25 Ohm for 2kW.
(this is why the 24V ODrive has a 0.5Ohm brake resistor )

EDIT: Also, you don’t need a 2kW rated resistor. A 100W one will happily take 2kW for a short time. (enough to stop the motor)

Ah. I didn’t think of that. I obviously don’t have a comprehensive enough idea of all the moving parts in this system.

So, just to check my understanding:

The voltage (back-emf) coming from the motor itself is Vm = rpm/kv, and the current generated is Im = kv*torque / ~8.27.

The voltage dropped over the resistor is Vr=I/R - is that ‘I’ the same as ‘Im’? What about the torque the ODrive is trying to apply in the other direction, where does that feature?

And is the DC bus V = Vm - Vr? Or is there more to it then that?

Nope. It’s not so much to do with Im. - The ODrive acts like a switch mode power supply. The voltages and currents on the motor side are NOT the same as on the DC Bus side, but the power is roughly the same.
It’s the same as your 24V PSU. On one side you have 240V 0-10A, on the other 24V 0-100A. But if you draw 10A from the 24V side you can expect to see at least 1A on the 240V side.

With a motor driver the power on the motor side is torque (in Nm) * speed (in rad/sec) PLUS I * R (of the windings) = Power(W)
On the DC bus side it is Volts*Amps as usual.

If the speed (in rad/s) is negative, but the torque is positive, (or if torque is negative and speed is positive) then the mechanical part of that equation goes negative, and you can have a negative current at the DC bus, which is what the resistor is for.

So, to clarify, the resistor is on the motor side or the DC bus side? If the ODrive is switching it on and off with FETs, doesn’t that make it the motor side? Yet you used 24V in your 122W power calculation above, implying it’s on the DC bus side. So how does that work?

The resistor is on the DC Bus side. ODrive switches one FET on and off with a duty cycle 0-100% which acts like a variable voltage on the resistor.
The reason it behaves differently to the motor is because the motor has a huge inductance compared to its resistance, whereas the resistor has very little inductance.
Due to the motor’s inductance, current continues to flow even when the FETs are OFF. That’s how the effective current is different on each side of the FETs.

So (in my own words, to make sure I understand):

• the DC bus is on one ‘side’ and the motor windings are on the other. They are connected by FETs.
• the ODrive switches FETs on and off to allow voltage across to the motor windings in a controlled way.
– this means the voltage on any winding is a proportion of the full DC bus voltage, the ‘proportion’ being that of the PWM controlling the FET.
• the motor is also generating back-emf, which is a voltage in the other direction.
• the current on the motor side comes from the difference between those two voltages * the internal resistance of the winding.
• the current on the DC bus comes from?
– I’m guessing the sum of the currents on all three windings, but it’s not a straight sum because they’re all out of phase with each other?
• even when the motor is totally disconnected from the DC bus, current might still be flowing because the motor is a big spinning magnet with inductance of its own.
• the braking resistor is connected between DC bus and ground, in series with a FET.
– when the FET is off, it looks like an open circuit. When the FET is on, it looks like a resistor connecting the DC bus to ground. Changing the duty cycle of the FET allows the resistor to ‘fade’ in or out.
– whatever proportion of the resistance is ‘faded in’ drops V = I/R across its length, and that drop in V is what you use to keep the overall bus voltage from climbing too high.

In my case:

• the back-emf is bigger than the winding voltage the ODrive is applying,
• which means the DC bus is trying to rise every time the FETs connect it to this higher voltage
• the ODrive is then responding by fading the braking resistor all the way in, but
• because the braking resistor is 4.7Ohms it can only drop 122W (=??V) across itself, which isn’t enough to bring the DC bus back down
• at which point either my ODrive or my power supply trips out, and they seem to have been letting each other take turns at doing so.

Is that accurate or have I got the wrong idea?

Not quite…
Its much easier to think of things in terms of power, because that is invariant.

Or failing that, think of current.
Don’t think of voltage, because that changes extremely fast all the time. i.e. at 40kHz with the PWM cycle.
If you must think of voltage, then think of it as the DC bus multiplied by the PWM duty cycle.

Thanks for taking the time to go through that in detail. It really is helpful.

I personally struggle when people tell me to think in terms of power. Power is a useful fiction. It’s useful for magically producing values of voltage/current (that must be true because of conservation laws) but leaves me totally clueless as to what real, physical effects are causing them.

In this case, voltages seem to be what I ought to think in, because they’re the causal root of everything else. By which I mean, the ODrive can’t set power or current any other way than by manipulating voltage levels via PWM signals.

• the current on the motor side comes from the difference between those two voltages * the internal resistance of the winding. no. the current on the motor side is controlled by a closed-loop system. It is always proportional to the torque demand that you set.

So in this case, the current is (hopefully) “set” to be whatever value gives you the torque you want. But what’s really setting it is the voltage the ODrive applies to the windings, and nothing else.

So if I were to rephrase it as "the current on the motor side comes from the difference between those two voltages (when summed as spinning vectors, not flat values) * the internal resistance of the winding, plus a larger component that grows towards V/R with time constant L/R because of the motor's inductance" - would it then be closer to the truth?

And then all those sums coincidentally wind up at the exact current value we want, because the ODrive has very cleverly chosen the voltage to make sure that’s the case.

The DC Bus current is the motor current * the PWM duty cycle %

Just one question: which motor current? There are three windings, so three currents. If you can’t just add them up (even as spinning vectors) because they sum to zero, what do you do?

The DC bus current bit otherwise makes sense to me. The motor is causing the current but the DC bus is only connected to it x% of the time, so it only sees x% of the current (unless you zoom in very close to the PWM cycle speed.)

This also plays out so that the DC bus has the “full” voltage and the motor gets x% percent of it, while the motor has the “full” current and the DC bus gets x% of it - and thus power is conserved.

…consider the motor as just a coil of wire around an iron core, ie, an inductor…

The modelling the motor as an resistor+inductor bit was very useful, makes me feel like that was the missing link to understanding all of this stuff all along.

So thanks for that, I will go back and work through it in detail.

The voltage is “faded in”, the resistance is constant.

Here you’ve got me. Do you mean, the voltage drop across the resistor is faded in?

My thinking was that when the FET is off, the resistance of the resistor is resistor+open circuit = infinity, and when the FET is on the resistance is just resistor.

So I saw that as a “resistance” fading in and out, and can happily understand it in terms of “voltage drop over said resistance” if taking about fading resistances is somehow a faux pas. But if instead something else is going on then I’ve misunderstood.

the back-EMF is always lower than the supply voltage, that’s what limits the max speed for a given voltage.

Now I’m confused again.

This is an oversimplification.

And apprehensive.

I don’t understand how the back-emf can always be lower than the supply voltage - I thought the whole concept of braking was that that’s when the back-emf is higher than the supply voltage.

At which point

• current is flowing the other way,
• power is coming out rather than in, and
• the motor is trying to slow down because that’s how Physics is making you pay for that power you’re getting out.

Hence, regenerative braking. Also, note, magic anthropomorphic Physics being invoked the minute I had to talk about “power”.

I might read up on inductors a bit and see if that helps clarify things.

yes, only 5.1A will flow through the resistor at 24V

Getting back to the immediate situation, I’ve got two of the little black 50W 2 Ohm resistors that come with the ODrive. Presumably I can attach those in parallel to get an equivalent 100W, 1 Ohm resistor.

That will, by my calculations, let me dump 24^2/1 = 576W through it, 476W of which is beyond the rating. Is that going to be safe (even just for testing)? I don’t particularly mind if the resistors burst into flames, provided nothing scary is going to happen to the rest of the board.

Yep, the wattage ratings are for continuous duty cycle. If you have a very short duty cycle it’s fine. If you’re doing a lot of braking (50% duty cycle) you’re going to have bigger problems.

Motor phase current in the d-q frame. This is the same as current_limit and motor.current_control.Iq_measured, etc.

Easiest way to calculate this:

P_{motor} = 0.8 * V_{bus} * I_q

I_{brake} = P_{motor} / (0.9*V_{bus})

R_{brake} \leq 0.9*V_{bus} / I_{brake}

So if you have a D5065 motor from the shop, which can do say… 60A at 24V (you probably won’t actually hit full speed at 60A, so unlikely combo but it sets a max bound), you have

0.8 * 60A * 24V = 1152W
I_{brake} = 1152W / (0.9*V_{bus}) = 53.3A
R_{brake} \leq (0.9*V_{bus}) / 53.3 = 0.405\Omega

Your brake resistor must be less than 0.4 ohms to hit that peak current. Which is why we ship 0.47 ohm resistors with 24V odrives

1 Like

Yep, the wattage ratings are for continuous duty cycle. If you have a very short duty cycle it’s fine. If you’re doing a lot of braking (50% duty cycle) you’re going to have bigger problems.

What kind of bigger problems are we talking here?

(I’m going to have to sit and digest the second half of your post, but that one line at the top has me worried.)

Resistor heating up too much. Won’t damage the ODrive