|
|
|
|
||||||||||||||||||||||||
|
This section shows how to construct a simple, yet very effective IR object detection circuit to help Micro-Bot navigate in his environment, and work his way around obstacles. Due to the intense amount of IR energy present in sunlight, infrared is best suited for indoor applications. Infrared will still work outdoors, but you'll find you get very limited range due to decreased sensitivity of the IR detector when used in sunlight. For operation outdoors see the Sonar experiments page.
As shown above in the illustration, an object in the path of the IR beam will reflect the IR energy back onto the face of the infrared detector module. We simply turn on the PWM carrier, take the LED cathode low, and sample the output of the IR detector. A logic 0 indicates the IR energy is striking the detector, and an object is in our path. A logic 1 on the detectors output indicates there is no object present to reflect IR energy back onto the face of the detector. Simple enough..! |
||||||||||||||||||||||||||
|
Parts List:
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Place two pieces of heat shrink over the both of the infrared LEDs as shown below in Figure #1a on the left LED, and wire both infrared LEDs to PortB as shown above in figure #1. The heat shrink prevents IR energy from exiting the rear by covering the LED leads, and also keeps IR energy from spreading sideways. Since we'll be detecting the IR beams being reflected from objects, we want to concentrate the infrared energy in a forward direction. Note: Be careful not to overheat the LED during the process. Use a candle or lighter to slowly apply heat to the heat shrink until it closes around the LED leads and lens as shown below on the left LED.
Port Pins Used & Configuration:
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Place the infrared detector in the center area of the bread board or solder it to the center prototyping solder pads similar to this photo HERE. Wire in the TSOP1740 infrared photo detector circuit shown in Figure #2. Note: The Micro-Bot parts kit includes two of the TSOP1740 IR detector modules. These detector modules will work at baud rates up to 2400 bps, and provide better noise rejection than most off-the-shelf, and less expensive IR detectors. This routine is very simple. First we jump to two sub routines in the hardware.inc file named Check_Right & Check_Left to check for obstacles on both the left and right sides. On return from these sub routines we check the values returned in Left_IR and Right_IR bits. Yes & No have been defined in the hardware.inc file with constants. No = 1 & Yes = 0. A return value of 0 = Yes, and indicates there was an obstacle detected. A return value of 1 = No, and indicates there was no obstacle detected. These bit values are then used to initiate right or left turns. Notice that we call the Check_Left and Check_Right sub routines from within each turn routine. Checking for obstacles during the turn allows us to continue turning away from the obstacle until it's no longer in our path. |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
Note: To change the time Micro-Bot
stays in a left or right turn, increase or decrease the loop values in each For Next loop
in the Right & Left turn routines. You can adjust the value of "X" in
the Important Note: You'll notice in all of the code examples & experiments that we use the INCLUDE directive to include most of the initial hardware setup, port assignments, and variable declarations. This allows you to setup variables and port assignments in a single file, then simply include it to remove the large number of program code lines displayed on-screen while you're working on your code. This makes things much easier to read & manage as your code grows. You can view the include file HERE. If you need to make changes to the I/O-pins, default servo speeds, etc, just modify the HARDWARE.INC file. One option is to save it with another name, and simply include your modified version in the beginning of your code instead. Example: Assume you have made changes to the
original hardware.inc file, and saved it with the name myhardware.inc. Just
include it like this; |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Copyright © 2007
Reynolds Electronics |
||||||||||||||||||||||||||