david@PAPDEV.COM wrote: > > I have a question for all the PIC experts out there: I am trying to > interface a quadrature decoder to a PIC which currently drives some > stepping motors. I can easily figure out how to build an external up/down > counter and "roll my own" absolute position decoder- but has anybody > successfully used the PIC itself to do this? > > I was thinking along the lines of using one externally clocked counter to > count all pulses, and another to count only those in one direction. > Subtracting these two give a relative number of steps in a particular > direction. I threw together a few latches and XOR gates to convert from quadrature to tachometer and direction. The tach input drove one of my interrupt on change pins. Whenever I got that interrupt, I'd just poll the direction pin. I needed to use 16 bit maths, but that wasn't too horrible. The only problem (?) with it was that when the direction changed, my circuit produced a one cycle latency. Not too tough to fix in software. I can't remember the circuit offhand, but I seem to recall that it used two XORs, two latches, and nothing else. I'll dig it up if you'd like. Jason ( # -e^(pi*i) )