Here's a video (it's kind-of low quality, but I'm working on that. (I am still trying to work out the part that it's too slow.)
Step 1: The Sensors
- Ultrasonic Rangefinder (aka "sonar")
- 2 Sharp GP2D12 IR Sensors
- 1 Standard IR Assembly (more on this later)
- 1 CdS (Cadmium Sulphide) Photocell
If anyone who has prior experience with any of the Sharp IR rangers, FYI, they are not being used for actual distance measurement in this robot. I do not have an ADC (Analog-to-Digital Converter), neither do I know how to use them that way. They are simply providing a HIGH or LOW signal to the BS2 microcontroller.
The datasheets for the Sharp IR's as well as the Ping))) sensor can be found on the net, but if you're lazy like me, you can scroll down a little further an there they are!
Step 2: The Hardware, Brain, and Other Components
Mounted on the chassis is Parallax's Boe-Board which came with my Boe-Bot kit, which is simply a development board that can be used with any Stamp microcontroller with the same voltage requirements and pin layout. There are many different Stamp development boards on the internet. It is $65 from Parallax.
On the dvelopment board, as Bob's brain, is the BS2e (BASIC Stamp 2 e), which is basically the same as the BS2, except with more memory (RAM and EEPROM). The EEPROM is for program storage, and the RAM is for storing the variables (temporarily, of course). Bob may not be the fastest thinker in the world (~4,000 instructions/sec), but hey, that's good enough.
Bob moves via two continuous rotation servos from Parallax which, as many servos do, have a LOT of torque. For the juice, he has a 4-cell AA battery pack (for a total of 6V) connected to the 5V regulator on the development board, which gives a steady output of, you guessed it, 5V as to not fry the components. Many devices for robotics run on either a 5V or 6V supply; for some reason, it's a standard. And you DON"T want to fry these components; they're expensive. The BS2e has an internal regulator, but don't give it more than 9V if you are not using a development board! Also, if you don't use a development board (which always have regulators), then BE SURE to use a 5V regulator.
NOTE: As for power consumption, Bob is very greedy. Use RECHARGEABLE batteries for this; they last a LOT longer. I used 4 Energizer rechargeables @ 2500ma each, which definitely prolongs the life.
Step 3: Assembling The Light Sensor Circuit
Step 4: Assembling The Dropoff Detector
Unfortunately, the frequency range on the IR detector I used was very wide, which means it is much more prone to interference. Luckily, RadioShack offers ones only tuned to 38Khz, which means Bob is less likely to act strange around remote controls and other devices that use IR. The DP2D12's are great because they are virtually interference-free because of advanced optics (the lenses) and circuitry. In future projects, I will not be using regular IR detectors. The Sharp IR's are preferable over simple IR receivers.
NOTE: PIN 8 IS ACTUALLY PIN 10. PIN 9 IS CORRECT
Step 5: Bob Needs Sound!
Step 6: Adding The 'Headlight'
Step 7: Fill up Bob's Brain!
All the connections to the BS2e are listed again below
- PIN 0 - 220ohm resistor to the CdS photocell
- PIN 5 - positive lead of piezo speaker
- PIN 6 - SIG (signal) line of left GP2D12 (left when looking at the robot from above)
- PIN 8 - SIG line of right GP2D12
- PIN 9 - OUT (output) line of the IR detector (dropoff sensor)
- PIN 10 - 1Kohm resistor to the positive lead of the IR LED
- PIN 15 - SIG lead of ultrasonic rangefinder
1) He, or course, avoids objects and dropoffs
2) counts the number of times each one of the sensors was triggered, and determines if he's in a spot that cannot be maneuvered in
3) generates pseudo-random numbers to randomize movement
4) turns on "headlights" after determining that he's in a dark room by using timers and IF...THEN statements
I am still working out the 'lag' part. It has to do with the discharge time of the capacitor for the light sensor, as well as an over-burdened BS2e.