Page 1 of 1

Reading encoder

Posted: Sun Jan 04, 2009 3:15 pm
by Jan Middel
Hello,

I'm working for an encoder to read.
This is not like I want
The rotation is not stable to read.
I have read devers forums.
but do not come out how to do it.
Can someone help me?
I have a program as an example
I have the encoder connected under this scheme

Groeten Jan

Re: Reading encoder

Posted: Mon Jan 05, 2009 2:31 pm
by Sean
Hello Jan.

Reading a quadrature encoder by using one channel as a clock (interrupt) and the other channel for direction can result in false readings, especially when changing the direction of rotation, or if the encoder stops with the clock line close to an edge (introducing jitter).

The 10ms delay in the interrupt service routine might also be the cause of some problems.

If the expected signal frequency is relaively low, it might be possible to use a timer interrupt to trigger a read of both of the encoder signals at regular intervals. A full quadrature decoding of the signal changes in the interrupt service routine should provide greater immunity from false edges, and increase the effective resolution of the encoder by a factor of 4 - the systm can respond to all 4 signal changes in a single cycle.

Re: Reading encoder

Posted: Thu Jan 29, 2009 9:09 am
by moxy
Hello Jan, It looks like you are building the same thing as me! My project is a manual pulse generator for a cnc milling machine. I am using a stepper motor to provide the detents (you will be able to vary the detent strength by applying some power to the stepper via a resistor) and the encoder is already mounted to the stepper so the hardware is already built. The encoder is a 1000line unit and I have written some code to divide it down to 200 line output to match the stepper.I would be very interested to know how your code is progressing.
Bes Regards
Les