Home » How To's » Take Charge of your Scribbler Robot’s IR Capabilities

Take Charge of your Scribbler Robot’s IR Capabilities

What’s Up? Dock!

Editor’s note: Eric Ostendorff has provided a two-part article on hacking the Parallax Scribbler robot. In part one, Eric shows how to program the Scribbler to follow an infra-red beam. This lets you use a TV remote control to drive and steer the Scribbler around. In part two, Eric modifies the Scribbler so that it can dock at a charging station and self-charge.

The Scribbler Robot represents a great value to the robotics enthusiast. It’s affordable and comes completely assembled with a built-in Parallax BASIC Stamp 2, drive motors and a host of on-board sensors. It comes preprogrammed with seven simple routines to demonstrate its sensors and motors. Software and a serial cable are included so it can be programmed in PBasic and it offers a simple GUI that lets children use it to draw patterns on paper as it rolls along. Although it has been used in a few introductory college courses, I believe that Scribbler has been largely dismissed as a “kiddie” robot. It is similar in many ways to its popular kit-based brother, the Boe-Bot, except that the Scribbler’s sensors and I/Os are hard-wired. It is just as programmable and a good match for this project.

Scribbler’s built-in IR sensor has a fixed, calibrated aperture that can receive and track external IR signals. Scribbler’s “set and forget” hardware motor drivers are easier to program than Boe-Bot’s servos, which require continuous software pulsing. Scribbler’s circular shape and low profile are superior for maneuvering and docking. Finally, Scribbler’s hard-wired sensors won’t vibrate loose or get knocked out of alignment.

For Phase 1 of this project, we’ll use a TV remote control to drive and steer Scribbler around, and track toward the remote control beam. This is great fun and only requires an infrared remote and an hour of programming; no robot modifications are necessary. In Phase 2 we’ll build a simple charger that Scribbler can locate and dock with using its on-board sensors. This will require minor robot mods and some electromechanical construction, but I have kept things as simple as possible so that you can get similar results. I’ll call out the specific items I used so you can duplicate my hardware if desired.

There is a wealth of online information on programming Scribbler and BASIC Stamps, and much of the programming info written for Boe-Bot applies to Scribbler as well. Andy Lindsay, who works in Parallax’s education division, is a genius, and his books “What’s a Microcontroller” and “Robotics with the Boe-Bot” are required reading for any robot enthusiast. The links below provide the information that we hunger for.

Primary Scribbler download page:

www.parallax.com/ProductInfo

BASIC Stamp Editor download:

www.parallax.com/tabid

Infra-Red (IR) with the Boe-Bot:

www.parallax.com/Portals

Robotics with the Boe-Bot:

www.parallax.com/Portals/0/

What’s a Microcontroller?:

www.parallax.com/Portals/0/Downloads/

STEERING

Like many more expensive robots, Scribbler’s differential drive isn’t perfect. Electromechanical variations between the two motors, fluctuating battery voltage and the lack of wheel encoders all can cause each wheel to turn at slightly varying rates, so the robot’s software must be periodically recalibrated to go (mostly) straight. It will generally tend to steer left or right somewhat, and perhaps not consistently. Fortunately, the robot can still track to an IR source using its IR sensor. Further, it can distinguish between multiple IR sources, so Scribbler could consistently navigate from A to B to C with line-of-sight restrictions. The single IR sensor senses the presence of an IR signal, but not its direction. As a result, our simplified tracking routine is as follows:

signal detected = drive forward,  signal not detected = turn until signal detected

IR REMOTE

Scribbler reads IR control pulses on a carrier frequency of ~39 kHz. Low intensity signals (like our charger beacon) have line-of-sight restrictions, while most remote controls emit high energy signals that reflect off walls and ceilings for thorough coverage in a room. We’ll control the robot using SONY television IR codes. You’ll want a nice big universal remote configured as such for several reasons. First, you want large buttons for good control ergonomics. Ideally, get one with control buttons styled as four obvious directional arrows: forward, reverse, left and right. Next, you need to broadcast a strong IR signal that the robot detects easily through its tiny forward-facing aperture. Finally, we want a strong TV remote IR signal to significantly overpower our charger beacon’s continuous low-intensity signal. I used Radio Shack Remote No. 15-2142.

PROGRAMMING

Using the PBasic editor, program the robot with the program listed for the Scribbler Hack in the downloadable source code, click here. You will also find Scribbler I/O declarations listed there.

Scribbler I/O Declarations

LedRightPIN 8

LedCenter PIN 9

LedLeft PIN 10

Speaker PIN 11

MotorRight PIN 12

MotorLeft PIN 13

ObsTxRight PIN 14

ObsTxLeft PIN 15

LightRight PIN 0

LightCenter PIN 1

LightLeft PIN 2

LineEnable PIN 3

LineRight PIN 4

LineLeft PIN 5

ObsRx PIN 6

Stall PIN 7

Now you can drive the robot around with the IR remote buttons shown in the diagram. This program monitors the wheels’ stall sensor on pin 7 and tries to stop the robot if it hits something. This sensor is most reliable at full speed. If you run the PBasic editor with the robot hooked up to your serial port, the IR command codes received will display in a DEBUG window. Use these codes to modify the software to use different buttons if desired.

You’ll also need to calibrate your robot’s straight-line driving ability by changing the numbers in the “fwd” and “bwd” subroutines. Their pulsout commands drive the left motor (on pin 13) and right motor (on pin 12). Values are 3000 for full speed forward, 2000 for stop, and 1000 for full speed reverse. Proportional numbers give proportional speeds. Ideally, pulsout 13, 3000 and pulsout 12, 3000 would drive the robot straight forward. But if your robot curves left, you need to slow down your right motor. In this case, you might try pulsout 13, 3000 and pulsout 12, 2900 then adjust as necessary.

TRACKING IR

The most interesting aspect of this program is having Scribbler follow your IR remote beam. Press the MUTE button, and the 3 green LEDs light to indicate TRACKING mode. It drives forward any time it senses a MUTE signal. When no MUTE signal is detected, the robot circles left. The remote’s intense IR signal overwhelms Scribbler’s IR sensor unless you point it away from the robot. Press & hold MUTE while you lead the robot around the room by aiming the remote at the floor or wall. Different features around your room will reflect the IR beam differently, and it is interesting to see how sensitive your robot is to the reflections. Your remote will “time out” after 30-60 seconds of holding the mute button, so release and press again. Pressing the STOP button will end tracking mode, as will a motor stall condition.

To make the robot track directly toward your remote, you must reduce the intensity of the IR signal. The easiest way is to cover your remote’s IR LED with a layer or two of black electrical tape and poke a small hole in it. Of course, you’ll have to trigger tracking mode by pointing your reduced-output remote directly at the robot’s IR sensor.

PHASE 2

To download the PHASE 2 software click here (zip file). The download is also available at the end of the article (page 2).

CONFIGURING THE CHARGER

In phase two of this project, I will show you how to create a docking station and how to modify the Scribbler so that it will self-dock and charge its batteries. This material, which was not included in the printed article, is laid out below. You’ll need an AC adapter to provide 14-18 volts DC, no load voltage. First choice is an old transformer-based “wall wart” rated at 12 volts, ~ 500 mA that actually puts out over 12 volts. New switching-type units (required by law) are more efficient, but regulated to 12.0 volts and may not charge our six batteries fully. Adapt and overcome! Scrounge around in your drawers; find an adapter from an old cordless drill or answering machine, or use an RC car battery charger. Use a multimeter to verify the no-load output is 14–18 volts.

Charger IR Beacon

Figure 3

The Charger IR Beacon emits a low-intensity IR signal for the Scribbler to home in on. Build the LM556 timer circuit shown in Figure 3 above; all parts are available at Radio Shack or equivalent. (I used a small copper PC board, half of RS # 276-148.) Construction is not critical, but keep your wiring short and neat. Use a socket for the LM556 IC, and use a multi-turn 10K pot RS #271-343. The LM556 has two timer/oscillator circuits; one will generate a 39 kHz carrier frequency (critical), and the other will pulse the carrier at about 1.35 kHz (non-critical). To calibrate your circuit, you’ll need a multimeter or scope that counts frequency. Temporarily ground pin 6 to pin 7 on the LM556 timer, and then adjust the 10K pot to obtain a 39 kHz signal at output pin 9. In use, this pulsing signal will be sent out of two IR LEDs, aimed horizontally about 30 degrees apart for good coverage as you can see in the photo of the beacon circuit board in Figure 4.

Figure 4

Beacon circuit board. Two IR LEDs are aimed horizontally angled slightly apart for good coverage.

You can adjust the LEDs’ series resistors to suit your environment. I got a detection range of 10+ feet using 82 ohm resistors. Lower resistances emit stronger signals that can be tracked from farther away, but they may reflect off various surfaces and give false signals. Scribbler will use the PBasic COUNT command to identify your particular beacon, so you must calibrate your software to recognize your beacon signal. Once your beacon is working, aim your Scribbler at it while attached to the serial port and run this one-line program to view the pulse rate of your particular beacon.

aaa:COUNT 6,15, B0:DEBUG ? B0:GOTO aaa

My beacon’s pulse rate was 18-19. Your exact values may be different, but the important thing is that your results should be steady, not varying by more than +/- one unit. You’ll use this range of numbers to calibrate your tracking software.

If you don’t have access to a frequency counter to adjust the pot to 39 kHz, you can try the following procedure, assuming that your beacon is built and functioning properly otherwise: run that same one-line program above, which counts the IR pulses received. With your Scribbler connected to your PC and the DEBUG screen displayed, let your robot see the working beacon and adjust the beacon’s 10K trimpot until you see numbers displayed in the DEBUG window in the range of 15-24. Adjusting the pot won’t change the values displayed, but will tune the beacon’s carrier frequency to match the robot’s IR sensor. Find the pot’s range of adjustment that works, and center the pot in this range.

My original plan was to hack a $5 remote control into a continuous IR beacon. That would be simple, fast and cheap. Phase 1 clearly demonstrates that Scribbler can track a handheld IR remote. True, but I haven’t found a remote yet that doesn’t auto-shut off after 30-60 seconds. A battery preserving routine for when we sit on the remotes? At least one remote lost its life before I figured that out.

If you’re familiar with 555/556 circuits, notice the 1N914 diode between pins 1 and 2. Without it, the modulation duty cycle is 50% and Scribbler’s IR detector can’t see it for more than a second. The diode drops the duty cycle under 50%, which Scribbler can continuously detect. I lost sleep figuring that out!

Batteries & Charger

Get six new Nickel Metal Hydride AA batteries to power your robot. New cells are rated 2500 mAH or more. Perfectly charging six series NiMH batteries is beyond the scope of this article. We’ll make a simple trickle charger to keep the batteries near full. Build the simple circuit shown in Figure 5 (left) on another small pc board. It uses an LM317T as a current regulator to drive a constant 125 mA into the robot, which we will leave “ON” all of the time. The 10-ohm resistor fixes the 125 mA current. Scribbler consumes ~20 mA just idling on the charger; we’ll add an LED charge indicator that takes 5 mA, so the remaining 100 mA will charge the batteries, which barely get warm to the touch. That is a very safe rate, it should take 25-30 hours to charge completely discharged 2500 mAH batteries. If you reduce the resistor value, more current will flow, up to the limitations of your AC adapter.

Note: Expect to see Scribbler’s original red LED power indicator blinking to indicate “low battery voltage” much of the time. Since we are using six 1.2 volt Ni-MH cells instead of six 1.5 volt alkaline cells, this indicator does not accurately reflect a low battery condition.

Figure 5

Note 1: If you’re in a hurry, batteries will charge 20% faster when the robot is switched OFF.

Note 2: If the charger contacts get short-circuited, the LM317T will still limit output current to 125 mA, but it will slowly get hot. Fuse and/or heat-sink the 317 accordingly if you anticipate this possibility. The robot mods shown include a diode to prevent any danger if the robot’s charging contacts get short-circuited.

Charging Contacts

Figure 6:The Scribbler shown after installation of charging contacts.

Use 3/4″ copper-clad metal hangar strap from the plumbing department (Lowe’s # 85802, Home Depot # 842-238), a 10-foot roll is plenty for 8 robots & chargers. Tell a friend! The strap can be cut with tin snips or even scissors. It is clear coated and needs to be lightly sanded to solder and conduct electricity. Figure 6 shows where to mount two 1-1/2″ pieces to the front of the body after soldering a 12″ insulated wire to each. Remove six Phillips screws and open Scribbler up to add the modifications shown in the schematic in Figure 7. Drill two small holes in the lower body and route the wires from the external charger contacts inside toward the robot’s battery contacts as indicated in Figure 8. The negative battery contact is at the right rear, and the positive battery contact is under the left motor. Just lift the motor up a bit while you solder the wire on.

Figure 7

We’ll add an LED “charge indicator” that lights up when the robot has a good connection to the charger. Drill the upper body for a small 3 mm red LED just left of the 3 green LEDs. Follow the pictorial in Figure 8 to add a 100-ohm resistor and rectifier diode. Connections are made internally to the battery terminals. Keep polarity consistent with the charger, and make the positive charging contact on the left (driver’s) side of the front of the robot. Bend the outer copper contact so it fits around the body, and fasten it in place with foam double stick tape, or hot-melt glue. Keep outer copper surface shiny, clean and flat for reliable charging. When you’re done, use test leads to make a proper-polarity connection to your charger’s output and you should see your charge indicator LED glowing as shown in Figure 9.

Figure 8

Figure 9. The charge light indicator is glowing, indicating the circuit is operating correctly.

Figure 9. The charge light indicator is glowing, indicating the circuit is operating correctly.

The charger shown in Figure 10 is an environment optimized for the Scribbler’s unique combination of sensors. It is made of wood, posterboard, and steel rod (OK, coathanger). The posterboard provides white inside walls and a thin white floor that the robot easily rolls up on. The IR beacon is mounted overhead on a steel rod above robot height, so the signal is lost once the robot gets underneath it. At that point, the robot uses its onboard IR emitters to see to the white charger walls. Finally, it finds and follows a black line into the charger contacts, and stops when the wheel stall sensor triggers.

The charger is detailed in Figure 11. I used one piece of lumber 1″ x 3″ x 48″. Cut the height of the short 6″ piece from 2.5″ down to 1.5″ so that your “leave charger” IR signal is easily received. Hold your joints together with screws and/or hot melt glue. Use the posterboard glossy side up to make a floor and white inside walls for IR reflection. Scribbler needs to see reflected IR to recognize the charger, and white walls reflect best. Tape, staple or glue the posterboard in place. My diagonal “line” is a 1″ strip of flat black posterboard taped onto the white posterboard. This way, I can change it or move it easily. Sharpie or flat black paint may also work, but is obviously permanent and unforgiving.

Figure 11

Figure 12. The Scribbler follows the black line toward the docking station.

Figure 12 shows Scribbler following the black line towards the charger contacts. Scribbler’ line-detecting is hardware-based and finicky. Software calibration would have been nice here, but no such luck. My robot’s sensors were predisposed to darkness, so I carefully used a hobby knife to open up the 4 bottom holes for more IR “flow”. Keep the charger away from sunny windows and doors, since sunlight can saturate IR sensors and cause problems. I used the same copper-clad hanger strap for my charger’s electrical contacts; two horizontal strips each held by a single short wood screw. Remove the clearcoat so the copper straps conduct properly. Bend them out slightly so they make good, springy contact when the robot is docked. A little experimentation is in order here. Before you hook up the wires, push the robot up against the contacts and use a multimeter to verify the contacts are getting robot battery voltage (~7.8 volts). Adjust as necessary. Verify polarity and connect the charger contacts to your current regulator. When the robot is docked and charging, the LED added to the robot will glow. As Figure 13 shows, I wired in a small analog milliammeter to monitor how much current is flowing. My charger beacon is held up by a simple coathanger-wire support. I drilled into the wooden walls of the charger and pressed the wire into it. The wire and IR LEDs are 4.5″ above the surface. The beacon is powered from the AC adapter through wires running along the coathanger; it only draws about 25 mA. The two IR LEDs each are aimed horizontally, each about 20 degrees off center to send a wide signal into the room. Use strong coathanger rod or equivalent to hold your beacon circuit board rigidly to it. You must adjust your LEDs by experimentation, and you want them to stay where you set them. Figure 14 shows an overhead view of the charger, robot, remote, and AC adapter.

Figure 13

Figure 14

Figure 15

Download the PHASE 2 software by clicking here (zip file). To view Eric’s individual videos, follow this article to the end. This is a different program from Phase 1. You can drive the robot around exactly as before, but the Track routine has been replaced by a routine to seek your charger’s beacon and dock with the charger. Remote control codes for Phase 2 are shown in Figure 15. Instead of the MUTE button, the POWER button is used to make Scribbler seek AND leave the charger.

The docking/undocking procedure goes like this:

1. Seek out and follow the IR beacon signal until it can’t be seen anymore (beacon overhead, out of view).

2. Drive forward until it finds the black stripe and turn right to follow it.

3. Wait for the wheel stall sensor to trigger after hitting the charger contacts, then shut off the motors.

4. Wait for ONLY another POWER IR signal received.

5. Back up a bit, turn right, and drive out of the charger a bit to get past the IR beacon signal.

The PHASE 2 software works well for MY robot, MY charger and MY environment. It is also a great starting point for your robot, but you should expect to adjust both your software and hardware (LED height & alignment, black line, charging contacts, battery condition, etc), since there are many variables in how you built your charger and your room environment and lighting. Welcome to the world of robotics and custom programming!

First, change the software to use the COUNT results from the beacon testing you did a few paragraphs ago. Locate the ‘trackcharger’ routine towards the beginning of the Phase 2 software. Two “IF beacon” statements must be adjusted for your results. Let’s say your COUNT values shown were usually 18 with an occasional 19. To be safe, let’s accept values from 17 to 20 inclusive. Adjust the IF statements to transfer if the beacon values are outside this range:

IF beacon<17 THEN checkbase’ limit pulse count reading low

IF beacon>20 THEN checkbase’ limit pulse count reading high

So if the wrong beacon count (or no signal, beacon=0) is received, program execution jumps to the ‘checkbase’ routine, which checks if the white walls of the charger base are near enough to reflect IR pulses sent out from Scribbler. If so, the robot stops looking for the IR beacon and starts looking for the black line which will lead it towards the charger contacts The program is commented so you can follow the logical intent of the robot step by step. You must obviously test your robot and determine if and how something needs to be adjusted for your particular situation. This very simple robot, charger and docking routine does have limitations that you should be aware of:

  1. The charger will work best in an unobstructed area with a wide view of the room, as Scribbler needs open area to “see” the charger in a line-of-sight manner.
  2. When the robot loses the signal, it assumes that anything detected nearby is the charger and it will attempt to dock with it. Again, not a problem if the room is open and the path to the charger is wide open. But if it gets too close to a wall or furniture, Scribbler may get confused and get friendly with your antique armoire.
  3. White walls, rooms and floors will reflect IR very well and Scribbler may receive bad directional information from phantom beacon signal reflections. You may need to decrease your beacon’s signal intensity by increasing the two 82 ohm resistors to 100 ohms or more.
  4. Scribbler may not receive your IR remote’s signal when it is facing the beacon within homing range. It can only detect one signal at at time.Try to avoid driving it directly toward the charger, since you may lose control.
  5. After Scribbler has docked, it will only recognize another DOCK command to leave the charger (the “Power” button as I programmed it). Scribbler will back up, turn right and drive out a bit to get it away from the beacon signal so you can drive it from there. You can adjust the undock procedure in the Phase2 software if you like.

Scribbler’s not perfect, but it’s a nifty little robot that’s capable of doing some very cool things. Mainly, teaching us! This article is an experiment to get hobbyists building things and tinkering down on the floor. We all learn by trying, failing, succeeding, speculating, and testing. But mostly by having fun. One of you young geniuses out there might just build ten different frequency beacons and master whole-house navigation with a $79 Scribbler. But I’ll be happy if a few of you dust off those Scribblers that you have in the closet and play with them for a few hours, and I will count my effort a success. Happy Scribbling!

Links

To download the PHASE 2 software, click here. (zip file)

View them on Youtube, Video 1, Video 2

Parallax, www.parallax.com , (888) 512-1024

Words by Eric Ostendorff