On Tue, 6 Mar 2001 14:30:34 -0000, you wrote:
These encoders usually have a roughly 90 degree phase shift between
the 2 outputs.
The simplest way is to wait for (or have an interrupt on) a falling
edge on one of the inputs, and when received, sample the other input.
The state of the second input represents direction, so you either add
or subtract one from the position depending on the state, e.g.
<wait for falling edge on input 1>
btfsc <input 2>
There are other ways which give more resolution but you probably won't
need to for your application.
One alternative, which gives the best resolution, is to use a state
lookup table, where on every change(rising or falling) in either input
(e.g. using RB4-7 int on change), you create a 4 bit value consisting
of the new and old states of the 2 inputs, and look up the increment
value (-1, +1 or 0 for illegal states) in a table.
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email mitvma.mit.edu with SET PICList DIGEST in the body listserv
In reply to: <AF211C95CF03D4119F7C00A024AB2375026C99@PLATINUM>
See also: www.piclist.com/techref/microchip/ios.htm?key=encoder
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the