Experimental Study to Show the Effect of Bouncing On Digital Systems

advertisement
Journalof Name,
Journal
NetworksVol.
and 1,
Telecommunication Systems, Vol. 1 (1), 28-38, September, 2015
ISSN: Pending, DOI: Pending, Published online: www.unitedscholars.net/archive
Experimental Study to Show the Effect of Bouncing
On Digital Systems
Fryad Muhammad Rashid
School of Computing, Clemson University, Clemson, USA
fryadm@g.clemson.edu
Keywords: Combinational and Sequential Logic
Circuits, Microcontroller Atmega168, and Common
Switch Types.
ABSTRACT
What is the reason that when you press on a remote
for a TV, the channel shifts by two or three or more?
Or have you noticed that while tuning to a channel on
the radio you will pass more channels than desired?
Have you thought about this problem? It is called
button bounce or switch bounce, or chatter. This is a
common problem in these types of switches, such as
push button switches, toggle switches, and
mechanical relays because they are made up of
metals and these metals have a characteristic called
elasticity or springiness. This project, proposed a new
system design to solve this problem. For that reason,
the project is divided into three parts: In the first
part, an algorithm was designed to show the effect of
the bouncing problem on the digital systems, which is
called “Bouncing Algorithm.” This algorithm has
been implemented by using a new hardware
technique to show this problem in the real world. In
the second part, another algorithm was designed to
solve this problem, which is called “De-bouncing
Algorithm.” This is a new method to avoid contact
bouncing problem. This solution has been
implemented by using a new hardware system design.
Both algorithms have been implemented by using
Multisim simulator for education purposes. These
two parts of hardware have been mixed to produce a
new integrated circuit (IC), which is called
“Bouncing/De-bouncing.” It is shown in fig.1. This IC
consists of two packages: The first package shows the
effect of the bouncing problem in reality by
connecting 4 LEDs to the pins (6-9) and the second
package shows the solution for this problem by
connecting the digital display to the pins (10-16). The
third part is related to the software de-bouncing
approach. It uses a program to solve the contact
bouncing problem in microcontroller Atmega168 and
then implements it.
Fig.1 IC to show bouncing and de-bouncing
INTRODUCTION
The main purpose of this project is to
understand and demonstrate what the switch
bouncing problem is. A new hardware and software
solution technique is designed and implemented to
eliminate this problem. In addition, one of the
fundamental problems in the embedded systems is
the contact problem to send and receive information
in a real time manner. In the real mechanical world
of switches, they aren’t simply closed or open when
activated, because it causes contact to make and
break a number of times before settling down into a
closed or open steady state. This is a factor to get
the noise. Therefore, this oscillation between high
and low is called button glitches. This is a non-ideal
behavior of the switches that causes multiple
electrical transitions for a single user input. One of
the fundamental components in the electrical
circuits is the switch. It can control current flow in
the circuit. All of the switches have two types of
states, which are off-state and on-state. In off-state,
© 2015 Fryad M. Rashid, open access article. Distributed under the terms of Creative Commons
Attribution (CC BY) license 4.0.
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
the switch is opened to prevent current flow of the
circuit which is called open circuit. In on-state, the
switch is closed to allow current through the circuit
which is called short circuit. One of the important
methods to change the state of the switch from offstate to on-state or vice versa is an actuation
method. It can be considered an important
characteristic for the switch to take a physical
action to flip switch states. The actuation of the
switch can come from pushing, sliding,
rotating….etc, or any other kind of physical
interaction to make the mechanical connection on
the inside of the switch get decent contact [1].
Basically, every switch should have two terminals,
one for current to go in and one for current to go
out. For that reason, two important parameters in
the switches have been defined which are poles and
throws. The poles are used to control separate
circuits. For example, one pole switch can control
one single circuit; two pole switches can control
two different circuits. The throws are used to
connect switch pole position. For example, one
throw can connect to one pole of the switch
terminal; if the switch has two throws, the pole can
connect to one of the throws to control the circuit.
For that reason, depending on the number of poles
and throws, switches are classified into four
common types: Single Pole Single Throw (SPST),
Single Pole Double Throw (SPDT), Double Pole
Single Throw (DPST), and Double Pole Double
Throw (DPDT) as shown in the following diagram
fig. 2 [2].
types of switches are made up of metals and these
metals have a characteristic which is elasticity or
springiness. In this situation, we have to ask
ourselves how does bounce generate? The answer
to this question is when the switch position is
changed from open state to closed state or vice
versa, the noise is generated because the switch
contact is metal and it has elasticity. This problem
can be demonstrated by giving this example; it is
similar to dropping a basketball. The ball continues
bouncing until it comes to rest. This case can be
considered as the analogue off-state and on-state of
a switch. When the ball touches the ground, it can
be considered as analogues to the on-state of the
switch when the ball arises to the certain level of
the ground to become stable, it can be considered as
the off-state of the switch. The result of this effect
is generating on and off transitions or oscillations
or damping when the switch moves between open
state and close state rapidly as shown in fig. 3. The
contact bounce is not a problem if the switch is
used to turn on and turn off the light or motor, but
the contact bounce is a problem if the switch is
used as an input to a personal computer,
microcontroller, and digital counter, because the
time it takes for contacts to stop bouncing is
measured in milliseconds but the digital logic
circuits can respond in microseconds.
Fig.3 Generating transition between on state and off state
Fig.2 Common switch types
PROBLEM STATEMENTS
Switch bounce, button bounce, contact bounce
or chatter are a very common problem related to
mechanical switches and relays, because these
In addition, we have to present this springiness
in the output diagram to deepen understanding of
the switch bouncing problem. For example, if we
have a push button switch in the simple circuit
when we pull down the switch, we can see the
transition problem between on state and off state as
shown in fig. 4. The switch does not directly go
from zero to one, as an ideal case shows some
dumping or little resistance happening, and then it
becomes stable.
At the same time, when the switch is pulled up, it
does not go directly from one to zero as an ideal
29
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
case also shows some oscillation happening, and
then it becomes stable as shown in fig. 5 [3-5].
Fig.4 Switch bouncing problem during pull down
Fig.4 Switch bouncing problem during pull up
Fig.6 Schmitt-Method of de-bouncing
This method consists of two resistors (R1>>R2),
C as (Capacitor), Hex Schmitt-Trigger Inverters
(Vin, Vout), and SPST switch. According to the
state of the switch, the circuit is working as
follows:
1) If the switch is in an open state “1”:
The capacitor will be charged to 5V via R1&R2.
The charging time constant for the capacitor can be
determined by C*(R1+R2). In this case, the voltage
at Vin=High “logic 1” and Vout=Low “logic 0”.
2) If the switch is in a closed state “0”:
The capacitor will discharge rapidly to zero via R2.
The discharge time for the capacitor can be
determined by C*(R2). In this case, the voltage at
Vin=Low “logic 0” and Vout=1.
3) Switch bounces condition:
The capacitor tries to charge slowly to backup to
High and then discharge rapidly to zero. The
voltage threshold levels for this type of Schmitt are
(VT- = 0.95 Volt for closed stated and VT+= 1.8 Volt
for open state). When the switch is closed, the
capacitor voltage drops below VT- because it
discharges rapidly, as a switch bounce tries to
charge back up, but it’s slow. When the switch is
opened, the capacitor is allowed to charge up to
+5V. When it crosses VT+, Vout will switch to 0.
All these are described briefly in Table I.
METHODOLOGIES
This review describes de-bouncing techniques or
methods to eliminate the effects of switch bounce.
Schmitt-Method
This technique is used to de-bounce SPST
(Single Pole Single Throw) switch or push button
which is called Schmitt trigger scheme as shown in
fig. 6 below.
TABLE I
Button
State
Time Constant for C
Threshold
Voltage
For Vcap
or Vin
Vcap
or Vin
Vout
Open
Charging Time:
T=C*(R1+R2)=10.1ms
VT+ (1.8
V)
“Logic
1”
“Logic
0”
Close
Discharge Time:
T=C*(R2)=0.1ms
VT- (0.95
V)
“Logic
0”
“Logic
1”
As a result by opening and closing the switch we
will get a single pulse at the output, though the
switch is bouncing as shown in fig.7. It shows
contact bouncing during open state and close state
of the switch. It also shows that when the switch is
closed the capacitor discharges very fast as it
appears as a thin line, but when the switch is open
the capacitor takes time to go up, that is because of
time it takes to charge the capacitor.
All in all, the charging time constant is 10 times
30
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
longer than the discharge time constant, because the
capacitor can’t charge up fast enough before the
switch bounces back to its final closed position so
Schmitt trigger keeps the output High. The result is
that it doesn’t matter how much the switch contact
bounces during opening and closing, a regular
single output pulse was obtained from the circuit
[6-8, 3].
3) Moving the switch from position A to position
B or vice versa. The output changes from High
to Low or from Low to High. As a cross
NAND circuit requires set and reset. During
these two switching actions if any contact
bounce happens in the input, it doesn’t affect
on the output. The output is a regular pulse, it
doesn’t contain any contact bounce as shown in
fig. 9.
Fig.9 Output of Cross-NAND Method
Fig.7 Output of Schmitt-Method
D Flip-Flop Method
Cross-NAND Method
This technique is used to avoid bounces in
another type of switch called SPDT (Single Pole
Double Throw). This method consists of two cross
coupled NAND gates, SPDT switch, and two pull
up resistors as shown in fig. 8.
Flip-flop is an important topic in the sequential
logic circuits. It is a storage element used to store
one bit of information. It has two outputs, one for
normal value, which is (Q), and the other for the
complement value of the bit stored in it. Generally,
flip-flops are working on the edge trigger of the
input signal. It causes change state of the flip-flop
[9, 6]. This is another method to de-bounce SPDT
switch. This method consists of D flip-flop, SPDT,
and two resistors as shown in fig. 10.
Fig.8 Cross-NAND Method
This type of de-bounce circuit operates like an SR
flip-flop, which is a second type of logic circuit
called sequential logic circuits [6-7, 2-3].
According to the state of the switch, the circuit is
working as follows:
1) When the switch is in position A, NAND gate
U1A is “Set” and the output is “High”.
2) When the switch is in position B, NAND gate
U1B becomes “Set” which “Reset” U1A and
the output is “Low”.
Fig.10 Flip-Flop Method of de-bouncing SPDT
According to the state of the switch, the circuit is
working as follows:
1) When the switch is in position A, putting zero
to set line (PR) the flip-flop is going to go (set,
set, set) while even though bouncing the output
31
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
of the flip-flop is going to go “High” or “logic
1”.
2) When the switch is moved to position B,
putting zero to reset line (CLR), the flip-flop
will (reset, reset, reset) until it settles down,
keeping it reset. It makes output “Low” or
“logic 0”.
3) The real output of the flip-flop is shown in fig.
11. It shows the pure output of the flip-flop.
After changing the state of the switch from open to
close or vice versa, the switch generates pulses, but
it is not pure. It contains bouncing. If we want to
use these pulses as an input to digital systems, it
will affect it. For example, the block diagram
shows that the connected switch to the digital
counter, giving us random digital numbers. It
doesn’t show a regular sequence of numbers,
because of the bouncing or glitches between pulses.
This is a method to prove that bouncing is a real big
problem in the world. In addition, based on this
method, the bouncing algorithm is clarified by this
flowchart to give us a good understanding, and
demonstrate the effect of bouncing or glitches
problem on digital systems as shown in fig. 13.
Start
Fig.11 The output of D Flip-Flop
PROPOSED SYSTEM DESIGN
The project is divided into three sections: In the
first section, an algorithm was designed to show the
effect of the bouncing problem on the digital
systems, which is called “Bouncing Algorithm.” In
the second section, another algorithm was designed
to solve this problem, which is called “De-bouncing
Algorithm.” This is a new method to avoid the
contact bouncing problem. Both algorithms have
been implemented by using Multisim simulator for
educational purposes. In the third section, a
different type of software solution was used by
converting bounced signal into stream signal and
found a solution based on this conversion.
Bouncing Algorithm
In this section, a block diagram is provided to
prove that contact bouncing is a real big problem in
the world. It gives us more understanding from the
contact bouncing problem. The following block
diagram shows the effect of bouncing on digital
systems as shown in fig. 12.
Two Manual Input
Actions: ON/OFF
SPST Process to
Generate Pulses That
Contains Bouncing
This Bouncing
Becomes Input To
Digital Counter
Digital Counter
Process to Analyze
Impure Input Signal
Output: Shows
Digital Random
Numbers
End
Fig.13 Bouncing Algorithm
Fig.12 Block diagram to show the effect of bouncing
32
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
Bouncing Algorithm Implementation
This implementation shows the bouncing
problem. This is a new hardware design that has
been implemented by using a Multisim simulator.
This is a well-known simulation software designed
by Texas National Instruments for educational
purposes. This simulator can be used to implement
any electronics models, or embedded systems that
you have designed, if you want to see the result of
your model before printing it on the board. This
design consists of SPST switch, digital counter, 4
LEDs; pull up resistor, and a capacitor as shown in
fig. 14 below.
effecting the result by getting random numbers in
each cycle. Fig. 16 shows some samples of the
output.
Fig.15 State diagram for the output
Fig.16 Show clock signal and the result
De-Bouncing Algorithm
Fig.14 bouncing algorithm implementation
According to the state of the switch, the circuit is
working as follows:
1) When the switch is in open position, it sends a
not-pure signal to the digital counter. The
capacitor was placed to show us the exact input
signal that was produced by the switch.
2) When the switch is moved to close, it is not
directly going to down, after some glitches
settle to down and then it becomes stable.
3) The output is shown by 4 LEDs. For that
reason, it has to show it by the state diagram for
each result. This is one of the implementations
of the sequential logic circuit, to see the
response for each opening and closing of the
switch. The result is shown in fig. 15 for each
state.
In this section, a block diagram is provided to
show us how to eliminate the bouncing problem in
the digital systems as shown in fig. 17.
Fig.17 De-Bouncing block diagram
After generating bouncing from the switch, it
should send this signal to the de-bounce circuit to
get the pure digital signal. Otherwise, the digital
counter doses not work properly. For example, the
block diagram shows that the new de-bounce circuit
connected to the digital counter, to get the digital
sequence numbers. In addition, based on this
method, the de-bouncing algorithm is explained by
a flowchart to prove how to avoid or eliminate this
problem, as shown in fig. 18.
Also, the following diagram presents the effect
of the bouncing problem in each cycle. It is
33
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
De-Bouncing Algorithm Implementation
Start
2
Two Manual Input
Actions: ON/OFF
SPDT Process to
Generate Pulses
That Contains
Bouncing
This Bouncing
Becomes Input
To De-Bounce
Circuit
De-Bounce Circuit
Process to Get
Pure Digital
Signal
Process of
Digital Decoder
is Sending
Digital Input to
Digital 7Segment
Display
Output: 7Segment
Display
Shows Digital
Sequence
Numbers
End
This Digital
Signal Becomes
Input To
Digital Counter
Digital Counter
Process to
Analyze Digital
Input Signal
The Digital
Signal Becomes
Input To
Digital Decoder
This is a new method to avoid the contact
bouncing problem. This is a new hardware design
to eliminate bouncing. This design consists of JK
flip-flop, SPDT switch, two pull up resistors, and
two capacitors, NAND gate, digital counter, BCDto-seven segment decoder, and seven-segment
display. This circuit is shown in fig. 19.
According to the state of the switch, the circuit is
working as follows:
1) When the switch is in position A; it connects to
a set line of the JK flip-flop through pull up
resistor R1, to working on the edge trigger of
the signal to smooth it out when the switch is
going to an open state. The capacitor C3 is to
show the bouncing before smoothing for open
status.
2) When the switch is in position B; it connects to
a reset line of the JK flip-flop, through pull up
resistor R2, to working on the edge trigger of
the signal in order to smooth it out when the
switch is going to a close state. The capacitor
C4 is for showing the bouncing before
smoothing for close status.
3) The output of the JK flip-flop becomes an input
to the digital counter. For that purpose, the
digital counter is like a checkpoint. It can only
accept a pure digital signal. After that the
digital counter sends the signal to the decoder
to change it to a decimal number and then the
7-segement display shows the digital numbers.
PRODUCED IC
These two sections of hardware have been
mixed to produce a new integrated circuit (IC),
which is called “Bouncing/De-bouncing”. This
IC consists of two packages; package one for
showing the bouncing problem, and the other
package for showing how to solve it. This IC
is shown in fig.1. The inside of this IC
described in fig.21, and it shows the input
requirements such as resistors, capacitors, and
switches for each package.
1
Fig.18 De-Bouncing Algorithm
34
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
Fig.19 De-bouncing algorithm implementation
Fig. 20 shows the pure digital input signal is going
to a digital counter. It means that the de-bouncer
circuit is working properly to produce the digital
input signal.
Fig.20 Digital input signals to counter
Fig.21 inside IC and the input requirements
35
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
SOFTWARE DE-BOUNCING
In this section, a scenario is prepared to solve the
bouncing problem through software. In this case,
we want to solve the bouncing problem using a
microcontroller Atmega168 through software. For
that purpose, we need the following requirements:
Atmega168, and two LEDs. PB0 was connected to
LED1; PB1 was connected to the button, and
finally connect PB2 to LED2. This circuit is setup
so that when you press the button, the stream will
be 0’s, and when you release the button the stream
will be 1’s. This is because the pin on the
microcontroller Atmega168 that the button is
connected to is pulled up high and then the button
goes to ground when you press it, and it reads the
signal, which is 0 [10]. The main purpose of this
scenario is to show you how to convert bounced
signal to stream 1’s and 0’s and then write a
program for it as shown in fig. 22.
LEDs are working like this, it means there is no
bouncing.
4) If the button was bouncing mechanically,
LED2 becomes ON and OFF with the same
button press very shortly because stream of 0’s
and 1’s are very short. At the same time LED1
is ON. This is true for vice versa.
5) To solve the bouncing problem: these two
counters can be used to count the press state
and release state. These counters will reset to
zero if opposite conditions exist. The main idea
behind these two counters is to find a good
threshold to get a good press state and release
state. This means that this threshold is sampling
numbers of 1’s and 0’s that should be enough
to omit any sporadic bouncing.
Through the following program, by trial and error it
was found that this threshold (750) is working quite
well to omit any sporadic bouncing.
Fig.22 Convert signal to stream to write a program
The following points are analyzing stream signals:
1) Released counter: It needs to count the button’s
release state.
2) Pressed counter: It needs to count the button’s
pressed state.
3) Toggling between LED1 and LED2: It needs to
show you the switching between LED1 and
LED2. When you press the button LED1 is ON
and LED2 is OFF, when you press the button
again LED1 is OFF and LED2 is ON. If the
36
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
not a problem if the switch is used to turn on and
turn off the light, but it is a problem if the switch is
used as input to a personal computer,
microcontroller...etc. All in all, our conclusions can
be classified into three parts:
In part one; it is concluded that understanding is
very important because it was very helpful as a
starting point to address the contact bouncing
problem. It helped me to design an algorithm to
show the effect of the problem on digital systems.
In part two, after deepening understanding of the
problem, it is concluded that this is a good step to
think about a solution for the problem. Another
algorithm was designed to eliminate glitches. It was
concluded that these two hardware parts can be
combined to get a new integrated circuit under the
name School of Computing/IC – Clemson
University. These two parts are hardware solutions.
These two algorithms can be implemented by an
electronics simulator which is called Multisim. It is
very helpful to implement your model before
printing it on the board.
EVALUATION
In this section, our result was compared with the
other result of the researchers that worked on this
problem before. They focused on the bouncing
problem and how to solve it. For that purpose, they
proposed some hardware and software solutions.
Our case is different because it was focused on the
effect of the bouncing problem on the digital
systems and how to see this problem in the real
world. For that reason, different approaches were
proposed or methods to look at this problem, and
how to solve it on the same integrated circuit. This
is the hardware solution. For the software solution,
bounced signals were directly converted into stream
signals. Based on this conversion, the solution was
found.
CONCLUSION AND FUTURE WORKS
In part three, this is the software solution part. It
was concluded that bounced signals had to be
converted into streams (0’s and 1’s) and separate
parts (open state and close state) from bouncing
parts to provide a good solution for this problem. A
new idea was used to achieve a good state, which is
using threshold to omit the bouncing problem. By
trial and error, a new value was obtained for
Atmega168 where, at this value, no bouncing was
observed.
Finally, hardware and software solutions were
provided for the contact bouncing problem. As for
my final conclusion, the hardware solution is more
difficult than the software solution, because the
hardware solution depends on a background in
design of electronic circuits. For that purpose,
combinational logic circuits and sequential logic
circuits were combined to get a decent design and
an optimal solution. The future work for this
research is the implementation of another method in
the software approaches, such as shift register
method, and to compare it with our result.
Ultimately, bouncing is one of the problems in the
switching systems and it affects the response of the
system. It can be concluded that contact bounce is
37
Fryad M. Rashid, Journal of Networks and Telecommunication Systems, ISSN: Pending, Vol. 1 (1), September, 28-38, 2015
DOI: Pending
REFERENCES
[1] Jimbo, “Switch Basics”, sparkfun, Retrieved
February 2 2015:
https://learn.sparkfun.com/tutorials/switch-basics
[2] Brunvand E., “Lights! Speed! Action! Fundamentals
of Physical Computing for Programmers”, Volume
(1.0), pages (55-56).
[3] Shenoy M., “Switch De-bouncing”, ElectroSome.
Retrieved January 26 2015:
https://electrosome.com/switch-debouncing/
[4] Engineering classes, “Contact Bouncing”, Youtube,
Retrieved February 9 2015 from:
https://www.youtube.com/watch?v=5EvWgKw92cs
[5] Electronics Tips: “Contact Bounce and De-
Bouncing”, 09/20/2005. Retrived February 16 2015,
from Rensselaer Polytechnic Institute:
http://www.rpi.edu/dept/ecse/mps/Switch_DeBouncing.pdf
[6] Dueck R., and Reid K., “Digital
Electronics”, Delmar Cengage Learning, 2011
[7] Input Interfacing Circuits: Retrived February 28
2015, from Electronics-Tutorial:
http://www.electronics-tutorials.ws/io/inputinterfacing-circuits.html
[8] How Can I Remove Glitches or Bounce on My
Digital Line?, 04/16/2008. Retrieved February 23
2015, from Texas National Instruments:
http://digital.ni.com/public.nsf/allkb/14A90E575987
5BBF86256DD400034FDD#SR
[9] Mano M., and Ciletti M., “Digital Design”, 4E,
Prentice Hall, 2007
[10] Microcontrooler- A Begineers Guide – Button
Debouncing Through Software, 2014. Retrieved
April 12 2015, from:
https://www.newbiehack.com/ButtonorSwitchDebo
unceinSoftware.aspx
38
Download