Hardware Reference
In-Depth Information
Chapter 8
Remote-Control Panel
Because of the Raspberry Pi's small size and low cost, it is an attractive platform for
remote-sensing applications. A remote station might need to sense control panel switches
or push button events. This electronic problem sounds simple until you discover that
switches and buttons suffer from contact bounce .
The remaining challenge resides on the software side. When your sensing stations
are remote, some kind of local software console needs to exist. In fact, your console may
monitor several remote Raspberry Pis. Then add redundant consoles, or consoles in
multiple locations. Each of these has the ability to monitor and control the same remote
devices. It doesn't take long before the problem becomes complex.
This chapter's project aims to solve two problems:
Debouncing a switch or push button (hardware)
Controlling remote consoles (software)
Let's first examine the contact bounce problem.
Switched Inputs
One of the aggravations of dealing with push buttons and switches in an electronic
computing environment is that contacts bounce . When you close a switch or push a
button, the contacts can bounce a thousand times before they settle and produce a
stable contact. A modern computer might see thousands of on/off transitions before the
contacts stabilize.
This is not only a nuisance for software design, but also wasteful of the CPU. Each time
the signal from the switch changes state, the CPU must be interrupted to make note of this
event and pass the information on to the interested software (for example, GPIO change
events). The software must then apply algorithms to smooth out these pulses and arrive at a
conclusion when the switch is fully on, or fully off. This is all very ugly and messy!
The same problem happens in reverse when contacts release. Thousands of pulses
are delivered to the CPU as the contacts slowly release and alternate between being in
contact and being disconnected.
There are several ways to reduce or eliminate the problem. One approach is to apply
a flip-flop ahead of the GPIO pins, as shown in Figure 8-1 . One end of a SPDT switch is
wired to the flip-flop reset input, while the other is wired to the set input. In this manner,
a single pulse on either end changes the flip-flop state and keeps it stable.
 
Search WWH ::




Custom Search