MICROMOUSE LECTURE #2 SENSORS, MINI PROJECT #2 11/6/2014.

Post on 16-Dec-2015

227 views 5 download

Tags:

Transcript of MICROMOUSE LECTURE #2 SENSORS, MINI PROJECT #2 11/6/2014.

MICROMOUSE LECTURE #2SENSORS, MINI PROJECT #2

11/6/2014

WHAT IS A SENSOR?

• Converts outside parameters to voltage signals

0 2 4 6 8 10 12 14 160

1

2

3

4

5

6

7

Reading

Distance (cm)

Vo

ltag

e (

V)

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

• Infrared LEDs emit light in wavelengths from 870nm to 950nm

• Receivers (phototransistors) sensitive to IR light

Emitter emits light

Light bounces off wall

Receiver measures reflected light

Determine wall presence

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

• Reduces interference

• Emitter/receiver pairs generally sold together

Note that max sensitivity at 940nm

Note high directivity

CALIBRATION• Mostly trial and error

• Vary distances and measure voltage with MCU

• IR calibration is non-linear

0 1 2 3 4 5 6 70

0.002

0.004

0.006

0.008

0.01

0.012

0.014

0.016

0.018

0.02

Distance vs. Voltage

Series1

Distance

Volt

age

THE SENSORS YOU WILL BE USING

• IR Emitter: an IR Light Emitting Diode

• IR Receiver: An NPN phototransistor

• Amplifies current going into the Baseand 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 HAUGENGUEST LECTURE ON SENSORS