Post on 21-Dec-2015
transcript
IR sensitiveIR sensitive - sense heat differences and construct - sense heat differences and construct images,images,
night vision applicationnight vision application
Infra RedInfra Red
sensorssensors
Variations of IR Variations of IR emitter/receiver emitter/receiver
pairspairs
Active Sensors
Used in Lynxmotion, Robix and Lego robots
Modulation / Modulation / Demodulation of Demodulation of
LightLightand Infra-Red and Infra-Red
SensorsSensors
Modulation / Modulation / Demodulation of Demodulation of
LightLightand Infra-Red and Infra-Red
SensorsSensors
Modulation and Modulation and Demodulation of LightDemodulation of Light
Ambient light is a problem because it interferes with the emitted light from a light sensor.
One way to get around this problem is to emit modulated light.
The modulated light rapidly turns the emitter on and off.
Modulated signa much easier and more reliably detected by a demodulator
Demodulator is tuned to the particular frequency of the modulated light.
Modulation and Demodulation of Modulation and Demodulation of LightLight
Not surprisingly, a detector needs to sense several on-flashes in a row in order to detect a signal.
It means, to detect signal frequency. This is important when you write the demodulator
code. The idea of modulated IR light is commonly used;
in household remote controls. Modulated light sensors are generally more
reliable than basic light sensors. They can be used for the same purposes:
detecting the presence of an object measuring the distance to a nearby object (clever
electronics required, see Martin’s textbook)
Infra Red (IR) SensorsInfra Red (IR) SensorsInfra red sensors are a type of light
sensorsThey function in the infra red part of the
frequency spectrum. IR sensors are active sensorsThey consist of:
an emitter a receiver.
IR sensors are used in the same ways as the visible light sensors are: as break-beams, as reflectance sensors.
Infra Red (IR) SensorsInfra Red (IR) Sensors
IR is preferable to visible light in robotics (and other) applications.
This is because it suffers a bit less from ambient interference, because it can be easily modulated, because it is not visible.
Sharp Sharp Infra Infra Red Red
DetectorDetector
Sharp IR DetectorSharp IR Detector The Sharp GP1U52X sensor detects infrared
light that is modulated (i.e., blinking on and off) at 40,000 Hz.
It has an active low digital output: meaning that when it detects the infrared light, its
output is zero volts.
The metal case of the sensor must be wired to circuit ground, as indicated in the diagram.
This makes the metal case act as a Faraday cage, protecting the sensor from electromagnetic noise.
Sharp IR DetectorSharp IR Detector It is a digital sensor because it detects infrared light modulated at
40kHz. Not analog! Inside the tin can, there is a IR detector, amplifier, and a demodulator. The sensor returns a HIGH when there is no 40kHz light, and is LOW
when it sees the 40kHz light.
Sharp IR sensor assemblySharp IR sensor assembly
You can use the IC command ir counts(port) to count the number of successive detected periods of the modulated frequency.
A count larger than 10 indicates a detection.
You may need to play around with what values of the counts are needed for detection.
These sensors can only be used in digital ports 4-7.
Sharp IR DetectorSharp IR Detector
Elimination of the effect Elimination of the effect of the stray IR lightof the stray IR light
There is a lot of infrared light that is ambient in the air. Some components of this light are at 40kHz, and straight
output from the sensor would look very glitchy.
The sun produces a lot of IR light, and in the sun, the sensor output bounces all over the place.
To eliminate the effect of the stray IR light, the IR emitters are modulated at 100 or 125 Hz and the output of the IR Detectors is demodulated to look for these frequencies. (see section A.7 for more information on the IR transmission)
The 40kHz frequency is known as the carrier frequency, and the other frequency is the modulated frequency.
PhototransistorPhototransistor body body and connectorand connector
The “bundle-of-wires" phototransistors are much more predictable. They should be wired with
a resistor of 100k to 300k (we recommend 220k).
They barely respond at all to visible frequencies of light.
They respond particularly well to the LEDs with which they are bundled, as well as to the grey IR LEDs.
Both LEDs are highly directional, and you should be able to get good break-beam results up to 5 or 6 cm apart (2 inches).
This might prove especially useful in ball-ring mechanisms, for example.
Note that both LEDs and phototransistors are just the right size to fit in LEGO axle-holes!
IR Photo IR Photo TransistorTransistor
Reflective Reflective OptosensorsOptosensors
If we use a light bulb in combination with a photocell, we can make a break-beam sensor.
This idea is the underlying principle in reflective optosensors: the sensor consists of an emitter and a detector.
Reflective OptosensorsReflective OptosensorsDepending of the arrangement of those
two relative to each other, we can get two types of sensors: reflectance sensorsreflectance sensors
the emitter and the detector are next to each other, separated by a barrier;
objects are detected when the light is reflected off them and back into the detector
break-beam sensorsbreak-beam sensors the emitter and the detector face each other; objects are detected if they interrupt the beam of
light between the emitter and the detector
IR Reflective OptosensorsIR Reflective Optosensors
•Quantity of light is reported by the sensor
•Depending on the reflectivity of the surface, more or less of the transmitted light is reflected into the detector
• This is an analog sensor - connects to board analog ports
Transmitter LED: only infrared light by filtering out visible light
Light detector (receiver) (photodiode or phototransistor)
Light from emitter LED bounces off of an external object and is reflected into the detector
Break-Beam Break-Beam SensorsSensors
• Any pair of compatible emitter–detector devices may be used:
–1. Incandescent flashlight bulbs and photocells
– 2. Red LEDs and visible-light-sensitive phototransistors
– 3. Infrared emitters and detectors
various commercial break-beam optosensors
Discrete infrared LED
phototransistor
Light-emitting component aimed at a light-detecting component
When opaque object comes between emitter and detector, the beam of light is occluded, and the output of the detector changes
Reflective OptosensorsReflective OptosensorsThe emitter is usually made out of a light-
emitting diode (an LED).The detector is usually a
photodiode/phototransistor. Note that these are not the same
technology as resistive photocells. Resistive photocells are nice and simple, but
their resistive properties make them slow. Photodiodes and photo-transistors are much
faster and therefore the preferred type of technology.
Light Reflectivity. Light Reflectivity.
What can you do with this simple idea of light reflectivity?
Quite a lot of useful things: object presence detection object distance detection surface feature detection (finding/following
markers/tape) wall/boundary tracking rotational shaft encoding (using encoder
wheels w/ ridges or black & white color) bar code decoding
In LegoIn Lego
Light reflectivity depends on the color (and other properties) of a surface.
A light surface will reflect light better than a dark one, and a black surface may not reflect it at all, thus appearing invisible to a light sensor.
Darker objects harder (less reliable) to detect .
In the case of object distance, lighter objects that are farther away will seem closer than darker objects that are not as far away.
Light Reflectivity. Light Reflectivity.
This gives you an idea of how the physical world is partially-observable; even though we have useful sensors,
we do not have complete and completely accurate information.
Light Reflectivity. Light Reflectivity.
Active Light SensingActive Light Sensing
The agent illuminates what is being sensed and uses the reflected light
Can be used for a number of tasks collision avoidance/proximity detection following (mail delivery)
We will discuss line following
Line Detecting and FollowingLine Detecting and Following
Complete Line Following Complete Line Following CircuitCircuit
Passive Light SensingPassive Light Sensing
Light is received from the environment directly
Used to, locate, move towards, or avoid
We will discuss a single cell eye
The Cyclops CircuitThe Cyclops Circuit
Cross connected single eyesSingle Photo-resistor per sideControls a differentially steered vehicle
e.g. The Solenodon IV
Partial CircuitPartial Circuit
What are the applications What are the applications of Reflective of Reflective Optosensors?Optosensors?
• 1. Object detection.1. Object detection.
•Reflectance sensors may be used to measure the presence of an object in the sensor’s field of view.
• In addition to simply detecting the presence of the object, the data from a reflectance sensor may be used to indicate the object’s distance from the sensor.
• Disadvantage:Disadvantage: These reading are dependent on the reflectivity of the object, among other things—a highly reflective object that is farther away may yield a signal as strong as a less reflective object that is closer.
• 2. Surface feature detection.
•Reflective optosensors are great for detecting features painted, taped, or otherwise marked onto the floor.
• Line-following using a reflective sensor is a typical robot activity.
What are the applications What are the applications of Reflective of Reflective Optosensors?Optosensors?
• 3. Wall tracking.
•Related the object detection category, this application treats the wall as a continuous obstacle and uses the reflective sensor to indicate distance from the wall.
• 4. Rotational shaft encoding.
• Using a pie-shaped encoder wheel, the reflectance sensor can measure the rotation of a shaft
• (angular position and velocity).
• 5. Barcode decoding.
•Reflectance sensors can be used to decode information from barcode markers placed in the robot’s environment.
Interfacing Reflective Interfacing Reflective OptosensorsOptosensors
• The emitter LED (LED1), is wired to the Handy Board’s +5v power supply through R1, the current-limiting resistor
– R1’s value can vary 220-47, depending on how much brightness is desired from the emitter LED
Reflectance Sensor Interface Diagram
Two components of the sensor, the emitter and detector, have logically separate circuits, though they are wired to the same connector plug
• Detector Q1, shown as a phototransistor, is wired between ground and the sensor signal line—just like a photocell
Properties of Photocells:
• easy to use - electrically they are resistors,
• their response time is slow compared to the photodiode or phototransistor’s semiconductor junction.
• photocells are suitable for:
• detecting levels of ambient light, or
• acting as break-beam sensors in low frequency applications
• (e.g., detecting when an object is between two fingers of a robot gripper).
• Properties of Photodiodes and Phototransistors:
• where we need a rapid response time:
•shaft encoding,
• more sensitive to small levels of light,
•which allows the illumination source to be a simple LED element.
How do youHow do you choose, choose, Photocells or Photocells or Phototransistors?Phototransistors?
The current, i, flowing through the Q1 phototransistor is indicated by the dashed line.
Interfacing PhototransistorsInterfacing Phototransistors
Light-sensitive current source: the more light reaching the phototransistor, the more current passes through it
• Current creates a voltage drop in the 47K pull-up resistor on HB
• This voltage drop is reflected in a smaller voltage on the Vsens sensor signal line, which has a level that is equal to 5 volts minus the 47K resistor’s voltage drop
•Smaller values than 47K may be required to obtain good performance from the circuit
– If transistor can typically generate currents >= 0.1 mA, then voltage drop across the pull-up resistor will be so high as to reduce Vsens to zero
– Solution is to wire a smaller pull-up resistor with the sensor itself
Quality Technologies QRD1114 IR Quality Technologies QRD1114 IR
OptosensorOptosensor
• LED emitter and detector phototransistor or photodiode are matched.
•This means that peak sensitivity of the detector is at same wavelength of emissions of the emitter
• You should use infrared detector card to test IR light output
Emitter LED connects through 330K resistor to +5v supply (constantly on)
Detector connects to sensor signal line
•Wiring
– Detector transistor pulled high with HB internal 47K resistor
– May have trouble figuring out which element is transistor and which is detector
• Length of leads: longer +, shorter -
Break-Break-Beam Beam
SensorsSensors
5.5.9 Breakbeam Sensors5.5.9 Breakbeam Sensors
Figure 5.9: Reflectance
Sensor
Break-beam SensorsBreak-beam SensorsWe already talked about the idea of break-
beam sensors. In general, any pair of compatible
emitter-detector devices can be used to produce such a sensors: 1. an incandescent flashlight bulb and a
photocell 2. red LEDs and visible-light-sensitive
photo-transistors 3. infra-red IR emitters and detectors
Figure 5.10: Figure 5.10: Breakbeam Breakbeam
Sensor Sensor using using
discrete discrete componentscomponents
..
Breakbeam sensorsBreakbeam sensorsBreakbeam sensors are another form of light
sensors. Instead of looking for reflected light, the
photosensor looks for direct light as shown in Figure 5.10.
The sensor is useful in detecting opaque objects that prevent the light beam from passing through.
This can be useful in detecting block between gripper, or when block passes through a passageway.
The sensor does not need to detect the block very quickly so the phototransistor can be plugged into the analog port.
Figure 5.11: Breakbeam Figure 5.11: Breakbeam AssemblyAssembly
Figure 5.12: Shaft encoding using a LEGO pulley WheelFigure 5.12: Shaft encoding using a LEGO pulley Wheel
Breakbeam sensorsBreakbeam sensors The breakbeam sensors can also be used for
counting holes or slots in a disk as it rotates (see Figure 5.12), allowing distance traveled to be measured.
Since this requires a very fast sampling, the sampling needs to be done at the assembly language level.
We have implemented shaft-encoder routines to do the fast sampling.
But in order to use these routines the sensors should be plugged into the lower two digital ports if the rate at which the holes or slots go by is very high.
Before you use the analog sensors in the digital switch you must make sure that there is a full swing in the analog reading from when the light goes through to when the light is blocked.
• For sensing objects between larger gaps, use discrete emitters and detectors
• Interface to HB the same as for the reflective optosensors
– Emitter LED powered from HB +5v supply through dropping resistor
– Detector phototransistor connected between sensor signal line and ground
– Polarity is not indicated by length of device leads; look for + marking
Motorola MOC70V1 Motorola MOC70V1 Infrared Break-Beam Infrared Break-Beam
OptosensorOptosensor
•Consider many robotic applications for break-beam sensing
– e.g., detecting something between something between fingers of a robotic gripperfingers of a robotic gripper
Ambient light. Ambient light. Another source of noise in light sensors is ambient light. The best thing to do is subtract the ambient light level
out of the sensor reading, in order to detect the actual change in the reflected light, not the ambient light.
How is that done? By taking two (or more, for higher accuracy) readings of the
detector, one with the emitter on, and one with it off, and subtracting the two values from each other.
The result is the ambient light level, which can then be subtracted from future readings.
This process is called sensor calibration. Of course, remember that ambient light levels can
change, so the sensors may need to be calibrated repeatedly.
What kind of Processing we need What kind of Processing we need for Infrared Sensors? for Infrared Sensors?
1. Correct for ambient light
2. Calibrate light levels for dark and light surfaces
3. Process the data to avoid spurious readings
4. Process the data adapting to changing conditions
1. Correcting Reflective Optosensors for 1. Correcting Reflective Optosensors for Ambient LightAmbient Light
• Question:Question: How can a robot tell the difference between:
• a stronger reflection
• an increase in light in the robot’s environment?
• Answer:Answer: switch a reflectance sensor’s emitter light source on and off under software control
– Take two light level readings, one with the emitter on, and one with the emitter off, then subtract away the ambient light levels
Wiring an LED to bit 2 of Port D (Serial Peripheral Interface) Pin
int active_read(int port){int dark, light; /* local variables */dark= analog(port); /* reading with light off */bit_set(0x1009, 0b00000100); /* turn light on */light= analog(port); /* reading with light on */bit_clear(0x1009, 0b00000100); /* turn light off */return dark - light;} Subtract ambient light
from each IR reading
Correcting for Ambient LightCorrecting for Ambient Light
• Need to differentiate between transmitted light and normal “ambient” light
• Can do so by using photosensor to read ambient light levels with transmitter off
•Can either use external photosensor
•Or use packaged photosensor if wired correctly
•Subtract ambient light from each IR reading
•Alternating ambient and IR readings
•Info about HB digital electronics:
– Typical LED draws 5-20 mA
– Typical processor digital output can supply 20-25 mA
– So, a 68HC11 pin can drive 1-5 LEDs
2. Sensor Calibration for dark and light 2. Sensor Calibration for dark and light surfacessurfaces
• Declare and use calibration routine
int LINE_SETPOINT= 100;int FLOOR_SETPOINT= 100;void calibrate() { int new; while (!start_button()) { new= line_sensor(); printf("Line: old=%d new=%d\n",
LINE_SETPOINT, new); msleep(50L); } LINE_SETPOINT= new; /* accept new value */ beep(); while (start_button());
/* debounce button press */ while (!start_button()) { new= line_sensor(); printf("Floor: old=%d new=%d\n",
FLOOR_SETPOINT, new); msleep(50L); } FLOOR_SETPOINT= new; /* accept new value */ beep(); while (start_button());
/* debounce button press */}
Robot is physically positioned over the line and floor and a threshold setpoint is captured
Huge improvement over fixed and hard-coded calibration methodsNOTE DEBOUNCING BUTTON PRESSES
setpoint variables are persistent
Proximity Sensing with Infrared Proximity Sensing with Infrared PairPair
•Proximity sensing:
•reflect IR off nearby object
•detect returned light
•emitter and detector point in same direction
• Modulated light
•By rapidly turning on and off, the source of light can be easily picked up from varying background illumination
Proximity Sensing with Proximity Sensing with Infrared PairInfrared Pair
• Modulated light
•By rapidly turning on and off, the source of light can be easily picked up from varying background illumination
Proximity Sensing with Proximity Sensing with InfraredInfrared
•With modulated light detector, object is either present or absent
•Modulated light is less susceptible to environment variables but non-modulated light magnitude sensing/thresholding works also
•Could try to determine object’s distance as well but, …
Re-Visiting IR CalibrationRe-Visiting IR Calibration
IR is very sensitive to ambient lighting, different color obstacles, varying distances, differing lighting conditions
Combining Light and IR to Combining Light and IR to Infer DistanceInfer Distance
IR = f(color, reflectance, ambient light, distance)
Don’t have a sensor that measures colorDistance is what we wantSo what we do?
1. We condition based on ambient light 2. We hope that all the obstacles are the same
color/reflectance
Closed-loop ControlClosed-loop ControlDrive parallel to wallFeedback from
proximity sensors (e.g. bump, IR, sonar)
Feedback loop, continuous monitoring and correction of motors -- adjusting distance to wall to maintain goal distance
Obstacle avoidance and tracking
Using a Proximity Sensor to Measure Distance to a Wall
Separate Sensor State Separate Sensor State Processing from ControlProcessing from Control
Functions might each make use of other sensors and functions – need to decide how to implement each
Use Proximity Sensor to Select Use Proximity Sensor to Select One of Three StatesOne of Three States
Sensor used to select one of three states
Obstacle Obstacle Avoidance Avoidance
and and Tracking Tracking Using IRUsing IR
Have continuously running task update IR state: Left, right, both, neither
If one obstacle detected then use closed-loop control to
keep it away from robot If two obstacles detected then
Either assume you can’t pass and treat like bump
Or try to pass in-between with closed-loop control
Depends on how you mounted/shielded your sensors, how you set your thresholds, and any ability to differentiate distances
Use of Infrared Ground SensorUse of Infrared Ground Sensor
Concluding on Concluding on Local Proximity Local Proximity Sensing using IRSensing using IR
Infrared LEDsInfrared LEDs cheap, active sensing usually low resolution - normally used for
presence/absence of obstacles rather than ranging
operate over small range
Shaft Shaft EncodingEncoding
Shaft Shaft EncodingEncoding
Our Wheel EncodersOur Wheel EncodersOptical encoder to measure wheel rotation of each drive wheel
Slotted disk attached to wheel or motor shaft
“Break-beam” IR counts number of slots that pass in given time (ports 7,8 )
Enable_encode, disable_encoder, read_encoder (number of on/offs since last reset), reset_encoder
Max 32,767 counts (16 bit)Encoder library must be loaded
Basics of Shaft EncodersBasics of Shaft EncodersA shaft encoder is a device that
measures the position of a shaft.There are two types of shaft encoders. One is incremental shaft encoder which
produces a pulse train of a certain frequency depending on the rotational speed of its shaft.
The other one is the absolute shaft encoder which measures the absolute position of its shaft.
Incremental shaft encoders.Incremental shaft encoders.
64 Segments Photo InterrupterA Shaft Pulse Train
Shaft EncodingShaft Encoding• Use Break-Beam Sensors
• Shaft encoder measures the angular rotation of an axle, reporting position and/or velocity information• Example: speedometer, which reports how fast the wheels are turning; odometer, which keeps track of the number of total rotations
Single-Disk Shaft EncoderA perforated disk is mounted on the shaft and placed between the emitter–detector pair. As the shaft rotates, the holes in the disk chop the light beam. Hardware and software connected to the detector keeps track of these light pulses, thereby monitoring the rotation of the shaft.
Shaft EncodingShaft EncodingShaft encoders measure the angular rotation
of an axle providing position and/or velocity info. A speedometer measures how fast the wheels of a
vehicle are turning, An odometer measures the number of rotations of
the wheels.
In order to detect a complete or partial rotation, we have to somehow mark the turning element.
This is usually done by attaching a round disk to the shaft, and cutting notches into it.
Shaft EncodingShaft EncodingA light emitter and detector are placed on
each side of the disk, so that: as the notch passes between them, the light
passes, and is detected; where there is no notch in the disk, no light
passes.
If there is only one notch in the disk, then a rotation is detected as it happens.
This is not a very good idea, since it allows only a low level of resolution for measuring speed: the smallest unit that can be measured is a full
rotation.
Shaft EncodingShaft Encoding Besides, some rotations might be missed due to noise. Usually, many notches are cut into the disk, and
the light hits impacting the detector are counted. (You can see that it is important to have a fast sensor
here, if the shaft turns very quickly.)
An alternative to cutting notches in the disk is to: paint the disk with black (absorbing, non-reflecting)
and white (highly reflecting) wedges, and
measure the reflectance.
In this case, the emitter and the detector are on the same side of the disk.
Shaft EncodingShaft EncodingIn either case, the output of the sensor is
going to be a wave function of the light intensity.
This can then be processed to produce the speed, by counting the peaks of the waves.
Note that shaft encoding measures both position and rotational velocity, by subtracting the difference in the position
readings after each time interval.
Velocity, on the other hand, tells us how fast a robot is moving, or if it is moving at all.
Shaft EncodingShaft Encoding There are multiple ways to use velocity:
measure the speed of a driven (active) wheel use a passive wheel that is dragged by the robot (measure
forward progress)
We can combine the position and velocity information to do more sophisticated things: move in a straight line rotate by an exact amount
Note, however, that doing such things is quite difficult, because: wheels tend to slip (effector noise/error) and slide and there is usually some slop and backlash in the gearing
mechanism.
Shaft encoders can provide feedback to correct the errors, but having some error is unavoidable.
Quadrature Shaft Quadrature Shaft EncodingEncoding
So far, we've talked about detecting position and velocity, but did not talk about direction of rotation.
Suppose the wheel suddenly changes the direction of rotation; it would be useful for the robot to detect that.
An example of a common system that needs to measure position, velocity, and direction is a computer mouse.
Without a measure of direction, a mouse is pretty useless.
How is direction of rotation measured?
Quadrature Shaft Quadrature Shaft EncodingEncoding
Quadrature shaft encoding is an elaboration of the basic break-beam idea; instead of using only one sensor, two sensors are needed.
The encoders are aligned so that their two data streams coming from the detector are one quarter cycle (90-degrees) out of phase, thus the name "quadrature".
By comparing the output of the two encoders at each time step with the output of the previous time step, we can tell if there is a direction change.
When the two are sampled at each time step, only one of them will change its state (i.e., go from on to off) at a time, because they are out of phase.
Quadrature Shaft Quadrature Shaft EncodingEncoding
Which one does, it determines which direction the shaft is rotating.
Whenever a shaft is moving in one direction, a counter is incremented, and when it turns in the opposite direction, the counter is decremented, thus keeping track of the overall position.
Other uses of quadrature shaft encoding are in: robot arms with complex joints (such as rotary/ball
joints; think of your knee or shoulder), Cartesian robots (and large printers) where an
arm/rack moves back and forth along an axis/gear.
Shaft EncodingShaft Encoding
Data from shaft encoder built from MOV70V1 break-beam sensor and pulley wheel:
The sensor data graph is a nearly ideal square wave. Using the standard HB analog input, which reports a sensor reading between 0 and 255, the sensor’s output varies from a low of about 9 (about 0.18 volts) to a high of about 250 (4.9 volts) with a sharp edge between the transitions.
Other break-beam sensors yield a time graph that looks more like a sine wave.
This assembly uses the Motorola break-beam sensor with the medium pulley wheel as a photo-interrupter. After determining a position of the break-beam sensor that yielded good break and make transitions, the sensor was hot-glued into position along the LEGO beam.
Shaft EncodingShaft EncodingCounting Encoder Clicks
• To make sense of data from a shaft encoder, install a routine that repeatedly checks the sensor value.
– If the encoder wheel turns faster than the routine checks the sensor state, it will start missing transitions and lose track of the shaft’s rotation
– Solution: check midrange point
• Variables for algorithm:
encoder_state - Keeps track of last encoder reading:1 if high (above 128), 0 if low (below 128)
encoder_counter - Keeps running total of encoder “clicks”
Shaft EncodingShaft EncodingDriver Software• Machine language routine loaded into IC’s underlying layer of direct 68HC11 code, with user interface - IC binary (ICB) files installed in interrupt structure of 68HC11
• Monitors shaft encoder values and calculates encoder steps and velocity needs quickly and at regular intervals
• HB’s software libraries include set of routines for supporting shaft encoders for both position-counting and velocity measurement. For each analog input on HB, a pair of shaft encoder routines is provided. For each pair, there is a high-speed version and a low-speed version.
– High speed version checks for transitions on the encoder sensor 1000 Hz
– Low speed version checks encoder at 250 Hz (less of a processing load on the system)
– Both versions calculate the velocity (position difference) measurement at about 16 Hz
• Once loaded into IC, the encoder routines are automatically active; no additional commands are needed to turn them on.
– Each encoder0_counts variable (running total of transitions on encoder sensor) will automatically increment every time it senses a transition on its corresponding encoder sensor
– The encoder0_velocity value (velocity measurement) is continuously updated
Library Drivers to do the CountingLibrary Drivers to do the Counting• Machine language routine loaded into IC’s underlying layer of direct 68HC11 code, with user interface - IC binary (ICB) files installed in interrupt structure of 68HC11
• Monitors shaft encoder values and calculates encoder steps and velocity needs quickly and at regular intervals
• HB’s software libraries include set of routines for supporting shaft encoders for both position-counting and velocity measurement. For each analog input on HB, a pair of shaft encoder routines is provided.
• Once loaded into IC, the encoder routines are automatically active; no additional commands are needed to turn them on.
– Each encoder0_counts variable (running total of transitions on encoder sensor) will automatically increment every time it senses a transition on its corresponding encoder sensor
– The encoder0_velocity value (velocity measurement) is continuously updated
(copyright Prentice Hall 2001)
Programming EncodersProgramming Encoders/* Normal encoders, on ports 7 and
8. Must load encoders.lis to use this, more info in the HB manual. */
void main(void) { enable_encoder(0); /* Turn on encoder on port 7 */ motor(0, 20); while (read_encoder(0) < 130) ; reset_encoder(0); motor(0, -20);
while (read_encoder(0) < 130)
; ao();}
/* Using encoders on analog ports 0 through 5
Must load the relevant file, sendr0.icb in this case.
Consult the readme in the libs directory for info. */
void main(void) { motor(0, 20); while (encoder0_counts < 130) ; encoder0_counts = 0; motor(0, -20); while (encoder0_counts < 130) ; ao(); /* Note that these analog functions
also provide velocity information */}
Shaft EncodingShaft EncodingMeasuring Velocity• Driver routines measure rotational velocity as well as position
– Subtract difference in the position readings after an interval of time has elapsed
• Velocity readings can be useful for a variety of purposes
– Robot that has an un-powered trailer wheel with a shaft encoder can easily tell whether it is moving or not by looking at encoder activity on the trailer wheel. If the robot is moving, the trailer wheel will be dragged along and will have a non-zero velocity. If the robot is stuck, whether or not its main drive wheels are turning, the trailer wheel will be still.
• Velocity information can be combined with position information to perform tasks like causing a robot to drive in the straight line, or rotate a certain number of degrees. These tasks are inherently unreliable because of mechanical factors like slippage of robot wheels on the floor and backlash in geartrains, but to a limited extent they can be performed with appropriate feedback from shaft encoders.
Reflective Optosensors as Shaft Encoders• It’s possible to build shaft encoders by using a reflective optosensor to detect black and white markings on an encoder wheel
• Wheels can be used with any of the reflective optosensor devices, as long as the beam of light they generate is small enough to fit within the black and white pie-shaped markings
Shaft EncodingShaft Encoding
Opto-Electronic Computer Mice• Common desktop mouse uses shaft encoder technology to figure out how the mouse ball is turned
• Two slotted encoder wheels are mounted on shafts that are turned by the ball’s movement
• On either side of each encoder wheel are the infrared emitter and detector pair
• Mice use quadrature shaft encoding, a technique that provides information about which way the shaft is turned (in addition to the total “encoder clicks”)
• IR detector on each shaft actually has two elements, aligned so that as one element is being covered up by the leaf between the slots, the other is being exposed
Shaft EncodingShaft Encoding
64 segment means 64 pulses per one complete revolution of the shaft.
1 revolution = 360o 1 revolution = 64 pulses1 pulse = 5.625o (angular resolution)
Increasing the number of segments, called the pulses per revolution (ppr) increases the angular resolution of the shaft encoder.
angular resolution of the shaft encoderangular resolution of the shaft encoder
An Example DatasheetAn Example Datasheet
Connection to HandyboardConnection to Handyboard
Signal
5VGround
01
Two shaft encoders can be
connected to handyboard!!!
Interactive C FunctionsInteractive C Functions
Load encoders.lis first.void enable_encoder(int encoder)
enables the encoder(0 or 1)void disable_encoder(int encoder)
disables the encoder(0 or 1)void reset_encoder(int encoder)
resets the counter of encoder(0 or 1) to zero
void read_encoder(int encoder)returns the number of pulses counted by the given encoder(0 or 1) since last reset or enable. Maximum number of counts is 32767, after that -32768, -32767…0 will come.
Interactive C FunctionsInteractive C Functions
Some Important RemarksSome Important RemarksUse an encoder which has a Vin =
5V and Vsignal = 5V.Use incremental shaft encoder.To use more than 2 encoders(upto
6), you can use analog ports instead of digital ports.
But you have to use a different encoder library available on the Handyboard web site.
KheperKhepera a
RobotRobot
Anatomy of the Anatomy of the KheperaKhepera
Microprocessor
IR-Sensors
Wheels & DC-Motors
Insights of KheperaInsights of Khepera
Microprocessor IR-Sensors Wheels & DC-Motors
Simplified Braitenberg Simplified Braitenberg AlgorithmAlgorithm
Turn Right
Obstacle onLeft side?
No
Yes
Obstacle onRight side?
Turn Left
Yes
NoMove Forward
No Obstacle onBack?
EndYes
No filter in Darkness
0
200
400
600
800
1000
1200
1 23
45
67
89
111
133
155
177
199
221
243
265
287
309
331
353
n
IR-v
alu
es
No filter in Light
0200400600800
10001200
1
78
15
5
23
2
30
9
38
6
46
3
54
0
61
7
69
4
77
1
84
8
92
5
10
02
n
IR-v
alu
es
Averaging in Light
0200400600800
10001200
1 23
45
67
89
111
133
155
177
199
221
243
265
n
IR v
alu
es
IIR filter in Light
0200400600800
10001200
1 23
45
67
89
111
133
155
177
199
221
243
265
n
IR v
alu
es
ResultsResults
On darkness Slow filter response when approaching
obstacle Even slower when moving away from
obstacleOn light
Acceptable filter response time when approaching obstacle
Acceptable filter response time when moving away from obstacle
Noisy readings greatly reduced
Results (cont.)Results (cont.)
Satisfactory performance of Braitenberg algorithm without filtered readings on darkness
Problems using filters with Braitenberg algorithm Robot slow to react to filtered sensory
readings
ConclusionsConclusions
Fluorescent light noise cause serious effects on Khepera’s performance
Digital filters proved to be useful in reducing noise in sensory readings
Filters performance are greatly affected by levels of ambient light
Future WorksFuture Works
Braitenberg algorithm modified to allows detection of ambient light Activate filters on high levels of ambient light Disable filters on low-light conditions
Develop user-friendly program for testing algorithms and filters
1. Build a shaft encoder using a break-beam optosensor and a perforated disk or LEGO pulley wheel. Verify the raw sensor performance—what values represent the light beam being broken vs. not broken?
2. Choose a suitable midpoint value for determining encoder transitions. Write a program in IC to implement the simple encoder counting algorithm presented in the flowchart. Use IC multi-tasking capability to display the encoder counter variable while the counting routine is running, and experiment with the encoder. Can you determine the performance limit of the algorithm in your implementation, in terms of counts per second? What is a fundamental problem with this implementation method?
3. Load a library shaft encoder routine and experiment with its performance. Capture raw data from the encoder. Based on the graph of raw encoder performance, choose suitable high and low threshold values. Explain your choices.
4. One limitation of current encoder routines, both the IC and library versions, is that they cannot determine which direction the shaft is rotating. Can you think of a different approach for determining the direction of rotation?
5. Implement the trailer wheel idea discussed in the text on your HandyBug. Write a program to make HandyBug drive around and stop, back up, and turn when the trailer wheel’s velocity is 0. Can you think of other applications for knowing the robot’s velocity, other than as a non-zero/zero (i.e., moving/not moving) quantity?
6. Instrument one of HandyBug’s drive wheels with an encoder, and write a program at attempts to maintain constant velocity on the drive wheel by varying the power level delivery to the motor. Experiment with the system by holding HandyBug in the air and applying pressure to the drive wheel. Is the system able to maintain the velocity? What happens if you suddenly remove the pressure?
Shaft Encoder ExercisesShaft Encoder Exercises
SourcesSources A. Ferworn
Saúl J. Vega Daisy A. Ortiz
Advisor: Raúl E. Torres, Ph.D., P.E.
Maja Mataric Ali Emre Turgut Dr. Linda Bushnell, EE1 M234,
bushnell@ee.washington.edu Web Site: http://www.ee.washington.edu/class/462/aut00/ Robotic Explorations: A Hands-on Introduction to
Engineering, Fred Martin, Prentice Hall, 2001.
Creative Uses: IR SensorsCreative Uses: IR Sensors Sharp IR sensors are very accurate and operate well over a large
range of distances proportional to the size of a Lego robot. However, they have almost no spread. This can cause a robot to miss an obstacle because of a narrow
gap. One solution is to make the sensor pan. One could also use a light sensor to detect obstacles indoors.
Inside, there tend to be lights at many angles and locations. Thus, around the edges of most obstacles, a slight shadow will
be cast. A light sensor could detect this shadow and thus the associated
object. Warning: this could be a very fickle design. Touch sensors can have their spread increased with large
bumpers, and can be used for wall following to implement bug2. They are also dirt cheap.
IR SensorsIR Sensors
750 nm to 1,000,000 nm Transmitters (LEDs or thermal)Detectors (photo diodes, photo
transistors)
IR: Three common strategiesIR: Three common strategies
IR RangefindersIR Rangefinders
What sorts of techniques can we use? Time of Flight (TOF) Signal Strength Triangulation
Shadow cast indicates obstacle: one way to navigate with photo resistors.
Example of sharp IR mounted to sweep for a wider field of view.
Creative Uses: IR SensorsCreative Uses: IR Sensors
Intensity Based Infrared Intensity Based Infrared
• Easy to implement (few components)• Works very well in controlled environments• Sensitive to ambient light
time
volt
age
timevo
ltag
e
Increase in ambient light raises DC bias
Modulated Infrared Modulated Infrared
http://www.hvwtechnologies.comhttp://www.digikey.com
• Insensitive to ambient light• Built in modulation decoder (typically 38-40kHz)• Used in most IR remote control units ( good for communications)• Mounted in a metal faraday cage• Cannot detect long on-pulses• Requires modulated IR signal
limiter demodulatorbandpass filteramplifier
comparatorintegrator
600us 600us
Input
Output
Digital Infrared RangingDigital Infrared Ranging
position sensitive device (array of photodiodes)
Optical lenses
Modulated IR beam
• Optics to covert horizontal distance to vertical distance• Insensitive to ambient light and surface type • Minimum range ~ 10cm • Beam width ~ 5deg• Designed to run on 3v -> need to protect input• Uses Shift register to exchange data (clk in = data out)• Moderately reliable for ranging
+5voutputinput
gnd
1k 1k
Polaroid Ultrasonic Polaroid Ultrasonic SensorSensor
Mobile Robot Electric Measuring Tape
Focus for Camerahttp://www.robotprojects.com/sonar/scd.htm
Theory of OperationTheory of Operation Digital Init Chirp
16 high to low -200 to 200 V
Internal Blanking Chirp reaches object
343.2 m/s Temp, pressure
Echoes Shape Material
Returns to Xducer Measure the time
ProblemsProblems Azimuth Uncertainty Specular Reflections Multipass Highly sensitive to temperature and pressure changes Minimum Range
Beam PatternBeam Pattern
Not Gaussian!!
(Naïve) Sensor Model(Naïve) Sensor Model
Problem with Naïve ModelProblem with Naïve Model
Reducing Azimuth UncertaintyReducing Azimuth Uncertainty
Pixel-Based Methods (Most Popular)
Region of Constant DepthArc Transversal Method Focusing Multiple Sensor
Combine info withBayes Rule (Morevac and Elfes)
Certainty Grid Certainty Grid ApproachApproach
Arc Transversal MethodArc Transversal Method
Uniform Distribution on Arc Consider Transversal Intersections Take the Median
Mapping ExampleMapping Example
VendorsVendorsMicromintWirzGleason Research
(Handyboard)Polaroid-oem
Metal DetectorMetal Detector
112kHz LC Oscillator
Oscillator signal coupled via transformer
Diode converts AC signal to DC rippleand applies as bias to T3
When T2 is turned off, T3 is turned on
LED will drop about 2volts
9v Signal to 5v logic9v Signal to 5v logic
+-
LM311 comparator
PIC
+5V
Rpullup
+9V
9v signal
A comparator can be used to convert a two-state signal to digital logicWhen the + voltage is above the voltage on the - pin, the output is highWhen the + voltage is below the - voltage, the output is lowThe LM311 has an open collector (you need to provide pullup resistor)This allows conversion from 9volt logic to 5volt logic
MASLab SensorsMASLab Sensors
January 2002Christopher Batten
AgendaAgenda
Quadrature phase sensorsSensors, in generalThe specific kinds of sensors in 6.186
Quadrature Phase Quadrature Phase EncodersEncoders
We have a precise method of measuring how much our wheels rotate
How can we use this for navigation?Pitfalls?
Slippage Inaccurate characterization
OdometryOdometry
Use odometry to find out how far each wheel has moved in some (short) time interval.
Assume that robot was turning at a constant rate during this interval.
x
y
(xk,yk)
θk
Odometry – the modelOdometry – the model
About how far did the robot actually go? Dk=(dL+dR)/2
The angle of the sector? αk=(dR-dL)/B
xk+1=xk+Dkcos(θk+ αk/2)
yk+1=yk+Dksin(θk+ αk/2)
θk+1= θk+ αk
Try this at home!x
y
dL
dR
θk
θk+1
(xk,yk)
(xk+1,yk+1)
αk
B is the “baseline”- the distance between the two wheels.
Odometry- Coping with ErrorOdometry- Coping with Error
Odometry, by itself, will get worse and worse…
Try to reconcile/confirm results with other navigation methods: Range to objects Angles to objects, targets, waypoints,
beacons Any other ideas?
6.186 - Sensors6.186 - Sensors
What is a sensor?Common types:
Infra-Red (IR) Ultrasound Physical contact
Other types: Magnetic field detectors (Reed switches) Be creative!
Infrared BeaconsInfrared Beacons
Custom hardware specifically designed for MASLab IR Beacon Transmitters broadcast
data packets containing a unique ID number (waypoints, targets, navigation beacons)
IR Beacon Receivers are directional and look for ID broadcasts to identify the direction of a specific beacon (one per team)
Infrared Beacons - Infrared Beacons - TransmittersTransmitters
Which IDs correspond to waypoints, targets, and navigation beacons is predetermined and will not change
The location of any beacon (in relative or absolute coordinates) is not known ahead of time
Transmitters broadcast their ID in eight different directions
IR Beacons will be either 10” or 8” and the walls will all be 9”
Infrared Beacons - ReceiversInfrared Beacons - Receivers
Receivers can receive packets in two opposite directions – combined with 180° servos this provides 360° listening
Beacons do not (directly) provide any information concerning the distance to the beacon (use triangulation or range sensors)
Range is approximately 15-20 feet and should be able to receive approximately 5 packets per second.
Each team is responsible for making their own baffles.
Receiver w/o Baffle
Receiver w/ Baffle
Infrared Range DetectorsInfrared Range Detectors
Sharp GP2D12 IR range detectors Two per team (more upon request)
Sensor includes: Infrared light emitting diode (IR LED) Position sensing device (PSD)
To detect an object: IR pulse is emitted by the IR LED Pulse hopefully reflects off object
and returns to the PSD PSD measures the angle at which
the pulse returns
Position Sensing Device Uses small lens to focus reflected
pulse onto a linear CCD array
LEDPSD
LEDPSD
Infrared Range DetectorsInfrared Range Detectors
0
0.5
1
1.5
2
2.5
3
Distance to reflected object (in)
Ana
log
Out
put V
olta
ge (V
)
Theoretical Range: 4in (10cm) to 31in (80cm)
Actual Range: ~4in (10cm) to ~ 18in (45cm)
Infrared Range DetectorsInfrared Range Detectors
Detecting Targets Placed target in various positions
in front of a standard MASLab wall Relatively narrow “field-of-view”
Noise Output voltage follows normal-like
distribution with constant std dev User-level averaging may be
useful
Sampling Sensor refreshes approx. every
32ms Can reasonably acquire 20
samples per second
0.45
0.45
0.69
0.45
0.45
0.45
0.45
1.05
0.45
0.45
0.45
0.44
2.40
0.44
0.45
0.5 ft
Infrared Range DetectorsInfrared Range Detectors
Uses Short range obstacle mapping - Mount sensor
on servo and collect range data for various angles Bump sensors - Threshold output voltage, Use
multiple sensors at appropriate angles to cover more area
Target detection - Arrange multiple sensors to detect shape of waypoints and targets
Final practical concerns Place a 10-20uF capacitor between Vcc & GND Position IR sensors to avoid dealing with < 4in
readings
Autonomous robotics based on simplesensor inputs.
Abstract A “robot” is explained as “a device that performs functions normally ascribed to humans” - Webster.
“Autonomous” means that the robot can work totally independently of itself, once it has been programmed, and it should be able to function without interaction from any human influence. Many robots are used nowadays to work in conditions where it is inaccessible for humans to work and therefore need to be autonomous.
The aim of this project is to program a robot (shown left) using PIC (peripheral interface controller) chips, so that it will utilise its infra red sensors and run its stepper motors to follow a boundary wall within an enclosed environment.
Stuart Dodds
Further WorkNow that the robot works properly and has been thoroughly tested using the IR sensors, the next stage of development is to implement a set of line following and ultra sonic sensors.
This involves adding two more PIC chips to the circuit board, then to program them so they can read and process the information from these completely different sensor types.
Once all of these have been fully implemented and tested I shall run a comparison between all three of them.
Starting Point
EnvironmentThis diagram is a depiction of an environment that has been built to test the robot with a selection of acute, obtuse and reflex angles.
As shown the robot follows the same sequence as it travels round the environment. When it reaches a wall the robot will stop then start to rotate until non of the sensors are active. Then it will move forward for a designated amount of time and rotate right and move forward again to look for the wall.
Any Sensor Active
DataSelector
PIC 16f84
B1
B4B2B3
B0A0
Stepper Controller
Stepper Motors
MultiplexerS0 S1 S2 S3Sensors
13
SensorData
Direction
Direction
Communication lines
Pulse
Pulse
PIC 16f84IR Sensor Controller
B2B5
B1A3A2
A0A1
B0
The devices that run all the computations of the robot are two PIC chips. One chip receives information from the IR sensors then executes an algorithm on this data. It then sends instructions to the other chip which controls the stepper motors.
Sensor Range
ON
OFF
Boundary
SensorsON
OFF
OFF
Infra-Red SensorsThere are 13 Infra Red (or IR) sensors attached to the front half of the Robot that are used to detect the environment boundary. These sensors are light sensitive and output a signal when they become active. The
sensor range is approximately 15mm which gives the robot enough time to read the information, decide on what to do and stop before it hits the boundary.
Sensor Range
ON
OFF
Boundary
SensorsON
OFF
OFF
Infra-Red SensorsThere are 13 Infra Red (or IR) sensors attached to the front half of the Robot that are used to detect the environment boundary. These sensors are light sensitive and output a signal when they become active.
The sensor range is approximately 15mm which gives the robot enough time to read the information, decide on what to do and stop before it hits the boundary.
Starting Point
EnvironmentThis diagram is a depiction of an environment that has been built to test the robot with a selection of acute, obtuse and reflex angles.
As shown the robot follows the same sequence as it travels round the environment. When it reaches a wall the robot will stop then start to rotate until non of the sensors are active. Then it will move forward for a designated amount of time and rotate right and move forward again to look for the wall.
Any Sensor Active
DataSelector
PIC 16f84
B1
B4
B2
B3
B0
A0
Stepper Controller
Stepper Motors
Multiplexer
S0 S1 S2 S3
Sensors
13
SensorData
Direction
Direction
Communication lines
Pulse
Pulse
PIC 16f84
IR Sensor Controller
B2
B5
B1
A3
A2
A0
A1
B0
The devices that run all the computations of the robot are two PIC chips. One chip receives information from the IR sensors then executes an algorithm on this data. It then sends instructions to the other chip which controls the stepper motors.
The Robot - KheperaThe Robot - Khepera
To make gas sensor move freely indoor. Khepera basic module and its General I/O extension module will be used in our experiment.
It features:
- a diameter size of 5cm
- 2 independent DC motors with encoders
- 8 infra-red sensors
- An onboard 68331 microcontroller
- An onboard battery
- A modular design with extension modulesKhepera Basic module
General I/O extension module General I/O extension module
It features:
- Digital inputs and outputs
- Power outputs
- Analog inputs with adjustable gain
- Pass-through K-bus to other turrets
The “general I/O” is a turret that can be plugged on the basic configuration making simple custom electronic extensions possible.
General I/O Turret
SENSORSENSOR
The Sharp GP2D02 IR Distance Measuring Sensor
Quick OverviewQuick Overview
Sensors are utilized for many types of detection schemes.
Such as: light intensity, temperature, etc…
For our purpose: Distance
ExamplesExamplesTactile Bumpers (simple sensor)
designed to form a contact closure when pressure is applied to the bumper
other actuators can be used to trigger control or decisions concerning course of action.
Optical Proximity Sensors (photoelectric sensors) Three groups
• Opposed: electric eye; emitter/detector beam interruption
• Retro-reflective: uses an object to reflect from emitter to the detector
• Diffuse: uses the target object to return the energy from the emitter to the detector
GP2D02 SENSORGP2D02 SENSOR Measures distance in
range from 20 to 80cm. Designed to interface to
small micro-controllers. It’s relatively insensitive to
the color and texture of the object at which it is pointed.
Low current consumption at stand-by mode (Approximately 3 A). Actual Sensor Size
Distance Measurement by Distance Measurement by TriangulationTriangulation
IR LED Transmits a bundled beam to the object plane.
Reflected beam is receive by the photo detector(PSD).
The angle of the received beam depends on distance of the object plane. Two Different Object Planes
Structure of Photo DiodeStructure of Photo Diode
N-conductive substrate layer is an isolation layer
P-conductive layer is embedded in isolation layer from IR irradiated
Contact of the p-layer is made on left and right side
Structure of a position sensitive photo diode(PSD)
How PSD Measures Distance?How PSD Measures Distance?
Spot irradiation in the center of the p-layer, both currents I1, I2 will have same value.
Spot irradiation goes to the right, the I1 will decrease and I2 will increase by the same amount.
The difference between the I1 and I2 will give the location of a spot irradiation on PSD.
PSD ContinuedPSD Continued Diodes in the Op-Amp’s
feedback give a logarithmic behavior to the I-to-V conversion circuit.
Collector current, Ic, in each Op-amp is identical to the I1 and I2.
Third Op-Amp processes the difference of the two output voltages from previous Op-Amps.
Vo =VT. ln(I1/I2) Circuit for position sensitive
Current-to-voltage conversion
Distance ChartDistance Chart
Distance vs. irRange Value
0
50
100
150
200
250
300
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Distance (inches)irR
ange
Valu
e (in
t)
Timing Timing When interfacing with any
type of hardware, timing is an issue.
Vin and Vout are control measurements.
Vin drops to low for minimum 70ms.
IR LED transmits 16 pulses towards the object.
Mean value of 16 measurements reduces possible errors.
Timing Diagram for Measurement and
data handling
ConfigurationConfigurationSensor has four pins
for electrical contact.
Pin 2 (IN) from the sensor connects to IR OUT.
Pin 4 (Signal) from the sensor connects to IR IN.
Pin 1 and 3 are connected to ground and +5V, respectively.
SW1 and SW2 refer to bumper switches.
Handy Board Connection
Example of Control ProgramExample of Control Programint distance = 1; /* Init and set the variable distance to 1 */ void range(){ while(1){ sleep(.30); /* Wait .3 seconds, without updating irRange */ pulse(1); /* Update irRange to new detected distance */ distance = irRange; /* set variable distance equal to irRange */} }
ContinueContinuevoid escape(){ while(TRUE)
{ if(distance >= 150) /*If IR sensor detects object within a close proximity take evasive action*/
{ escape_output_flag = TRUE;printf("STATUS = IR SENSE \n");sleep(2.0);
printf("\n"); escape_output= -30; escape_output1= -30;
sleep(6.0); escape_output= -60; escape_output1= 115; sleep(10.0); escape_output= 30; escape_output1= 30; sleep(2.0); escape_output= 30;
}
escape_output_flag = FALSE;
}}
BREAK TIMEBREAK TIME
Any Questions So far?
OK! LET’S MOVE ON TO THE
LAB!
Lab ExerciseLab ExerciseLab Objective: Load pulse.icb , which is a compiled assembly object
file. Pulse.icb enables 2 interactive C functions pulse() and
irRange
Every time you want the IR sensor to obtain a position, call the pulse subroutine, the position integer is updated in the variable irRange.
ContinueContinueExercise: Write a behavioral program, using your bumper
switches and the new IR sensor to avoid obstructions.
Upon pushing the START button, the robot moves forward and stops after 3 minutes or the STOP button is pushed.
After IR detector detects an obstruction: Backup a quarter of the length of your robot using the
IC time commands, storing any constants set as persistent global variables for use in later programming (see page 12 of the Handy Board manual).
Turn 45 degrees in either direction and continue forward.
IR CommunicationIR Communication Modulated infra red can be used as a serial line for transmitting
messages.
This is is fact how IR modems work.
Two basic methods exist: bit frames (sampled in the middle of each bit; assumes all bits take the
same amount of time to transmit)
bit intervals (more common in commercial use; sampled at the falling edge, duration of interval between sampling determines whether it's a 0 or 1)
Notes: you are strongly encouraged to pay careful attention to the exercises and
problems given in your assigned readings.
Projects, exams, homeworks and reports will use some of those, so it is in your interest to think about the answers to their questions, and work some of them out as practice.
Also the additional recitations (Fridays) problems may appear on the exams.