Micromouse_Lecture_2

advertisement
MICROMOUSE LECTURE #2
SENSORS, MINI PROJECT #2
11/6/2014
WHAT IS A SENSOR?
• Converts outside parameters to voltage signals
Reading
Voltage (V)
7
6
5
4
3
2
1
0
0
5
10
Distance (cm)
15
20
SENSORS IN A MICROMOUSE
Encoders
Gryoscope
Infrared
GRYOSCOPE
• Outputs angular velocity
Mouse turns
Gryo outputs angular
velocity
Code integrates angular
velocity
Determine what mouse
should do
HOW TO CHOOSE A GRYO
• Range
• Need at least +/- 1000 degrees/second
• Can be analog or digital
• Only need to measure 1 axis
INFRARED SENSORS
Emitter emits light
Light bounces off
wall
Receiver measures
reflected light
Determine wall
presence
• Infrared LEDs emit light
in wavelengths from
870nm to 950nm
• Receivers
(phototransistors)
sensitive to IR light
HOW TO CHOOSE AN IR RECEIVER/EMITTER
Emission Angle
Power Density
LED EMITTER
•
Make sure to choose a narrow
emission angle
•
•
•
Maximize power efficiency
Maximize signal amplitude

Power Density
•
•
Measures solid angle
Often measured in mW/sr
(miliwatt/steradians)

LED RECEIVER
•
•
Make sure to match the
receiver with emitter
wavelength
Make sure to choose small
angles=high directivity
•
•
Note that max sensitivity at 940nm
Reduces interference
Emitter/receiver pairs
generally sold together
Note high directivity
CALIBRATION
• Mostly trial and error
• Vary distances and measure voltage with MCU
• IR calibration is non-linear
Distance vs. Voltage
0.02
0.018
0.016
Voltage
0.014
0.012
0.01
Series1
0.008
0.006
0.004
0.002
0
0
1
2
3
4
Distance
5
6
7
THE SENSORS YOU WILL BE USING
• IR Emitter: an IR Light Emitting Diode
• IR Receiver: An NPN phototransistor
• Amplifies current going into the Base
and sends it out the Emitter
• An overly-simplified analogy:
think of it as a dimmer switch
IR SENSOR SCHEMATIC
IR SENSOR SCHEMATIC
• Emitter: you can drive the LED directly from the MCU
• Make sure you use a series resistor so you don’t burn out the LED!
• Orientation matters! Anode goes to power, cathode goes
towards ground
• Receiver: need to use a pull down resistor at the Emitter
• BJTs work with current, but MCU reads voltage.
• Resister allows current to pass and have a readable voltage
AMBIENT LIGHT
• Ambient light will definitely confuse your mouse
• Might seem like there is a wall when there isn’t
• How to deal with softer ambient light:
•
•
•
•
Turn IR emitter off and read from receiver
Turn IR emitter on and read from receiver
Subtract the first reading from the second
Won’t work if light is too bright and saturates receiver
IR SENSORS SAMPLE PROGRAM
JEREMY HAUGEN
GUEST LECTURE ON SENSORS
Download