Two Absolute Encoders to ODrive

Hello,

My name is jimmy.

We bought ODrive v3.6 56v board.

May we communicate with ODrive by UART with two absolute encoders?

And we also need one UART to communicate with Arduino.

So we need total three UART.

Do you have any idea of experience similar to this situation?

Thank you!

ODrive normally communicates with absolute encoders via SPI, not UART.
What type of encoder are you trying to use?

1 Like

We use orbis encoder.
https://www.rls.si/cn_en/orbis-true-absolute-rotary-encoder?___from_store=cn

If we want to use two absolute encoders to ODrive via SPI,
How do I create the second SPI CS Port?

The CS “port” is just a GPIO pin. You can use any of the GPIOs, just set encoder.config.abs_spi_cs_gpio_pin to the corresponding number.

The Release Candidate version of the firmware supports those encoders natively. Hook up CLK, MISO, and the two CS pins (GPIO 8 and GPIO 7 shown below, but that’s configurable).

odrv0.axis0.encoder.config.mode = 259
odrv0.axis0.encoder.config.cpr = 2**14
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 8
odrv0.axis1.encoder.config.mode = 259
odrv0.axis1.encoder.config.cpr = 2**14
odrv0.axis1.encoder.config.abs_spi_cs_gpio_pin = 7

odrv0.axis0.config.startup_closed_loop_control = True
odrv0.axis0.config.startup_encoder_offset_calibration = True
odrv0.axis0.config.startup_motor_calibration = True

odrv0.save_configuration()
odrv0.reboot()

odrv0.axis0.encoder.config.cpr = 2**14
2**14 =>This is a value?

I bought AMT20-V KITS (https://www.mouser.tw/datasheet/2/670/amt20_v-1775926.pdf)
Do u know what cpr value?

It tells you right there in the datasheet: 4096

Thank you!
And another question.
AMT20-V
Command 0x10: rd_pos (read position)
Command 0x70: set_zero_point (zero set)
How do I set config? and how to send command by odrive native protocol?

We’ve discovered recently (two days ago) that the AMT20 is not supported by ODrive. Please substitute the AMT232-b

Supported absolute encoders are:

  • AS5047p
  • AS5048A
  • AMT232-b
  • RLS Orbis (SSI LVTTL 5V)

Probably also AS5147U. AS5047P seems to be discontinued (I wonder why, given the issues we have been having…)

The AS5147U is explicitly NOT supported at this time, but could easily be added (the protocol is slightly different)

1 Like

Hi, I am testing your release candidate version of the firmware. I am a bit confused about the encoder doc (https://github.com/madcowswe/ODrive/blob/rc-v0.5.1/docs/encoders.md). It mentioned “The encoder’s SCK, MISO (aka “DATA” on CUI encoders), GND and 3.3V should connect to the ODrive pins with the same label.” I have CUI AMT232B encoder, it requires 5v power supply. Should I tie 5v to 3.3v from Odrive or 5v from Odrive please?

Hello
I’m having a hard time getting the second encoder working. I have 2x AS5047p encoders and a 24V v3.6 board.
With only one encoder it works well. For one axis I have MOSI connected to 3.3V.
For 2 axis I connect all MOSI to MOSI, all MISO to MISO and use a sperate GPIO for chip select (CSn), in my case GPIO 4 and 5.

My encoder config is as follows:

"encoder": {
            "config": {
                "abs_spi_cs_gpio_pin": 4,
                "bandwidth": 1000.0,
                "calib_range": 0.019999999552965164,
                "calib_scan_distance": 50.26548385620117,
                "calib_scan_omega": 12.566370964050293,
                "cpr": 16384,
                "direction": 1,
                "enable_phase_interpolation": true,
                "find_idx_on_lockin_only": false,
                "hall_polarity_calibrated": false,
                "hall_polarity": 0,
                "ignore_illegal_hall_state": false,
                "index_offset": 0.0,
                "mode": 257,
                "phase_offset_float": 0.5352544188499451,
                "phase_offset": 21092,
                "pre_calibrated": true,
                "sincos_gpio_pin_cos": 0,
                "sincos_gpio_pin_sin": 0,
                "use_index_offset": true,
                "use_index": false
            }
        },

As soon as I turn it on and do dump_errors(odrv0) I see:

In [18]: dump_errors(odrv0)
system: no error
axis0
  axis: no error
  motor: Error(s):
    MotorError.DRV_FAULT
  DRV fault: none
  sensorless_estimator: no error
  encoder: Error(s):
    EncoderError.ABS_SPI_COM_FAIL
  controller: no error
axis1
  axis: no error
  motor: Error(s):
    MotorError.DRV_FAULT
    MotorError.UNKNOWN_TORQUE
  DRV fault: none
  sensorless_estimator: no error
  encoder: Error(s):
    EncoderError.ABS_SPI_COM_FAIL
  controller: no error

Any help would be greatly appreciated.

@Wetmelon perhpas you could help with these short questions:

  1. Is daisy chaining supported as an option in stead of the n+3 wire mode?
  2. If using n+3, do I need pull up resistors on the chip select?
  3. Is there a good build-log/tutorial/referince for how to use two absolute SPI encoders at the same time?

Try a tri-state buffer on the MISO pin

Ok, just googled tri-state buffers. I think that that the chip select is active low, so in that case I would need 1 of these (CD74HC125E) and then need to connect the enable pin for each to the chip select for that axis. Is this correct?

1 Like

Hi,

Did support for this encoder ever get added? I am using a the Odrive pro and can’t get the AS5147U working.

I have ordered the supported encoder but we are on a very tight deadline and this is all I have currently. Would be happy to contribute the code change.

Cheers
Lewis