Newsgroups: comp.robotics
Path: brunix!sgiblab!swrinde!sdd.hp.com!saimiri.primate.wisc.edu!mimbres.cs.unm.edu!intvax!bryan
From: bryan@isrc.sandia.gov (Jon R Bryan)
Subject: Re: Shaft Encoders using 6811 timers
Message-ID: <1994Apr15.162832.14867@isrc.sandia.gov>
Organization: Sandia National Labs, Org. 2111, Albq., NM
References: <CntvxM.9yu@syd.dms.CSIRO.AU>
Date: Fri, 15 Apr 1994 16:28:32 GMT
Lines: 31

Let me begin by admitting that I haven't done what you are attempting.
I am pretty familiar with the HC11, however (I'm not a doctor, but I
play one on TV ;).  I have also done shaft encoders with programmable
logic and up/down counters.

An example of a shaft encoder might be available on the Motorola BBS at
512-891-3733, but you probably don't want to call them from Australia.
There is supposed to be a servo motor control example, but I can't find
it.

You imply that you have a shaft encoder with a quadrature output, and
you're feeding the two phases into two of the Port A Input Capture
pins.  You could set up the two Input Captures to trigger on either a
rising or falling edge and test the state of the lines.  Or you could
test the resting state and trigger on the appropriate edge.  You will need
to remember the last state to tell which direction you're going.  I
don't know what the limitation will be on the shaft rotation rate.  The
software overhead will probably limit you to a few kilohertz interrupt
rate.

As concisely as I can put it:

You have to know the current and previous state for each line.
Only one line can change state at a time (or you're screwed anyway).
There are four combinations which equate to a clockwise step, and four
combinations which equate to a counter-clockwise step.
-- 
Jon R. Bryan	(505) 844-2015	<=>	jrbryan@isrc.sandia.gov
Intelligent System Sensors and Controls Dept. 2111
Sandia National Laboratories
P.O. Box 5800, Albuquerque, New Mexico 87185-0949
