Chapter 8. Explorer-Bot

The previous robots in this book were intended to be completely autonomous in operation with no user input. This project puts the control in your hands, letting you decide where the robot goes and what it does. It is strong enough to carry a human and can traverse the outdoors with ease. To make this robot even more accessible, it has a wireless camera mounted to the top, so you can operate the bot without seeing it (see Figure 8-1).

The finished Explorer-bot, ready to go.

Figure 8.1. The finished Explorer-bot, ready to go.

Although it is fun to watch a robot wander around, making decisions as to where it travels next, sometimes you need to direct the bot to a specific location that can be achieved only by a human. To do this, you need a control system that responds to your inputs several times per second to ensure that the bot stops when you tell it to. We have briefly discussed Radio Control (R/C) methods in Chapter 2, "Arduino for Robotics," but it is now time to implement this control on a robot.

How the Explorer-Bot Works

The Explorer-bot is similar to Linus from Chapter 4, "Line-Bot," but much larger and more powerful. A few features make this robot unique from the previous projects in this book; let's discuss them before continuing.

R/C Control

I use standard Hobby-grade R/C equipment to interface directly to the Arduino. This type of radio system requires a Transmitter (Tx) and a Receiver (Rx) used to link your inputs to the Arduino to control the motors (see Figure 8-2). The control signals are updated approximately 50 times each second, so changes to the inputs appear smooth at the motors.

A 2.4GHz radio transmitter and receiver

Figure 8.2. A 2.4GHz radio transmitter and receiver

Use 2.4GHz radio equipment for the R/C link because it is allowed for use on surface operated vehicles and R/C aircraft.

You can purchase a good hobby radio control system online for approximately $40 (www.hobbypartz.com part# 79P-CT6B-R6B) or at your local hobby shop. Using 2.4GHz radio equipment ensures that there will be no other R/C operators nearby on the same channel that could cause interference. These systems are also easily interfaced to the Arduino using any digital input pin. The R/C receiver requires a +5v power signal, which can be supplied from the Arduino's +5v regulated supply. Remember to also connect the GND supplies together.

Note

The R/C receiver needs only one power supply connection; although, there are +5v and GND pins for each R/C channel, and any one channel can supply power to the entire unit.

Powerful Motors

Although there are many good DC gear motors to choose from, I prefer a set of power wheelchair motors because they have excellent power and appropriate speed for a large robot. They are typically operated anywhere from 6V to 30V DC (rated at 24VDC) and can together carry approximately 400 to 500lbs, making them a versatile choice for medium-to-large robots that weigh between 30 to 300lbs. Depending on the weight of the bot, these motors draw anywhere from 3amps to 30amps continuously but can consume upwards of 50 to 100 amps if stalled.

I used two FRACMO brand power wheelchair motors that are rated at 24v and 9amps. The motors have six holes on each side of a flat gear-box that are used to mount the motors to the power wheelchair. I used these mounting holes to secure two 18-inch pieces of 3/4-inch angle iron to the top of the motor gear boxes, and a third piece of shaped angle iron bolted to the gear boxes, also used to mount the front caster wheel.

Current Sensing

The motor controller for these massive motors needs to handle approximately 30 amps continuously and have some kind of feedback to determine if the motor controller is over-stressed. To accomplish this, I designed a simple dual H-bridge that incorporates a +/− 30amp current sensor into each H-bridge to tell the Arduino exactly how much power is pulled through the motors each time they are updated. If either motor consumes more current (amps) than the limit set in the Arduino code, the Arduino sends stop commands to both motors for 1 second to keep them from over-heating the motor controller. This ensures that the PCB is protected and the bot cannot be allowed to draw an excess of heat through the board that would result in a burned PCB trace. (Trust me, I have done this several times, and it is not fun to rebuild.)

Video-Enabled

The bot can be driven in plain view or using the on-board wireless video camera to transmit the video feedback to a base station. The video camera has pan and tilt functions to enable a full 180 degrees of rotation along two axes, which provides an adjustable view of the bot's surroundings. The video comes from a wireless outdoor camera with an automatic night-vision feature enabled using a built-in photo detector. When the light level is too low, the infrared LEDs automatically turn on to provide an excellent view at night.

Xbee-Enabled

In addition to having R/C control, this bot uses another wireless protocol called Xbee, which is used to create a Serial connection between the Arduino and your PC. This can be used to replace the R/C control completely if you want to control the bot solely from your computer. Because Xbee is a 2.4gHz device, the range is comparable to that of the R/C radio systems. Xbee works using two radios: one connected to your computer and the other connected to the Arduino controlling the robot. Using a two Xbee radios setup is like having your Arduino plugged into the computer, only wirelessly. You can send and receive values using a serial connection from your PC or programmed device (like another Arduino).

In this chapter, the Xbee modems transmit data from the Arduino to a computer for you to view the real-time current sensor and R/C readings on your serial monitor. In Chapter 13, "Alternate Control Bot, "I enlist the help of a friend to revisit the Explorer-bot and write a serial interface between the Arduino and your computer (through the Xbee link) to control the robot using a PC game pad controller.

Now take a look at what you need to build the Explorer-bot.

Parts List for the Explorer-Bot

Several parts on this robot can be substituted for similar parts. The motors can be nearly any DC gear motor that fit in your frame. Both the Arduino and motor controller can be built or purchased, depending on how much work you want to put into the project (see Table 8-1).

Table 8.1. Explorer-Bot Parts List

Part

Description

Price

Two high power DC motors with wheels attached

You can find these power chair motor/wheel combos on eBay or pulled from an old power wheelchair.

$150 per/set

2.4gHz R/C transmitter/receiver

For R/C control you need a standard (min 2 channel) transmitter with receiver.

$35.00

Arduino Clone–from Chapter 6. (Any Arduino works.)

Homemade Arduino clone–uses FTDI cable for programming, has own +5v regulator, and accepts most Arduino shields.

$10–$15

12 feet of 3/4-inch angle iron

Hardware store comes in 3-foot, 4-foot, and 6-foot sections. I bought two of the 6-foot sections and had a bit left over.

$10.00

Large caster wheel (front)

Hardware store: I chose a padded wheel to keep the rest of the bot from rattling.

$10.00

Two Hobby Servo motors–full size

Hobbypartz.com item #Servo_SG5010.

These should be standard; unmodified servo motors will be used for the camera pan/tilt mechanism.

$5.00 each

2.4gHz or 900mHz wireless camera

Sparkfun part#WRL-09189 The camera is used to control the robot remotely; this is optional but cool.

$55.00

2-inch wide aluminum flat bar 1/16-inch thick

You need two 7-inch pieces to bend into the camera mounting brackets. I would buy a 24-inch piece.

$2.00

12-inch x 24-inch pc plexiglass

Your local hardware store should sell sheets of 1/4-inch plexiglass, or you can order it online.

$15.00

2-inch wide steel flat bar–1/8-inch thick–24-inch long.

Again, your hardware store should sell assorted pieces of metal; if not look online.

$4.00

Two SPST power switches

Radio Shack part#275-324. These are standard SPST switches: one for power, and the other to toggle the mode of the robot. These are optional but make things easier.

$2.99 each

5-inch x 7-inch plastic project box

Radio Shack part# 270-1807 7-inch × 5-inch × 3-inch.

$4.99

(2) Xbee radios

Sparkfun part#WRL-08876 I bought the high-power version capable of up to 1 mile signal transmission. I also used the 2.5 series radios.

$40 each

Xbee Explorer USB

Sparkfun part#WRL-08687 This unit has a built in 3.3v regulator and can be interfaced directly to a PC using a mini USB cable.

$24.95

Xbee Explorer Regulated

Sparkfun part#WRL-09132 This unit has a built in 3.3v regulator and can be directly interfaced to the Arduino using the DIN and DOUT pins.

$9.95

Motor Controller: The Parts Listed Are to Build Two of These Motor Controllers on the Same PCB

Two ACS714 +/−30amp current-sensor ICs

Digikey part#ACS714ELCTR-30A These current sensors read from −30 amps to +30 amps at the motor output.

$4.66 each

Eight P-channel power mosfets - STP80PF55

Digikey part#STP80PF55 These are cheaper if you buy ten or more.

$2.92 each

Eight N-channel power mosfets - STP80NF55-08

Digikey part#STP80NF55-08 These are cheaper if you buy ten or more.

$2.44 each

Four N-channel signal mosfets-2n7000

Digikey part#2n7000 These are cheaper if you buy ten or more.

$0.40 each

Two 12v regulator IC

Digikey part#L78S12CV 12v regulator 2amp – 12 to 30vdc input.

$0.82 each

Two TC4427 mosfet driver ICs

Digikey part#TC4427CPA It is also helpful to use 8-pin IC sockets to solder to the board.

$1.37 each

(8) 1N914 signal diodes

Digikey part#1N914 These are cheaper if you buy ten or more. Used between the gate pin of N-channel power mosfets to speed turn-off time.

$0.12 each

Two five-position terminal block

Digikey part#ED2612 These are the input terminals.

$0.52 each

Two four-position terminal block

Digikey part#A98361 These are the motor output and main power terminals.

$1.31 ea

Capacitors

Two 1000uF 50v, two 470uF 25v, four 1uF 50v, and two 1nF 50v.

$5.00

Resistors

Eight 10k ohm (Digikey part# CF14JT10K0).

$1.44

 

Eight to twelve 150ohm (Digikey part# CF14JT150R).

(for 50)

One pc copper clad PCB

Digikey part#PC9-ND 3-inch × 4.5inch blank copper one-sided board.

$4.76

In addition to the materials in the parts list, you also need a few tools to make this project go smoothly. To make a sturdy frame, you either need to use steel or aluminum, either of which is tedious to cut with a hand saw. I recommend using a reciprocating saw (or jigsaw) with a fine-tooth metal blade to cut through the various pieces of metal in this project. It can also be helpful to have a grinding wheel, Dremel tool, or angle grinder to clean rough edges on the metal created during the cutting process. You also need a handful of 1/4-inch to 3/8-inch nuts and bolts to hold each frame piece together. Lastly, you need an electric drill (with metal bits) to make holes for bolts to connect each piece of the frame together.

Building the Frame

The frame of this robot can be as simple as possible, built mostly around the motors and wheels. The frame must connect both of the back motors and wheels to the front caster wheel, hold the batteries, and secure all the electronics. I choose to use a 3/4-inch angle iron for most of the frame, with a plexiglass deck to cover the top. I wanted this bot to go through the average door frame in a house, but also be large enough to drive across rough terrain and large hills without trouble.

Specs

Before building the frame shown in Figure 8-3, review the specs and materials you need to do so:

  • Motor gear-box dimensions = 5.5-inch L • 3-inch W • 3.5-inch H

  • Battery dimensions = 6-inch L • 2.5-inch W • 3.5-inch H (each)

  • Rear wheels = 12-inch diameter

  • Caster wheel = 6inch diameter wheel, 7inch from mount plate to bottom of wheel

  • Frame = 17-inch L • 19inch W • 7.5inch H

  • Total bot dimensions with wheels and camera = 20inch L • 24inch W • 27inch H

Explorer-bot frame

Figure 8.3. Explorer-bot frame

The basic frame is made using five pieces of metal, sixteen bolts, the drive motor/wheel assemblies, and the front caster wheel. Steel is an excellent choice for a large robot because it is extremely strong and can be welded or bolted together. However, steel used in large quantities becomes heavy. As the bot gets heavier, the amperage draw from the motors goes up, so too much steel can over-stress your motor controller and drain the batteries more quickly, reducing run time. Try to use steel only as a skeleton for the frame, and use a plexiglass (acrylic) sheet for the deck of the robot to reduce weight.

Follow several steps to create the frame using metal stock. First, cut a piece of metal to secure the bottoms of the motors together and provide a base to mount the batteries. Next, cut two more pieces to secure the top, a support bar for the caster wheel, and finally the main frame piece that must be cut and bent to give the frame its shape. It is then only a matter of mounting the motors and caster wheel into the new metal frame to get it rolling. The following sections walk you through the steps required to build the frame.

Adding Battery Bracket

The first thing I did was cut a 19-inch piece of flat steel bar to hold the bottom of the motor gear boxes together, as well as provide a place to mount the batteries. Because the batteries I use are 6 inches each, my frame needed to have a 12-inch minimum space between the motor gear boxes for the two batteries to sit end to end. My motors have six mounting holes on each side of the gear box to mount the bottom bracket, and I used only the two center mounting holes on each motor (see Figure 8-4). I decided to use two 12v batteries on this bot, so it can be arranged for either 24v 7Ah (series) or 12v 14Ah (parallel) operation.

The battery brace attached to the bottom of the motor gear boxes, using two bolts to secure the brace to each motor

Figure 8.4. The battery brace attached to the bottom of the motor gear boxes, using two bolts to secure the brace to each motor

The battery bracket is nothing more than a 19-inch piece of a 2-inch wide flat steel bar (1/8-inch thick). This piece mounts to the center holes in the bottom of the motor gear boxes. I used two bolts in each gear box to hold the bracket in place. When secured, you have a place to mount the two batteries between the motors. My batteries just happened to be the same height as the motor gear boxes, so they fit nicely between the motors (see Figure 8-5).

The two drive motors connected together by the battery brace

Figure 8.5. The two drive motors connected together by the battery brace

Cut Top Frame Brackets

The bottom bracket needs to have two holes drilled in each end to mount to the bracket to the motors. Measure the distance between the two mounting holes on each motor. (My motors have a 2.5-inch spacing between mounting holes.) Now mark and drill the two holes (2.5-inches apart) on each end of the bottom bracket. You should then secure this bracket to the bottom of the motor gear boxes. Double-check to make sure both batteries fit in the new space before proceeding to the next step.

Cut Top Frame Braces

Cut two pieces of the 3/4-inch angle iron to 19-inch using a reciprocating saw if available, or a hacksaw. These two pieces can secure the motors at the top while keeping the wheels parallel to each other. These pieces also require marking and drilling two mounting holes on both ends of each brace. The mounting holes should be the same measurement as in the previous step (2.5-inch for me).

Measure, mark, and then drill holes in the upper frame braces to secure them to the motors (see Figure 8-6).

The two upper frame braces, used to hold secure the motors together on the top, which should be the same length as the bottom battery brace.

Figure 8.6. The two upper frame braces, used to hold secure the motors together on the top, which should be the same length as the bottom battery brace.

Secure only the inside bolts of the top braces for now. You use the outside mounting holes in the next step to also secure the main frame piece to the motors. (see Figure 8-7).

Start by securing the two upper frame braces using four bolts. Do not secure the bolts on the outside of the frame ye, because there will be one more frame piece installed before these bolts are secured to the motors.

Figure 8.7. Start by securing the two upper frame braces using four bolts. Do not secure the bolts on the outside of the frame ye, because there will be one more frame piece installed before these bolts are secured to the motors.

Cut and Bend Main Frame Piece

The main frame piece gives the robot its shape and enables you to mount a caster wheel to the front of the bot that connects to the rear portion of the frame. I made four cuts with my reciprocating saw and a metal blade, cutting V shapes from one side of the angle iron at premeasured points (see Figure 8-8). When cut, the angle iron is easily bent; you make the shape permanent when you bold the piece to each motor gear box with two bolts per side (four bolts total). You need to measure the distance between the two mounting holes on the motors and drill two holes for each side.

Start modifying the main frame piece by cutting V shapes where shown; then drill (measured) holes to mount to each motor as shown.

Figure 8.8. Start modifying the main frame piece by cutting V shapes where shown; then drill (measured) holes to mount to each motor as shown.

To avoid having sharp corners typical to a standard square shape, I decided to go with a semi-octagonal shape that has a flat nose and slanted, less-pointed corners. Bend your newly cut piece into the shape shown in Figure 8-9, making sure the long 14-inch legs are approximately 19 inches apart from each other.

This diagram shows the dimensions of each segment of the main frame piece, between each V cut.

Figure 8.9. This diagram shows the dimensions of each segment of the main frame piece, between each V cut.

With the main frame piece cut, you still need to add a crossbar to provide support for the front caster wheel.

Add Crossbar and Mount Caster Wheel

Because you use a thin 3/4-inch wide angle iron, there is only enough room to mount two of the four bolts on the front caster wheel mounting plate. Because this might leave the front wheel a bit wobbly, you need to add a crossbar from the lower bend on each side of the main frame piece, making sure that it travels across the other two mounting holes on the caster wheel mounting plate. If you have a welder, you can tack-weld the crossbar into place (see Figure 8-10). Otherwise you can place a bolt on each end of the crossbar into the main frame piece to hold them securely together.

The main frame piece ready to be mounted to the motors and wheels

Figure 8.10. The main frame piece ready to be mounted to the motors and wheels

You should now be ready to mount the caster wheel to the main frame piece and crossbar, drilling holes where necessary. A diagram of the top of the frame is shown in Figure 8-11.

This diagram shows the various pieces of the frame assembled together.

Figure 8.11. This diagram shows the various pieces of the frame assembled together.

When selecting a caster wheel, you should measure the height of your rear wheel assemblies to determine the approximate deck height. By matching the height of the caster to the height of the robot's deck, you can avoid having a bend in the frame to compensate for a height difference. The caster wheel mounting plate typically has four holes on a rectangular plate mounted to a swivel bearing. These holes should be used to mount the caster wheel assembly to the front of the bot frame. You should keep in mind when placing objects near the front of the bot that the caster wheel must spin a full 360 degrees without hitting anything.

My caster assembly has a height of 7 inches total, with a wheel diameter of 6 inches. Because the height of the main deck is approximately 7.5 inches as mounted to the motors, the caster wheel I use gives the bot a slight downward angle that is barely noticeable.

With the caster wheel mounted to the front of the frame, you can now mount the rear of the main frame piece into the motors. You can see the main frame piece mounted to the motor gear boxes, through the remaining holes in the two top frame braces, as shown in Figure 8-12.

The main frame piece attached to the rear wheels using four bolts through the remaining mounting holes on each side.

Figure 8.12. The main frame piece attached to the rear wheels using four bolts through the remaining mounting holes on each side.

When the main frame piece is mounted to the rear frame assembly and the caster wheel mounted to the front, the frame is complete. You can now either proceed to building the motor controller or add an optional plexiglass deck to the top of the frame.

Plexiglass Deck (Optional)

I tend to use sheets of clear acrylic plexiglass in projects that require a top or lid. Because it is clear, the insides of the bot can still be seen when assembled, adding a nice "look, but don't touch" effect. These sheets can also be cut to fit any shape and drilled to mount power switches, electronics, or a project box. Plexiglass is lighter than an equivalently sized piece of plate glass and is far more resistant to cracking or breaking.

I cut the plexiglass to fit the rectangular section on the top part of the frame, 18-inchW × 13-inch L. The plexiglass can then be mounted to the metal frame using 1/4-inch bolts. I later use the plexiglass deck to mount the project-box with all the electronics inside for easy access. The plexiglass sheets usually come with a protective film on each side; leave this film intact until you finish with all cutting. When the film is removed, the clear sheet should be free from scratches.

With the frame finished, you need a motor controller to get this robot moving.

Building the Motor Controller

If you are not interested in building a motor controller and would like to buy one, please refer to the (Large) motor controller suggestions in Chapter 3, "Let's Get Moving," Chart 3.4 for a few different options.

The motor controller for this project is more complex than the previous controllers because of the size of the motors it powers. Because most motor controllers can handle the dual 9 amp power chair, motors will be in the $100+ range (for two motors). I decided to build a simple mosfet H-bridge that also has a current sensor built in to allow for adjustable current limiting. The current-limiting feature is important because it is the only way you can know if the motors are drawing too much current for the motor controller to handle. The result of drawing too much current through your motor controller is usually a fried PCB copper trace, or a blown up mosfet! By monitoring the current-sensor IC with the Arduino, you can instantly stop either motor if it exceeds the preset level.

Current Sensing and Limiting

Whether you need current limiting on your robot depends on the power of your motors. If you use a smaller gear motor that has a stall current of 15 amps, you can likely burn up the motor before a motor controller rated for 25 amps continuous current.

These power chair motors however were designed to carry not only a chair the size of a large robot, but also a human being riding in the chair–up hills, through a parking lot, and without burning up. This means that each motor can draw upward of 50 to100amps during a stall (depending on the motor), which is plenty of heat to burn a weak spot on a motor controller.

I used the ACS714 +/−30amp current sensor from Allegro Microsystems to measure the current flowing through one of the two motor outputs on each H-bridge. The AC714 current sensor operates using a +5v power supply, which can be provided by the Arduino. The sensor has three outputs connections: +5v, GND, and the analog output signal. The output voltage of each sensor is actually centered at 2.5v when the motors are not moving (0 amps) and move to 5v as the current flows positively (that is, the motor is spinning forward) or down to 0v as the current flows negatively. (That is, the motor is spinning in reverse.)

The Arduino can read this value from the current-sensor on any Analog Input pin and translate the voltage to a value between 0 and 1023, with the center value of 0 amps being 512 (1023/2). The ACS-714 datasheet lists the voltage sensitivity as 66mV per amp, so you must calculate how many millivolts are in each "step" of the 0–1023 value range of the Arduino's analog inputs to determine how many amps are measured at a given time.

There is only one catch: The current sensor chip is only available as a Surface Mount Device (SMD) chip, which takes a little finesse to solder onto the PCB. I also made an alternative PCB design without the current sensor, for those who do not want to use one.

H-bridge Design

For this H-bridge, I used standard P-channel and N-channel power mosfets both rated for 80amps and 55vdc. I used the TC4427 low-side mosfet driver as a signal buffer for the Arduino to provide the PWM signal to the N-channel mosfets (similar to the motor controller in Chapter 5, "Bump-Bot"). The TC4427 supplies 1.5 amps to the Mosfet Gate pins during high-speed PWM switching, enabling for use of ultrasonic (silent) motor operation at 32kHz PWM. The N-channel mosfets also each get a fast-recovery signal diode attached to their Gate pin, to help drain the excess current more quickly between switching cycles.

The P-channel mosfets are switched on using small N-channel signal mosfets, and pulled-up to the supply voltage using a resistor divider to turn them off. The P-channel mosfets (AHI and BHI) are only intended to be turned on or off when changing directions and should not be driven with a PWM signal. The resistor divider enables you to select resistor values based on your desired operating voltage; the resistor values used in this chapter are safe for use with 12v to 24v battery packs.

The schematic of the home made H-bridge motor controller used on the Explorer-bot. This schematic depicts one H-bridge circuit; the complete motor controller requires two of these identical circuits.

Figure 8.13. The schematic of the home made H-bridge motor controller used on the Explorer-bot. This schematic depicts one H-bridge circuit; the complete motor controller requires two of these identical circuits.

In addition to using higher-powered mosfets than the last motor controller, this board gets double mosfets. That is, I placed two mosfets in parallel on each leg of both H-bridges to double the current carrying capacity of the motor controller by halving the resistance. Remember from Chapter 1, "Introduction," lower resistance equals less heat.

It is now time to collect the needed parts and start building the motor controller! If you have not yet tried to etch a PCB, you might need to review Chapter 6. "Making PCBs," to build this circuit. When you are ready, follow these steps to print, transfer, etch, and build the PCB.

  1. Download Eagle PCB files from https://sites.google.com/site/arduinorobotics/home/chapter8.

  2. Open the .brd file, and select only Bottom, Pads, and Vias from the Layers menu.

  3. Click the Ratsnest button to fill in the GND plane.

  4. Print onto magazine paper using options Black and Solid.

  5. Iron on to copper clad.

  6. Etch PCB.

  7. Drill PCB.

  8. Place components using silkscreen and schematic files; then solder.

  9. Test with a 12v power supply and 5v input signals, checking for voltage at the motor terminals.

For instructions on how to etch a PCB, refer to Chapter 6. When assembling each board, make sure to check the silkscreen on the Eagle file, the motor controller schematic, and the component data sheets to verify the proper orientation of each part.

Note

To solder the surface mount ACS714 current sensor, it is best to heat the copper pads and apply a small amount of solder before placing the chips. For best results, solder the motor-terminal side of the current sensor first. When you get the first two terminals securely soldered and each pin lined up, carefully solder the remaining pins, heating each pin for as short a time as possible.

The Eagle board file in Figure 8-14 shows only one of the two h-bridges needed. You can either print out two separate boards, or use the dual-print board file that has two of these h-bridges side by side and ready to print onto a single board. They both share a common ground plane, so only one GND wire needs to connect from the Arduino.

The PCB file used to make the H-bridge schematic shown in Figure 8-13

Figure 8.14. The PCB file used to make the H-bridge schematic shown in Figure 8-13

Use the silkscreen (component outlines) from the PCB board file shown in Figure 8-14 to place each component before soldering. You should also make sure your finished motor controller looks like the one shown in Figure 8-15.

A few notes about the motor controller layout:

  • The striped (cathode) end of the diodes should face the center of each H-bridge.

  • The source pins of the power mosfets should face the center of each H-bridge.

  • The resistors can be placed in any orientation.

  • The indented end of the TC4427 IC should face the left side of the board.

See Figure 8-15 for a picture of the finished dual H-bridge board. Notice the two sets of header pins near the top of the board; these connect to the ACS714 current sensors mounted to the bottom of the board. Also notice that only one of the center GND pins connect to the Arduino at the bottom.

The finished dual motor controller with eight mosfets in each H-bridge.

Figure 8.15. The finished dual motor controller with eight mosfets in each H-bridge.

This motor controller design enables for individual control of each switch in the H-bridge. Though this bridge is capable of ultra-sonic PWM switching speeds (32kHz), the PWM signals should be used only on the low side inputs that feed into the high-speed mosfet driver IC. The high side inputs that control the P-channel mosfets are not set up for high-speed switching and should be switched on and off only when changing directions or stopping. Now that you have a working motor controller, it is time to set up the Arduino to control it.

Setting Up the Arduino

You can use a standard Arduino for this project, though I used a home-made breakout board for the Atmega chip that is programmed using an FTDI programming cable. The advantage of using the home-made Arduino (or any Arduino programmed with an FTDI cable) is that the Xbee Explorer Regulated module can plug directly into the FTDI programming port, supplying both power and the required serial connections from the Xbee to the Arduino (see Figure 8-16).

The Xbee breakout board from Sparkfun.com

Figure 8.16. The Xbee breakout board from Sparkfun.com

Several other Arduino variants also use the FTDI programming port, such as the Arduino Pro and the Pro mini. The purpose of these boards is to create a smaller alternative to the Arduino main board that incorporates the FTDI programming chip into the programming cable, instead of putting one on each Arduino board. This makes each board a bit cheaper and easier to make at home.

Also, because I got to design the Arduino breakout board in Eagle, I added screw terminals to each digital pin and 3-pin male header connectors to each analog pin, supplying +5v and GND signals to the current sensors plugged into these ports. You can also plug servo motors directly onto these pins for easy interfacing.

You can download the Eagle board files to build your own Arduino from https://sites.google.com/site/arduinorobotics/home/chapter8.

If you use a standard Arduino board, you need to use four jumper wires to interface the Sparkfun Xbee Explorer Regulated adapter to the Arduino. The Xbee adapter board has an on-board 3.3v regulator, so it can accept a 5v power supply from the Arduino. You need to connect the GND and +5v to Arduino; then connect the DOUT from Xbee to Arduino DP0 (rx) and DIN from Xbee to Arduino DP1 (tx).

Connecting the H-Bridges

Each H-bridge provides control of all four switches individually. This basic design works well, but there is no external protection against commanding the bridge into a short-circuit because this is done in the code; you should check all connections twice to ensure proper wiring. The H-bridge connections are labeled as AHI (A High Input), ALI (A Low Input), BLI (B Low Input), and BHI (B High Input). The low inputs connect to the N-channel power mosfets, and the high inputs connect to the P-channel power mosfets. Because only the N-channel power mosfets will be driven with a PWM signal, they connect to four of the six PWM outputs on the Arduino (PWM pins 3, 9, 10, and 11).

I do not use PWM pins 5 and 6 if possible because I plan to change the default PWM frequency and do not want to affect the system timer 0. To use different PWM frequencies requires changing the system timers that the PWM pins use. Because PWM pins 5 and 6 are attached to the main system timer 0, changing that timer changes the outputs of any function depending on Timer 0 (that is Delay(), millis(), and micros()). Because you need only four PWM outputs, but you need to change the default timing of all those outputs, use PWM pins 9 and 10 on timer 1 and PWM pins 3 and 11 on timer 2, changing both to a 32kHz PWM frequency for silent motor operation. Pins 5 and 6 will be used, but only as Digital Output pins; the PWM ability will not be utilized for this project.

Make each connection from the Arduino to the motor controller, Xbee, and R/C receiver according to Table 8-2.

Table 8.2. Connect Each Wire to the Arduino as Shown Here: Double-Check Each Connection Before Testing

Input/Output

Connection to Arduino

Xbee DOUT

Arduino digital pin 0 (rx)

Xbee DIN

Arduino digital pin 1 (tx)

R/C up/down input (ELE)

Arduino digital pin 2

R/C left/right input (AIL)

Arduino digital pin 6

R/C switch input (AUX)

Arduino Analog pin 0

M1 current sensor (on motor controller)

Arduino Analog pin 1

M2 current sensor (on motor controller)

Arduino Analog pin 2

M1 BHI (on motor controller)

Arduino digital pin 7

M1 BLI (on motor controller)

Arduino PWM pin 3

M1 ALI (on motor controller)

Arduino PWM pin 11

M1 AHI (on motor controller)

Arduino digital pin 8

M2 BHI (on motor controller)

Arduino digital pin 5

M2 BLI (on motor controller)

Arduino PWM pin 10

M2 ALI (on motor controller)

Arduino PWM pin 9

M2 AHI (on motor controller)

Arduino digital pin 4

I chose to mount all my electronics into the 5-inch x 7-inch project box from Radio Shack. This box provides a place to mount both the motor controller and the Arduino with Xbee. The box can then be moved without disconnecting the Arduino from the motor controller. The project box is optional but makes for a nicer looking installation.

Setting Up Xbee

You can choose from three different types of Xbee radios: Series 1, Series 2.5, and 900MHz. All these models offer high serial data speeds (115,200 bps+) with both low-power and high-power modules. We focus on the Series 1, low-power modules (Sparkfun part# WRL-08665), which are ready to go out-of-the-box. All you need to do is plug each Xbee radio into the Sparkfun adapter boards to start (see Figure 8-17).

To set up Xbee you need the following:

  • Two Xbee radios

  • Xbee Explorer Regulated

  • Xbee Explorer USB

  • XCTU Xbee programming software (Free: download latest version from www.digi.com.)

  • Mini USB cable

From left to light: Xbee Explorer regulated, two Xbee radios, Xbee Explorer USB

Figure 8.17. From left to light: Xbee Explorer regulated, two Xbee radios, Xbee Explorer USB

When using Series 1 modules for simple data transmission, I found that no reprogramming was necessary and that the Xbee modules communicated with each other out-of-the-box at 9600 bps serial data speed. If you would like to use a different serial speed or change the Xbee radios to operate on a private channel, you need to use the programming software XCTU.

Though the Series 2.5 modules are only a few dollars more than the Series 1, they use a different type of networking that requires each Xbee to have a specific role and must be programmed as such; these do not work without being reprogrammed. Although these work just as well as the Series 1 for simple data transmission, there is a bit more setup required to get them going. Unless you have a reason, stick with the Series 1 modules.

Note: The high-power Xbee modules offer a range of up to 1 mile but require more than 200mA of current. The low-power modules have a range of approximately 300 feet and consume only approximately 50mA of current. The Sparkfun Explorer boards can power either type of Xbee. When connected, the Xbee radio link emulates a wireless USB cable; that is, you can connect to the Arduino using the serial monitor to read real-time updates from the current sensors and R/C signals. For this chapter, set up the Xbee modules to communicate between the PC and the robot to send status updates. Chapter 13 uses this link to control the robot from the PC.

Testing the Xbees

To test the Xbee connection, load the code in Listing 8-1 to the Arduino and open a Serial monitor with the Xbee Explorer USB port to check the connection. With the serial monitor opened, type any character into the space and press send. If everything connects properly, whatever characters you send to the Arduino loop back through the Xbee and appear on the serial monitor.

Example 8.1. This Code Can Be Used to Test the Connection of the Xbee Modems from Your PC to the Arduino and Back

// Code 8-1 - Xbee Test code

int incomingByte = 0;   // for incoming serial data

void setup() {
  Serial.begin(9600);    // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);

}

void loop() {

  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, BYTE);

    digitalWrite(13, HIGH);  // turn on LED pin 13
    delay(1000);  // leave LED on for 1 second

  }

  else {

    digitalWrite(13, LOW); // otherwise, turn off LED pin 13

  }

}

When loaded, power the Xbee Explorer Regulated adapter board with +5v and GND, connect the DOUT pin to Arduino DP0 (rx), and the DIN pin to Arduino DP1 (tx). Or if you built the Arduino clone, simply plug the Xbee Explorer onto the FTDI programming port of the Arduino.

Remember that the serial monitor baud rate must be set to 9600bps before you can communicate through the Xbee modems. If a different baud rate is wanted, you need to reprogram both Xbee radios with the wanted speed, and change the speed in the Arduino code.

The last component that to add to the Explorer-bot is a wireless camera used to provide an audio/video link when guiding the robot to a location that cannot be seen by the operator.

Adding a Camera

To add remote visibility to your robot, you need a wireless camera (see Figure 8-18). Most common wireless video cameras operate at either the 900mHz or 2.4gHz frequency range. If you want to avoid interference with your 2.4gHz R/C radio and the 2.4gHz Xbee, you should probably get the 900mHz video camera if available. Otherwise, you might get slightly more interference from the other devices than ideal, but a 2.4gHz camera can still work.

Any wireless camera can work for this purpose. I used a camera with automatic night vision.

Figure 8.18. Any wireless camera can work for this purpose. I used a camera with automatic night vision.

Because the bot has full speed control and can turn in any direction, you might decide to simply strap a wireless video camera to the top of your bot and go—turning the bot to see what is around. Some video cameras come with a built-in rechargeable battery pack that enables for no wires to connect to the camera. The camera that I bought has an RCA cable coming from the back that powers the camera with a 12v power supply.

The camera receiver has RCA outputs for video and audio. I simply plugged the yellow RCA cable from the video port of the receiver to the video input of my TV, and plugged the 9v AC adapter into the wall, and I was instantly watching video from the wireless camera. You can also use a smaller 7-9-inch LCD screen attached to your R/C transmitter for portable video control; although, you would also need to add a battery pack to your transmitter.

Pan and Tilt

To allow control of the camera position without moving the robot frame, you need a pan-and-tilt base for the camera. The pan-and-tilt functions are achieved using two standard sized hobby servo motors to create X and Y axes with 180-degrees rotation along either axis. This setup gives a full view of anything in front of the robot and enables much more precise movement than is provided by the robot base and the ability to look up and down.

By connecting the servo motors directly to the R/C receiver, you can control the orientation of the video camera using the R/C transmitter and without the extra overhead of processing the signals through the Arduino. (These servos can alternately be controlled by the Arduino if needed.)

The pan/tilt mechanism requires two standard-size hobby servo motors and two 7-inch long pieces of 2-inch wide aluminum flat bar (see Figure 8-19). The flat bar was cut and bent into two C-shaped pieces that connect together with the video camera mounted on top.

The pan/tilt mechanism is made from a few pieces of aluminum, some nuts and bolts, and two hobby servo motors.

Figure 8.19. The pan/tilt mechanism is made from a few pieces of aluminum, some nuts and bolts, and two hobby servo motors.

To make the camera pan/tilt base, complete the following steps.

Make First Bracket

Cut the first piece of aluminum to 7 inches with a hacksaw or reciprocating saw and a fine-tooth metal blade. Next measure and mark the flat bar into three sections: 2 inches on each end and 3 inches in the center (2-inch left end + 3-inch center + 2 -inch right end = 7-inch total). Use a bench vise to bend this piece of flat bar at these marked points to 90-degree angles, making somewhat of a C shape cut servo mounting hole.

Now use one of the servo motors to mark the outline of the motor casing, centered onto the side of the first aluminum piece. When marked, use a Dremel tool and a metal cutoff wheel to cut out the hole for the servo motor, as shown in Figure 8-20.

Cut a hole for the servo motor using a Dremel tool and metal cutoff wheel.

Figure 8.20. Cut a hole for the servo motor using a Dremel tool and metal cutoff wheel.

After you test fit the servo motor into the mounting hole, mark the four mounting holes with a permanent marker and drill holes for them. Use four #8 bolts and nuts to secure the servo motor to the bracket, as shown in Figure 8-21.

Mount the servo motor into the first aluminum bracket.

Figure 8.21. Mount the servo motor into the first aluminum bracket.

Make Second Bracket

The second bracket needs only to be bent and have a few holes drilled into it. Measure and mark the bracket at 1.75-inch on each end and 3.5-inch in the center to equal 7 inches total. Bend the bracket at the marked points to make the same shape as the first bracket. This bracket needs to be mounted to the first servo mounting plate on one side (see Figure 8-22), and have a 1/4-inch hinge bolt on the other side that enables the camera to freely pivot. The camera should mount to the top of this bracket.

Finished servo motor pan/tilt with camera installed

Figure 8.22. Finished servo motor pan/tilt with camera installed

The second servo motor is the main motor that rotates the entire pan/tilt assembly, as shown at the bottom of Figure 8-22. I mounted this motor into an aluminum plate that is bolted to a 24-inch riser bar, mounted to the back of the robot frame. The riser bar serves to give the camera a better point of view.

To mount the servo into the aluminum plate (obtained as an extra piece from the Radio Shack project box), again mark the outline of the servo motor using a permanent marker, and cut the outline with a Dremel tool and a metal cutoff wheel. You can then mount the pan/tilt assembly to the top of this servo motor. With the servo motors installed, you can control their direction using two open channels on your R/C transmitter.

With the camera pan/tilt assembly completed, all that you need to do is to load the code and start testing.

Loading the Code

Now it is time to load the code to the Arduino and double-check your connections. When you are comfortable that you have connected everything properly, download Listing 8-2 from the book website, and remember to press the Compile button to check for errors before uploading to the Arduino. Updates to this code are in the Chapter 8 page of the book website at https://sites.google.com/site/arduinorobotics/home/chapter8.

Example 8.2. This Is the Main Code for the Explorer-Bot. Check All Connections as Per Table 8-2 Before Loading the Code.

// Code 8-2 - Explorer-bot
// Decode 3 R/C signals connected to pins A3, A4, and A5.
// Code is used to drive a tank-steering robot with joystick control (mixed steering)
// AUX channel is used to toggle speed mode fast/slow.
// THIS CODE USES CHANNEL MIXING -- you need to use channel 1 up/down, and channel 2
left/right.

int ppm1 = 17;  // digital input from R/C Elevator channel, marked "ELE" - connect to Arduino
A3
int ppm2 = 18;  // digital input from R/C Aileron channel, marked "AIL" - connect to Arduino
A4
int ppm3 = 19;  // digital input from R/C switch channel, marked "AUX" (if equipped) - connect
to Arduino A5

// variables to read R/C channel 1
unsigned int servo1_val;
int adj_val1;

// variables to read R/C channel 2
unsigned int servo2_val;
int adj_val2;

// variables to read R/C channel 3
unsigned int servo3_val;
int adj_val3;


// Motor-controller connections to Arduino
int motor1_BHI = 7;  // m1_B hi-side (P-channel mosfet) digital output
int motor1_BLI = 3;  // m1_B low-side (N-channel mosfet) PWM output
int motor1_ALI = 11; // m1_A low-side (N-channel mosfet) PWM output
int motor1_AHI = 8;  // m1_A hi-side (P-channel mosfet) digital output

int motor2_BHI = 5;  // m2_B hi-side (P-channel mosfet) digital output
int motor2_BLI = 10; // m2_B low-side (N-channel mosfet) PWM output
int motor2_ALI = 9;  // m2_A low-side (N-channel mosfet) PWM output
int motor2_AHI = 4;  // m2_A hi-side (P-channel mosfet) digital output

int ledPin1 = 13;    // used as a neutral indicator
int ledPin2 = 12;  // used as an over-current indicator light that turns On when the
current_limit is exceeded by either motor.

int current_sense_1;  // variable to hold value of left motor current sensor
int current_sense_2;  // variable to hold value of right motor current sensor
int current_limit = 25;  // sets the amperage limit that when exceeded on either motor, stops
the motors for a "cool_off" time.

int cool_off = 1000;  // amount of time (milliseconds) to stop motors if they exceed the
current_limit above (25 amps)



////////////////////////////////

int deadband = 10;  // sets the total deadband - this number is divided by 2 to get the
deadband for each direction. Higher value will yield larger neut
l band.
int deadband_high = deadband / 2;  // sets deadband_high to be half of deadband (ie. 10/2 = 5)
int deadband_low = deadband_high * −1;  // sets deadband_low to be negative half of deadband
(ie. 5 * −1 = −5)

int x;  // variable used for mixing adj_val1
int y;  // variable used for mixing adj_val2

int left;  // variable to hold mixed value for left motor
int right;  // variable to hold mixed value for right motor

int speed_low;  // variable to set lower speed value determined by adj_val3
int speed_high; // variable to set upper speed value determined by adj_val3

int speed_limit = 255; // default the speed limit to 255 (max speed), unless switched.

// variables to hold speed mapping values
int speed_max = 255;
int speed_min = 0;

// end of variables

void setup() {

  TCCR1B = TCCR1B & 0b11111000 | 0x01; // change PWM frequency on pins 9 and 10 to 32kHz
  TCCR2B = TCCR2B & 0b11111000 | 0x01; change PWM frequency on pins 3 and 11 to 32kHz

  Serial.begin(9600);

  //motor1 pins
  pinMode(motor1_ALI, OUTPUT);
  pinMode(motor1_AHI, OUTPUT);
  pinMode(motor1_BLI, OUTPUT);
  pinMode(motor1_BHI, OUTPUT);

  //motor2 pins
  pinMode(motor2_ALI, OUTPUT);
  pinMode(motor2_AHI, OUTPUT);
  pinMode(motor2_BLI, OUTPUT);
  pinMode(motor2_BHI, OUTPUT);
//led's
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);

  //PPM inputs from RC receiver
  pinMode(ppm1, INPUT);
  pinMode(ppm2, INPUT);
  pinMode(ppm3, INPUT);

  // wait 1 second after power-up to start loop to give R/C time to connect
  delay(1000);

}



void loop() {

  // go to current_sense() function below loop first
  current_sense();
  // then go to pulse() function below loop
  pulse();

  // Now we can check the R/C values to see what direction the robot should go:

  if (x > deadband_high) {  // if the Up/Down R/C input is above the upper threshold, go
FORWARD

    // Going Forward, now check to see if we should go straight ahead, turn left, or turn
right.
    if (y > deadband_high) { // go forward while turning right proportional to the R/C
left/right input
      left = x;
      right = x - y;
      test();
      m1_forward(left);
      m2_forward(right);
      // quadrant 1 - forward and to the right
    }
    else if (y < deadband_low) {  // go forward while turning left proportional to the R/C
left/right input
      left = x - (y * −1);  // remember that in this case, y will be a negative number
      right = x;
      test();
      m1_forward(left);
      m2_forward(right);
      // quadrant 2 - forward and to the left
    }
    else {  // left/right stick is centered, go straight forward
      left = x;
      right = x;
test();
      m1_forward(left);
      m2_forward(right);
      // go forward along X axis
    }
  }

  else if (x < deadband_low) {    // otherwise, if the Up/Down R/C input is below lower
threshold, go BACKWARD

    // remember that x is below deadband_low, it will always be a negative number, we need to
multiply it by −1 to make it positive.
    // now check to see if left/right input from R/C is to the left, to the right, or
centered.
    if (y > deadband_high) {   // go backward while turning right proportional to the R/C
left/right input
      left = (x * −1);
      right = (x * −1) - y;
      test();
      m1_reverse(left);
      m2_reverse(right);
      // quadrant 4 - go backwards and to the right
    }
    else if (y < deadband_low) {  // go backward while turning left proportional to the R/C
left/right input
      left = (x * −1) - (y * −1);
      right = x * −1;
      test();
      m1_reverse(left);
      m2_reverse(right);
      // quadrant 3 - go backwards and to the left
    }
    else {  // left/right stick is centered, go straight backwards
      left = x * −1;
      right = x * −1;
      test();
      m1_reverse(left);
      m2_reverse(right);
      // go straight backwards along x axis
    }
  }

  else {    // if neither of the above 2 conditions is met, then X (Up/Down) R/C input is
centered (neutral)

    // Stop motors!
    left = 0;
    right = 0;
    m1_stop();
    m2_stop();

  }
// Print the 2 R/C values
  Serial.print(servo1_val);
  Serial.print("  ");
  Serial.print(servo2_val);
  Serial.print("  ");
  // now print the value of the speed limit
  Serial.print(speed_limit);
  Serial.print("  ");
  // lastly, print the values of the current sensors
  Serial.print(current_sense_1);
  Serial.print("  ");
  Serial.print(current_sense_2);
  Serial.println("  ");

}
// End of loop







// Begin current_sense() function
void current_sense(){

  // read current sensors on motor-controller
  current_sense_1 = analogRead(1);
  current_sense_2 = analogRead(2);

  // determine which direction each motor is spinning
  if (current_sense_1 > 512){
    current_sense_1 = current_sense_1 - 512;
  }
  else {
    current_sense_1 = 512 - current_sense_1;
  }
  if (current_sense_2 > 512){
    current_sense_2 = current_sense_2 - 512;
  }
  else {
    current_sense_2 = 512 - current_sense_2;
  }

  // adjust the directional value into Amperes. Divide by 13.5 to get amps
  current_sense_1 = current_sense_1 / 13.5;
  current_sense_2 = current_sense_2 / 13.5;

  // if either Ampere value is above the threshold, stop both motors for 1 second
  if (current_sense_1 > current_limit || current_sense_2 > current_limit){
    m1_stop();
m2_stop();
    digitalWrite(ledPin2, HIGH);
    delay(cool_off);
    digitalWrite(ledPin2, LOW);
  }
}
// End current_sense function





// Begin pulse() function
void pulse(){

  // read servo1 pulse from ELE
  servo1_val = pulseIn(ppm1, HIGH, 20000);
    // check to make sure it is valid
  if (servo1_val > 800 && servo1_val < 2200){
    // then adjust it to a −255 to 255 value range for speed and direction
    adj_val1 = map(servo1_val, 1000, 2000, -speed_limit, speed_limit);
    x = constrain(adj_val1, -speed_limit, speed_limit);
  }
  else {
    // if the pulse is not valid, set it equal to 0
    x = 0;
  }

  // read servo1 pulse from ELE
  servo2_val = pulseIn(ppm2, HIGH, 20000);
  // check to make sure it is valid
  if (servo2_val > 800 && servo2_val < 2200){
    // then adjust it to a −255 to 255 value range for speed and direction
    adj_val2= map(servo2_val, 1000, 2000, -speed_limit, speed_limit);
    y = constrain(adj_val2, -speed_limit, speed_limit);
  }
  else {
  // if the pulse is not valid, set it equal to 0
    y = 0;
  }

  servo3_val = pulseIn(ppm3, HIGH, 20000);
  if (servo3_val > 1600){
    speed_limit = 255;
  }
  else{
    speed_limit = 128;
  }
}
// End pulse() function
// Begin test() function
int test() {

  // make sure we don't try to write any invalid PWM values to the h-bridge, ie. above 255 or
below 0.
  if (left > 254) {
    left = 255;
  }
  if (left < 1) {
    left = 0;
  }
  if (right > 254) {
    right = 255;
  }
  if (right < 1) {
    right = 0;
  }
}
// End test() function



// Create single instances for each motor direction, so we don't accidentally write a shoot-
through condition to the H-bridge.
void m1_forward(int m1_speed){
  digitalWrite(motor1_AHI, LOW);
  digitalWrite(motor1_BLI, LOW);
  digitalWrite(motor1_BHI, HIGH);
  analogWrite(motor1_ALI, m1_speed);
  digitalWrite(ledPin1, LOW);
}

void m1_reverse(int m1_speed){
  digitalWrite(motor1_BHI, LOW);
  digitalWrite(motor1_ALI, LOW);
  digitalWrite(motor1_AHI, HIGH);
  analogWrite(motor1_BLI, m1_speed);
  digitalWrite(ledPin1, LOW);
}

void m2_forward(int m2_speed){
  digitalWrite(motor2_AHI, LOW);
  digitalWrite(motor2_BLI, LOW);
  digitalWrite(motor2_BHI, HIGH);
  analogWrite(motor2_ALI, m2_speed);
  digitalWrite(ledPin1, LOW);
}
void m2_reverse(int m2_speed){
  digitalWrite(motor2_BHI, LOW);
  digitalWrite(motor2_ALI, LOW);
  digitalWrite(motor2_AHI, HIGH);
  analogWrite(motor2_BLI, m2_speed);
  digitalWrite(ledPin1, LOW);
}

void m1_stop(){
  digitalWrite(motor1_BHI, LOW);
  digitalWrite(motor1_ALI, LOW);
  digitalWrite(motor1_AHI, LOW);
  digitalWrite(motor1_BLI, LOW);
  digitalWrite(ledPin1, HIGH);
}

void m2_stop(){
  digitalWrite(motor2_BHI, LOW);
  digitalWrite(motor2_ALI, LOW);
  digitalWrite(motor2_AHI, LOW);
  digitalWrite(motor2_BLI, LOW);
  digitalWrite(ledPin1, HIGH);
}
// End motor functions

This code uses two channels from an R/C receiver to control the direction and speed of the Explorer-bot, using a home made motor controller. Because I used an R/C transmitter with at least four usable control channels, I decided to designate the left transmitter control stick to operate the pan/tilt camera system, and the right transmitter control stick controls the speed and direction of the robot.

Though there are servo motors used in this project, they are not controlled using the Arduino. Instead, they connect directly to the R/C receiver, which alleviates the extra processing power that would be required by the Arduino to process those signals.

I installed two separate power toggle switches, one for the Arduino and the other for the motor controller. This way I can troubleshoot the Arduino without the motors being active. These switches were mounted to the plexiglass deck. When you are comfortable that each input is connected properly, power on the Arduino, waiting to power the motor controller until the R/C receiver LED turns on (verifying a connection). When connected, you can power on the motor controller and give the bot a thorough testing around the yard.

You can use this bot with different code in Chapter 10: Lawn-bot 400, utilizing the 2.4gHz wireless serial connection from the Xbee radios.

Summary

In this chapter you built a powerful motor controller with built-in current sensing to power a large outdoor robot equipped with an audio/video link, remote radio control, and telemetry for wirelessly monitoring the robot's Arduino. This robot required a steel frame, large (power wheelchair) DC gear motors, and a 2.4GHz radio control system capable of reliable and long distance signal transmission.

The purpose of this robot is still undetermined; although it is extremely fun to play with. You could use the Explorer-bot as a security robot to patrol dark, cold, or otherwise undesirable locations remotely, or just as an excuse to play with a neat robot. I have been known to attach a small chair to the top of this robot (see Figure 8-23 for a view of the potential chair-riding platform), which immediately converts it into a children's (or feline) taxi service.... Just don't let the children drive themselves!

In the next chapter, you head to the open sea with the GPS guided Roboboat. This project focuses on guiding a catamaran style boat around a lake, using a GPS sensor and an Arduino variant designed specifically for integration with hobby R/C products.

The Explorer-Bot ready for action.

Figure 8.23. The Explorer-Bot ready for action.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset