'Quadrature decoding using 16C84'
The 14-year old son of one of my colleagues is doing a major science
project, with me as technical helper.
As part of the project, which is a Michaelson interferometer, we need to
count quadrature encoded TTL signals up to about 2MHz up/down rate. I
worked up a design using SSI LSTTL technology which gives a fairly large
board because of the 0-999999 count and non-multiplexed 7-seg display.
Since I have recently got into PICs, using a uC should simplify the
board considerably. I would appreciate anyone's comments on the following
1. Use a few XOR gates and RC delays to convert the quadrature signal
into UP or DOWN pulses at each edge. Each pulse is active for long enough
that a 16C84 can have its TMR0 incremented (2*Tosc = 200ns).
2. The UP pulse clocks TMR0.
3. The DOWN pulse clocks a HC4060 counter whose 8 LSBs feed into port B,
with the most slowly changing bit feeding into B0 so that its falling
edge can trigger an interrupt.
4. The PIC is programmed to increment internal registers on overflow
from TMR0 and the external counter (B0 low-going) - all interrupt
driven. This adds the extra count digits required, for a total
count range of 24 bits.
5. To take the current position reading, the DOWN counter is subtracted
from the UP counter. The result is then sent using a simple serial
protocol to another processor, using the 4 remaining I/O pins.
The readout rate is low, but the counting rate can be quite high. If
anyone knows of suitable devices to aid in quad-decoding, I would
appreciate some advice. One would think this would be a common function,
but I can't find anything useful in my NatSemi, TI or any other logic
HP make a device HCTL 2000 (or the HCTL 2016 which has a 16 bit counter)
It has a digital filtering of the AB signals, up/down detection,
12 (or 16 bit counter), works upto 14 MHz etc.
All you have to do is read position as two bytes.
They are commonly used in robot controllers.
They have two drawbacks:
1) price (about 14 uk pounds in 1 off quantitys)
2) they need lots of pins: 8 bit + 3 control lines (but you can cheat a little)
David Eastlake | uwe.ac.ukdj-eastl
InFACT Group | Extn: 2892 1D5
UWE | Tel: +44 117 9763861
Bristol | Fax: +44 117 9763852
BS16 1QY | zen.btc.uwe.ac.uk/Public/infact/david.html
UK | Robotics, Electronics and Sailing
>If anyone knows of suitable devices to aid in quad-decoding, I would
>appreciate some advice.
I suggest that you investigate the HCTL-20XX family of Quadrature Decoder/
Counter Interface ICs from Hewlett Packard. These ICs are described in the
HP Optoelectronics Designers Catalog. These ICs hhave the following features:
- 14 MHz clock operation
- full 4X decoding
- Schmitt trigger inputs and digital noise filter
- 12 or 16-bit binary up/down counter
- latched outputs
- 8-bit tristate interface
I've used the HCTL-2016. They are easy to implement and work reliably.
You could also investigate the quadrature decoder ICs from U.S. Digital Corp.
(800-736-0194 [in the USA!] or 360-696-2468 in the USA). For example, their
LS7166 has similar features to the HCTL-20XX family, but it does not have a
digital filter. However, it does have a 24-bit counter. US Digital has an
IC that can handle 2 encoders, and it has the digital filter. I have not
used these chips yet, but the one with the digital filter is very appealing.
(You will note that I put a high priority on this filter feature.)
US Digital has a web site that provides on-line data sheets of their products
but I cannot recall the address. If you do a web search, please ignore the
other company in the States with a similar name - as it seems to be a real
estate company. :-) (When I first searched for US Digital on the net, I got
all sorts of hits for the real estate company but none for the encoder
company. I can't remember what I did to get the correct address.)
I hope this information helps. Please write me if you think I can answer
Mark K Sullivan
If your PIC is doing nothing else, I would think you could do all quadrature
decoding in software. Since this is a once-off science fair project, you could
over clock if necessary.
If you use external logic (or software for that matter), beware of the following
common mistake in quadrature decoders: You must count up and down on the same
edge(s). For example, don't count up on the forward rising edge of channel A
and down on the reverse falling edge of channel A. I call this the "small
circle" problem. To check your circuit, imagine the shaft oscillating back and
forth across a single edge without reaching the other three edges. Many
circuits (especially with XOR) will count unidirectionally under this condition.
If you do need a hardware assist, I recommend a PAL implemented state machine
(16R4 works good). Email me back channel if you need help with this.
- Mark Sullivan -
More... (looser matching)
- Last day of these posts
- In 1996
, 1997 only
- New search...