CUI AMT203-V problems with SPI connection


New to Arduino, I am trying to use an Arduino Mega 2560 as a Master to read data from a CUI AMT203-V.

I have read several posts online about this sensor and there is a code that seems to do the trick:

#include <SPI.h>
#define CS 53 //Chip or Slave select 
uint16_t ABSposition = 0;
uint16_t ABSposition_last = 0;
uint8_t temp[1];
float deg = 0.00;
void setup()
  pinMode(CS,OUTPUT);//Slave Select
uint8_t SPI_T (uint8_t msg)    //Repetive SPI transmit sequence
   uint8_t msg_temp = 0;  //vairable to hold recieved data
   digitalWrite(CS,LOW);     //select spi device
   msg_temp = SPI.transfer(msg);    //send and recieve
   digitalWrite(CS,HIGH);    //deselect spi device
   return(msg_temp);      //return recieved byte
void loop()
   uint8_t recieved = 0xA5;    //just a temp vairable
   ABSposition = 0;    //reset position vairable
   SPI.begin();    //start transmition
   SPI_T(0x10);   //issue read command
   recieved = SPI_T(0x00);    //issue NOP to check if encoder is ready to send
   while (recieved != 0x10)    //loop while encoder is not ready to send <<--- This does not work in MATLAB
     recieved = SPI_T(0x00);    //cleck again if encoder is still working
     delay(2);    //wait a bit
   temp[0] = SPI_T(0x00);    //Recieve MSB
   temp[1] = SPI_T(0x00);    // recieve LSB
   digitalWrite(CS,HIGH);  //just to make sure   
   SPI.end();    //end transmition
   temp[0] &=~ 0xF0;    //mask out the first 4 bits
   ABSposition = temp[0] << 8;    //shift MSB to correct ABSposition in ABSposition message
   ABSposition += temp[1];    // add LSB to ABSposition message to complete message
   if (ABSposition != ABSposition_last)    //if nothing has changed dont wast time sending position
     ABSposition_last = ABSposition;    //set last position to current position
     deg = ABSposition;
     deg = deg * 0.08789;    // aprox 360/4096
     Serial.println(deg);     //send position in degrees
   delay(10);    //wait a bit till next check

The CUI AMT203-V is directly powered through the 5V / GND pins of the Mega 2560 and the MISO, MOSI, SCK and CSB lines are attached respectively to the 50, 51, 52 and 53 pins as per the specifications.

However, it seems that the program is stuck in the “while” loop as if it is not receiving any data (wait message is displayed over and over). After a few checks it seems that my device is not sending back any data at all.

I have tried with two different sensors, two different connectors and still no luck. I have still 2 other spares but I am not convinced it would change anything.

My guesses:

1)I fried both sensors by running them directly through the 5V output of the Arduino. Maybe the output current is too strong? I need to find a way to limit the output current to a more acceptable level using resistors? It seems the required input current is lower than 10mA from the data sheet. However some people seem to have no issue with it: see here: direct 5V power from the Arduino to the CUI AMT203…

  1. The SPI setup is not correct and I can’t communicate through the SPI bus to the device. The encoder data rate seems to be 1MHz, capturing data on the rising edge of SCK and output on the falling edge of SCK. So the SPI.Setclockdivider should work at DIV32 (i.e. effective rate of 500kHz) with MODE0 and MSBFIRST.

  2. Something else is preventing the SPI from communicating? Maybe I need to do a Set Position command before anything else? That’s what I tried to do with the second sensor and I got no answer as well. Is there a preliminary setup i need to do?

  3. I have zero luck and all my sensors are broken, which statistically would be very unlikely since I have tried one AMT203-V and one AMT203S-V (different locking connectors), i.e. different batches.

Any help is appreciated, thanks for your suggestions!



Maybe the output current is too strong? I need to find a way to limit the output current to a more acceptable level using resistors? It seems the required input current is lower than 10mA from the data sheet.

This is not the problem. You only need to provide a 5 V supply that can provide at least 10 mA (which the Arduino can certainly do). If the supply can provide more than 10 mA, that's no problem at all. You don't need to limit the current.

Thanks for your reply. I have contacted CUI technical support which backs the fact that Arduino should not have any issue powering the sensor.

This leads me to (1) a connector problem, (2) a code issue and (3) a sensor issue. Since I already downloaded and ran the Cui code directly from their website and tried the third sensor I bought to no avail, I am lost as to why is this not working. The arduino itself?

To make sure the sensors are properly working I bought an USB to connector cable and will try connecting the encoder to the AMT Viewpoint software. Then I will be able to isolate the pb.

I will let you know how it goes..

Any other feedback is most welcomed!