Encoder calibration first time

ok. Not working…
I erased again and I wrote this:

In [162]: odrv0.axis0.controller.config.control_mode = 0

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

In [164]: odrv0.axis0.motor.config.current_lim =20

In [166]: odrv0.axis0.motor.config.calibration_current=20

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

In [168]: odrv0.config.brake_resistance=0.5

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

In [170]: dump_errors(odrv0, True)
In [171]: odrv0.save_configuration
In [172]: odrv0.reboot()

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

The motor just rotate cw. And dump_errors(odrv0) returns:
axis0
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_NO_RESPONSE
controller: no error

Please help me to figure it out.

Did you check your wiring? Can you share pictures of your setup?
Do you have an oscilloscope?
you can also use the live-plotter of the position estimate. Not sure if you tried that

Ok. To summarize.
I just run the code above to calibrate the motors and encoders. But it seems not working well.

I don’t have oscilloscope.

Here is my wiring structure:

can you make a better connection with your motor leads?
show us a picture of the encoder mounted on the back of the motor so we can check the wiring.

did you try to erase config and redo everything clean, following the getting started guide and nothing else?

I’ll connect the motor directly to the Odrive and I’ll erase the configuration and try again… Btw I followed the getting started guide and nothing happened… As you see my encoders has Z index… So in the getting started guide they don’t configure the z axis to True

Btw, the resistor connection is ok?

the Z index can be there and wired, but you don’t need to enable it in ODrivetool. You’re just adding one more element into the equation. Get the encoder to calibrate without the Z index configured, and then you can re-enable it and go from there.

Same goes with the resistor, although I don’t think it could cause these errors. It doesn’t hurt to take it off and put the brake resistor value to 0 (to disable it).

your wiring is correct, I mean aside from the taped motor wires I don’t see anything obviously wrong.

Yes, erase config, reboot. power cycle if needed. Then get into Odrivetool and check that all parameters went back to default. Once that’s done go with the most basic config: Pole pairs and Motor type (default should be good for both). Current, 10 limit, 5 cal limit (those numbers are what I remember from when I got started with a 5065). Brake resistance to 0 if you removed it. save config, and finish with:

  odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

followed by an error dump

I did everything from the beginning and I’ve just changed odrv0.axis0.motor.config.pole_pairs=6 because the 5065 has 12 magnet poles

just rotate to the left… and this is the error:

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

Wait… I’ve changed odrv0.axis0.motor.config.pole_pairs to 7 and now rotate both sides

1 Like

it’s a 14 magnet rotor, so 7 pole pairs, not 6.
you had 7 yesterday in your first post.

You should be good then, no error after the encoder did the full calibration cycle?

Indeed no errors… and position control is working well. Thanks a lot. I will examine what was wrong

1 Like

Awesome. You may want to go through the guide for encoders with indexes, there are steps to do before putting the precalibrated parameter to true.

Cheers

Thank you for your help. May I ask you something?
I run code in Arduino and is working well but every time when I calibrate the motors by odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
First motor 0 calibrate without problems but when the motor 1 starts to calibrate, motor 0 starts moving a few steps forward and back. Do you know why? It only happens whit Arduino and not with Odrive Tool

Can you show your code?

Have you verified this particular calibration routine (offset) works with odrivetool? On both motors

Hello Zytra. Now it is working well but I have one more question.
When the motor is running for instance odrive.SetPosition(0, pos_m0);
if I try to stop the motor with my hand definitely the motor stops but I have to reset the power supply to run again the motor.
I need to read by Arduino that the velocity or torque is increasing because my hand and from the Arduino program I have to stop the motor.
What do you recommend?

After you “stop” the motor by hand and before you reset power can you dump the errors?
By applying an external torque, the current may be reaching the limit you’ve set?

I can’t see dump errors from Arduino.
When the motor runs and I try to stop the motor,it doesn’t mean that the motor has to increase it’s torque?

Yes the torque increases as you apply external forces. But the current is also increasing. So perhaps your current limit is too low for what you’re doing.

You should be able to read errors in ascii, not sure if the arduino lib has some prebuilt error reading functions though.

I did the same experiment using odrivetool and when I try to stop the motor indeed the motor increases its force but after a few seconds died and I have to reboot odrv0.reboot()

axis0
axis: Error(s):
ERROR_CONTROLLER_FAILED
motor: Error(s):
ERROR_CONTROL_DEADLINE_MISSED
encoder: no error
controller: Error(s):
ERROR_OVERSPEED

But when running with Arduino the motor doesn’t fight and died and I can’t reboot from Arduino, this command odrive.write("sb",'\n'); doesn’t work.

that overspeed error is weird, especially if the motor was not spinning while you are holding it.
the control deadline missed is not something I have ever seen personally.

what control mode are you using? position control?

ok. To summarize…

I am using position control to move the motors.
The motors runs well. I want to implement a function to detect collison of the motor. So, if the motor hit a surface it’s mean the current will increase and this increment I need to measure to stop the motor from arduino. The problem is when running the motor with arduino I try to stop the motor with my hand and the motor stop without fight and died, I can’t reboot the odrive because there is not command to that from arduino. I’d like to know why the motor died without fight even if the current is 50A.