Error : ERROR_CURRENT_LIMIT_VIOLATION

Hi, I have a problem.
I follow the Odrive “getting started” step. After encoder and motor calibration, I set the “pre_calibration” to True.
But every time I give the power supply, and do

“odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL”

the motor looks overshoot (turn a little suddenly)and then stop, there is an error:
motor:
ERROR_CURRENT_LIMIT_VIOLATION.

Ps: 1. I can use “dump_errors(odrv0,True)” to set error to true, and then close-loop. the motor going well.
2. if I do full calibration (odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE) from the beginning, the motor also have no problem.

I try increase the current_limit but it doesn’t work, The Odrive document says I may have stability issues in the current controller. I don’t understand what is that. I also try change the pos_gain, but no effect.

Any ideas for this problem? Thank you so much

What encoder are you using? You will need to calibrate each time if you’re not using an absolute encoder.

Hi, I use an absolute encoder

@huihui521leilei It’s been a while, but I have a similar problem, but I use Hall encoder. Have you solved your problem ? If so, what have you done ?

Thanks

Have you checked current_lim, current_lim_margin, and requested_current_range?

I checked current_lim, but I can’t find current_lim_margin and requested_current_range. Is it just me or it’s not available with the Odrive Pro, because I can see people discussing over these parameters, so I know they exist, but I can’t find them.

The only parameters I changed related to current are the ones below:

odrv0.config.dc_max_positive_current = bat_capacity * 10
odrv0.config.dc_max_negative_current = -bat_capacity * 1
odrv0.axis0.config.motor.current_soft_max = 45 # [A]
odrv0.axis0.config.motor.current_hard_max = 60 # [A]

I’m using the Odrive Pro and ODrive control utility v0.6.3.post.

They may only be settings in the 3.6

Try running this command and crtl + F for “current”, no promise it does anything but it might tell you of some settings you don’t know about
odrivetool backup-config my_config.json

What mode and input are you running the motor in?

I just find out that those settings have effectively migrated ([0.6.3] - 2022-08-19 — ODrive Pro Documentation 0.6.3 documentation).

I’m running it closed_loop and velocity_input

odrv0.axis0.requested_state = AxisState.CLOSED_LOOP_CONTROL
odrv0.axis0.controller.config.control_mode = ControlMode.VELOCITY_CONTROL
odrv0.axis0.controller.input_vel = 1

And since I’ve read about the migrations, that line might be an interresting parameter, but I can’t find it in the prompt.

<axis>.motor.current_control moved to <axis>.foc

The only parameter that is similar is that one (which is probably the corresponding one) :

odrv0.axis0.motor.foc.Iq_setpoint 

That parameter is set to 0, but the Id_setpoint is set to 10, could that be my problem ?!
Which I’m not really sure how to use it as there is no description for that parameter in the doc.

Can I control in velocity_mode + FOC, because FOC seems to be a way to control motors.

Thanks

Iq is phase current, so if you are in velocity control it will use motor current (which is directly proportional to torque) to accelerate or decelerate the motor, if you have the system plot the Iq setpoint you can see it go up and down as the motor overshoots and undershoots the velocity setpoint

FOC (field orientation control) is a method of energizing coils, BLDC uses a square wave which has more power but is less efficient and has that high pitch whine, FOC is a sine wave approximation and is much smoother

But if I set it in ControlMode.VELOCITY_CONTROL, I don’t have to bother with the Iq and or Id setpoint right ?

And unfortunatly I can’t use the liveplotter because I have a thread error saying that it must be run in the main thread and it is not, so I don’t even have a windows that opens…

Nah it is all internal, you should never be writing to the setpoints, only things you modify are inputs and settings

run these commands
import matplotlib
matplotlib.use(‘TkAgg’)
cancellation_token = start_liveplotter(lambda: [odrv0.axis0.motor.current_control.Iq_setpoint, odrv0.axis0.motor.current_control.Iq_measured])

1 Like

First of all, THANK YOU, the liveplotter is now working with small modifications (for other users of OdrivePro with v0.6.3)

import matplotlib
matplotlib.use('TkAgg')
cancellation_token = start_liveplotter(lambda: [odrv0.axis0.motor.foc.Iq_setpoint, odrv0.axis0.motor.foc.Iq_measured])

I can finally see that there’s a lot of noise on the measured current. On the figure below the commands were:

In [35]: odrv0.axis0.controller.input_vel = 6

In [36]: odrv0.axis0.controller.input_vel = 10

and I got the following error when the velocity was set to 10 :

In [37]: dump_errors(odrv0)
axis0
  active_errors: no error
  disarm_reason: Error(s):
    ODriveError.CURRENT_LIMIT_VIOLATION
  procedure_result: ProcedureResult.DISARMED
  last_drv_fault: none
internal issues: none

because the Iq_setpoint goes sky high and reach the current limit (after I saved the graphic). My motor has no load, so the current shouldn’t be that high for such low speed and no torque applied…
Iq mesured

It’s really odd that it would hit 14A phase current and hold steady, it should never be that stable

UPDATE : I pushed the current limit to 100 A, the motor is allowed to turn at a higher speed, however (probably because of the noise) I lose the connection with the drive, the plot stops updating and the prompt display :

And I have to power off the Drive to re-connect…

At that point, it has hit the limit current, that’s why I pushed the current limit to see how it handles it and as I described it, everything freezes…

My main concern is : Why the measured current is that noisy AND why is it that high, because the motor has no load… hence the current shouldn’t be that high

If the motor is trying to maintain velocity or position it will be over and undercompensating constantly, the only time motor current should be stable is if it is idle

“the only time motor current should be stable is if it is idle” by idle you mean not moving ?

What can I do to reduce the noise in the current, because I can’t reach over 20 rot/s without reaching my current limit and my current_limit is 100A which is quite high for a motor without any load on it.

A motor can be not moving and still use power, if you set it to constant position or zero velocity it will use motor current to hold the motor in place and you will still see the current spiking, if the motor is idle and can spin freely without resistance then it should be stable at 0A phase current, but while it’s actively in closed loop control it will use power