Read Encoder Values (RasPi)

Not sure if this is the right forum for this, but I assume people in the Odrive community have faced this problem.

I am trying to read data off of an AMT212B encoder (separate from the one used by my Odrive) using Raspberry Pi and the MinimalModbus python library.

My hardware set up is the encoder (which works when Odrive is using it), raspberry pi, and an USB to RS485 converter. The encoder is plugged into the 5V and GND pins on the PI and then the A and B signal wires from the encoder are plugged into the USB converter along with a ground connection.

My python code on my pi is as follows:
import minimalmodbus
instrument = minimalmodbus.Instrument('/dev/ttyACM)', 1, debug=True)

When everything is plugged in, the USB converter lights has the power light and the RXD light illuminated. When I execute the code the TXD illuminates.

Minimalmodbus is sending “01 03 00 54 00 01 C5 DA” and is reading “Response from instrument: (0 bytes)”

Any idea what I am doing wrong to read this encoder data?

Update: I had tried all the baud rates except 1 Mbps. 1 Mbps recieves a response from the sensor.

The new error depends on if I’m in RTU or ASCII mode. When in ASCII mode the error is Did not find header ( ' : ' ) at start of ASCII response.

In RTU mode the error is Checksum error in rtu mode: 'oo" instead of "°Ü"

Hi Aidandf,

The AMT212 requires a 2Mbaud communications rate, and cannot communicate any slower than this.

Unfortunately, your methodology has some issues – the AMT212 isn’t a modbus instrument, so any modbus library / communication protocol won’t work. You should look at implementing pure binary reads/writes - just sending a “0x54” packet at the proper baudrate will result in a response from the sensor.