ELM404
Rotary Decoder - 3 wire 2x Interface
Description
The ELM404 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 ELM404, as this is all
performed within the integrated circuit. After
debouncing the encoder signals, the ELM404
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 ELM404 provides 2x decoding of a rotary
encoder signal. If your application requires 4x
decoding, please see the ELM405 (it is identical to
the ELM404 in every respect, except that it provides
4x decoding).
Features
•
•
•
•
•
•
Low power CMOS design
Wide supply range – 2.0 to 5.5 volts
Complete debouncing of the encoder inputs
No external filtering needed
2x decoding
Startup delay timer
• High current drive outputs
Connection Diagram
PDIP and SOIC
(top view)
V
DD
A
1
2
3
4
8
7
6
5
V
SS
CS
Clk
U/D
Applications
•
•
•
•
Digital audio potentiometer controls
Variable voltage or temperature circuits
Positioning controls
Tuning circuits
B
Clk
Invert
Block Diagram
V
DD
A
2
Debounce
Circuit
Direction
Decoding
Debounce
Circuit
Output
Logic
7
CS
Clk
U/D
6
V
DD
B
3
5
Rotary
Encoder
Clk
Invert
4
ELM404DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
1 of 9
ELM404
Pin Descriptions
V
DD
(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 V
DD
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.
V
SS
(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.
ELM404DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
2 of 9
ELM404
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............................... ELM404P
150 mil SOIC..................................... ELM404SM
Outline Diagrams
The diagrams at the right show the two package
styles that the ELM404 is available in. The first shows
our ELM404P product, which is an ELM404 in a
300 mil DIP package. This is a standard through hole
type dual inline package. The ELM404SM is our
surface mount version of the ELM404. 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
•
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.
ELM404P
2.54
6.35
max
10.92
ELM404SM
1.27
3.90
6.00
Note: all dimensions shown are in mm.
ELM404DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
3 of 9
ELM404
Absolute Maximum Ratings
Storage Temperature....................... -65°C to +150°C
Ambient Temperature with
Voltage Applied..................................-40°C to +85°C
Voltage on V
DD
with respect to V
SS
............ 0 to +6.5V
Voltage on any other pin with
respect to V
SS
........................... -0.3V to (V
DD
+ 0.3V)
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.
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
Supply voltage, V
DD
V
DD
rate of rise
Power on reset time
Average supply current, I
DD
Minimum
2.0
0.05
9
Typical
5.0
Maximum Units
5.5
V
Conditions
V/msec see note 2
18
0.6
0.2
30
1.1
0.3
msec
mA
mA
mA
mA
mA
mA
msec
msec
4
%
see note 5
see note 3
V
DD
= 5.0V
V
DD
= 2.0V
V
OL
= 0.25V
V
OL
= 0.25V
V
OH
= 4.75V
V
OH
= 2.75V
see note 4
Output low current
(sink)
V
DD
= 5.0V
V
DD
= 3.0V
10
5.0
2.5
1.7
5.5
50
1
Output high current
(source)
V
DD
= 5.0V
V
DD
= 3.0V
Debounce period
Startup time delay
Internal timing variation
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 ELM404 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
≤
V
DD
≤
5.5V, and
temperatures of -40°C to +85°C
ELM404DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
4 of 9
ELM404
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
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 ELM404 uses electronic means to
remove the bounce.
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
Figure 2. Actual Rotary Encoder waveform
ELM404DSA
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
5 of 9