Tải bản đầy đủ (.pdf) (35 trang)

McGraw-Hill - The Robot Builder''''s Bonanza Episode 2 Part 7 potx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (468.14 KB, 35 trang )

End If
I = I + 2 ' Do even number elements only;
' spaces are in odd number elements
Digit = Digit + 1
Loop While I <= (MaxPulses - 1)
‘ Determine item selected
‘ Tx is for debug window display
‘ MotorVal is the value to use on PortA
Select Case Value
Case 16706
Tx = "0"
MotorVal = 0
Case 16898
Tx = "1"
MotorVal = 1
Case 16642
Tx = "2"
MotorVal = 2
Case 17154
Tx = "3"
MotorVal = 3
Case 16514
Tx = "4"
MotorVal = 4
Case 17026
Tx = "5"
MotorVal = 5
Case 16770
Tx = "6"
MotorVal = 6
Case 17282


Tx = "7"
MotorVal = 7
Case 16450
Tx = "8"
MotorVal = 8
Case 16962
Tx = "9"
MotorVal = 9
Case 16802
Tx = "Power"
MotorVal = 0
Case 16930
Tx = "Channel Up"
MotorVal = 0
Case 16674
Tx = "Channel Down”
MotorVal = 0
Case 16546
Tx = "Volume Up"
MotorVal = 0
Case 17058
Tx = "Volume Down"
MotorVal = 0
Case Else
Tx = "[other]"
End Select
' Set PortA output to motor value (lower four bits only)
Register.PORTA = (Register.PORTA AND bx11110000) OR _
Motors(CInt(MotorVal))
Call PutStr (Tx) ' display on debug window

546 REMOTE CONTROL SYSTEMS
Ch34_McComb 8/21/00 3:31 PM Page 546
Call NewLine
Call Delay(0.25) ' wait quarter of a second
Continue:
Loop
End Sub
'————————————————————————————————-
' Lifted from NetMedia BasicX code examples
Sub TranslateSpace(ByVal Space As UnsignedInteger, _
ByRef BitValue As Integer, ByRef Success As Boolean)
' Translates the specified space into a binary digit.
' Each space must be within this range.
Const MaxValue As Single = 1700.0E-6
Const MinValue As Single = 300.0E-6
' This is the crossover point between binary 0 and 1.
Const TripPoint As Single = 1000.0E-6
Const UnitConversion As Single = 135.63368E-9 ' => 1.0 / 7372800.0
Dim SpaceWidth As Single
' Convert to seconds.
SpaceWidth = CSng(Space) * UnitConversion
If (SpaceWidth < MinValue) Or (SpaceWidth > MaxValue) Then
Success = False
Exit Sub
Else
Success = True
End If
If (SpaceWidth > TripPoint) Then
BitValue = 1
Else

BitValue = 0
End If
End Sub
'————————————————————————————————-
Sub Initialize()
' Wait for power to stabilize
Call Delay(0.25)
' Used for serial port communications
Call OpenSerialPort(1, 19200)
End Sub
Of critical importance is the Select Case structure, which compares the values that are
returned from the remote. These were the actual numeric values obtained using the Sharp
TV code setting mentioned earlier. If your universal remote doesn’t support these same
values, you can easily determine the correct values to use for each button press on the
remote through the code in Listing 34.3, RemoteTest.Bas. (Only the Main subroutine is
shown; the other routines in SharpRemote.Bas, given in Listing 34.2, are used as is.)
LISTING 34.3 REMOTETEST.BAS.
Sub Main()
Dim I As Integer, Digit As Byte, Success As Boolean
Dim BitValue As Integer, Value As Integer, Tx As String
COMMANDING A ROBOT WITH INFRARED REMOTE CONTROL 547
Ch34_McComb 8/21/00 3:31 PM Page 547
Call Initialize
Do
Call InputCapture(PulseTrain, MaxPulses, 0)
I = 2
Digit = 1
Value = 0
Do
Call TranslateSpace(PulseTrain(I), BitValue, Success)

If (Success) Then
Call PutI(BitValue)
Value = Value * 2
Value = Value + BitValue
Else
GoTo Continue
End If
I = I + 2
Digit = Digit + 1
Loop While I <= (MaxPulses - 1)
Call PutByte (9)
Call PutI (Value)
Call Delay(0.5)
Call NewLine
Continue:
Loop
End Sub
When this program is run, pressing keys on the remote control should yield something
like the following on the BasicX Development Program debug window:
100001000000010 16898
100000100000010 16642
100001100000010 17154
100000010000010 16514
100001010000010 17026
The first set of numbers is the signal pattern as on/off bits. The second set is the
numeric equivalent of that pattern. If you see a string of 0s or nothing happens, either
the circuit isn’t working correctly or the remote is not generating the proper format of
signal patterns.
CONTROLLING ROBOT MOTORS WITH THE
SHARPREMOTE.BAS PROGRAM

The SharpRemote.Bas program assumes that you’re driving the traditional two-motor
robot, using DC motors (as opposed to stepper or modified servo motors). To operate a
robot, connect a suitable motor driver circuit to pins 17 through 20 of the BX-24 chip. You
can use most any motor driver that uses two bits per motor. One bit controls the motor
direction (0 is “forward”; 1 is “backward”), and another bit controls the motor’s power (0
is off; 1 is on). Chapter 18, “Working with DC Motors,” presents a variety of motor dri-
vers that you can use.
Note: Whatever motor drivers you use make sure that you provide adequate bypass fil-
tering. This prevents excess noise from appearing on the incoming signal line from the IR
receiver-demodulator. DC motors, particularly the inexpensive kind, generate copious noise
from radio frequency (RF) interference as well as “hash” in the power supply lines of the
548 REMOTE CONTROL SYSTEMS
Ch34_McComb 8/21/00 3:31 PM Page 548
circuit. If you fail to use adequate filtering unpredictable behavior will result. Your best bet
is to use opto-coupling, with completely separate battery power supplies for the microcon-
troller and IR electronics on the one hand and the motors and motor driver on the other.
In SharpRemote.Bas, the following line,
Motors(1) = bx00000100
Motors(2) = bx00000101
[etc.]
set up the bit patterns to use for the four pins controlling the motors. Yes, the patterns show
eight bits. We’re only interested in the last four, so the first four are set to 0000. The bits
are in “DLDR” format. That is, the left-most two bits control the left motor, and the right-
most two bits control the right motor. The D represents direction; and L and R represent
left and right, as you’d expect.
After the program has received a code pattern from the remote, it reconstructs that pat-
tern as a 16-bit word. This word is then translated into a numeric equivalent, which is then
used in the Select Case structure, as in the following example:
Select Case Value
Case 16706

Tx = "0"
MotorVal = 5
Case 16898
Tx = "1"
MotorVal = 1

The value 16706 represents the 0 button. When it’s pressed, the program stores the string
“0” (for display in the debug window) as well as the motor value, 5. Five is used as “stop,”
with both motors turning off (the numeric keypad on the remote forms a control diamond).
The program interprets the value 16898 received from the remote as a 1 and sets the MotorVal
to 1. The pattern for this value calls for the robot to turn left by turning off its right motor and
turning on its left. Review SharpRemote.Bas for other variations, which are self-explanatory.
You will note that several of the buttons on the remote are not implemented and set the
MotorVal to 5, or stop. You can add your own functionality to these buttons as you see fit.
For example, pressing the Volume Up/Down or Channel Up/Down buttons could control
the arm on your robot, if it’s so equipped.
OPERATING THE ROBOT WITH THE REMOTE
Now that you have the remote control system working and you’re done testing, it’s time to
play! Disconnect the BX-24 chip from its programming cable, set your robot on the
ground, and apply all power. In the beginning, the robot should not move. Point the remote
control at the infrared receiver-demodulator, and press the 2 button (forward). The robot
should move forward. Press 5 to stop. Press other buttons to test out the other features.
GOING FURTHER
Perhaps the BX-24 is not your microcontroller of choice. Or maybe you don’t want to use
the signal patterns for Sharp TVs and VCRs. You can adapt the receiver-demodulator inter-
COMMANDING A ROBOT WITH INFRARED REMOTE CONTROL 549
Ch34_McComb 8/21/00 3:31 PM Page 549
face and the SharpRemote.Bas program for use with a wide variety of controllers, com-
puters, and signal pattern formats. Of course, you’ll need to revise the program as neces-
sary, and determine the proper bit patterns to use.

You will probably find that the signal patterns used with a great many kinds of remote
controls will be usable with the SharpRemote.Bas program. You merely need to test the
remote, using the RemoteTest.Bas variation to determine the values to use for each button
press. The program still works even if the signal from the remote contains more data bits
than the 16 provided. For this application, it doesn’t really matter that the last couple of bits
are missing—we’re not trying to control a TV or VCR but our own robot, and the code val-
ues for its control are up to us. The only requirement is that each button on the remote must
produce a unique value. Things won’t work if pressing 2 and 5 yield the same value.
Multifunction Encoder and Decoder
Remote Control
Remote control devices, like those detailed in the previous section, typically use a special
function integrated circuit called an encoder to generate unique sequences of digital puls-
es that can then be used to modulate an infrared light beam or radio signal. A matching
decoder, on the receiving end, translates the digital pulses back into the original format.
For example, pressing the number 5 on the remote control might emit a sequence of 1s
and 0s like this:
0111000100010111
The decoder receives this sequence and outputs a 5. In the previous section you used a
BasicX-24 microcontroller as a kind of generic decoder for translating signals from a uni-
versal remote control. Another, less expensive, alternative is to use an encoder/decoder IC
pair, which are available from a number of manufacturers such as National Semiconductor,
Motorola, and Holtek. In this section, we’ll examine a system that uses the popular Holtek
HT-12E and HT-12D four-bit encoder/decoder. The HT-12 chips are available from a num-
ber of sources—you can also substitute most any encoder/decoder pair you wish to use.
Most require minimal external parts and cost under $3 each, so you should feel free to
experiment.
Fig. 34.5 shows the pinout diagram for the HT-12E encoder. Consult the data sheet for this
chip (available at www.holtek.com, Web site for the maker of the chip) for a variety of circuit
suggestions. The HT chips support up to 256 different addresses. To receive valid data, you
must set the same address on both the encoder and the decoder. The data input is four bits

(nibble), which you can connect to individual push-button switches. You can press multiple
switches at a time for up to 16 different data values.
The output of the HT-12E gates an astable multivibrator circuit that oscillates at approx-
imately 40 kHz. I have specified the use of two high-output infrared LEDs. The higher the
output, the longer the range of your remote control system.
550 REMOTE CONTROL SYSTEMS
Ch34_McComb 8/21/00 3:31 PM Page 550
Fig. 34.6 shows the pinout diagram for the HT-12D decoder. When used with infrared
communications, the chip is typically connected to a receiver-demodulator that is “tuned”
to the 40 kHz modulation from the encoder. When the 40 kHz signal is received, the mod-
ulation is stripped off, and only the digital signal generated by the HT-12E encoder
remains. This signal is applied to the input of the HT-12D encoder. The Holtek Web page
provides data sheets and circuit recommendations for the HT-12D chip.
There are five important outputs for the HT-12D: the four data lines (pins 10-13) and
the valid data line (pin 17). The valid data line is normally low. When valid data is received,
it will “wink” high then low again. At this point, you know the data on the data lines is
good. The data lines are latching, which means their value remains until new data is
received.
You can use the decoder with your robot in several ways. One way is to connect each of
the output lines to a relay. This allows you to directly operate the motors of your robot. As
detailed in Chapter 18, “Working with DC Motors,” two relays could control the on/off
operation of the motors; and two more relays could control the direction of the motors.
Chapter 18 also shows you how to use solid-state circuitry and specialty motor driver ICs
instead of relays.
Another way to use the decoder is to connect the four lines to a microcontroller, such
as the Basic Stamp or the BasicX-24. In this way, you can send up to 16 different com-
mands. Each command could be interpreted as a unique function for your robot.
Using Radio Control Instead of Infrared
If you need to control your robot over longer distances consider using radio signals instead
of infrared. You can hack an old pair of walkie-talkies to serve as data transceivers, or even

build your own AM or FM transmitter and receiver. But an easier (and probably more reli-
able) method is to use ready-made transmitter/receiver modules. Ming, Abacom, and sev-
eral other companies make low-cost radio frequency modules that you can use to transmit
and receive low-speed (less than 300 bits per second) digital signals. Fig. 34.7 shows trans-
mitter/receiver boards from Ming. Attached to them are “daughter boards” outfitted with
Holtek HT-12E and HT-12D encoder/decoder chips.
USING RADIO CONTROL INSTEAD OF INFRARED 551
1
9
10
18
+V
Out
Osc 1
Osc 2
TE
AD11
AD10
AD9
AD8
Gnd
A7
A6
A5
A4
A3
A2
A1
A0
FIGURE 34.5 Pinout diagram for the

Holtek HT-12E encoder.
Ch34_McComb 8/21/00 3:31 PM Page 551
The effective maximum range is from 20 to 100 feet, depending on whether you use
an external antenna and if there are any obstructions between the transmitter and
receiver. More expensive units have increased power outputs, with ranges exceeding
one mile. You are not limited to using just encoder/decoders like the HT-12. You may
wish to construct a remote control system using DTMF (dual-tone multifrequency) sys-
tems, the same technology found in Touch-Tone phones. Connect a DTMF encoder to
the transmitter and a DTMF decoder to the receiver. Microcontrollers such as the Basic
Stamp can be used as either a DTMF encoder or decoder, or you can use specialty ICs
made for the job.
552 REMOTE CONTROL SYSTEMS
1
9
10
18
+V
VT
Osc 1
Osc 2
Data in
D11
D10
D9
D8
Gnd
A7
A6
A5
A4

A3
A2
A1
A0
FIGURE 34.6 Pinout diagram for the Holtek
HT-12D decoder.
FIGURE 34.7 RF transmitter/receiver modules can be used to remotely control
robots from a greater distance than with infrared systems.
Ch34_McComb 8/21/00 3:31 PM Page 552
From Here
To learn more about… Read
Interfacing and controlling DC motors Chapter 18, “Working with DC Motors”
Connecting to computers and Chapter 29, “Interfacing with Computers and
microcontrollers Microcontrollers”
Using the Basic Stamp microcontroller Chapter 31, “Using the Basic Stamp”
Using the BasicX microcontroller Chapter 32, “Using the BasicX Microcontroller”
FROM HERE 553
Ch34_McComb 8/21/00 3:31 PM Page 553
This page intentionally left blank.
PART
6
SENSORS AND NAVIGATION
Ch35_McComb 8/21/00 3:30 PM Page 555
Copyright 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
This page intentionally left blank.
Like the human hand, robotic grippers often need a sense of touch to determine
if and when they have something in their grasp. Knowing when to close the grip-
per to take hold of an object is only part of the story, however. The amount of
pressure exerted on the object is also important. Too little pressure and the object
may slip out of grasp; too much pressure and the object may be damaged.

The human hand—indeed, nearly the entire body—has an immense network of
complex nerve endings that serve to sense touch and pressure. Touch sensors in a
robot gripper are much more crude, but for most hobby applications these sensors
serve their purpose: to provide nominal feedback on the presence of an object and
the pressure exerted on the object.
This chapter deals with the fundamental design approaches for several touch-
sensing systems for use on robot grippers—or should the robot lack hands, else-
where on the body of the robot. Modify these systems as necessary to match the
specific gripper design you are using and the control electronics you are using to
monitor the sense of touch.
Note that in this chapter I make the distinction between “touch” and collision.
Touch is a proactive event, where you specifically wish the robot to determine its
environment by making physical contact. Conversely, collision is a reactive event,
where (in most cases) you wish the robot to stop what it’s doing when a collision
is detected and back away from the condition. Chapter 36, “Collision Avoidance
and Detection,” deals with the physical contact that results in collision.
35
ADDING THE SENSE OF TOUCH
557
Ch35_McComb 8/21/00 3:30 PM Page 557
Copyright 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
Mechanical Switch
The lowly mechanical switch is the most common, and simple, form of tactile (touch)
feedback. Most any momentary, spring-loaded switch will do. When the robot makes con-
tact, the switch closes, completing a circuit (or in some cases, the switch opens, breaking
the circuit). The switch may be directly connected to a motor or discrete circuit, or it may
be connected to a computer or microcontroller, as shown in Fig. 35.1.
You can choose from a wide variety of switch styles when designing contact switches
for tactile feedback. Leaf switches (sometimes referred to as Microswitch switches, after
a popular brand name) come with levers of different lengths that enhance the sensitivity of

the switch. You can also use miniature contact switches, like those used in keyboards and
electronic devices, as touch sensors on your robot.
In all cases, mount the switch so it makes contact with whatever object you wish to
sense. In the case of a robotic gripper, you can mount the switch in the hand or finger sec-
tions. In the case of “feelers” for a smaller handless robot, the switch can be mounted fore
or aft. It makes contact with an object as it rolls along the ground. By changing the
arrangement of the switch from vertical (see Fig. 35.2), you can have the “feeler” deter-
mine if it’s reached the edge of a table or a stair landing.
Optical Sensors
Optical sensors use a narrow beam of light to detect when an object is within the grasping
area of a gripper. Optical sensors provide the most rudimentary form of touch sensitivity
and are often used with other touch sensors, such as mechanical switches.
558 ADDING THE SENSE OF TOUCH
Frame
Switch
FIGURE 35.1 A mechanical
switch makes a
perfect touch
sensor.
Vertical mount detects
changes in terrain
FIGURE 35.2 By orienting the switch to the vertical, your robot
can detect changes in topography, such as when
it’s about to run off the edge of a table.
Ch35_McComb 8/21/00 3:30 PM Page 558
Building an optical sensor into a gripper is easy. Mount an infrared LED in one finger
or pincher; mount an infrared-sensitive phototransistor in another finger or pincher (see
Fig. 35.3). Where you place the LED and transistor along the length of the finger or pinch-
er determines the grasping area.
Mounting the infrared pair on the tips of the fingers or pinchers provides for little grasp-

ing area because the robot is told that an object is within range when only a small portion
of it can be grasped. In most gripper designs, two or more LEDs and phototransistors are
placed along the length of the grippers or fingers to provide more positive control.
Alternatively, you may wish to detect when an object is closest to the palm of the gripper.
You’d mount the LED and phototransistor accordingly.
Fig. 35.4 shows the schematic diagram for a single LED-transistor pair. Adjust the value
of R2 to increase or decrease the sensitivity of the phototransistor. You may need to place
an infrared filter over the phototransistor to prevent it from triggering as a result of ambi-
ent light sources (some phototransistors have the filter built into them already). Use an
LED-transistor pair equipped with a lens to provide additional rejection of ambient light
and to increase sensitivity.
During normal operation, the transistor is on because it is receiving light from the LED.
When an object breaks the light path, the transistor switches off. A control circuit con-
nected to the conditioned transistor output detects the change and closes the gripper. In a
practical application, using a computer as a controller, you’d write a short software pro-
gram to control the actuation of the gripper.
Mechanical Pressure Sensors
An optical sensor is a go/no-go device that can detect only the presence of an object, not
the amount of pressure on it. A pressure sensor detects the force exerted by the gripper on
MECHANICAL PRESSURE SENSORS 559
LED
Phototransistor
FIGURE 35.3 An infrared LED and phototransistor
pair can be added to the fingers of a
gripper to provide go/no-go grasp
information.
Ch35_McComb 8/21/00 3:30 PM Page 559
the object. The sensor is connected to a converter circuit, or in some cases a servo circuit,
to control the amount of pressure applied to the object.
Pressure sensors are best used on grippers where you have incremental control over the

position of the fingers or pinchers. A pressure sensor would be of little value when used
with a gripper that’s actuated by a solenoid. The solenoid is either pulled in or it isn’t; there
are no in-between states. Grippers actuated by motors are the best choices when you must
regulate the amount of pressure exerted on the object.
CONDUCTIVE FOAM
You can make your own pressure sensor (or transducer) out of a piece of discarded con-
ductive foam—the stuff used to package CMOS ICs. The foam is like a resistor. Attach two
pieces of wire to either end of a one-inch square hunk and you get a resistance reading on
your volt-ohm meter. Press down on the foam and the resistance lowers.
The foam comes in many thicknesses and densities. I’ve had the best luck with the
semistiff foam that bounces back to shape quickly after it’s squeezed. Very dense foams are
not useful because they don’t quickly spring back to shape. Save the foam from the vari-
ous ICs you buy and test other types until you find the right stuff for you.
Here’s how to make a “down-and-dirty” pressure sensor. Cut a piece of foam 1/4-inch
wide by 1-inch long. Attach leads to it using 30-gauge wire-wrapping wire. Wrap the wire
through the foam in several places to ensure a good connection, then apply a dab of solder
to keep it in place. Use flexible household adhesive to cement the transducer onto the tips
of the gripper fingers.
A better way is to make the sensor by sandwiching several pieces of material together, as
depicted in Fig. 35.5. The conductive foam is placed between two thin sheets of copper or alu-
minum foil. A short piece of 30 AWG wire-wrapping wire is lightly soldered onto the foil
(when using aluminum foil, the wire is wound around one end). Mylar plastic, like the kind
used to make heavy-duty garbage bags, is glued on the outside of the sensor to provide
560 ADDING THE SENSE OF TOUCH
LED1
Q1
+5V
R2
10K
270Ω

R1
Infrared filter
To comparator, amplifier,
A/D converter, etc.
FIGURE 35.4 The basic electronic circuit for an
infrared touch system. Note the
infrared filter; it helps prevent the pho-
totransistor from being activated by
ambient light.
Ch35_McComb 8/21/00 3:30 PM Page 560
electrical insulation. If the sensor is small and the sense of touch does not need to be too great,
you can encase the foam and foil in heat-shrink tubing. There are many sizes and thicknesses
of tubing; experiment with a few types until you find one that meets your requirements.
The output of the transducers changes abruptly when they are pressed in. The output
may not return to its original resistance value (see Fig. 35.6). So in the control software,
you should always reset the transducer just prior to grasping an object.
For example, the transducer may first register an output of 30K ohms (the exact value
depends on the foam, the dimensions of the piece, and the distance between wire termi-
nals). The software reads this value and uses it as the set point for normal (nongrasping)
level to 30K. When an object is grasped, the output drops to 5K. The difference—25K—
is the amount of pressure. Keep in mind that the resistance value is relative, and you must
experiment to find out how much pressure is represented by each 1K of resistance change.
The transducer may not go back to 30K when the object is released. It may spring up to
40K or go only as far as 25K. The software uses this new value as the new set point for the
next occasion when the gripper grasps an object.
STRAIN GAUGES
Obviously, the home-built pressure sensors described so far leave a lot to be desired in
terms of accuracy. If you need greater accuracy, you should consider commercially avail-
able strain gauges. These work by registering the amount of strain (the same as pressure)
exerted on various points along the surface of the gauge.

MECHANICAL PRESSURE SENSORS 561
Mylar sheet
Mylar sheet
Conductive foam
Foil
Foil
Outputs
FIGURE 35.5 Construction detail for a pressure sensor using con-
ductive foam. The leads are soldered or attached to
foil (copper works best). Choose a foam that has a
good “spring” to it.
Ch35_McComb 8/21/00 3:30 PM Page 561
Strain gauges are somewhat pricey—about $10 and over in quantities of 5 or 10. The
cost may be offset by the increased accuracy the gauges offer. You want a gauge that’s as
small as possible, preferably one mounted on a flexible membrane. See Appendix B,
“Sources,” for a list of companies offering such gauges.”
CONVERTING PRESSURE DATA TO COMPUTER DATA
The output of both the homemade conductive foam pressure transducers and the strain
gauges is analog—a resistance or voltage. Neither can be directly used by a computer, so
the output of these devices must be converted into digital form first.
Both types of sensors are perfect for use with an analog-to-digital converter. You can
use one ADC0808 chip (under $5) with up to eight sensors. You select which sensor out-
put you want to convert into digital form. The converted output of the ADC0808 chip is an
eight-bit word, which can be fed directly to a microprocessor or computer port. Fig. 35.7a
shows a the basic wiring diagram for the ADC0808 chip, which can be used with conduc-
tive foam transducer; Fig. 35.7b shows how to connect a conductive foam transducer to
one of the analog inputs of the ADC0808.
Notice the 10K resistor in Fig. 35.7, placed in series between the pressure sensor and
ground. This converts the output of the sensor from resistance to voltage. You can change
the value of this resistor to alter the sensitivity of the circuit. For more information on

ADCs, see Chapter 29, “Interfacing with Computers and Microcontrollers.”
Experimenting with Piezoelectric Touch
Sensors
A new form of electricity was discovered just a little more than a century ago when the two
scientists Pierre and Jacques Curie placed a weight on a certain crystal. The strain on the
562 ADDING THE SENSE OF TOUCH
3
0
0 1 2 3 4 5 6 7 8 9
1
1
5
20
2
Pressure (ounces)
Press
Release
Resistance
(k ohms)
FIGURE 35.6 The response curve for the conductive foam pres-
sure sensor. Note that the resistance varies
depending on whether the foam is being pressed
or released.
Ch35_McComb 8/21/00 3:30 PM Page 562
crystal produced an odd form of electricity—significant amounts of it, in fact. The Curie
brothers coined this new electricity “piezoelectricity”; piezo is derived from the Greek
word meaning “press.”
Later, the Curies discovered that the piezoelectric crystals used in their experiments
underwent a physical transformation when voltage was applied to them. They also found
that the piezoelectric phenomenon is a two-way street. Press the crystals and out comes a

voltage; apply a voltage to the crystals and they respond by flexing and contracting.
All piezoelectric materials share a common molecular structure, in which all the mov-
able electric dipoles (positive and negative ions) are oriented in one specific direction.
Piezoelectricity occurs naturally in crystals that are highly symmetrical—quartz, Rochelle
salt crystals, and tourmaline, for example. The alignment of electric dipoles in a crystal
structure is similar to the alignment of magnetic dipoles in a magnetic material.
When the piezoelectric material is placed under an electric current, the physical dis-
tance between the dipoles change. This causes the material to contract in one dimension
EXPERIMENTING WITH PIEZOELECTRIC TOUCH SENSORS 563
Analog
Inputs (8)
Input
Select
Digital outputs
+5V
21
MSB
LSB
20
19
18
Q1
Q7
Q6
Q5
Q4
Q3
8
Q2
15

14
Q0
17
IN1
IN0
IN2
IN3
IN4
IN5
IN6
IN7
26
27
28
1
2
3
4
5
1
2
3
4
5
6
7
0
A1
A2
A4

Sc
Start
Conversion
500kHz In
Eoc
End of
conversion
Clk
Ale
11
Vcc OE
229
+Rf
12
Gnd
13
-Ref
16
25
24
23
6
7
10
A
B
To ADC input (0-7)
+V
10K
Foam transducer

FIGURE 35.7 a. The basic wiring diagram for converting pressure data into digi-
tal data, using an ADC0808 analog-to-digital converter (ADC) IC.
You can connect up to eight pressure sensors to the one chip. b.
How to interface a conductive foam sensor to the ADC0808 chip.
Ch35_McComb 8/21/00 3:30 PM Page 563
(or axis) and expand in the other. Conversely, placing the piezoelectric material under pres-
sure (in a vise, for example) compresses the dipoles in one more axis. This causes the
material to release an electric charge.
While natural crystals were the first piezoelectric materials used, synthetic materials
have been developed that greatly demonstrate the piezo effect. A common human-made
piezoelectric material is ferroelectric zirconium titanate ceramic, which is often found in
piezo buzzers used in smoke alarms, wristwatches, and security systems. The zirconium
titanate is evenly deposited on a metal disc. Electrical signals, applied through wires bond-
ed to the surfaces of the disc and ceramic, cause the piezo material to vibrate at high fre-
quencies (usually 4 kHz and above).
Piezo activity is not confined to brittle ceramics. PVDF, or polyvinylidene fluoride
(used to make high-temperature PVDF plastic water pipes), is a semicrystalline polymer
that lends itself to unusual piezoelectric applications. The plastic is pressed into thin, clear
sheets and is given precise piezo properties during manufacture by—among other things—
stretching the sheets and exposing them to intense electrical fields.
PVDF piezo film is currently used in many commercial products, including noninductive
guitar pickups, microphones, even solid-state fans for computers and other electrical equip-
ment. One PVDF film you can obtain and experiment with is Kynar, available directly from
the manufacturer (see Measurement Specialists at www.msiusa.com for more information).
Whether you are experimenting with ceramic or flexible PVDF film, it’s important to
understand a few basic concepts about piezoelectric materials:

Piezoelectric materials are voltage sensitive. The higher the voltage is, the more the
piezoelectric material changes. Apply 1 volt to a ceramic disc and crystal movement
will be slight. Apply 100 volts and the movement will be much greater.


Piezoelectric materials act as capacitors. Piezo materials develop and retain an electri-
cal charge.

Piezoelectric materials are bipolar. Apply a positive voltage and the material expands in
one axis. Apply a negative voltage and the material contracts in that axis.
EXPERIMENTING WITH CERAMIC DISCS
The ubiquitous ceramic disc is perhaps the easiest form of piezoelectric transducer to
experiment with. A sample disc is shown in Fig. 35.8. The disc is made of nonferrous
metal, and the ceramic-based piezo material is applied to one side. Most discs available for
purchase have two leads already attached. The black lead is the “ground” of the disc and
is directly attached to the metal itself.
You can use a ceramic disc as an audio transducer by applying an audio signal to it.
Most piezo discs will emit sound in the 1K to 10K region, with a resonant frequency of
between 3K and 4K. At this resonant frequency the output of the disc will be at its
highest.
When the piezo material of the disc is under pressure—even a slight amount—the disc
outputs a voltage proportional to the amount of pressure. This voltage is short lived: short-
ly after the initial change in pressure, the voltage output of the disc will return to 0. A neg-
ative voltage is created when the pressure is released (see the discussion of the bipolar
nature of piezo materials earlier in the chapter).
564 ADDING THE SENSE OF TOUCH
Ch35_McComb 8/21/00 3:30 PM Page 564
You can easily interface piezo discs to a computer or microcontroller, either with or
without an analog-to-digital converter. Chapter 36, “Collision Avoidance and Detection,”
discusses several interface approaches. See the section “Piezo Disc Touch Bar” in that
chapter for more information.
EXPERIMENTING WITH KYNAR PIEZO FILM
Samples of Kynar piezoelectric film are available in a variety of shapes and sizes. The wafers,
which are about the same thickness as the paper in this book, have two connection points, as

illustrated in Fig. 35.9. Like ceramic discs, these two connection points are used to activate the
film with an electrical signal or to relay pressure on the film as an electrical impulse.
You can perform basic experiments with the film using just an oscilloscope (preferred)
or a high-impedance digital voltmeter. Connect the leads of the scope or meter to the tabs
on the end of the film (the connection will be sloppy; later in this chapter we’ll discuss
ways to apply leads to Kynar film). Place the film on a table and tap on it. You’ll see a fast
voltage spike on the scope or an instantaneous rise in voltage on the meter. If the meter
isn’t auto-ranging and you are using the meter at a low setting, chances are that the volt-
age spike will exceed the selected range.
ATTACHING LEADS TO PIEZO FILM
Unlike piezoelectric ceramic discs, Kynar film doesn’t usually come with preattached
leads (although you can order samples with leads attached, but they are expensive). There
EXPERIMENTING WITH PIEZOELECTRIC TOUCH SENSORS 565
FIGURE 35.8 Piezo ceramic discs are ideally suited to be contact and pressure
sensors for robotics.
Ch35_McComb 8/21/00 3:31 PM Page 565
are a variety of ways to attach leads to Kynar film. Obviously, soldering the leads onto the
film contact areas is out of the question. Acceptable methods include applying conduc-
tive ink or paint, self-adhesive copper-foil tape, small metal hardware, and even miniature
rivets. In all instances, use small-gauge wire—22 AWG or smaller. I have had good
results using 28 AWG and 30 AWG solid wire-wrapping wire. The following are the best
methods:

Conductive ink or paint. Conductive ink, such as GC Electronics’ Nickel-Print paint,
bonds thin wire leads directly to the contact points on Kynar film. Apply a small glob-
ule of paint to the contact point, and then slide the end of the wire in place. Wait sever-
al minutes for the paint to set before handling. Apply a strip of electrical tape to provide
physical strength.

Self-adhesive copper-foil tape. You can use copper-foil tape designed for repairing

printed circuit boards to attach wires to Kynar film. The tape uses a conductive adhe-
sive and can be applied quickly and simply. As with conductive inks and paints, apply
a strip of electrical tape to the joint to give it physical strength.

Metal hardware. Use small 2/56 or 4/40 nuts, washers, and bolts (available at hobby
stores) to mechanically attach leads to the Kynar. Poke a small hole in the film, slip the
bolt through, add the washer, and wrap the end of a wire around the bolt. Tighten with
the nut.

Miniature rivets. Homemade jewelry often uses miniature brass or stainless steel rivets.
You can obtain the rivets and the proper riveting tool from many hobby and jewelry-
making stores. To use them, pierce the film to make a small hole, wrap the end of the
wire around the rivet post, and squeeze the riveting tool (you may need to use metal
washers to keep the wire in place).
USING KYNAR AS A MECHANICAL TRANSDUCER
Fig. 35.10 shows a simple demonstrator circuit you can build that indicates each time a
piece of Kynar film is struck. Tapping the film produces a voltage output, which is visu-
ally indicated when the LED flashes. The 4066 IC is an analog switch. When a voltage is
applied to pin 3, the connection between pins 1 and 2 is completed and that finishes the
electrical circuit to light the LED. For a robotic application, you can connect the output to
a computer or microcontroller.
566 ADDING THE SENSE OF TOUCH
Front-side
conductive layer
Reverse-side
layer
Kynar film
substrate
FIGURE 35.9 A close-up look at Kynar piezo film
and its electrical contacts.

Ch35_McComb 8/21/00 3:31 PM Page 566
CONSTRUCTING A KYNAR PIEZO BEND SENSOR
You can easily create a workable touch sensor by attaching one or two small Kynar trans-
ducers to a thick piece of plastic. The finished prototype sensor is depicted in Fig. 35.11.
The plastic membrane could be mounted on the front of a robot, to detect touch contact,
or even in the palm of the robot’s hand. Any flexing of the membrane causes a voltage
change at the output of one or both Kynar film pieces.
Other Types of “Touch” Sensors
The human body has many kinds of “touch receptors” embedded within the skin. Some
receptors are sensitive to physical pressure, while others are sensitive to heat. You may
wish to endow your robot with some additional touchlike sensors:

Heat sensors can detect changes in the heat of objects within grasp. Heat sensors are
available in many forms, including thermisters (resistors that change their value
depending on temperature) and solid-state diodes that are specifically made to be ultra-
sensitive to changes in temperature. Chapter 39, “Fire Detection Systems,” discusses
using solid-state temperature sensors.

Air pressure sensors can be used to detect physical contact. The sensor is connected to
a flexible tube or bladder (like a balloon); pressure on the tube or bladder causes air to
push into or out of the sensor, thereby triggering it. To be useful, the sensor should be
sensitive down to about one pound per square inch, or less.

Resistive bend sensors, originally designed for use with virtual reality gloves, vary their
resistance depending on the degree of bending. Mount the sensor in a loop, and you can
detect the change in resistance as the loop is deformed by the pressure of contact.

Microphones and other sound transducers make effective touch sensors. You can use
microphones, either standard or ultrasonic, to detect sounds that occur when objects
touch. Mount the microphone element on the palm of the gripper or directly on one of

the fingers or pinchers. Place a small piece of felt directly under the element, and
OTHER TYPES OF “TOUCH” SENSORS 567
2
13
1
14
7
+V
Output
R1
10M
IC1
4066
Piezo
film
FIGURE 35.10 A strike/vibration
indicator using
Kynar piezo film.
Ch35_McComb 8/21/00 3:31 PM Page 567
cement it in place using a household glue that sets hard. Run the leads of the micro-
phone to the sound trigger circuit, which should be placed as close to the element as
possible.
From Here
To learn more about… Read
Designing and building robot hands Chapter 27, “Experimenting with Gripper
Designs”
Connecting sensors to computers and Chapter 29, “Interfacing with Computers and
microcontrollers Microcontrollers”
Collision detection systems Chapter 36, “Collision Avoidance and Detection”
Building light sensors Chapter 37, “Robotic Eyes”

Fire, heat, and smoke detection for robotics Chapter 39, “Fire Detection Systems”
568 ADDING THE SENSE OF TOUCH
FIGURE 35.11 The prototype Kynar piezo bend sensor.
Ch35_McComb 8/21/00 3:31 PM Page 568
You’ve spent hundreds of hours designing and building your latest robot creation. It’s
filled with complex little doodads and precision instrumentation. You bring it into your liv-
ing room, fire it up, and step back. Promptly, the beautiful new robot smashes into the fire-
place and scatters itself over the living room rug. You remembered things like motor speed
controls, electronic eyes and ears, even a synthetic voice, but you forgot to provide your
robot with the ability to look before it leaps.
Collision avoidance and detection systems take many forms, and all of the basic sys-
tems are easy to build and use. In this chapter, we present a number of passive and active
detection systems you can use in your robots. Some of the systems are designed to detect
objects close to the robot (called near-object, or proximity, detection), and some are
designed to detect objects at distances of 10 feet or more (called far-object detection). All
use sensors of some type, which detect everything from light and sound to the heat radi-
ated by humans and animals.
Design Overview
Collision avoidance and collision detection are two similar but separate aspects of robot
design. With collision avoidance, the robot uses noncontact techniques to determine the
proximity and/or distance of objects around it. It then avoids any objects it detects.
36
COLLISION AVOIDANCE AND
DETECTION
569
Ch36_McComb 8/29/00 8:32 AM Page 569
Copyright 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
Collision detection concerns what happens when the robot has already gone too far, and
contact has been made with whatever foreign object was unlucky enough to be in the
machine’s path.

Collision avoidance can be further broken down into two subtypes: near-object detec-
tion and far-object detection. By its nature, all cases of collision detection involve making
contact with nearby objects. All of these concepts are discussed in this chapter.
Note: In this book I make a distinction between a robot hitting something in its path
(“collision”) and sensing its environment tactilely by using grippers or feelers (“touch”).
Both may involve the same kinds of sensors, but the goal of the sensing is different.
Collision sensing is reactive with an emphasis on avoidance; tactile sensing is active with
an emphasis on exploring. See Chapter 35, “Adding the Sense of Touch,” for additional
information on the sensors used for deliberate tactile feedback.
Additionally, robot builders commonly use certain object detection methods to navigate
a robot from one spot to the next. Many of these techniques are introduced here because
they are relevant to object detection, but we develop them more fully in Chapter 38,
“Navigating through Space.”
NEAR-OBJECT DETECTION
Near-object detection does just what its name implies: it senses objects that are close by,
from perhaps just a breath away to as much as 8 or 10 feet. These are objects that a robot
can consider to be in its immediate environment; objects it may have to deal with, and
soon. These objects may be people, animals, furniture, or other robots. By detecting them,
your robot can take appropriate action, which is defined by the program you give it. Your
‘bot may be programmed to come up to people and ask them their name. Or it might be
programmed to run away whenever it sees movement. In either case, it won’t be able to
accomplish either behavior unless it can detect objects in its immediate area.
There are two ways to effect near-object detection: proximity and distance:

Proximity sensors care only that some object is within a zone of relevance. That is, if an
object is near enough in the physical scene the robot is looking at, the sensor detects it
and triggers the appropriate circuit in the robot. Objects beyond the proximal range of
a sensor are effectively ignored because they cannot be detected.

Distance measurement sensors determine the distance between the sensor and whatev-

er object is within range. Distance measurement techniques vary; almost all have
notable minimum and maximum ranges. Few yield accurate data if an object is smack-
dab next to the robot. Likewise, objects just outside range can yield inaccurate results.
Large objects far away may appear closer than they really are; very close small objects
may appear abnormally larger than they really are, and so on.
Sensors have depth and breadth limitations: depth is the maximum distance an object can
be from the robot and still be detected by the sensor. Breadth is the maximum height and
width of the sensor detection area. Some sensors see in a relatively narrow zone, typically
in a conical pattern, like the beam of a flashlight. Light sensors are a good example. Adding
a lens in front of the sensor narrows the pattern even more. Other sensors have specific
breadth patterns. The typical passive infrared sensor (the kind used on motion alarms) uses
a Fresnel lens that expands the field of coverage on the top but collapses it on the bottom.
570 COLLISION AVOIDANCE AND DETECTION
Ch36_McComb 8/29/00 8:32 AM Page 570

×