A, 55K - Elm Electronics

ELM405
Rotary Decoder - 3 wire 4x Interface
Description
Features
The ELM405 is an 8 pin integrated circuit that is
used to convert the output from a rotary encoder into
three signals (chip select, clock and up/down) that
can be used to control various devices. The low
power CMOS technology used ensures that only a
very small current is required over the entire 2.0 to
5.5 volt operating range.
There is no need for external filtering or
debounce circuits with the ELM405, as this is all
performed within the integrated circuit. After
debouncing the encoder signals, the ELM405
determines the direction of shaft rotation, and then
generates the appropriate outputs. The polarity of
the clock output can be changed at any time to
accommodate different needs.
The ELM405 provides 4x decoding of a rotary
encoder signal. If your application requires 2x
decoding, please see the ELM404 (it is identical to
the ELM405 in every respect, except that it provides
2x decoding).
•
•
•
•
•
•
•
Low power CMOS design
Wide supply range – 2.0 to 5.5 volts
Complete debouncing of the encoder inputs
No external filtering needed
4x decoding
Startup delay timer
High current drive outputs
Connection Diagram
PDIP and SOIC
(top view)
VDD
1
8
VSS
A
2
7
CS
B
3
6
Clk
Clk
Invert
4
5
U/D
Applications
•
•
•
•
Digital audio potentiometer controls
Variable voltage or temperature circuits
Positioning controls
Tuning circuits
Block Diagram
VDD
A
2
VDD
ELM405DSA
Direction
Decoding
B
3
Rotary
Encoder
Debounce
Circuit
Output
Logic
Debounce
Circuit
Clk
Invert
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
7
CS
6
Clk
5
U/D
4
1 of 10
ELM405
Pin Descriptions
VDD (pin 1)
This pin is the positive supply pin, and should always
be the most positive point in the circuit. Internal
circuitry connected to this pin is used to provide
power on reset of the internal logic, so an external
reset signal is not required. Refer to the Electrical
Characteristics section for more information.
A (pin 2)
This input should be connected to what is normally
known as the ‘A’ signal from a rotary (quadrature)
encoder. The signal at this pin should lead (ie
change state before) the signal at pin 3 when the
device is being moved in a clockwise or up direction.
An external pullup resistor is required for the encoder
(a typical value is 10 KΩ), but no external capacitors
are needed (as the internal debounce circuitry
provides the filtering).
B (pin 3)
This input should be connected to what is normally
known as the ‘B’ signal from a rotary (quadrature)
encoder. The signal at this pin should lag behind (ie
change state after) the signal at pin 2 when the
device is being moved in a clockwise or up direction.
An external pullup resistor is required for the encoder
(a typical value is 10 KΩ), but no external capacitors
are needed (as the internal debounce circuitry
provides the filtering).
Clk Invert (pin 4)
This input controls the polarity of the pulse at pin 6. If
pin 4 is at a low level, the Clk output will maintain a
low quiescent level, with the pulses going to the VDD
level. If pin 4 is at a high level, then pin 6 will
normally be at a high level, with pulses going low (to
Vss). This input can be changed at any time.
U/D (pin 5)
This ‘Up/Down’ output changes with the direction of
encoder rotation. For a clockwise movement (the A
input appears first, followed by the B), this output will
be set high before the CS output (pin 7) is switched
low. For counter-clockwise movement, the output will
be set low prior to the Chip Select going low. The
U/D output does not change state when the CS and
Clk pulsing is complete - it remains at the level it was
just prior to the CS going low.
Clk (pin 6)
A ‘Clock’ pulse will be output at this pin 200 µsec
after the Chip Select (pin 7) has gone low. The pulse
is 200 µsec wide, and is typically used to cause the
controlled device to change state based on the level
at the U/D pin. The polarity of this output can be
changed at any time by changing the logic level at
pin 4.
CS (pin 7)
This output provides a ‘Chip Select’, or enable
function. As the shaft rotates, a series of clock
pulses are generated at pin 6. Just prior to these
pulses appearing, the CS output will go low, and stay
at that level until 200 µsec after the Clk pulse is
complete. See the Output Waveforms section (on
page 7) for more information.
VSS (pin 8)
Circuit common is connected to this pin. This is the
most negative point in the circuit.
All rights reserved. Copyright 2011 Elm Electronics.
Every effort is made to verify the accuracy of information provided in this document, but no representation or warranty can be
given and no liability assumed by Elm Electronics with respect to the accuracy and/or use of any products or information
described in this document. Elm Electronics will not be responsible for any patent infringements arising from the use of these
products or information, and does not authorize or warrant the use of any Elm Electronics product in life support devices and/or
systems. Elm Electronics reserves the right to make changes to the device(s) described in this document in order to improve
reliability, function, or design.
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
2 of 10
ELM405
Ordering Information
These integrated circuits are only available in either a 300 mil plastic DIP format, or in a 150 mil SOIC surface
mount type of package. To order, add the appropriate suffix to the part number:
300 mil Plastic DIP............................... ELM405P
150 mil SOIC..................................... ELM405SM
Outline Diagrams
The diagrams at the right show the two package
styles that the ELM405 is available in. The first shows
our ELM405P product, which is an ELM405 in a
300 mil DIP package. This is a standard through hole
type dual inline package. The ELM405SM is our
surface mount version of the ELM405. The device
package has a 3.90 mm wide body, and is commonly
called a 150 mil SOIC package.
The drawings shown here provide the basic
dimensions for these ICs only. Please refer to the
following Microchip Technology Inc. documentation for
more detailed information:
• Microchip Packaging Specification, document name
en012702.pdf (7.5MB). At the www.microchip.com
home page, click on Packaging Specifications, or go
to www.microchip.com/packaging
ELM405P
2.54
6.35
max
10.92
ELM405SM
1.27
3.90
6.00
• PIC12F508/509/16F505 Data Sheet, document
41236E.pdf (1.5 MB). At the www.microchip.com
home page, click on Data Sheets, then search for
12F508.
ELM405DSA
Note: all dimensions shown are in mm.
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
3 of 10
ELM405
Absolute Maximum Ratings
Storage Temperature....................... -65°C to +150°C
Ambient Temperature with
Voltage Applied..................................-40°C to +85°C
Voltage on VDD with respect to VSS............ 0 to +6.5V
Note:
Stresses beyond those listed here will likely
damage this device. These values are given as a
design guideline only. The ability to operate to
these levels is neither inferred nor recommended.
Voltage on any other pin with
respect to VSS........................... -0.3V to (VDD + 0.3V)
Electrical Characteristics
All values are for operation at 25°C and a 5V supply, unless otherwise noted. For further information, refer to note 1 below.
Characteristic
Minimum
Typical
Supply voltage, VDD
2.0
5.0
VDD rate of rise
0.05
Power on reset time
9
Average supply current, IDD
Maximum Units
5.5
Conditions
V
V/msec see note 2
18
30
msec
see note 3
0.6
1.1
mA
VDD = 5.0V
0.2
0.3
mA
VDD = 2.0V
VDD = 5.0V
10
mA
VOL = 0.25V
VDD = 3.0V
5.0
mA
VOL = 0.25V
VDD = 5.0V
2.5
mA
VOH = 4.75V
VDD = 3.0V
1.7
mA
VOH = 2.75V
Debounce period
5.5
msec
Startup time delay
50
msec
Internal timing variation
1
Output low current
(sink)
Output high current
(source)
4
%
see note 4
see note 5
Notes:
1. This integrated circuit is based on a Microchip Technology Inc. PIC12F5XX device. For more detailed
specifications, please refer to the Microchip documentation (www.microchip.com).
2. This spec must be met in order to ensure that a correct power on reset occurs. It is quite easily achieved
using most common types of supplies, but may be violated if one uses a slowly varying supply voltage, as
may be obtained through direct connection to solar cells, or some charge pump circuits.
3. The internal reset circuitry stops the ELM405 from doing anything during this period, so that the power
supplies and oscillators have time to stabilize. During this time, all pins behave like inputs.
4. Typical only - the actual period varies with the amount of noise present in the input signal.
5. All filtering, delay, and output timing is based on an internal master oscillator. The frequency of this oscillator
will vary with voltage and temperature. Values shown are typical maximums for 2.0V ≤ VDD ≤ 5.5V, and
temperatures of -40°C to +85°C
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
4 of 10
ELM405
Rotary Encoders
A rotary encoder (sometimes referred to as a
quadrature encoder) is a device that produces digital
(on/off) outputs in response to rotary, or circular,
motion. It is often constructed such that it looks very
much like a potentiometer, or audio volume control
(see the picture of a typical device, at the right).
As the encoder shaft is turned, internal contacts
open and close, creating two waveforms that are
ideally separated in phase by 90 degrees (ie ‘in
quadrature’). Actually, you need to provide external
‘pullup’ resistors and a power supply to create these
waveforms, as the contacts themselves can not do
this. An ideal waveform from a rotary encoder would
look like this:
A
B
Figure 1. Quadrature Waveforms
Due to the 90 degree phase difference, when one
waveform changes, the other is always stable. By
noting the direction of the change and the level of the
other input at that time, you can determine the
direction of motion of the shaft.
Rotary encoders are not ideal, however. Due to
their construction, and variations in shaft speed, the
A typical rotary encoder
waveforms are not perfectly square with the 50% duty
cycles shown. Figure 2 shows a captured trace from a
real rotary encoder that is more representative of what
you will typically find. Note that the two ‘scope
channels (1 and 2) represent the encoder outputs A
and B, respectively. The ch 1 (A) waveform leads the
ch 2 (B) waveform, which usually means that the shaft
is turning in a clockwise direction.
The first rising edge of the channel 2 waveform
shows another problem that occurs with moving
mechanical contacts - multiple pulses due to bounce.
When two contacts meet, the moving one will tend to
bounce, like a ball does when it is dropped on the
floor. Each bounce results in an electrical connection
being made, then broken, which will look like multiple
inputs to a fast electronic circuit. Various mechanical
means are used to reduce the amount of bounce, but it
can never really be eliminated. The following section
discusses how the ELM405 uses electronic means to
remove the bounce.
Figure 2. Actual Rotary Encoder waveform
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
5 of 10
ELM405
Debouncing Circuits
Any time that two metal surfaces meet, as they do
inside a rotary encoder, there will be a tendency for
the moving one to bounce, which causes the electrical
connection to make and break. The duration of this
bouncing action may be very short, but it is usually fast
enough to cause multiple counts to be recorded by
connected electronic circuits. As the number of
bounces can not be predicted, a means of removing
them is necessary. Circuits that remove the bounce
are usually called ‘debouncing’ circuits.
Many debouncing circuits employ a simple timer to
determine if an input is stable. This generally works
well if the two contacts meet and then remain still. With
a rotary encoder however, one of the contacts meets
the other then usually continues sliding over the
surface of the stationary contact. This will produce
noise while the contact is sliding, occasionally enough
to make it look like there are more inputs.
The ELM405 employs a two stage system to
remove the bounce and the sliding noise from the
input signal. A block diagram of the stages are shown
in figure 3. The first stage is a digital filter circuit that is
used to determine the average value of the waveform
over a time. If a long enough time is chosen, short
duration pulses will have little effect on the overall
average. If the time chosen is too long, however, the
circuit will be slow to respond, and may in fact average
out some legitimate inputs. Choosing the time period
(or time constant of the circuit) is thus very important in
determining how effective the filtering function will be.
We have found that with typical rotary encoder
specifications (usually 3.0 msec of bounce or noise,
maximum), the ELM405 debounce circuit works quite
well.
After the signal has been filtered, it is compared to
some reference levels, and the output of these
comparators are used to control a simple timer. The
timer is used to ensure that the output of the filter is
stable, and not just a momentary transient, while the
use of two comparator levels provides hysteresis, so
that some variation in the filter output can be tolerated.
Once the signals from the rotary encoder have
been debounced, they may be used by the direction
logic circuitry. The following section shows what the
ELM405 is able to produce from these signals.
rotary
encoder
input
3 msec
timer
to
output
logic
tc = 1.7 msec
filter
timer
Figure 3. Internal Debouncing Logic
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
6 of 10
ELM405
Output Waveforms
Once the ELM405 has some bounce-free signals
to work with, it can generate outputs based on them.
The logic to decode the motion of an encoder
shaft is not as simple as it would first appear. Some
authorities recommend simply monitoring an input and
when it changes, provide an output based on the level
of the other input. This does not always work, as the
encoder can output multiple signals from only the ‘A’ or
or only the ‘B’ contact if the shaft is moved ever so
slightly when at the detent or at the mid-point position
(between detents). Simply seeing one input change is
not sufficient to say that there is any significant shaft
rotation.
The ELM405 monitors both ‘A’ and ‘B’ transitions,
and determines the outputs based on the sequence in
which the transitions have occurred. This is a better
way to guarantee that the output signals are generated
properly. The internal logic also performs some self-
checking, and monitors for problems such as an output
pulse being initiated before the previous one had
completed, which might occur for some very fast
inputs (the second one will be ignored in this case).
The output of the ELM405 is a series of pulses, as
shown in Figure 4 (representative pulses are enlarged
and shown in Figures 5 and 6). When the encoder is
moving in a clockwise direction, the pulses will be
generated with the U/D output at a high level, while a
counter-clockwise rotation of the shaft results in pulses
generated with the U/D output at a low level. The
direction assumes that the encoder is a standard one,
where the ‘A’ signal leads the ‘B’ for a clockwise
rotation.
Outputs are usually generated each time that one
of the inputs change, so for each full cycle of both of
the inputs, there will be 4 output pulses. This is what is
known as 4x decoding. The other type of decoder that
direction changes
A Input
B Input
debounce
delay
CS
Clk
U/D
Figure 4. Output signals (pin 4 = 0V)
CS
Clk
CS
200 µsec
U/D
200 µsec
U/D
Figure 5. Up or Clockwise Output
ELM405DSA
Clk
Figure 6. Down or Counter-clockwise Output
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
7 of 10
ELM405
Output Waveforms (continued)
is very common is the 2x decoder, as used by the
ELM404. We do not currently offer a product with 1x
decoding - if you require one, you will need to use the
ELM401 and decode the signal with your own logic.
Output pulses do not always occur when one of
the inputs change. After startup, the first output can
not be generated until the ELM405 has seen both of
the inputs change, and no output is generated until
then. Also, if an input is seen to be ‘chattering’ the
ELM405 will block the output. Chattering can occur
when the shaft is wiggled, or when it is subjected to
severe vibration. Figure 7 below shows how the
ELM405 handles the multiple inputs due to chatter. If
this logic were not in place, multiple outputs could
occur due to vibration (as found in an automobile, or
Change in B (expecting a change in A)
causes the ELM405 to anticipate a change
in direction, and generate a Down output
an industrial setting), and the setting could ‘creep’ with
time – even though the shaft was not turned.
Generally, output pulses will occur in groups of
four (between each detent), so resistance values or
settings will repeat consistently as the shaft is rotated
in one direction and then in the other. Depending on
when the shaft changes direction, however, the pulses
may not be generated in groups of four. If you are
designing a circuit and require that the controlled
variable must repeat exactly as the shaft is turned in
either direction, you may prefer to use a 2x decoder
such as the ELM404.
A changes, meaning that
the shaft is now rotating,
and pulses can be output
Multiple pulses are ignored while
the ELM405 waits for a change at
the A input
The shaft direction
changes again
A Input
B Input
CS
Clk
U/D
Figure 7. Input Chattering
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
8 of 10
ELM405
Design Considerations
There are a few details to consider when using the
ELM405 to interface to a rotary encoder. The first is
the fact that the signals available from the encoder are
usually only dry contacts closing and opening. You will
need to provide pullup resistors for these signals in
order to use them in a circuit.
The size of the pullup resistor is chosen based on
the encoder specifications. The main concern is the
maximum current carrying capacity, which sets a lower
limit for the pullup resistance. An upper limit for the
resistance is set by the minimum current required for
contact wetting. If you do not provide enough current
through mechanical contacts when they are closed,
they will tend to go open with time. A maximum current
specification is usually in the range of 1 to 10 mA,
while the minimum wetting current would be in the
range of 1 mA. This means that with a 5V supply, a
pullup resistor of 5 to 10 KΩ is typically required.
The second concern is the use of capacitors on
the ‘A’ and ‘B’ signal lines. Many encoder circuits show
these as a way to provide some pre-filtering of the
signal. That is fine, as long as you realize that the
ELM405 inputs are CMOS and do not have Schmitt
trigger waveshaping. This means that you should keep
the rate of change of the input signal as high as
possible to avoid problems (we usually try to maintain
at least 1V/µsec). Typically, with a 5V supply, a 10 KΩ
ELM405DSA
pullup, and TTL thresholds, this means capacitor
values of no more than about 330 pF, while with a
2.0V supply, the limit would be about 100 pF.
One other issue to consider is that during the initial
circuit startup, there is a period (of about 20 msec)
when the ELM405 is being held in a reset state, and
the outputs are in a tristate condition. During this time,
the outputs will sit at the level they were at before
power up (0V) due to stray capacitance having
discharged through the protection diodes. Since the
CS (Chip Select) is an active low output, this may
cause a problem, if your controlled circuit is ready too
fast. If you require that pin 7 (and possibly pin 6) go
high as quickly as possible, you may want to install a
pullup resistor (of about 10 KΩ) on the output(s) to
ensure that the voltage rises quickly to VDD.
After the initial 20 msec period, the ELM405 sets
all pins to their quiescent levels, but does not change
any outputs for an additional 50 msec. This ensures
that the external circuits have had adequate time to
initialize, before being presented with signals to
process.
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
9 of 10
ELM405
Example Application
Figure 8 below shows how the ELM405 might be
used with a digital potentiometer (in this case, an
AD5220 from Analog Devices).
Pullup resistors of 10 KΩ are used with the rotary
encoder to provide voltages for the A and B inputs.
Power for the ELM405 and the AD5220 has been
supplied from a common source (it must be between
2.7V and 5.5V for the AD5220), and a small capacitor
has been added to ensure that the supply is filtered.
Note that the output lines are directly connected to the
AD5220 inputs, but we have added a 10 kΩ pullup
resistor on the CS line, to ensure that it rises rapidly to
the VDD level as quickly as possible after power up.
This may not be absolutely necessary in this case (as
the AD5220 setting only changes on the falling edge of
the clock signal), but it does not hurt to add it.
That’s about all there is to using the ELM405.
Connect pullup resistors to your rotary encoder,
connect the encoder signals to the ELM405, then
connect the ELM405 to the controlled circuit. Use a
common supply for all the devices, and add a small
bypass capacitor across the supply line. The controlled
devices can be digital pots, microprocessors, or almost
any circuit that will accept CMOS signals. Enjoy!
VDD
VDD
VDD
0.01µF
10 KΩ
10 KΩ
10 KΩ
1
8
2
7
3
6
1
4
5
2
VDD
A
B
rotary
encoder
3
C
4
8
AD
5220
H
7
L
W
6
5
Figure 8. Connecting the ELM405 to an AD5220
ELM405DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
10 of 10