sensors material taken from robotics with the boe-bot

37
Sensors Material taken from Robotics with the Boe-Bot

Upload: oscar-hoover

Post on 23-Dec-2015

236 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Sensors Material taken from Robotics with the Boe-Bot

Sensors

Material taken from Robotics with the Boe-Bot

Page 2: Sensors Material taken from Robotics with the Boe-Bot

Where Are We Going?

Sumo-Bot competitions

Page 3: Sensors Material taken from Robotics with the Boe-Bot

Devices that Contain Sensors

The boebot uses sensors to interact with its environment.

There are a variety of sensors used for a variety of purposes: Pressure, rotation, temperature, smoke, tilt, vibration, light, proximity and so on.

Page 4: Sensors Material taken from Robotics with the Boe-Bot

Ultrasonic Proximity Sensor

PING Ultrasonic Range Finder

•PING ultrasonic distance sensor provides precise distance measurements from about 2 cm (0.8 inches) to 3 meters (3.3 yards).

•It works by transmitting an ultrasonic burst and providing an output pulse that corresponds to the time required for the burst echo to return to the sensor.

•By measuring the echo pulse width the distance to target can easily be calculated.

Page 5: Sensors Material taken from Robotics with the Boe-Bot

Simple to Connect

Page 6: Sensors Material taken from Robotics with the Boe-Bot

Theory of Operation

The PING sensor emits a short ultrasonic burst and then "listens" for the echo.

Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst.

This burst travels through the air at about 1130 feet per second, hits an object and then bounces back to the sensor.

The PING sensor provides an output pulse to the host that will terminate when the echo is detected, hence the width of this pulse corresponds to the distance to the target.

Page 7: Sensors Material taken from Robotics with the Boe-Bot

Limited Detection Range

Page 8: Sensors Material taken from Robotics with the Boe-Bot

Basic Program' -----[ I/O Definitions ]-------------------------------------------------Ping PIN 15

' -----[ Constants ]-------------------------------------------------------Trigger CON 5 ' trigger pulse = 10 uSScale CON $200 ' raw x 2.00 = uSRawToIn CON 889 ' 1 / 73.746 (with **)RawToCm CON 2257 ' 1 / 29.034 (with **)IsHigh CON 1 ' for PULSOUTIsLow CON 0

' -----[ Variables ]-------------------------------------------------------rawDist VAR Word ' raw measurementinches VAR Wordcm VAR Word

' -----[ Initialization ]--------------------------------------------------Reset:DEBUG CLS,"Parallax PING))) Sonar", CR, ' setup report screen"======================", CR, CR,"Time (uS)..... ", CR,"Inches........ ", CR,"Centimeters... "

Page 9: Sensors Material taken from Robotics with the Boe-Bot

Basic Program' -----[ Program Code ]----------------------------------------------------Main:DO GOSUB Get_Sonar ' get sensor value inches = rawDist ** RawToIn ' convert to inches cm = rawDist ** RawToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, ' update report screen DEC rawDist, CLREOL, CRSRXY, 15, 4, DEC inches, CLREOL, CRSRXY, 15, 5, DEC cm, CLREOL PAUSE 100LOOPEND

Get_Sonar: Ping = IsLow ' make trigger 0-1-0 PULSOUT Ping, Trigger ' activate sensor PULSIN Ping, IsHigh, rawDist ' measure echo pulse rawDist = rawDist */ Scale ' convert to uS rawDist = rawDist / 2 ' remove return tripRETURN

Page 10: Sensors Material taken from Robotics with the Boe-Bot

Object Detection Using IR

Page 11: Sensors Material taken from Robotics with the Boe-Bot

The IR Detector

The IR detector is only looking for infrared that’s flashing on and off 38,500 times per second. It has built-in optical filters that allow very little

light except the 980 nm infrared. It also has an electronic filter that only allows

signals around 38.5 kHz to pass through.

This prevents IR interference from common sources such as sunlight and indoor lighting.

Page 12: Sensors Material taken from Robotics with the Boe-Bot

Schematics

Page 13: Sensors Material taken from Robotics with the Boe-Bot

Detecting IR

The key to making each IR LED/detector pair work is to send 1 ms of 38.5 kHz FREQOUT harmonic, and then, immediately store the IR detector’s output in a variable.

FREQOUT 8, 1, 38500irDetectLeft = IN9

The IR detector’s output state when it sees no IR signal is high. When the IR detector sees the 38500 Hz harmonic reflected by an object, its output is low.

The IR detector’s output only stays low for a fraction of a millisecond after the FREQOUT command is done sending the harmonic, so it’s essential to store the IR detector’s output in a variable immediately after sending the FREQOUT command.

Page 14: Sensors Material taken from Robotics with the Boe-Bot

Simple Display Program

Page 15: Sensors Material taken from Robotics with the Boe-Bot

IR Detection Range

Less series resistance will make an LED glow more brightly.

Brighter IR LEDs can make it possible to detect objects that are further away.

Page 16: Sensors Material taken from Robotics with the Boe-Bot

OBJECT DETECTION AND AVOIDANCE

Page 17: Sensors Material taken from Robotics with the Boe-Bot

OBJECT DETECTION AND AVOIDANCE

Page 18: Sensors Material taken from Robotics with the Boe-Bot

Light Sensors

Light sensors are also used in a variety of applications: Automatic street

lights Camera flash and

exposure controls Security alarms

Page 19: Sensors Material taken from Robotics with the Boe-Bot

Introducing the Photoresistor While there are a variety of light sensors,

a very popular one is the photoresistor in that it is easy to use and inexpensive.

As the name implies, it is a resistor that reacts to light. The active ingredient Cadmium Sulfide (CdS) allows electrons to flow more easily when light energy hits it, thus lowering it resistance (opposition to current flow).

The brighter the light the lower the resistance.

Page 20: Sensors Material taken from Robotics with the Boe-Bot

Why? A photoresistor is made of a high

resistance semiconductor. The photons of high frequency light are

absorbed by the semiconductor giving bound electrons enough energy to jump into the conduction band. The resulting free electrons (and their hole partners) conduct electricity thereby lowering resistance.

Page 21: Sensors Material taken from Robotics with the Boe-Bot

Basic Circuit

As the photoresistor’s resistance changes with light exposure, so does the voltage at Vo. As R gets larger, Vo gets smaller, and as R gets smaller, Vo gets larger.

Vo is what the BASIC Stamp I/O pin is detecting when it is functioning as an input.

If this circuit is connected to IN6, when the voltage at Vo is above 1.4 V, IN6 will store a 1. If Vo falls below 1.4 V, IN6 will store a 0.

V0

R

Page 22: Sensors Material taken from Robotics with the Boe-Bot

A Better Idea: Measuring Using Time

The photoresistor can also be used with the BASIC Stamp in an RC circuit (Resistor-Capacitor circuit) to obtain a value in relation to the amount of resistance, or, in this case, the amount of light hitting the sensor.

In a RC-network, the capacitor is charged and discharged at different rates determined by the resistor and the capacitor sizes.

Page 23: Sensors Material taken from Robotics with the Boe-Bot

Introducing the Capacitor The capacitor is a device which can store

an electron charge. Its size is expressed typically in microfarads (F) or millionths of Farads.

Certain types of capacitors are polarity sensitive, that is, they can only be connected in one direction.

Connecting a polarity sensitive capacitor backwards can cause the device to explode.•Wear safety glasses.•Ensure proper polarity when connecting.

Page 24: Sensors Material taken from Robotics with the Boe-Bot
Page 25: Sensors Material taken from Robotics with the Boe-Bot

Polled RC Time

In the Polled RC Time circuit the following occurs:

Button is pressed charging the capacitor.

The button is released, the BASIC Stamp begins timing and the capacitor begins to discharge.

5V

Page 26: Sensors Material taken from Robotics with the Boe-Bot

Polled RC Time (continued)o The BASIC Stamp continues timing until input

P7 changes to a low (drops below 1.4V).

o Time is displayed in tenths of seconds.

V => 1.4VLogic 1

V < 1.4VLogic 0

Page 27: Sensors Material taken from Robotics with the Boe-Bot

Polled RC Time (continued)

The time to discharge the capacitor is in proportion to the size of the resistor and capacitor network (RC).

The larger the capacitance (C), the greater the charge it can hold, increasing time.

The larger the resistance (R), the slower the capacitor will discharge, increasing time.

Page 28: Sensors Material taken from Robotics with the Boe-Bot

Reading RC-Time with BASIC Stamp

The BASIC Stamp has an instruction to perform much of the timing operation automatically:RCTIME Pin, State, VariableWhere: Pin is the pin the RC network is connected.State is the initial state when timing

begins.Variable is the memory location to store

the results. Just like PULSOUT the time is the number of 2uS increments.

Page 29: Sensors Material taken from Robotics with the Boe-Bot

Build & Test

The RC Time circuits is configured so that the capacitor is charged by the output (P2 in this case) and the time to discharge though the resistor is measured.

In this case, as light level changes, discharge time will change.

Page 30: Sensors Material taken from Robotics with the Boe-Bot

What happens to the value of time as the light level changes? When is it lowest? Highest?

Page 31: Sensors Material taken from Robotics with the Boe-Bot

Using A Sample Plot This image shows a plot of the light level.

Note how the value increases from left to right then drops again suddenly. Why?

Page 32: Sensors Material taken from Robotics with the Boe-Bot

QTI Line Sensor

Page 33: Sensors Material taken from Robotics with the Boe-Bot

How it Works

The Parallax QTI uses a QRD1114 infrared (IR) reflective sensor to determine the reflectivity of the surface below it.

When the Bot is over the black playing field, the reflectivity is very low

When the QTI is over the white border, the reflectivity is very high and will cause a different reading from the sensor.

Page 34: Sensors Material taken from Robotics with the Boe-Bot

It’s operation is similar to the RC circuit

The QRD1114 is a reflective object sensor. There’s an infrared diode behind its clear window and an infrared transistor behind its black window.

When the infrared emitted by the diode reflects off a surface and returns to the black window, it strikes the infrared transistor’s base, causing it to conduct current.

The more infrared incident on the transistor’s base, the more current it conducts.

Page 35: Sensors Material taken from Robotics with the Boe-Bot

The basic connection

Time VAR wordDO HIGH 3 RCTIME 3, 1, time DEBUG CLS, ? Time PAUSE 100LOOP

Page 36: Sensors Material taken from Robotics with the Boe-Bot

A digital line sensor

W is connected to Vdd B is connected to Vss R is connected to an input pin The R’s voltage will drop below 1.4 V when the IR transistor

sees infrared reflected from the IR LED. When the IR LED’s signal is mostly absorbed by a black

surface, the voltage at R goes above 1.4 V. The BASIC Stamp interprets any voltage above 1.4 V as 1 and

any voltage below 1.4 V as 0.

Add a 10k Ohm resister as shown

Page 37: Sensors Material taken from Robotics with the Boe-Bot

Mount the QTI sensor close to the ground