Close

AMT10 Encoder setup

A project log for Open Robotics Eurobot

Open Source competition robot development. You will never be alone for your contest again!

barbiercharles1barbier.charles1 03/29/2016 at 18:230 Comments

In our project we chose to use the encoders from the AMT10 series ($23 at Digi-Key, datasheet: www.cui.com/product/resource/amt10-v.pdf). Here is how to use it, the simple way.

We will explain the mechanical setup later, first let’s concentrate on electronics and programming.

These encoders works with a direct current between 3.6 and 5.5V, 5V being the nominal voltage. There are 3 different data output pins, the index “I” sends a pulse each time the encoder makes a full rotation, the pins “A” and “B” switch between high and low logic states each time the encoder makes a certain fraction of a full rotation. This fraction / the resolution of the encoder can be set thanks to a DIP switch on the encoder from 48 to 2048 ppr (pulse per revolution).

A and B have the same frequency but B is a half period late compared to A. This way when turning clockwise B is at low state at when A is rising edge, but when turning counter clockwise B is already high at each of A’s rising edges. This allows you to know which way you are going by reading B when A is rising edge.


I have written a short code you can use to test your encoder and see how it works, I have noticed that when using an Arduino uno some pulses are skipped when the resolution is over 100 ppr, seemingly because the microcontroller isn’t fast enough. Also, we do not have fixed the encoder axis, so lateral movement may tamper with the capacitive sensor in the encoder.


int A = 12;
int B = 11;
int I = 10;

int countTick = 0;
int countIndex = 0;
char precTick = 0;
char precIndex = 0;
char tick = 0;
char tickB =0;
char index = 0;

void setup() {
  pinMode(A, INPUT);
  pinMode(B, INPUT);
  pinMode(I, INPUT);
  Serial.begin(9600);

}

void loop() {
  tick = digitalRead(A);
  tickB = digitalRead(B);
  index = digitalRead(I);
  
  if(tick != precTick)
  {
    if(tick != tickB)
    {
      countTick = countTick + tick;
      precTick = tick;
    }
    else
    {
      countTick = countTick - tick;
      precTick = tick;
    }
    Serial.print("tick :");
    Serial.println(countTick);
  }
  
  if(index != precIndex)
  {
    if(countTick > 0)
    {
      countIndex = countIndex + index;
      precIndex = index;
    }
    else
    {
      countIndex = countIndex - index;
      precIndex = index;
    }
    countTick = 0;
    Serial.print("turn :");
    Serial.println(countIndex);
  }
  
  
}

Discussions