Adding Electronic Control to the RBB-Bot

Attaching Battery Holder and 9V Battery Clip

From: Mounting the L298 Module Board

The 3-cell battery holder used in the Phase 1 RBB-Bot doesn't provide enough voltage for operating the L298 H-bridge. As a replacement, use a 6-cell, double sided (three cells per side) AAA or AA battery holder. Get the kind with the two tabs for connecting with a polarized 9-volt battery clip.

Locate the three-terminal block at the bottom of the L298 module. The strip has connections labeled VMS, Gnd (for ground), and +5V. The +5V terminal provides 5 volts, provided by the built-in 5 volt regulator on the bottom of the L298 module.

Wire the 9-volt battery clip to the L298 module. The red (+, positive) lead connects to the power terminal marked VMS. The black (–, negative) lead connects to the power terminal marked Gnd.

Prepare a 7" length of 22 AWG solid conductor wire by stripping off 1/4" from both ends. Insert one end of this wire to the same Gnd connection as the black battery lead. Prepare a second 7" length of 22 AWG solid conductor wire in the same manner as above. Insert one end of this wire into the +5V power terminal. See the illustrastion on the right for a view of the wired power terminal. I've used a small cable tie to keep everything together.

Use a small flat-bladed screw driver to tighten the terminals so the wires remain snug. You DO NOT want any of these wires to accidentally come loose, or else they could cause a short circuit and damage to the L298 module.

Attach the battery holder to the RBB-Bot base using two 1" Velcro square. This arrangement allows you to pull the holder off the base to replace or recharge the batteries.

For the prototype RBB-Bot I used a set of six AA-size nickel-metal hydride (NiMH) cells. You can use AAA-size if you wish, and substitute nickel-cadmium (NiCd) or alkaline cells. I prefer NiMH batteries because they're a little more environmentally friendly. Though they initially cost more than alkaline cells, when you factor in recharging them hundreds of times, they're a very good deal. (Be sure to use a recharger made for NiMH batteries.)

When using NiMH or NiCd batteries, the 6-cell pack delivers a nominal 7.2 volts. When using alkaline batteries, the pack delivers 9 volts. Either voltage is acceptable. However, be sure to recharge your NiMH or NiCd batteries when the pack voltage falls under 7 volts.

Add the Solderless Breadboard Deck

Augmenting the L298 motor module is a small collection of circuitry to provide the RBB-Bot with sensitivity to light. Rather than solder together this circuitry you can use a small solderless breadboard. A mini breadboard with 170 contact points will do.

The control circuit uses two cadmium sulfide (CdS) photocells, an inexpensive and readily available 74HC14 integrated circuit, a couple of resistors, and some wire. The solderless breadboard connects with the L298 module via the two power wires you provided earlier, plus a pair of 10" length 3-conductor male-to-female R/C servo extensions.

At the heart of the control circuit is a CdS photocell, also called a light sensitive resistor. It's connected as shown with a 22 kΩ resistor to form a voltage divider. The output of a photocell is a varying resistance -- the darker it is, the higher the resistance. With the resistor added and a connection point in between, the output becomes a voltage that varies between 0 and 5 volts, depending on the brightness of the light.

The 22 kΩ resistor helps establish the sensitivity of the light sensor. The higher the value, the more sensitive it is, but the less linear the photocell's response to light. Different photocells exhibit different output behaviors, so you need to select a resistor value that best matches the photocell, and the light conditions you expect.

I selected the 22 kΩ value because I wanted to operate the RBB-Bot in a mostly darkened room, and lead it using an LED flashlight. Use trial-and-error to find the best value for your components, or else use the circuit to the left, which adds a potentiometer for adjusting sensitivity.

Remember that you need two photocells and resistors (and potentiometer), one for the right motor, and one for the left motor.

(And no, it's not a mistake that the photocell on the left controls the right motor, and vice versa. This arrangement establishes the RBB-Bot as favoring light; if you reverse the connections it will behave as if it's avoiding light.)

The output of each photocell is a voltage is applied to one of six inputs of a 74HC14 Schmitt inverting buffer. This one integrated circuit contains six separate buffers; we'll be using four of them in this project. With a Schmitt buffer, the circuit triggers at pre-defined input levels, called thresholds. This "snap action" provides clean On/Off switching, even though the light falling on the photocell is a varying voltage.

(The exact voltage the switching threshold depends on the supply voltage to the chip, whether the voltage change is positive-going or negative-going, and variations that can occur from one chip to another. But for a 74HC14 running at 5 volts, the positive-going threshold voltage is around 2.4 volts, and the negative-going threshold voltage is about 1.5 volts.)

In total darkness, the output of the photocell is 0 volts (more or less). As the 74HC14 is an inverting buffer, it will take this 0 volts, and the output will be 5 volts. As the light increases the buffer does not react until the voltage from the photocell reaches the threshold value. At that point, the output of the buffer immediately switches to 0 volts.

Figure A shows how each motor uses two inverting buffers. They're wired in such a way that there are two complimentary (opposite) outputs: when one output is 0 volts, the other is 5 volts. This complimentary voltage state is needed for the L298 H-bridge. Each motor has two control inputs. The motor will turn only when one input is 0 volts, and the other is 5 volts. The direction of the motor is reversed by swapping the voltages at each input.

[Figure A]

Input A Input B What Happens
0 volts 5 volts Motor turns one direction
5 volts 0 volts Motor turns other direction
0 volts 0 volts Motor stops
5 volts 5 volts Motor stops

Figure B shows the wiring of the solderless breadboard, indicating the position of the components. Note the two 3-pin connections for attaching the right and left motor control wires. These wires attach from the solderless breadboard as shown, to the right and left motor control terminals on the L298 module. Be sure to observe correct polarity in the wiring, or else the circuit won't work.

[Figure B]

When mounting the photocells don't clip off their leads. Leave them as long as you can. Add a length of heat shrink tubing, both to protect against short circuits, and to stiffen the wire leads of the photocells. The picture on the left shows the two photocells sticking out of the breadboard, with heat shrink tubing added. I selected the largest, most sturdy photocells I could find.

Once the control circuit has been built, secure the solderless breadboard to the breadboard deck using a 1" Velcro square. Secure the deck over the L298 module with a set of four 4-40" x 7/16" flat machine screws. Counter-sink the top holes of the deck so that the machine screws lay flat across the top. The deck fits neatly over the 1" standoffs in the four corners of the module.

Next: Testing the Robot's Light Seeking Ability