# Current limit vs. current limit margin?

Hi,

I’m just having a quick question. What is the difference between the current limit and current limit margin of an axis?

We have some hoverdrive like motors installed on our ODrive and it hit the curb. The ODrive gave us an error that the current limit was exceeded, which makes sense. It was also set fairly low. Now we increased it but didn’t know what the difference the current limit and the current limit margin is. Is the margin a temporary tolerance for current spikes?

Thank you

Depending on your answer, I can also update the variable descriptions in the docs if you like.

1 Like

Hi MrRobotic,

That’s the right way to think about the current limit margin! The current limit represents the max value that the current in our motor can take on and the margin is the threshold that it can surpass the current limit before the board throws an error. You can see that logic here in the firmware. Hope that helps!

1 Like

if motor says stall current is 13A does that mean current limit should be no higher than 13? and how would you decided what is ok for margin? won’t motor burn out if margin too high?

It depends on what kind of motor you have. If you look at the datasheet for your motor, does it specify anything about hold limitations or stall time limitations? If not, it should be ok to run your motor at a current limit of 13A and have a small current limit margin or lower the limit and raise the margin so long as you don’t exceed 13A.

I SINCERELY would appreciate your comment on this. I have limited knowledge. I don’t want to burn the motor or drive, but I also don’t want to needlessly limit the motor. So for this kind of setup, is 13 for limit and 13 for ‘requested range’ and 8 (default) for margin ok? or is it risky?

It’s this motor (inhub motor like hoverboard):

There is definitely someone more knowledgeable than me that can speak on this, but my interpretation of stall current is that it represents the amount of current that can safely pass through the motor while it is stalled. With that said, you can probably set the current limit to 13A and start off with a low margin, like 2A, and ramp up the limit gradually if you are encountering CURRENT_LIMIT_VIOLATION’s.

thank you. I wasn’t really sure I was even interpreting the meaning of those amp ratings correctly. ie, I had read somewhere that 60A was a good value so was going to do that, until i looked at motor sheet and got scared.

Motors are thermally limited, generally. The windings have a resistance of 1.37 Ohms, and Power = I^2 R. So at 60A, you would be putting nearly 5kW (!) into the winding. That’s a recipe for smoke / flames.

At 13A, it’s only 230W. That sounds reasonable - maybe this motor acts as enough of a heat sink to get rid of 230W of heat without getting too hot - that’s where the 13A comes from.

However, there’s nothing stopping you from using a higher power for short bursts, as long as you are aware that sustained high currents will overheat the motor. 20A (550 W) shouldn’t be a problem, you could maybe even get away with 25A (850 W) if it’s for less than a second and the motor is not already hot.

The first motor you posted has a resistance of 5 Ohms, apparently. This is not suitable for use with ODrive - the max current is too low.

@towen so, the motor wasn’t doing anything until I set odrv0.axis0.resistance_calib_max_voltage = 12.0. But I don’t understand what you mean odrive isn’t suitable. I was driving the robot around last night. what exactly is not suitable? (I have the 56V odrive with 36V battery). That was taken from product page, so if it’s different from the second link, maybe it’s the wrong data or something. Or am is it just a matter of time till i kill my nice new Odrive? maybe that page has specs that are wrong. the second image is from the manual they sent me.

this is my config

``````odrv0.config.enable_brake_resistor = True
odrv0.config.dc_max_negative_current = -10.0
odrv0.config.dc_max_positive_current = 40.0
odrv0.config.max_regen_current = 5.0
odrv0.save_configuration()
odrv0.reboot()

def motor_setup(x):
wheel_diameter_cm = 17.5
cm_per_sec = 50.0
vel_limit_rps = cm_per_sec / (wheel_diameter_cm * 3.14159)

x.encoder.config.cpr = 3200
x.encoder.config.bandwidth = 1000
x.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
x.motor.config.torque_lim = 20.0

x.motor.config.calibration_current = 10.0
x.motor.config.current_lim = 13.0
x.motor.config.pole_pairs = 15
x.motor.config.resistance_calib_max_voltage = 12.0
x.motor.config.torque_constant = 8.27 / 8.75
x.motor.config.current_control_bandwidth = 100

x.controller.config.pos_gain = 50
x.controller.config.vel_gain = 0.5
x.controller.config.vel_integrator_gain = 0.5
x.controller.config.vel_limit = 5.0

x.trap_traj.config.accel_limit = 0.5 * vel_limit_rps
x.trap_traj.config.decel_limit = 0.2 * vel_limit_rps
x.trap_traj.config.vel_limit = vel_limit_rps

x.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL
x.controller.config.input_mode = INPUT_MODE_TRAP_TRAJ
``````

And here’s how it’s working: odrive test - YouTube

can you tell me how I can check if it’s suitable or if something is overly strained?

Normally people struggle with high resistance motors (which work at less than 1A), because the current measurement shunt resistors of ODrive are meant for up to +/- 120A. There is a programmable gain amplifier on the ODrive, but even at the lowest range, the noise is a bit too much for these motors.
Normally I’d choose a motor that can take at least 20A, or has a winding resistance less than 1 Ohm.

The robot in the video, Is that using the motors with 1.37 Ohm resistance / 13A limit? That’s fine.
But another motor you posted had 5 Ohms, which is too high - although it may still work at high voltages, but there will be a lot of current sensor noise, so control performance might be not so good.

There’s no risk of damage to the ODrive, just the motor won’t perform so well - you’ll find that you can’t increase vel_gain very much before you get vibration, for example.

there is a setting for motor type HIGH CURRENT or GIMBLE. does it make sense to set it to gimble for a lower amp higher resistance motor?

Yes, it does.
Gimbal mode doesn’t use the current sensors - but it assumes that the motor moves quite slowly i.e. voltage across the resistance dominates, and there is little back-EMF.
So it might not work for high speeds.

My max vel is 4 rotations per second, though generally 1 rotation per sec is the normal speed. So should i try gimbal mode? is there a danger?