arduino uno + AEAT-6012 rotary encoder

Hello all,

I’m trying to implement an SSI interface between an arduino uno and a rotary encoder (AEAT-6012 http://www.avagotech.com/pages/en/motio … -6012-a06/

i’m using this code example: http://www.circuitsonline.net/forum/view/112693

i have just modified it for 12 bits instead of 10

// Definitions for the AEAT-6010
int SSI_CLK = 7;
int  DataIN = 8;
int  NCS = 4;
int Test = 13;
 
// Definitions for variables
unsigned int reading;
 
// program starts here
// **************************
 
void setup() {                
 
  Serial.begin(9600);
 
  // initialize the digital pin as an output.
  pinMode(NCS, OUTPUT);   // Chip select
  pinMode(SSI_CLK, OUTPUT);   // Serial clock
  pinMode(DataIN, INPUT);   // Serial data IN/OUT
  pinMode(Test, OUTPUT);   
 
  digitalWrite(SSI_CLK, HIGH);  
  digitalWrite(Test, LOW);   
}
 
//***********************************************************************
// Main program loop
//***********************************************************************
void loop() {
 
unsigned int reading;
 
  ReadSSI();
  Serial.println(reading,DEC);
  delay(10);
 
}
 
 
//***********************************************************************
// Main Loop ends here
// Start of subroutines
//***********************************************************************
 
void ReadSSI(void)
{
int i;
char Res = 10;
unsigned int mask;
 
	reading = 0;
        mask = 0x0200;
	digitalWrite(NCS, LOW);
	delayMicroseconds(1);
	digitalWrite(SSI_CLK, LOW);
 
	for(i=(Res-1);i>0;i--)
	{
  	digitalWrite(SSI_CLK, HIGH);
  	delayMicroseconds(1);
	if (digitalRead(DataIN)) reading |= mask;	
	digitalWrite(SSI_CLK, LOW);
	mask = mask >> 1;
 
	if (i == 1) 
          {
          digitalWrite(SSI_CLK, HIGH);
 	  if (digitalRead(DataIN)) reading |= mask;	
          }
	}
 
	digitalWrite(NCS, HIGH);
}

for some reason i get nothing on the data output.

i have also tried another encoder of the same type and the 10bit version with the same results.

i have tried using a modified spi interface, that also didn’t work, but this version with bit banging as clock seems much more reliable so i would like to make it work.

does anybody have an idea what might not be working?

Thank you

I think the code is violating the 500 ns min timing btw a clock falling edge and a clock rising edge. I think you should put a delayMicroseconds(1) after every command to write a LOW to the the clock pin (2 places).

I’m a little unsure about his shifting technique, I guess it depends on whether D9 is the MSB of a 10 bit reading or if D0 is. I’d have thought the former, the code looks (to me) to assume the latter. If your data looks responsive to motion but odd, that might be the cause.

Lastly you need to change the values for Res and the mask to do 12 bits.

hi, thanks for your reply

i tried adding a delay but still nothing.

additionally, from what i see from the data sheet, the data out line should be in tristate while not transmitting, for me, it always stays high

in the attachment there is a screenshot of what i get from a logic analyzer

The timing appears good so if the connections and power are good … I’d say it’s dead Jim.

i finally managed to find the right connector for the encoder and i tried a third sample but still nothing.

that was my last idea as i thought maybe, somehow, when soldering the wires to the connector pins i damaged the encoder. But now i just plugged it and nothing.

i’ll find some other solution to get the position…