2-phase / Quadrature Rotary encoder
Dennis Plunkett email (remove spam text)
At 09:15 6/10/99 +0200, you wrote:
>Hej Dennis Plunkett. Tack fšr ditt meddelande 11:42 1999-10-06 +1000
>>This routine has the problem in that all possible changes of state for the
>>same direction produce a GOTO to the same routine,
>That is perfectly configurable: just fill in in the table, it has entry
for *all 16* possibilities:
that you wish will count into the zero position to point to specialized
count up/down routines that also checks the sync signal.
>This will give the best possible zero position synchronization, with a
resolution of four steps per cycle, making the most out of the encoder.
>>may be done by running a counter. Also the routine must see all chages of
>>state else an error is encounted.
>Of course, if it misses one change, how can you be sure it did not miss
>This is *required* for safe machine positioning.
>If it just is reading a knob on a panel: ignore the overspeed.
>> On a quadrature cycle only looking for a
>>complete rotation, the software only needs to check one line.
>That is wasting resolution.
>By detecting all four changes per cycle, the resolution for a 128 cycle
encoder is 512 steps per revolution.
>And only detecting one line makes overspeed error detection impossible.
>Using interrupt on change for the two lines is the best.
>If you need to poll for changes instead, we we might want to add a few
lines of code before my example that just check if any line has changed,
thus minimizing the cycles needed when no change. (but will add total
cycles when a change has occurred)
>>I hae included a high level respone to this, the code produced is not very
>>efficent and you can clean it up to make it faster, just done so that
>>people can see what I am on about
>Sorry, I have not learned C... still yet.
>I could also add "2-bit gray" to the subject.. how many names do this
device have? ;)
Yes we could grey code the thing, but there should be no need to. I think
that you are maybe thinking a bit too complex i.e. *NOT ALL QUADRATURE
ENCODERS* have 32, 64 , 512 etc... Pulses per revoulution. In the
hydrography industry, some only have *4*, and one full revoulution is 1mm
of height, and they only want to measure to 5, 10 20 or 100mm, so why worry
about .25mm or less in this case <G>
PS Learn C!
>Morgans Reglerteknik, HŠllekŒs, 277 35 KIVIK, SWEDEN
> tel +46(0)414-446620, fax -70331, iname.commrt
See also: www.piclist.com/techref/io/sensors.htm?key=quadrature
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the