ODrive Pro SPI/AMS Encoder config

Hi, I have a couple ODrive pros we are are looking to run with absolute magnetic encoders (AS5048A).

I’ve dug around the documentation, but have not found a good set of commands for configuring SPI encoders, so I’ve been winging it a bit.

Here’s what I have tried:

odrv0.spi_encoder0.config.mode = SpiEncoderMode.AMS
odrv0.spi_encoder0.config.ncs_gpio = 4

odrv0.axis0.config.load_encoder = EncoderId.SPI_ENCODER0
odrv0.axis0.config.commutation_encoder = EncoderId.SPI_ENCODER0

Comparing with the AMT encoder configuration example, I feel like I’m missing an “enable” call, but there doesn’t seem to be any equivalent in the API.

After saving the configuration, I get:

config:
  mode: 2 (uint8)
  ncs_gpio: 4 (uint8)
raw: 0.0 (float)
status: 13 (uint8)

The bad config status implies that my config is wrong, so I want to make sure I’m not missing anything stupid before assuming it’s a connection issue and messing with the wiring. Dump errors shows no errors.

Thanks in advance for the help!

Status 13 is ComponentStatus.BAD_CONFIG. For the SPI encoder, the possible reasons for this are:

  1. ncs_gpio out of range
  2. unknown mode
  3. any of the SPI pins (on ODrive Pro that is 0, 14, 18, ncs_gpio) are used by another component
  4. maybe unknown firmware bug

Based on your info, #1 and #2 do not apply which leaves only #3 and #4. Maybe you had an old configuration that wasn’t fully erased?

I tried your commands, starting from an erased configuration, and after saving it I get status 1 (NO_RESPONSE because I have nothing connected).

1 Like

Thanks for your help; got it working. I think it turned out to be an issue with my chip select connection. Might be helpful to add a description into the API reference for the bad config status.

Another quick documentation thing, for motor config, the correct order appears to be
odrv0.axis0.motor.config whereas it is currently written odrv0.axis0.config.motor in the getting started page.

What was the issue exactly? If it’s an electrical issue only I would not expect the error BAD_CONFIG to show up. In that case I would rather expect something like NO_RESPONSE.

odrv0.axis0.motor.config moved to odrv0.axis0.config.motor in the 0.6.0 => 0.6.1 firmware update.

1 Like