Hello all,
I have a few 288T232R161A2 rotary encoders and want to hook them up to my Arduino, naturally. They are relative encoders, so they only output 'up' or 'down' rather than absolute positions, so I figured this would be fairly straightforward.
I searched the forum before and found this circuit diagram posted by Grumpy Mike:
Twitpic (can't work out how to upload the full size image with Twitpic...)
So now I've wired all that up plus the Vcc and Gnd on pins 7 and 14 on the 74LS74 and 74LS14, pin 1 and 3 of the 74 going to the Uno's pin 2 and 4 respectively, then uploaded the following code to my Arduino:
int stepPin = 4;
int dirPin = 2;
int stepVal = 0;
int dirVal = 0;
void setup(){
Serial.begin(9600);
pinMode(stepPin, INPUT);
pinMode(dirPin, INPUT);
}
void loop(){
stepVal = digitalRead(stepPin);
dirVal = digitalRead(dirPin);
Serial.print(stepVal, DEC);
Serial.print(",");
Serial.println(dirVal, DEC);
}
When run, the serial monitor just prints "0,1" for two of the four possible steps, but on the other two it will print "1,0", but the second digit will go high and low (seemingly) randomly and loop like that. It doesn't matter which way you turn it, either. I'm struggling to get my head around how the 74LS74 works and why I need the 74LS14, or in fact why I need a dual flip-flop when I seem to only be using one channel...
The datasheets, for convenience:
Encoder: http://www.ctscorp.com/components/datasheets/288.pdf
74LS74: http://docs-europe.electrocomponents.com/webdocs/0021/0900766b80021806.pdf
74LS14: http://docs-europe.electrocomponents.com/webdocs/0024/0900766b80024ea8.pdf
So yeah, if anyone has any idea what's going on (I assume there's a lot more to the circuit diagram than has been labeled!), I'd love to know your thoughts. Seeing as I went ahead and bought the IC's I'd prefer to work out how to use them instead of a work around that doesn't involve them, but the priority is to get the encoder working.
Thanks guys!