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