Configure Absolute Encoder AS5048A

odrv0.erase_configuration()
dump_errors(odrv0)
##expecting a motor: Error(s):   MOTOR_ERROR_DRV_FAULT
##this error goes away after these are set and odrv is rebooted
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 4
odrv0.axis0.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
odrv0.axis0.encoder.config.cpr = 2**14
odrv0.axis0.config.startup_encoder_index_search = False
dump_errors(odrv0)
odrv0.save_configuration()
odrv0.config.enable_brake_resistor = True
odrv0.config.dc_max_negative_current = -1
dump_errors(odrv0)
odrv0.save_configuration()
odrv0.reboot()
dump_errors(odrv0)
odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

at this point I was able to run closed loop control and move the motor as I wanted. I had to run the calibration again before saving otherwise the save_configuration would return false, but thats fine.

odrv0.save_configuration()
odrv0.reboot()

problem starts here. I can’t figure out how to go straight into closed loop control after reboot.

Connected to ODrive 206235A55748 as odrv0
In [1]: dump_errors(odrv0)
system: no error
axis0
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error

In [2]: odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

In [3]: dump_errors(odrv0)
system: no error
axis0
  axis: no error
  motor: Error(s):
    MOTOR_ERROR_UNKNOWN_PHASE_ESTIMATE
  sensorless_estimator: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error

I turned the power off and waited, then turned it back on.
once turned back on I was able to do

dump_errors(odrv0)
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
dump_errors(odrv0)
odrv0.axis0.controller.input_pos += 1
dump_errors(odrv0)

the motor moved correctly and didn’t give any errors when I ran the dump.
it appears a power off as opposed to just a reboot/save_configuration is necessary sometimes.

but then I decided to do this test again.
powered off system, waited, power on.

dump_errors(odrv0)
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
dump_errors(odrv0)
odrv0.axis0.controller.input_pos += 1
In [24]: dump_errors(odrv0)
system: no error
axis0
  axis: no error
  motor: Error(s):
    MOTOR_ERROR_UNKNOWN_TORQUE
    MOTOR_ERROR_UNKNOWN_VOLTAGE_COMMAND
  sensorless_estimator: no error
  encoder: no error
  controller: Error(s):
    CONTROLLER_ERROR_SPINOUT_DETECTED
axis1
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error

and it failed…

but then I decided to do this test again.
powered off system, waited, power on.

dump_errors(odrv0)
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
dump_errors(odrv0)
odrv0.axis0.controller.input_pos += 1

and everything worked correctly …

Resolved?
I ran everything again, and it worked.

ran everything again and got a series of different errors today
one permutation of errors from today

axis0
  axis: no error
  motor: Error(s):
    MOTOR_ERROR_UNKNOWN_TORQUE
  sensorless_estimator: no error
  encoder: Error(s):
    ENCODER_ERROR_NO_RESPONSE
    ENCODER_ERROR_ABS_SPI_COM_FAIL
  controller: Error(s):
    CONTROLLER_ERROR_INVALID_ESTIMATE

cable length is 12 inches. it is not shielded

1: Unfortunately using the AMS AS5048A on an ODrive is unreliable
1: People have had the most luck with the AS5047P.
1: But in general i don’t recommend SPI encoders
2: are you referring to https://www.digikey.com/en/products/detail/ams/AS5047P-TS-EK-AB/5452344 when you say the AS5047P
1: Yep, people use that commonly