Encoder calibration first time

Hi, dear community.
I got an Odrive v3.6, Odrive motor D5065-270kv, and encoder cui-amt102.
I’m following the documentation about how to calibrate the encoder using the odrive tool but I have errors

This is my configuration:
In [18]: odrv0.axis0.encoder.config.use_index=True

In [19]: odrv0.axis0.encoder.config.pre_calibrated=True

In [20]: odrv0.axis0.motor.config.pole_pairs=7

In [21]: odrv0.axis0.motor.config.motor_type=MOTOR_TYPE_HIGH_CURRENT

In [22]: odrv0.config.brake_resistance=0.47

In [23]: odrv0.axis0.encoder.config.cpr=8192

In [24]: odrv0.axis0.encoder.config.use_index =True

In [25]: odrv0.axis0.encoder.config.pre_calibrated=True

In [26]: odrv0.save_configuration()

In [27]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

In [28]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

In [29]: odrv0.axis0.controller.pos_setpoint = 9000

In [30]: odrv0.reboot()

Reconnected to ODrive 2057397C4D4D as odrv0
In [31]: odrv0.axis0.controller.pos_setpoint = 10000

In [32]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

In [33]: odrv0.axis0.controller.pos_setpoint = 10000

In [34]: odrv0.axis0.controller.pos_setpoint = 100

These are the errors:

In [35]: hex(odrv0.axis0.motor.error)
Out[35]: ‘0x0’

In [36]: hex(odrv0.axis0.error)
Out[36]: ‘0x100’

In [37]: hex(odrv0.axis0.encoder.error)
Out[37]: ‘0x20’
When I run dump_errors(odrv0) I got this:
In [47]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_INDEX_NOT_FOUND_YET
controller: no error
axis1
axis: no error
motor: no error
encoder: no error
controller: no error

It seems there is a lack of information about setting up & calibration for encoders.
I followed this documentation: Encoders

Hey

Calling for pos_setpoint right after the calibration will not actually do anything until you request the closed loop state. The command for that would be:

    odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

Now, you probably want to check for errors like you did right after your calibration, before trying closed loop control to make sure the calibration went fine.

Based on the error you’re getting, you may want to check your current limit and calibration current, respectively. I had a case once where the calibration current was too low and the calibration routine wouldn’t go through.

    odrv0.axis0.motor.config.current_lim
    odrv0.axis0.motor.config.calibration_current

Here’s a link to Doc that talks about that:

By the way, after you clear errors and run the calibration, does the motor turn or not all? the command to clear errors is:

      dump_errors(odrv0, True)

Hi!
Thank you for answer my question.
after running
odrv0.axis0.motor.config.current_lim
odrv0.axis0.motor.config.calibration_current
I got this:
In [48]: odrv0.axis0.motor.config.current_lim
Out[48]: 10.0

In [49]: odrv0.axis0.motor.config.calibration_current
Out[49]: 10.0
This means 10 A, right? I changed this value to 40A for each one and also cleaned the “dump_errors(odrv0, True)”

then I run:
odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
the motor start the calibration and after that I run again the command “dump_errors(odrv0)” but I got the same errors:

axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_INDEX_NOT_FOUND_YET
controller: no error

I would try bringing the calibration current down to 5A - it’s been a while since I played with the 5065 myself, I forgot what values worked for me, but if I recall 5A is what I had.

You didn’t say if you had any movement on the motor when running the calibration?

re-reading your first post I got more comments:

  • I think you should not be putting the encoder config to precalibrated until after you’ve actually calibrated… change this back to false, clear errors and try running the calibration again:

     odrv0.axis0.encoder.config.pre_calibrated=False
    
  • Also, are you using a brake resistor? if not, that value should be 0 to disable it.

Ok with 5A the motor don’t move…
I got this error:

In [69]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_MOTOR_DISARMED
ERROR_MOTOR_FAILED
motor: Error(s):
ERROR_CURRENT_UNSTABLE
encoder: no error
controller: no error

ok, bring the calibration current back to 10A.
and turn the index precalibration to false.
clear errors and try again

with odrv0.axis0.encoder.config.pre_calibrated=False
and odrv0.axis0.motor.config.current_lim=20 odrv0.axis0.motor.config.calibration_current=20
and dump_errors(odrv0, True)

The motor move during the calibration

I got this error
In [79]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_INDEX_NOT_FOUND_YET
controller: no error

one more time, but also change:

  odrv0.axis0.encoder.config.use_index =False

I got this

In [107]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_NO_RESPONSE
controller: no error`

btw sorry I forgot to tell you I have a R5J as a resistance

I would try erasing the board and follow the commands in the getting started guide, because doing the more advanced encoder configuration with precalibration and such.

mode 0
cpr 8192
current/cal current 10/10
7 pole pairs
brake resistance to whatever your resistance is
save config
reboot
full calibration
dump errors
and if none, then closed loop

When you say erase, you mean run this command odrv0.erase_configuration() , right?

yes, give that a shot

if is ok if I add odrv0.axis0.motor.config.motor_type=MOTOR_TYPE_HIGH_CURRENT ?

yes. MOTOR_TYPE_HIGH_CURRENT is defined as 0

I am getting crazy with it…

i did everything and now I got:

In [142]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_NO_RESPONSE
controller: no error
axis1
axis: no error
motor: no error
encoder: no error
controller: no error

does it move at all during the calibration?

yes. just 1 cicle…

What do you mean? it rotates in one direction, but does not come back the other direction?
if so, play with your calibration current (push it up) and try again.

oh and of course, double check your wiring. make sure nothing’s loose.

I tried again… I changed from 10 A to 20A and the response is the same…
Just rotate one direction…

Do I have to add these lines, right?

odrv0.axis0.encoder.config.use_index =True// I am using the AMT102 so it has z index

odrv0.axis0.encoder.config.pre_calibrated=False

still rotate one direction

Not if you erased the configuration. They should back to their default. One way to check is to enter the variable without the equal sign and value and hit enter. That will return their current value.

Try lowering the calib current just in case.