Hello,
I have a motor with encoder. 3 of the 5 cable to receive our engine (blue-orange-yellow) of the DC motor encoder cable for the other two power inputs. 5 V encoder supply Orange, Blue graund, Yellow Encoder signal output. I do not know how to do this I want to read the speed of the motor. I found an example similar to this but this is the one for 2 channel. Absolute encoder on how to speed read? Thank you in advance for your help.
/* Read Quadrature Encoder
* Connect Encoder to Pins encoder0PinA, encoder0PinB, and +5V.
*/
int val;
int encoder0PinA = 3;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
void setup() {
pinMode (encoder0PinA,INPUT);
pinMode (encoder0PinB,INPUT);
Serial.begin (9600);
}
void loop() {
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(encoder0PinB) == LOW) {
encoder0Pos--;
} else {
encoder0Pos++;
}
Serial.print (encoder0Pos);
Serial.print ("/");
}
encoder0PinALast = n;
}
http://robotus.net/wp-content/uploads/2012/07/japan-servoco-encoder-motor.jpghttp://catalog.nidec-servo.com/digital/english/general/pdf/DME34_4.pdf