Go Down

Topic: Rotary Encoder Help (Read 3 times) previous topic - next topic

potter

Does anyone have experience with Rotary Encoder - 1024 P/R (Quadrature) ?

https://www.sparkfun.com/products/11102

On the hardware side is a custom wood frame connected to a rotating mount. Attached to the back of the frame is a rotary encoder sensor.
I have some problems with finding out what I actually need to get only rotation degrees from pulses..Mechanical absolute encoder or incremental encoder?
If someone have experience with this models please help me with schema and some code.

Thanks!


pylon

This is a standard rotary encoder with a high resolution (1024 pulses per rotation). A lot of example code exists for such encoders, a page in the playground may help you further:

http://arduino.cc/playground/Main/RotaryEncoders

On page 5 of the datasheet you have the exact schema of the internals. For most applications wires A (black) and B (white) are enough, you don't need wire Z (orange).

Quote
Mechanical absolute encoder or incremental encoder?


Incremental encoder.

Quote
I have some problems with finding out what I actually need to get only rotation degrees from pulses.


If you only measure at the rising edge of A you get one pulse per 0.3515625° or about 3 pulses per degree.

potter

Thanks pylon!

What to do with the BLUE wire ?

BROWN - 5V
SMELD - GND

I have Arduino Diecimila. Arduino Diecimila's digital pins 2 and 3 can be used as External Interrupts. I don't understand Interrupt service and how to connect OUTA and OUTB if I want to know encoder turning direction (CW or CCW)..

Here is Example 1 from arduino playground:

Code: [Select]
/* Read Quadrature Encoder
  * Connect Encoder to Pins encoder0PinA, encoder0PinB, and +5V.
  *
  * Sketch by max wolf / www.meso.net
  * v. 0.1 - very basic functions - mw 20061220
  *
  */ 


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;
}


Please help me with Interrupt routine and which code is than usable (Interrupt Example, Interrupt Example (the Encoder interrupts the processor)) ??

pylon

Quote
What to do with the BLUE wire ?


Blue goes to GND as well as the shielding. Brown goes to 5V, correct.

Quote
I don't understand Interrupt service and how to connect OUTA and OUTB if I want to know encoder turning direction (CW or CCW)..


OUTA and OUTB has to go to digital IO pin on the Arduino. Do you need an interrupt? How fast will the encoder be rotated? Please tell more about your specs to help you find the best solution for your case. What other devices are connected to your Arduino? How many such decoders do you wanna connect to the Arduino, what's their purpose?

potter

only one decoder..

An explanation of what I'm trying to do is in this 2 videos:

http://vimeo.com/35109750

http://www.youtube.com/watch?v=0G7-Y-QSsRo

Interrupt are used for faster speeds?

I need a solution for both slow and faster versions..

Go Up