INTRODUCTION TO ROBOTICS Robotics and Automation Part 4: Sensors

advertisement
INTRODUCTION TO
ROBOTICS
Part 4: Sensors
Robotics and Automation
Copyright © Texas Education Agency, 2013. All rights reserved.
1
So, like, dude,
what’s a sensor?
Copyright © Texas Education Agency, 2013. All rights reserved.
2
A sensor detects
the environment.
Copyright © Texas Education Agency, 2013. All rights reserved.
3
What does
that mean?
Copyright © Texas Education Agency, 2013. All rights reserved.
4
A sensor is like one of our
five (5) senses; it tells you what is
going on in the outside world;
except that sensors send information
to an electronic device, like
a computer.
Copyright © Texas Education Agency, 2013. All rights reserved.
5
Yeah, a sensor can help
a robot move around
without running into
anything.
Copyright © Texas Education Agency, 2013. All rights reserved.
6
Sensors
• A device that measures something (a
detector)
• A transducer that converts one form of
energy into another form of energy
(example: temperature into voltage)
• Produces an output related to what it
measures
Copyright © Texas Education Agency, 2013. All rights reserved.
7
Characteristics of a Sensor
• Is sensitive only to the property you
want to measure and insensitive to any
other property
• Does not influence the measurement
itself
• The output has a mathematical
relationship to the measured property
Copyright © Texas Education Agency, 2013. All rights reserved.
8
Human Senses
• Humans have five senses:
o Sight
o Sound
o Taste
o Touch
o Smell
http://en.wikipedia.org/wiki/File:Structure_of_sensory_system_%284_models%29_E.PNG
• Humans have a brain to analyze and
interpret what they sense.
Copyright © Texas Education Agency, 2013. All rights reserved.
9
Human vs. Mechanical
• Human senses are generally much more
sensitive than sensors we can build.
• There are many, many individual sensors.
o For example, an eye has about 120 million rods for
light detection.
o That much data would be impossible for a current
generation computer to analyze.
• Human senses are generally not precise.
o How hot is it?
o How many pounds of pressure are exerted?
Copyright © Texas Education Agency, 2013. All rights reserved.
10
Human vs. Mechanical (cont’d)
• The number of sensors cannot be
duplicated.
• Human ability to analyze data cannot be
duplicated.
• Human senses work for the brain, and
the output from them cannot (yet) be
connected to a computer.
Copyright © Texas Education Agency, 2013. All rights reserved.
11
Sensor Output
• Sensor output needs to
be in a form that can be
measured. Generally,
this means the output
must be electrical.
• Sensor output needs to be in a form that
can be analyzed.
o Output needs to be a number.
o Computers work with binary numbers.
Copyright © Texas Education Agency, 2013. All rights reserved.
12
Input Voltage is Useful
• The galvanometer is an example where a
voltage creates a force that can be seen
and measured.
• It is easy for voltage to be measured, and
there are a lot of ways of doing so.
• This makes voltage the preferred type of
input to a computer or electronic device.
Copyright © Texas Education Agency, 2013. All rights reserved.
13
Galvanometer
Copyright © Texas Education Agency, 2013. All rights reserved.
14
A Galvanometer
• A galvanometer uses a needle on a dial to
indicate the amount of voltage or current
present.
• Two forces:
o The force of interaction due to a magnetic field
created by and proportional to the input
o The force of a spring deflected by the previous
force
• The needle comes to rest at a position where
the two forces are equal.
Copyright © Texas Education Agency, 2013. All rights reserved.
15
Sensor Outputs
• Some sensors will produce a voltage
output.
• This voltage output can be used directly
by an electronic device.
• Other sensors do not produce a voltage
output.
• The output they produce must be
converted to voltage.
Copyright © Texas Education Agency, 2013. All rights reserved.
16
Temperature Sensors
• One type of temperature sensor called a
thermocouple produces an output voltage
related to the temperature.
• Another type of temperature sensor called
an RTD produces a resistance change
related to the temperature.
• The resistance change can be converted
into a voltage, so the two (2) sensors are
roughly equivalent.
Copyright © Texas Education Agency, 2013. All rights reserved.
17
Computers Need Numbers
• There is generally at least one more
step in the conversion process.
• The process of converting the voltage
value into a binary number.
• Some types of sensors can produce
binary numbers without using voltage.
Copyright © Texas Education Agency, 2013. All rights reserved.
18
Global Positioning System
• A GPS tells you your position.
• Data is sent digitally and received digitally from at
least four (4) satellites.
• Your GPS receiver basically measures time.
• The time it takes for each signal to go from the
satellite to the receiver is a function of the
distance to the satellite.
• The onboard computer can triangulate a position
from those four (4) signals.
• Time is accurate to 10 nanoseconds.
Copyright © Texas Education Agency, 2013. All rights reserved.
19
Sensor Technologies
• Most sensor technologies are not as complex
as GPS.
• The GPS example shows how digital data
(binary numbers) are getting more and more
important and more and more common these
days for sensors.
• There may be multiple conversion processes
needed to make a sensor useful.
• Because of how we use sensor data, in a
computer, there is a link between sensor
technology and computers.
Copyright © Texas Education Agency, 2013. All rights reserved.
20
Computer Programming
• The link between a sensor and a
computer is the software program.
• A sensor is only as useful as a software
program can make it.
o Sensor data must be analyzed.
o Decisions must be made as a result.
• A software program is used to do both.
Copyright © Texas Education Agency, 2013. All rights reserved.
21
Example
• Is the room temperature above 75 degrees
and rising?
Turn on the air conditioner.
• Is the room temperature below 72 degrees
and falling?
Turn off the air conditioner.
• A microcontroller can be, and often is, used
to control an air conditioner.
Copyright © Texas Education Agency, 2013. All rights reserved.
22
Categories of Sensors
There are many different ways to
categorize sensors:
o What they measure
o How they work
o Type of output they produce
Copyright © Texas Education Agency, 2013. All rights reserved.
23
Sensor Measurement
• Temperature
• Sound level
• Position
• Fluid flow
• Pressure
• Electrical current
• Force
• Voltage
• Proximity
Copyright © Texas Education Agency, 2013. All rights reserved.
24
Sensor Process Types
• Chemical: pH, smoke detectors, carbon monoxide,
gas detectors
• Electrical: capacitance, galvanometer, Hall effect,
resistance, voltage, current, metal detector,
piezoelectric
• Mechanical: fluid flow (air and water), bi-metallic
strip, encoder (rotary and linear ), position,
diaphragm
• Radiation: Geiger counter, photoresistor, light
sensitive diode, scintillation counter, particle
detector, bubble chamber, Fabry-Perot
Copyright © Texas Education Agency, 2013. All rights reserved.
25
Sensor Output Types
• Position: galvanometer, bimetallic strip,
bourdon tube, thermometer
• Voltage: thermocouple, microphone,
piezoelectric effect, Hall effect
• Digital signal: MRI, video camera, GPS,
range finder, switch
• Linear or non-linear output
Copyright © Texas Education Agency, 2013. All rights reserved.
26
Robotic Sensors
• Robotic sensors are only as useful as
the ability to use a computer program
to evaluate data and make decisions as
a result.
• Sensors are getting more and more
complicated and so are the computer
programs needed to use them.
Copyright © Texas Education Agency, 2013. All rights reserved.
27
Robotic Sensors (cont’d)
• There is a link between computer
programming and the usefulness of a
sensor.
• Therefore, we will categorize sensors
based on the type of computer
programming needed to make them
work.
Copyright © Texas Education Agency, 2013. All rights reserved.
28
Simple Sensors
• The simplest sensor acts like a switch.
• Produces only two values:
o On
o Off
• These values correspond directly to the
language a computer uses: Binary (1 or 0).
Copyright © Texas Education Agency, 2013. All rights reserved.
29
First Example
• Contact switch (Bumper Switch)
• Normally open switch
• Closes on contact with an object
Input
+5V
Output
0V
Open, value = 0
Input
+5V
Closed, value = 1
Copyright © Texas Education Agency, 2013. All rights reserved.
Output
+5V
30
VS = + 5V
Here is the same
example using a
light sensitive diode.
VO = + 0V
The diode is an open switch, the output is connected to ground.
VO =
Copyright © Texas Education Agency, 2013. All rights reserved.
0V
31
VS = + 5V
Here is the same
example using a
light sensitive diode.
diode
VO = + 5V
The diode is a closed switch, the output is connected to power.
VO =
Copyright © Texas Education Agency, 2013. All rights reserved.
5V
32
Conditions
• The robot car drives straight until it hits
something.
• When it hits something, it must stop.
• We put a push button switch on the
front of the car.
• The way the car program knows when it
hits something is when the switch
closes.
Copyright © Texas Education Agency, 2013. All rights reserved.
33
Data
• The position of the switch represents data;
in this case, binary data (0 or 1).
• We need to “read” the position of the switch
(voltage or no voltage on the input).
• Data needs to be stored in a computer’s
memory to be used. We need a memory
location for the data.
• We need to control the car based on the
data.
Copyright © Texas Education Agency, 2013. All rights reserved.
34
Commands
• Call the switch position data value
“switchdata.”
• It is typical to use 16 bits for the data
size.
• First command: int switchdata
• This is a typical C++ type of command.
Copyright © Texas Education Agency, 2013. All rights reserved.
35
int switchdata
int is a command
that reserves 16 bits
of memory space
for data.
Copyright © Texas Education Agency, 2013. All rights reserved.
36
int switchdata
switchdata is both the name
we give to the switch data
and to the memory location
where the data is stored.
Copyright © Texas Education Agency, 2013. All rights reserved.
37
int switchdata
switchdata is both the name
we give to the switch data
and to the memory location
where the data is stored.
Right now we have no idea
what value is going into
“switchdata” so we set the
initial value manually.
Copyright © Texas Education Agency, 2013. All rights reserved.
38
int switchdata = 0;
Sets the initial value
of switchdata to 0.
Copyright © Texas Education Agency, 2013. All rights reserved.
39
int switchdata = 0;
By setting the value
we created something
called a statement.
Statements in C++
must be terminated
by a semicolon.
Copyright © Texas Education Agency, 2013. All rights reserved.
40
Next Command
• A microcontroller can only read a value
on one of its inputs.
• The voltage output of the switch is
connected to a microcontroller input pin
(with a wire).
o Assume the input pin is pin 7.
o Use the read command for that pin.
switchdata = GetDigitalInput (7);
Copyright © Texas Education Agency, 2013. All rights reserved.
41
switchdata = GetDigitalInput (7);
We now set
the value of
switchdata to
whatever we
read on the
Input.
Copyright © Texas Education Agency, 2013. All rights reserved.
42
switchdata = GetDigitalInput (7);
This is a special command
that reads the value of
the digital input defined
inside the parenthesis.
Copyright © Texas Education Agency, 2013. All rights reserved.
43
switchdata = GetDigitalInput (7);
The value of the digital
input (0 or 1) is placed
into the memory location
called switchdata.
Copyright © Texas Education Agency, 2013. All rights reserved.
44
switchdata = GetDigitalInput (7);
This is also a statement
so it must be terminated
by a semicolon.
Copyright © Texas Education Agency, 2013. All rights reserved.
45
What’s Wrong?
Copyright © Texas Education Agency, 2013. All rights reserved.
46
What’s Wrong?
I don’t think it’s
that simple.
Copyright © Texas Education Agency, 2013. All rights reserved.
47
It’s not. There are a couple
of things wrong with this
example.
Copyright © Texas Education Agency, 2013. All rights reserved.
48
To learn more about how to make sensors
work, we need to learn more about
programming.
Programming is covered in the next lesson
module:
INTRODUCTION TO
ROBOTICS
Part 5: Programming
Copyright © Texas Education Agency, 2013. All rights reserved.
49
Download