ELM ELM401SM

ELM401
Rotary Encoder Debounce Circuit
Description
Features
The ELM401 is an 8 pin integrated circuit that is
used to ‘debounce’ the signals from a mechanical
rotary (quadrature) encoder. 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 ELM401, as this is all
performed within the integrated circuit. The ‘A’ and
‘B’ motion sensing encoder signals are both passed
through a filter then a comparator circuit, and finally
a timer circuit to remove noise and contact bounce,
while the switch input receives standard debounce
processing. The result are three virtually noise-free
signals that are suitable for direct use by an
electronic circuit.
Note that no inversion or manipulation of any
kind is performed on the input signals, other than the
debouncing. If your applications requires decoding of
the signals, you may wish to look at our ELM402 to
ELM408 family of products.
•
•
•
•
•
•
•
Low power CMOS design
Wide supply range – 2.0 to 5.5 volts
Complete debouncing of the encoder signals
No external filtering needed
Includes switch debouncing circuit
Startup delay timer
High current drive outputs
Connection Diagram
PDIP and SOIC
(top view)
VDD
1
8
VSS
A
2
7
A out
B
3
6
B out
Sw
4
5
Sw out
Applications
• Microcontroller Interfaces
• Monitoring of Encoder Signals
• General Switch Debouncing
Block Diagram
VDD
A
2
VDD
7
A out
Debounce
Circuit
6
B out
Debounce
Circuit
5
Sw out
B
3
VDD
Debounce
Circuit
Sw
4
Rotary
Encoder
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
1 of 8
ELM401
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 is usually connected to what is normally
known as the ‘A’ signal from a rotary (quadrature)
encoder. 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).
Sw out (pin 5)
This output is the debounced representation of the
signal that is at pin 4.
B out (pin 6)
This output is the debounced representation of the
signal that is at pin 3.
A out (pin 7)
This output is the debounced representation of the
signal that is at pin 2.
VSS (pin 8)
Circuit common is connected to this pin. This is the
most negative point in the circuit.
B (pin 3)
This input is usually connected to what is normally
known as the ‘B’ signal from a rotary (quadrature)
encoder. 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).
Sw (pin 4)
This input may be used to debounce any standard
mechanical contact (from a switch or relay). The
circuitry uses simple set/reset logic to control a timer,
so is not suitable for use with the A or B signal from
a rotary encoder (as those signals continue to
generate sliding noise while the contact is closed).
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.
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
2 of 8
ELM401
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............................... ELM401P
150 mil SOIC..................................... ELM401SM
Outline Diagrams
The diagrams at the right show the two package
styles that the ELM401 is available in. The first shows
our ELM401P product, which is an ELM401 in a
300 mil DIP package. This is a standard through hole
type dual inline package. The ELM401SM is our
surface mount version of the ELM401. 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
ELM401P
2.54
6.35
max
10.92
ELM401SM
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.
ELM401DSB
Note: all dimensions shown are in mm.
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
3 of 8
ELM401
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
A & B 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 ELM401 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
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
4 of 8
ELM401
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 ELM401 uses electronic means to
remove the bounce.
Figure 2. Actual Rotary Encoder waveform
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
5 of 8
ELM401
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 ELM401 employs a two stage system to
remove the bounce and the sliding noise from the
encoder 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 ELM401 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.
The Sw input uses a very simple debounce circuit
that employs a timer only (and not the filter section
shown in Figure 3). This is very similar to the logic
used by our ELM409, ELM410, and ELM411 circuits.
Once the signals from the rotary encoder have
been debounced, they may be used by your circuit to
decode direction, etc.- the following sections provide
some tips on this.
rotary
encoder
input
3 msec
timer
to
output
logic
tc = 1.7 msec
filter
timer
Figure 3. Internal Debouncing Logic
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
6 of 8
ELM401
Design Considerations
There are a few details to consider when using the
ELM401 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
ELM401 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Ω
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 ELM401 is being held in a reset state, and
ELM401DSB
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. If you
require that the outputs be at a high level as soon as
possible after powerup, you may want to install a
pullup resistor (of about 10 KΩ) on each output to
charge the capacitance quickly.
After the initial 20 msec period, the ELM401 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
7 of 8
ELM401
Example Application
Figure 4 below shows how the ELM401 might be
used with a microprocessor. Power for the ELM401
has been obtained from the microprocessor circuit,
and a small capacitor has been added to ensure that
the supply is filtered. The positive supply has been
shown simply as VDD, since the ELM401 will operate
with any voltage from 2.0 to 5.5 volts.
The circuit uses 10 KΩ pullup resistors with the
rotary encoder signals in order to convert the signal
from the dry contacts into one that swings from VDD to
VSS. The momentary pushbutton contact from the
encoder is treated no differently than the ones from the
encoder wheel. Since both ICs share the same supply,
they can be directly connected as shown.
That’s about all there is to using the ELM401 in
your circuit. Connect pullup resistors to your rotary
encoder signals, connect the encoder signals to the
ELM401, then connect the ELM401 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
your microprocessor
VDD
0.01µF
10 KΩ
A
10 KΩ
10 KΩ
B
port pins
1
8
2
7
3
6
4
5
Sw
rotary
encoder
C
Figure 4. Connecting the ELM401 to a microprocessor
ELM401DSB
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
8 of 8