Encoder calibration at odrive startup

Is it possible to set odrive to go into closed-loop mode immediately at startup without an encoder calibration process?

odrv0.axis0.config.startup_encoder_offset_calibration = False
odrv0.axis0.encoder.config.pre_calibrated = True

I tried the above two, but if I turn off the encoder calibration process by setting odrv0.axis0.config.startup_encoder_offset_calibration = False, closed-loop mode does not run.

What encoder are you using? This is only possible with hall sensors or absolute encoders.

I am using as5047p absolute encoder

I think you first need to run encoder calibration, then set pre_calibrated, then save_configuration(). I assume you have startup_closed_loop_control set?

I didn’t write it above, but I already did that and the closed-loop works fine as long as odrv0.axis0.config.startup_encoder_offset_calibration = False

Can you please set the following:

odrv0.axis0.config.startup_encoder_offset_calibration = False
odrv0.axis0.config.startup_closed_loop_control = False
odrv0.save_configuration()
# Wait for the ODrive to reappear
odrv0.axis0.requested_state = ENCODER_OFFSET_CALIBRATION # Wait for this to complete before moving on 
dump_errors(odrv0) # Check there are no errors after calibration
odrv0.axis0.encoder.config.pre_calibrated = True
odrv0.save_configuration()
# Wait for ODrive to reappear
print(odrv0.axis0.encoder.config.pre_calibrated) # Check this is either True or 1
odrv0.axis0.config.startup_closed_loop_control = True
odrv0.save_configuration()
# Wait for ODrive to reappear

# Should now start up in closed-loop mode. If it doesn't, run dump_errors(odrv0) and see what the issue is

didn’t work

Can you give more information? What exactly is happening?

The situation is that when odrive is restarted, if odrv0.axis0.config.startup_encoder_offset_calibration = False is set and calibration is not performed, closed-loop mode is not executed and there is no response.

Nothing will change even if i’m follow the instructions above.

What happens if you run dump_errors(odrv0) in that situation?

Also, just to check, are you using this encoder over SPI or incremental A/B/Z?

I am using SPI

In [154]: dump_errors(odrv1)
system: not found
axis0
axis: no error
motor: no error
DRV fault: not found
sensorless_estimator: no error
encoder: no error
controller: no error
axis1
axis: no error
motor: no error
DRV fault: not found
sensorless_estimator: no error
encoder: no error
controller: no error

Just checking – which ODrive is this? And what firmware version?

I am using odrive 3.6 (56V), AS5047P absolute encoders, SPI, firmware v0.5.1

This is the code I have sent to the drives:

odrv0.erase_configuration()

odrv0.config.brake_resistance = 0
odrv0.config.dc_max_negative_current = -5
odrv0.axis0.motor.config.pole_pairs = 20
odrv0.axis0.encoder.config.cpr = 214
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 3
odrv0.axis0.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
odrv0.axis1.motor.config.pole_pairs = 20
odrv0.axis1.encoder.config.cpr = 2
14
odrv0.axis1.encoder.config.abs_spi_cs_gpio_pin = 4
odrv0.axis1.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
odrv0.save_configuration()

odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
odrv0.axis1.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
odrv0.save_configuration()

odrv0.axis0.motor.config.pre_calibrated = True
odrv0.axis0.config.startup_encoder_offset_calibration = True
odrv0.axis0.config.startup_closed_loop_control = True
odrv0.axis0.encoder.config.pre_calibrated = True
odrv0.axis1.motor.config.pre_calibrated = True
odrv0.axis1.config.startup_encoder_offset_calibration = True
odrv0.axis1.config.startup_closed_loop_control = True
odrv0.axis1.encoder.config.pre_calibrated = True
odrv0.save_configuration()
odrv0.reboot()

As an aside, I send the calibration sequence individually to each axis after I power cycle the board (i.e.
Send the first set of commands and do the save
Power down the board
Send the calibration to axis0 and wait for completion
Send the calibration to axis1 and wait for completion
Save

Send the remaining code to the board, save & reboot.

I have the two encoders: MOSI, MISO, SCK connected to the same SPI inputs on the Odrive
I have encoders power connected to 3.3V of the incremental inputs ( M0 & M1)
I have the encoders ground connected to the last two ground pins of the SPI inputs

This works for me, might give it a try.

When I re-power the ODrive, the motors perform a small turn (L & R) then go into Closed Loop Mode

Only thing I would like to see different is for the motors to NOT perform the small turn on power up, but have been unable to figure that one out.

Hope it helps

Ciao

The startup_encoder_offset_calibration being set to True is why they’re doing the left/right movement on startup; if you have an absolute encoder, this shouldn’t be necessary :slight_smile: so you should be able to start right up into closed loop mode.

Solomon

Thanks for the info, will give this a try this weekend :slight_smile:

Hope kj2468mm has some success as well.

Ciao