Read in 10-bits Magnetic Encoder AEAT-6010-A06 into Arduino Uno

Dear members,

for a school project I have to implement a 10-bits magnetic encoder on a plant.
To explain the plant, I will give you a similar example: Arduino + Matlab: Controlador PID - test 1 - YouTube
I have to inplement PID controle with LabVIEW and an Arduino Uno..

Instead of the potentiometer to check the angle of the bar, and use PID depending on the angle, I now have to use a 10-bits magnetic encoder.

The following one: AEAT-6010-A06 10-bits Magnetic Encoder

Link tot the datasheet: http://www.avagotech.com/docs/AV02-0188EN

The AEAT-6010 magnetic angular based rotary detector uses a serial data stream and clock to be able to read out the absolute position in digital form.
The CLOCK and DATA signals are transmitted according RS-422 standards.

About the code:

As you can see in the characteristics in datasheet I have to "produce" a 10 times "HIGH" and "LOW" signal for the CLOCK.
I also have to watch the delay times which are given in the datasheet and making the Chip select and CLK high as given in the characteristics.

I have allready made the following code, but on the Serial Monitor I only get a "1" out..

My pin connection is the following one:

1: VDD (5V supply voltage): 5V power supply Arduino
2: CSn (Chip select): Digital output 4 Arduino
3: VSS (GND): GND Arduino
4: CLK (Serial clock-input): Digital output 7 Arduino
5: DO (Serial Data-Output): Digital output 8 Arduino

Does anyone has some experience with reading this kind of sensor into the Arduino?
I would appreciate your help a lot!

// Read in 10-bits Magnetic Encoder AEAT-6010-A06  into Arduino Uno
// RobinL
 
// Declarate

const int CSn = 4; // Chip select
const int CLK = 7; // Clock signal
const int DO = 8; // Digital Output from the encoder which delivers me a 0 or 1, depending on the bar angle..
 
unsigned int sensorWaarde = 0;
 
void setup(){

	//Fix de tris

	pinMode(CSn, OUTPUT);
	pinMode(CLK, OUTPUT);
	pinMode(DO, INPUT);
 
	//Let's start here
	digitalWrite(CLK, HIGH);
	digitalWrite(CSn, HIGH);
}
 
 
 
void loop() {

	sensorWaarde = readSensor();
	delayMicroseconds(1); //Tcs waiting for another read in
}
 
unsigned int readSensor(){
	unsigned int dataOut = 0;
 
	digitalWrite(CSn, LOW);
	delayMicroseconds(1); //Waiting for Tclkfe
 
	//Passing 10 times, from 0 to 9
	for(int x=0; x<10; x++){
		digitalWrite(CLK, LOW); 
		delayMicroseconds(1); //Tclk/2
		digitalWrite(CLK, HIGH);
		delayMicroseconds(1); //Tdo valid, like Tclk/2
		dataOut = (dataOut << 1) | digitalRead(DO); //shift all the entering data to the left and past the pin state to it. 1e bit is MSB
	}
 
	digitalWrite(CSn, HIGH); // 
        Serial.println(dataOut);
	return dataOut;
 
}

Best regards,

RobinL

Hi RobinL,

May be too late, but I tested your code with my AEAT-6012-A06 (notice the 12-bit resolution, one digit change in the code) on an Arduino Nano and it had worked for me perfectly after I added Serial.begin(115200) into your setup. Great Code!

Regards,

Linarism

Edit:
P.S.

Did you manage to find a 5-pin PicoBlade connector for your encoder?

Hi Linarism, I have a couple of connectors. I can send you one. Please can you share your complete source code?
Thanks
Lynass

Hey lynass,

Here's the slightly modified code I used to work with the 12-bit variant of this encoder. I'm going to write a simple library for talking to these encoders as I will need to use it for reading many of them from one controller soon. Hopefully I'll be able to use it over hardware serial.

// Read in 12-bits Magnetic Encoder AEAT-6012-A06  into Arduino Nano
// RobinL modified by linarism

// Declarate

const int CSn = 4; // Chip select
const int CLK = 7; // Clock signal
const int DO = 8; // Digital Output from the encoder which delivers me a 0 or 1, depending on the bar angle..

unsigned int sensorWaarde = 0;

void setup(){

  Serial.begin(115200);
  Serial.println("Hello World!"); //send sample text to monitor for debug
  
  //Fix de tris

  pinMode(CSn, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DO, INPUT);

  //Let's start here
  digitalWrite(CLK, HIGH);
  digitalWrite(CSn, HIGH);
}



void loop() {

  sensorWaarde = readSensor();
  delayMicroseconds(1); //Tcs waiting for another read in
}

unsigned int readSensor(){
  unsigned int dataOut = 0;

  digitalWrite(CSn, LOW);
  delayMicroseconds(1); //Waiting for Tclkfe

  //Passing 12 times, from 0 to 11
  for(int x=0; x<12; x++){
    digitalWrite(CLK, LOW); 
    delayMicroseconds(1); //Tclk/2
    digitalWrite(CLK, HIGH);
    delayMicroseconds(1); //Tdo valid, like Tclk/2
    dataOut = (dataOut << 1) | digitalRead(DO); //shift all the entering data to the left and past the pin state to it. 1e bit is MSB
  }

  digitalWrite(CSn, HIGH); //deselects the encoder from reading
        Serial.println(dataOut);
  return dataOut;

}