Chapter 10. Lawn-Bot 400

Until now, each robot presented has been intended for educational, research, and testing purposes. This robot fuses learning and playing, with actually getting something done.

Simply put, the Lawn-bot 400 (Figure 10-1) is a remotely controlled yard helper.

The completed Lawn-bot400, working in the backyard

Figure 10.1. The completed Lawn-bot400, working in the backyard

Note

Why the Lawn-bot 400? Well, I didn't like the first 399 prototypes. Actually, the 400 was simply added to the end of Lawn-bot as a joke to make it sound more important.

I have always enjoyed being outside, but never pushing a lawnmower around the yard. So to avoid the tedious task of having to walk around my backyard for 2 hours every few weeks, getting hit by rocks and sticks, and breathing in a cloud of dust and pollen, I decided to make a robot to push my lawnmower around the yard for me. All that was needed was something strong enough to push the lawnmower deck, which could be controlled wirelessly.

You start by building the frame of the robot and then select and install the electronic components. First see how the Lawn-bot works.

How the Lawn-bot 400 Works

The Lawn-bot 400 works like a larger version of the Explorer-bot in Chapter 8, "Boat-Bot," using two powerful DC gear motors salvaged from a power wheelchair, a sturdy metal frame, and a 2.4GHz R/C link. This robot is different because it has a gas-powered lawnmower hanging from its frame, a remotely operated dump-truck bucket on top, outdoor pneumatic tires, and a set of high-power headlights to provide light if operating at night.

Because this robot is intended to be a workhorse, it should be outfitted accordingly. With motors easily capable of carrying a person, enough battery power to last several hours, and a motor controller that has built-in over-current protection, the Lawn-bot should handle anything you throw at it.

The Lawn-bot 400 uses two drive motors (left and right) to propel the robot forward or reverse with varying speeds. By changing how much power is applied to each drive wheel, the bot can be turned with great accuracy. The R/C transmitter control sticks determine how fast and in what direction each motor spins (see Figure 10-2).

This image shows the control scheme for the Lawn-bot 400. The left transmitter control stick commands the left motor (forward or reverse) and the right control stick commands the right motor.

Figure 10.2. This image shows the control scheme for the Lawn-bot 400. The left transmitter control stick commands the left motor (forward or reverse) and the right control stick commands the right motor.

By moving the left control stick upward, the left motor spins forward with proportional speed-moving the same control stick downward spins the left motor in reverse. To make the robot drive forward, you must apply equal power to both motors in the same direction; to turn left or right, decrease the power to the motor whose direction you want to turn. This type of drive enables zero-turn radius; if one motor is driven forward and the other in reverse, the robot begins to turn a complete circle in place (without moving forward or reverse).

Following are a few specific features of the Lawn-bot required to help it complete its tasks.

Lawn Mower Deck

The Lawn-bot can cut grass using a gasoline lawnmower that is hanging from the robot frame. To operate the mower, simply pull the starting cable to crank the engine, then activate the motors using the R/C transmitter to direct the lawnmower anywhere that you want to cut the grass. If you miss a spot, turn it around! You will amazed at how little energy you exert while driving the Lawn-bot. The gas-powered lawnmower does not affect the capability of the Lawn-bot to drive; the drive motors are electric and have no operational dependency on the mower deck.

High-Capacity Batteries

The Explorer-bot from Chapter 8 used high-power DC gear motors to drive the frame, but it did not weigh nearly as much as the Lawn-bot, so we used small SLA batteries with decent run time. The Lawn-bot is heavy and would drain a small set of SLA batteries in a matter of minutes.

To make sure you have enough battery power to finish an entire yard, you need a set of large, deep-cycle lead acid batteries. This type of battery is usually reserved for use in boats and RVs to power trolling motors, radios, pumps, and lights, and can be discharged/recharged many times. Do not attempt to use a starting type battery because these are not meant to be fully discharged and are likely to fail if drained below a certain point. The batteries that I used were Everlast Marine deep-cycle, rated at 12v and 80AH. This battery pack provides enough power to drive the Lawn-bot continuously for approximately 3 to 6 hours, depending on the terrain.

Steel Frame

The frame on this robot needs to be made to take a beating. This rolling cage made from 2-inch wide angle-iron can be driven through heavy grass, mud, over rocks, and even through heavily wooded areas without any problems. The rugged steel frame is the backbone of the Lawn-bot, providing the strength it needs to power through most outdoor conditions. You can use bolts to hold each frame piece together, needing only a drill to make holes and a saw to make cuts. A small welding machine can strengthen connections after each piece is verified to fit, but is not necessary.

Dump-Bucket

After seeing how well the Lawn-bot mowed the grass, I began to think of other uses for it. One of the first seemed to be when my wife asked me to help her carry a few bags of potting soil to the other end of the yard, each one weighing about 50 lbs. As it turns out, the Lawn-bot can carry 150 lbs of potting soil with no problem, which gave me an idea.

To transport dirt, rocks, soil, tools, or anything else that I didn't feel like carrying, I mounted a tilting wheel-barrow bucket to the top of the robot using two gate hinges. And of course, to keep from having to lift the bucket manually I installed a 24v linear actuator (lift motor) to dump the contents of the bucket with the push of a button.

Pneumatic Tires

This is the first robot to use heavy-duty pneumatic (air) tires. Most push-type lawnmowers come equipped with small plastic wheels that provide little traction and cannot work for the Lawn-bot. Pneumatic tires provide much better traction than solid rubber or plastic wheels, and provide a cushion to absorb shocks and jolts caused by rough terrain. For the front use heavy duty 10-inch caster wheels, and for the rear, use 13-inch heavy-duty utility wheels, each rated for 300-lb load capacity. Each rear wheel must be fitted with a sprocket and a chain that connects it to a smaller sprocket on the motor output shaft.

Headlights

If you happen to mow grass at night, this robot even has two adjustable headlights that can be activated from the R/C transmitter. By adding two 55W halogen automotive fog lights to the front of the frame and a simple relay interface switch, you can illuminate anything that happens to be in front of the Lawn-bot. These lights are also handy to have around when a project leads you outside at night; just drive the Lawn-bot near your project and turn on the super bright lights. Using only the headlights, one of the batteries should have enough power to keep them lit for at least 8 hours!

Failsafe

Now, if you think that an unmanned lawnmower sounds dangerous, you might be right; that's why you also need to include a mandatory remote failsafe switch that can disconnect all power to the motors in case of an emergency or signal loss. The main function of the Arduino in this project is to monitor a third failsafe R/C channel for a valid signal. If the signal is lost at any time, or the operator activates the failsafe switch on the R/C transmitter, the Arduino is programmed to immediately remove all power to the motor controller, thereby disabling the robot. The failsafe is turned off by default, so the only way to activate the robot is to provide the Arduino with a specific R/C signal. By using a separate circuit to control the failsafe, there is little chance that the robot can get out of control.

Tools and Parts List

You can design your Lawn-bot in several ways, depending on what you intend to do with it. Some lawnmowers have built-in caster wheels on the front and might require replacing only the rear lawnmower wheels with two wheelchair motors. For this reason, I will not say that you must have a specific type of frame because it may be easier for you to make minor modifications. But in most cases it will be easier to build a frame around the mower deck to provide a safe mounting place for the batteries and electronics.

Lawnmower

No matter how you plan to build your Lawn-bot, it needs a lawnmower to cut grass. One of the neat things about this project is that you reuse a standard, old push mower-and nearly any push mower can work. I picked up a used Weed-eater brand 22-inch lawnmower from a small-engine repair shop for about $60 and used it for 2 years before converting it into the Lawn-bot 400. If you don't already own a working push mower, you need to get one before continuing.

If you simply plan to cut grass, you might want to focus on building the smallest frame possible to reduce weight, thereby extending battery run time and reducing the current draw from the motors. I wanted a multipurpose bot that would not only cut my grass, but also carry materials and soil, which requires a sturdy metal frame. There are many possibilities and options when building a Lawn-bot; you should build what works best for you.

Parts Lists

The parts list for this project is extensive, and because you may not find the exact parts that I used (or you may find something better), minor adjustments may be needed to fit part availability and your unique design.

Because several different sections of the Lawn-bot could be independently replaced and the rest of the bot left alone, I decided to place individual parts lists at the beginning of each corresponding section. There are, however, several tools that can make this project quite a bit easier, which are listed in Table 10-1.

Table 10.1. Lawn-Bot Tools List

Tool

Use

Price

Drill

Drilling holes in metal. I used an 18v cordless Ryobi drill.

$20 to $75

Drill bits: ⅛-inch, ¼-inch, 3/8-inch, ½-inch, and 5/8-inch

Small bits for pilot holes, other bits need to be the size of the bolts you use.

Assorted pack $10 to $15

Tape measure

You need to measure metal pieces to cut and space holes to drill.

$5.00

Hacksaw or reciprocating saw (with metal cutting blades)

Cutting angle-iron and other metal frame pieces, go for the power saw if you can afford it. Angle-grinders work, too.

$5 for hand saw, $50 for power saw

Wrench and/or assorted socket set

Used to tighten nuts and bolts together.

$5 to $20

Welder (optional but handy)

I use a 110v wire-feed welder to weld small joints and permanent pieces on the frame.

$60 to $150 (optional)

Dremel rotary tool with metal cutoff discs

Used to cut channels in the frame rails.

$40.00

Zip ties

Holding wires secure.

$3.00

Hammer

Can be helpful.

$3.00

Three main parts to the frame are covered separately and in the same order as the frame is built. First, select the wheels, then start cutting and assembling the main frame pieces, and finally install both drive motors and connect the chains to each drive wheel. After the frame is completed, move to installing the electronics.

The Wheels

The wheels are an important part of the Lawn-bot because they determine how much traction it has and how much weight it can handle. I chose to use pneumatic tires for both the front caster wheels and the rear drive wheels to provide a smoother ride, more traction, and a higher load capacity than solid core wheels.

I have always had good luck finding wheels for robotics projects at Harbor Freight tools stores; the 13-inch drive wheels were around $13 each, and the front caster wheels were around $16 each (see Table 10-2 and Figure 10-3).

Table 10.2. Parts Needed for the Wheels and Sprockets

Part

Description

Price

Rear wheels: 13-inch diameter x 4-inch width pneumatic tire/wheel (×2)

Harbor Freight Tools part # 67467

$13.99 each

Front wheels: 10-inch x 4-inch width, with 360-degree caster assembly pneumatic caster wheel (X2)

Harbor Freight Tools part # 38944

$16.99 each

Motor sprockets (×2)

#25, 17 teeth, ½-inch slotted bore Goldmine-elec.com part # G13610

$1.50 each (×2)

Wheel sprockets (×2)

#25, 55 tooth

PartsForScooters.com part # 127-9

$17 each (×2)

Woodruff key for motor shaft (×2)

Multipack from an automotive store

$5 (variety pack)

Front Caster Wheels

The front caster wheels are 10-inch in diameter, with a total mounting height of around 13-inch including the mounting plate (see Figure 10-3, left). Each caster wheel has a caster bracket with 360-degree turn radius, enabling the wheel to move freely in any direction. Make sure that the front wheels are spaced far enough apart that they do not hit each other when turning.

Rear Drive Wheels

The rear wheels are 13-inch in diameter but mount to an axle instead of a caster bracket (see Figure 10-3, right). So the mounting height for the rear axle is equal to the radius of the wheel, which is 6.5-inch (13 inch / 2 = 6.5 inch). You must use two rear frame riser pieces to bridge the gap between the 6.5-inch rear axle mounting height and the 13-inch front caster wheel mounting height. The bearings used for mounting the wheel to the axle have a 5/8-inch hole, meaning this wheel needs a 5/8-inch threaded rod (axle) to mount to.

The front caster wheel and rear drive wheel from Harbor Freight Tools

Figure 10.3. The front caster wheel and rear drive wheel from Harbor Freight Tools

You can use whatever size wheels/tires you can find, though I would recommend using pneumatic tires for outdoor robots because they absorb much of the bumpy ride, which helps protect the electronics. After I was ready to put the finishing touches on the Lawn-bot and start using it full time, I took the rear wheels off, squirted as much packing grease into the center hub of the wheel as would fit, before remounting them to the Lawn-bot, which can keep the rear-wheel bearings from locking up.

Note

Remember when building your frame that the caster wheels swivel in a complete circle. You should take care to ensure that nothing on your frame interferes with the complete rotation of either caster wheel.

Now install the sprockets to the main drive wheels and the motor output shafts. These connect together using a chain to transmit the power from the motors to the wheels.

Installing Sprockets

There are two different types of sprockets used on this bot. The smaller sprockets have 17 teeth and are mounted directly to the motor output shaft. This sprocket has the same size bore (mounting hole) as the motor output shaft, and has a slotted keyway (using a Woodruff key) to keep the motor shaft and sprocket from slipping.

Install the smaller motor sprocket by placing the Woodruff key onto the motor output shaft and sliding the smaller sprocket onto the shaft with the Woodruff key sliding through the slotted bore of the sprocket. When in place, use a small hex wrench (Allen wrench) to tighten the set screw on the sprocket to lock the Woodruff key into place.

The larger sprockets have 55 teeth and are mounted directly to the rear wheels using three bolts (¼-inch diameter, 4-inch long) to hold each securely. I paid about $2 each for the smaller sprockets and $16 each for the larger ones (see Figure 10-4). Both sets of sprockets are intended for use with #25 chain.

The two different sized sprockets used on each side of the Lawn-bot

Figure 10.4. The two different sized sprockets used on each side of the Lawn-bot

Now secure the large sprockets to the rear-drive wheels. The following three steps guide you through this process.

  1. Prepare the rear sprockets. Start by inserting each bolt through the sprocket mounting holes, and use one nut on each bolt to tighten them securely to the sprocket. When tightened, loosely thread one more nut about 1 inch onto each bolt.

  2. Mount sprockets. Next, place the new sprocket/bolt assembly onto the center of the wheel, and mark the spot where each bolt touches the wheel. Drill ¼-inch holes at each mark, making sure the center of the sprocket aligns to the center of the wheel hub. If it is not centered, the wheel cannot spin in a perfect circle, which can cause the chain to break.

    Note

    Make sure the sprocket is centered on the wheel hub before you secure it down to the wheel.

  3. Secure sprocket to wheel. Slide the three bolts through the holes in the wheel, flip the wheel over, and thread the last nut onto each bolt, securing tightly. Then, use the second nuts that are loosely threaded between the wheel and sprocket to serve as a backing nuts, giving the third (and final) nuts something to tighten up against (See Figure 10-5).

The rear wheel with sprocket installed

Figure 10.5. The rear wheel with sprocket installed

When you have both of the larger sprockets secured to the rear wheels, you can build the frame. In the next section, assemble the frame pieces needed to mount the wheels.

The Frame

The frame is mostly composed of steel pieces bolted together to make a metal cage around the mower deck. The interior of the frame must be large enough to accommodate for the lawnmower deck that you use, so each frame measurement should be taken specifically for your lawnmower.

The frame connects the drive wheels, motors, lawnmower, and front caster wheels together to provide a solid platform, so care should be taken to make sure every bolt is tight and each piece fits together securely. Any weak spots in your frame will be apparent when mowing your lawn. It is better to plan ahead than to spend a Saturday fixing your Lawn-bot instead of using it.

Before starting to build the frame, take a brief look at the parts list in Table 10-3.

Table 10.3. Parts List for the Frame

Part

Description

Price

2-inch angle-iron

Three 48-inch long pieces, main frame rails (A), one rear cross-bracket (B), and two frame riser bars (E).

$8.00 each

1-inch square steel tubing

One 48-inch long piece, two front cross-brackets used to mount front caster wheels.

$4.00

1-inch steel flat bar

One 48-inch long piece, support braces.

$3.00

5/8-inch threaded rod

One 36-inch long piece, used for the rear axle. Also need six 5/8-inch nuts.

$10.00

Twenty-four 3/8-inch nuts, bolts, flat washers, and lock washers

Get twice as many flat washers as everything else; you might need one on each side of the bolts.

$10.00

Two Deep-cycle marine batteries

Automotive store: I used two batteries in series, rated for 12v, 80AH each = to produce 24v, 80AH total.

$62 each

The complete rolling frame from the Lawn-bot 400 can be assembled using only ten frame pieces. The frame height was decided by the height of the front caster wheels that I chose, which can be different to fit your project.

Figure 10-6 shows the ten main pieces of the frame, which are grouped together by color; pieces that are the same color/letter should be cut the same length.

The various pieces needed to construct the frame

Figure 10.6. The various pieces needed to construct the frame

Following is a listing of each part of the frame and how each piece should be cut.

  • A (•2) – Blue = 2 main frame rails: 2-inch angle-iron, 48-inch long each

  • B (•3) – Green = 3 cross-brackets: 2 front are 1-inch square tubing, 1 rear is 2-inch angle-iron, 20″ long each.

  • C (•2) – Red = 2 support braces: 1-inch flat steel bar, 10-inch long each

  • D (•1) – Yellow = rear drive axle: 5/8-inch Threaded rod, 36-inch long

  • E (•2) – Black = frame riser bars: 2-inch angle-iron, 8-inch long each

The two main frame rails (A) are the long pieces that span from the rear of the bot to the front. The three cross-brackets (B) are mounted to the two main frame rails (A) on both ends. The front cross-brackets are then mounted to the front caster wheels. The rear frame risers (E) keep the main frame rails level even though the axle (D) is about 12 inches below the top of the frame; these should be measured to fit your frame. The two support braces (C) keep the frame risers securely in place. Figure 10-7 shows a picture of the assembled Lawn-bot, to physically place the parts from the illustration in Figure 10-6.

The axle and frame support bar

Figure 10.7. The axle and frame support bar

The frame riser bars are not visible because the rear wheels cover them up, but the rest of the pieces can be seen in Figure 10-7. The diagram is for the frame only; it does not include the mower deck that is shown next. These measurements are not rocket science and can be slightly off and still work just fine. The key to building the frame is to get into the mindset to make it work and work around any problems you encounter. If you drill a hole in the wrong place, don't worry about it; just drill a new one in the right place and keep moving. This will be your prototype, so it does not have to be perfect.

If you use a 22-inch lawnmower deck, your basic frame without wheels, batteries, or accessories will be around 46-inch long x 20-inch wide x 13-inch tall (my Lawn-bot dimensions). With the battery rack mounted to the rear, the wheel barrow bucket mounted to the top, and the wheels mounted, my Lawn-bot measures in a bit larger at 52-inch long x 30-inch wide x 26-inch″ tall.

The following 11 steps guide you through cutting each piece of metal and assembling the frame:

  1. Cut the two main frame rails (A) using a 2-inch angle iron. Depending on the size of your frame, you may not have to cut these; you can buy 36-inch or 48-inch long pieces from the hardware store, which might work nicely. I used 48-inch pieces for these frame rails.

  2. Cut the three cross-brackets (B). The rear bracket should be 2-inch angle iron and the two front brackets should be 1-inch square tubing. These three pieces should all be cut the same length to ensure that the bot is square. For my 22-inch lawnmower deck, the width to provide adequate clearance turned out to be 20-inch, which may be slightly different depending on your specific lawnmower design.

  3. Bolt the rear cross-bracket (2-inch angle-iron) to the ends of the two main frame rails. You need to drill a hole on each end through both the cross-bracket and the main frame rails to secure them together. Line the cross-bracket flush with the bottom of the main frame rails.

  4. Mount the front cross-brackets (1-inch square tubing) with caster wheels to the front of the main frame pieces. Drill one hole on each end of the cross-brackets and through the front of the main frame rails (see Figure 10-8).

    The main frame rails connected to the front caster wheel support braces

    Figure 10.8. The main frame rails connected to the front caster wheel support braces

  5. Cut the frame riser pieces. Measure the height of your caster wheels; now subtract the radius of the rear wheel and add 1 inch. The extra inch is to provide some room to drill a mounting hole; my frame riser bars were cut to 8-inch each.

  6. Mount the frame riser pieces. I drilled one hole at the top of each frame riser piece to bolt them into the main frame rails. When tightened, you can notice that the frame risers pivot without much force. To keep them in place, you need a support brace on each side of the frame, connecting the bottom portion of each frame riser to the main frame rails at another spot. This creates a triangle that when bolted no longer enables the rear frame riser pieces to pivot. These pieces do not have to be the exact same length because they simply hold the frame risers in place (see Figure 10-9).

    The support brace from the frame riser to the main frame rails

    Figure 10.9. The support brace from the frame riser to the main frame rails

  7. Mount the rear drive axle. I used a 5/8-inch diameter threaded rod (36-inches long) to serve as the rear axle. You need four 5/8-inch nuts to mount the axle to the frame and two more nuts to hold the rear wheels onto the axle when installed. To mount the axle, drill a 5/8-inch hole at the bottom of each frame riser piece, centered 1 inch from the bottom of each frame riser.

Slide the threaded rod through the hole on one side; then thread two of the nuts onto the end of the rod. These two nuts should fit securely to the insides of the frame risers. When the two inside nuts are threaded toward the center of the rod, continue sliding the rod through the other axle hole on the other frame riser piece.

Now thread two more nuts on the rod, one on each side. Tighten the two nuts on each side securely to each frame riser piece.

Make sure you have approximately the same amount of excess threaded rod sticking out of each side of the frame; you can cut the excess from this threaded rod with a hacksaw when the wheels are mounted later.

  1. Test fit rear wheels and check the top of the frame to make sure it is level. With the 10 frame pieces mounted together and the front caster wheels attached, you can slide the rear wheels onto the rear axle to make sure your measurements are correct and that the top of the frame is level (see Figure 10-10).

    The completed frame

    Figure 10.10. The completed frame

  2. Tighten all the bolts. After you decide that the frame is straight, you can go back and tighten each nut/bolt to secure the frame together tightly. I used 3/8-inch diameter bolts (ranging from 1-inch to 2-inch long) for most of the frame, occasionally using ¼-inch diameter bolts for less important pieces. You should now have a rolling frame capable of carrying several hundred pounds.

  3. Attach the mower deck. The mower deck needs only four pieces of metal to hang from the main frame rails of the Lawn-bot. The length of these four mower-deck hanger pieces is determined by the distance from the vertical center of the main frame rails, down to the ground, minus the radius of the old lawnmower wheels.

Example: My frame rails measured 13 inches from center to ground. My old mower wheels had a 4-inch radius, so I made my four mower-deck hangers 9 inches long using 1-inch square tubing (13-inch – 4-inch = 9-inch).

Test fit the mower deck to make sure there is adequate clearance around the frame, specifically the front caster wheels with full swing and the rear tire clearance (see Figure 10-11).

The Lawn-bot with mower deck attached by four metal hanger pieces

Figure 10.11. The Lawn-bot with mower deck attached by four metal hanger pieces

  1. Lastly, add a small rack to the rear of the frame to hold the large deep-cycle batteries. This cage can be made from scrap metal or what you have left over from the frame. Just measure the batteries to make sure the rack is large enough to hold them at the base, and use two hangers to tie the rack to the top of the frame. I used a welder to secure these joints (see Figure 10-12).

    The battery rack on the rear of the Lawn-bot frame

    Figure 10.12. The battery rack on the rear of the Lawn-bot frame

With the frame completed, mount the motors and connect the chain and sprockets for the drive-train.

The Drive-Train

The drive-train on this bot is slightly more complicated than my other bots, using a chain and sprockets to transmit power from the motors to the wheels. Typically, it is easier to use wheelchair motors that already have the wheels mounted to them (as we did with the Explorer-bot in Chapter 8) because this not only removes an extra building step but is also far more reliable than using chain and sprockets. Nonetheless, we discuss how to set up a chain/sprocket drive-train just in case you cannot find motors with premounted wheels.

The drive-train that I built uses #25 roller chain and #25 sprockets. The sprockets must be the same size (#25) as the chain, or the sprocket teeth will not mate properly to the chain links. Before starting, take a look at the parts list for the drive-train in Table 10-4.

Table 10.4. Parts List for the Drive-Train

Part

Description

Price

Two DC gear motors

Ebay.com: I used power wheelchair gear motors like the ones used in Chapter 8.

$75 set

2-inch angle-iron

Hardware store: You need 16-inch total, cut in half for the motor mount brackets.

$4.00

Eight ¼-inch bolts: flat topped, ¾-inch long with nuts and lock-washers

Hardware store: These are used for securing the motors to the motor mounts.

$2.00

10 feet #25 roller chain

Allelectronics.com part # CHN-25.

$2.50/foot (×4)

Universal chain links (2x) ElectricScooterParts.com part # $1 each

CHN-25ML: These enable you to fix or resize a chain.

Start by making a mounting bracket for each motor; mount the sprockets to each wheel and motor output shaft, and cut and install each drive chain. Make some brackets to mount the motors to so that you can adjust the position of each motor, which is how you can adjust the tension of each chain.

Motor Mount Brackets

When using separate motors and wheels, you must find some way to transfer the power from the motor output shaft to the wheel drive sprockets. I chose to mount a set of sprockets to the motors and wheels and use a chain to connect them. The problem that arises when using a chain to transmit power is finding the proper tension that is not too tight or too loose because either can cause problems when operating. To get proper tension, you need a tensioning mechanism that enables you to adjust each chain until it is correct; this is where the motor mount brackets come in.

To adjust the tension of each chain, I had to make two motor mount brackets. These are nothing more than a piece of 2-inch angle-iron about 8 inches long (each). The motors mount to these brackets using four small bolts (see Figure 10-13), and the brackets bolt into some specially cut holes in the main frame rails. By cutting two "channels" in the top of the frame rails, the motor mount brackets can slide forward or backward when the bolts are loosened.

The motor mounting plate with ¼-inch bolts

Figure 10.13. The motor mounting plate with ¼-inch bolts

The following four steps guide you through making each motor mount bracket.

  1. Measure and cut (2) pieces of 2-inch angle-iron, 8-inch long each.

In Figure 10-10, you can see the power wheelchair motor, the 8-inch long motor mount bracket with holes drilled, and the small bolts/washers/nuts to secure the motor to the motor mount bracket. The bolts have perfectly flat heads; this enables the bottom of the motor mount bracket to sit flush on the main frame rails when mounted.

  1. Mount motors to the brackets. To do this, you need to mark and drill six holes in each bracket. The four center holes should be ¼-inch in diameter and secure the motor to the bracket, whereas the two outer holes will be 3/8-inch and are used to secure the motor mount bracket to the main frame rails.

First, place one of your motors onto the center of each bracket, and mark the mounting holes for each motor onto the motor mount bracket. Next, mark one hole (centered) on each end of the motor mount pieces, about 1-inch from each end of the bracket; these secure the motor mount brackets to the frame.

Lastly, drill the mounting holes into the motor mount piece, and secure the motor to the motor mount using four flat-topped bolts. My motors have four ¼-inch threaded mounting holes on each gear box.

When finished, the motor mount bracket with DC motor attached should look like Figure 10-14.

The motor secured to the motor mounting plate

Figure 10.14. The motor secured to the motor mounting plate

  1. Cut motor mount bracket mounting holes. With the motors secured to the motor mounts, make grooves in the main frame rails for the motor mounts. These grooves enable the bolts holding the motor mount to the frame rails to slide along the frame rails so that you can adjust the tension of the drive chains.

Start by placing the motors mounts (with motors mounted) onto the main frame rails. The 2-inch angle-iron motor mount bracket should sit nicely on top of the 2inch angle-iron main frame rails. Slide the motor mounts as far back as they can go toward the rear of the frame (without protruding from the rear of the frame), and mark the location of both mounting holes (onto the main frame rails) with a permanent marker or pencil. These marks will be the rearmost position of the motor mount bracket. Next, slide the motor mount bracket forward 2 inches, and mark both holes again with a permanent marker or pencil.

Drill 3/8-inch holes at both sets of marks; then draw a line between the tops and the bottoms of each set of holes. Use a Dremel rotary tool with a metal cutoff wheel to cut these two lines, thereby making two channels the size of the drill bit. When you finish cutting out the center of each channel with the Dremel tool, you should slide the 3/8-inch drill bit back and forth through the channel without resistance.

Figure 10-15 shows the two motor mount bracket mounting holes after drilling and cutting out the metal between them with a Dremel tool. You should be left with two grooves: 3/8-inch wide and 2-inch long each.

The motor mount bracket holes cut into the main frame rails

Figure 10.15. The motor mount bracket holes cut into the main frame rails

  1. Secure motor mount brackets to the main frame rails. You need two 3/8-inch bolts, four regular washers, and two lock washers to mount each motor to the frame.

Place the motor assembly onto the main frame rail, and use the two bolts to secure the motor mount to the main frame. Place one washer on each bolt before placing it through the motor mount bracket mounting hole and then another washer beneath the main frame rail on each bolt. Finally put a lock washer and nut on the end of the bolt and secure only hand-tight because later you need to install the chain and adjust the tension.

To verify that your motor mount bracket works, slide it forward and backward to make sure it moves. The bracket should move forward about 2 inches (the length of the mounting hole channels). Figure 10-16 shows the complete motor mount assembly, mounted to the main frame rails with the two silver bolts holding the motor mount bracket to the frame.

The motor mount secured to the main frame rail using two bolts

Figure 10.16. The motor mount secured to the main frame rail using two bolts

Note

Although I installed my motors "pointing" toward the rear of the bot, this makes no difference in function. I tried mounting the motors both ways and liked the backward look better.

With the motors secured to the frame, all that you need to do to complete the drive-train is to cut and install the chain for each motor.

Installing the Chain

In Figure 10-17, you can see one of the chains used on the Lawn-bot (you need two of these), along with a universal (master) chain link used to adjust the length of the chain if it needs to be resized. I purchased a 10-foot section of this chain for about $25 and the universal chain links are about $1 each; get plenty of these because they are also handy to repair a broken chain.

Each drive chain should be approximately 28-inches long and requires a master link to connect each cut end.

Figure 10.17. Each drive chain should be approximately 28-inches long and requires a master link to connect each cut end.

After you place each motor bracket to its center position, you should wrap the chain around both sprockets and use a black permanent marker to mark the link that overlaps at the beginning. Now cut the chain to that length using your Dremel tool. My chains turned out to be 28-inches long each.

After cutting to length, use a universal chain link to connect the two loose ends of the chain together around the wheel sprocket. Now, gently wrap the chain around the motor sprocket, and slide the motor forward until the chain is barely tight. When the chain has about ¼-inch of play when pressed with your finger, you can tighten down the two motor mount bracket bolts to the main frame rails.

Always double-check the chain tension after securing the bolts down to the frame because they could have caused the chain to tighten or loosen from your previous check. If so, loosen the bolts and make slight adjustments until you get proper tension. When finished, your chain should look like Figure 10-18.

The motor with chain attached to both sprockets

Figure 10.18. The motor with chain attached to both sprockets

Note

I always check for proper tension by squeezing both sides of the chain about 3 inches below the motor sprocket with my index finger and thumb. If the chain gives more than ¼-inch on either side, it is too loose. If it won't give at all, it is too tight.

If you chain is too loose, it can cause unnecessary jerking on the motor sprocket, which can cause breakage of sprocket teeth. If the chain is too tight, it cannot enable any variation or stretching of the frame and will be more likely to break the chain.

After you have the chains attached, your frame should be ready to go. You can test the motor output by connecting a voltage meter to one set of motor terminal and pushing the robot around to see the motor act as a generator, producing voltage on the meter as the bot moves. Now that the building is complete, install the electronics.

The Motor Controller

For the first version of the Lawn-bot, I decided to design and build my own motor controller, which I called the Triple8. This motor controller worked well for more than a year, until one hot summer day (during heavy use), the power connector melted right off the board. I fixed the Triple8, but this made me think: if it can get hot enough to melt without me knowing, I was eventually going to break it again at some point. I then realized that if the motor controller broke, I would not keep my yard looking nice.

Because this robot is actually used quite a bit and for important household duties, I decided to buy a commercial motor controller unit that would protect itself from over-heating during use.

Buying a Motor Controller

Most commercially available motor controllers can be controlled using the Arduino, even if it is intended to work with a specific signal type. If you have never built a motor controller before or you are not confident doing repair work with a soldering iron, I recommend buying the Sabertooth 2×25 motor controller (or similar) for the main drive motors.

Sabertooth 2×25

The Sabertooth 2×25 is a dual DC motor controller made by Dimension Engineering that can handle 25amps continuously with 50-amp peaks (see Figure 10-19). The Sabertooth has a built-in microcontroller (actually the same type of chip as the Arduino, though not reprogrammable) that can accept either R/C signals, analog voltage, or serial commands, depending on the DIP switch settings. This driver also incorporates over-current protection, auto-calibration for R/C mode, and utilizes regenerative braking for more efficient stopping.

The Sabertooth 2×25 motor controller

Figure 10.19. The Sabertooth 2×25 motor controller

This motor driver automatically shuts down the power to the motors if the current level exceeds 50amps to keep from damaging the PCB and mosfets. This self-preserving limit is evident when the bot appears to have trouble climbing a steep hill or making a fast change in direction. The solution is to go slowly when climbing a hill and distribute the power between both motors evenly to keep from over-stressing either channel of the motor controller.

The Sabertooth has a 6-port DIP switch module on the corner of the PCB near the Input screw terminals. The orientation of these switches can set the Sabertooth to operate in different modes and with different options, including the battery type, input type, and control methods. These DIP switches must be set properly for the Sabertooth to work correctly. Refer to the manufacturers website for a full explanation of these switches at

http://www.dimensionengineering.com/sabertooth2×25.htm.

Use the Sabertooth in R/C mode, connecting inputs S1 and S2 to the two main drive signals from the R/C receiver, THR (left motor), and ELE (right motor). The DIP switches must be set for R/C mode, as shown in Figure 10-20.

Set the Dip switches as shown for R/C control

Figure 10.20. Set the Dip switches as shown for R/C control

Table 10-5 has a few motor controllers suitable to drive the Lawn-bot.

Table 10.5. Motor Controller Options

Motor Controller

Feature

Price

Sabertooth 2×25 (used in this chapter) www.dimensionengineering.com

Controls both motors, over-current protection, up to 24vdc 25amp, several input methods, built-in heat sink

$125.00

Pololu 24v23 CS (□2) www.pololu.com

Single motor-controller, 24vdc 23amps, current-sensor, must be driven by Arduino or other uC, requires only 1 PWM pin per motor

$63.00 (×2)

Basic Micro Robo Claw 2×25 www.basicmicro.com

Similar to Sabertooth in specs, with wheel encoder support

$125.00

Even when using a commercial motor controller, you can still add a fan or heat sink to help dissipate more heat. Doing so can increase the maximum amperage limit of the motor controller.

Cooling Fans

The easiest way to optimize any motor controller is to add a cooling fan to dissipate heat. Because these are relatively cheap ($2 each), it makes sense to plan to install one above any motor controller that will be used continuously for any length of time. I typically use an 80mm PC cooling fan (see Figure 10-21).

The typical case fan spins at 2000 to 3000RPM and only consumes about 150mA at 12vdc. I usually connect these directly to the motor controller's +24v and GND power supply from the main batteries. This causes the fan to run at twice the intended voltage, thereby doubling both the RPM and the current consumption (approximately). The downside is that the fans may not last as long as if they were run at 12v. They do provide much better cooling for the motor controller at 24v, and I have had to replace only one fan in more than a year of use-so it is worth it to me.

A standard 80mm PC cooling fan works perfectly to remove heat from a motor controller.

Figure 10.21. A standard 80mm PC cooling fan works perfectly to remove heat from a motor controller.

Motor Controller feedback

When using my first few home-made motor controllers, I would periodically drive the Lawn-bot back to me so that I could put my finger on the back of the mosfets to see if they were too hot (despite having a cooling fan mounted directly above them). This was the only way I could get some feedback to see if I needed to park it for a few minutes to let everything cool down.

To look cool while mowing your grass, you probably don't want to stop to check your mosfets every 15 minutes, and you certainly don't want to burn up your motor controller if you forget. The answer is to let the Arduino monitor the motor's current for you, but to do that you need a current sensor. Each of the motor controllers in Table 10-2 has a built-in current sensor to provide over-current protection-if you use a motor controller that does not have a built-in current sensor, fear not! You can use an external current sensor breakout board to monitor your motor controllers using the Arduino.

Current sensor IC

The ACS714 bidirectional +/− 30amp current sensor (used in Chapter 8) can be used for larger robots like the Lawn-bot to measure the amperage going through the motor controller circuit. Pololu.com sells a breakout board with this chip installed that enables you to simply place it in series with one of the motor terminal wires, between the motor controller and motor (see Figure 10-22). You can then connect each sensor to the Arduino into one of the Analog input pins to read the current level as an Analog voltage.

The Pololu ACS-714, +/−30A current sensor IC (item# 1187)

Figure 10.22. The Pololu ACS-714, +/−30A current sensor IC (item# 1187)

With a few lines of code, you can tell the Arduino to check this value each time the main loop is run and stop the motors if the desired limit is exceeded. This way the Arduino looks out for the motor controller constantly to make sure it is not over-stressing itself. This feedback method is an effective way to protect your motor controller from overheating and burning a PCB trace or switching component.

Now that you have the motor controller selected, you need to add an Arduino to control everything else on the robot, including the failsafe, headlights, and dump bucket.

The Arduino

The Arduino in this project can decode several R/C signals to control the Failsafe and any accessories you might have on your bot, such as headlights, a lawnmower kill-switch, or a lift motor for a dump-bucket attachment.

I started with two Arduino boards on my Lawn-bot, using one to decode the R/C signals for the main drive motors, and the other Arduino to decode the remaining channels for the accessories. After switching to the Sabertooth 2×25 as the motor controller for the Lawn-bot, I now use only one Arduino to control the Failsafe and all other accessories, leaving the decoding of the motor control signals to the Sabertooth. You can still use the Arduino to decode the drive signals from the R/C receiver or another control source if you want, and I provide code on this book's website for both options.

With the overhead of decoding the motor drive signals offloaded to the Sabertooth 2×25, the Arduino has less responsibility and can thus decode more R/C channels without worrying about update intervals for the motors. Under these circumstances, you can decode all available R/C channels with the Arduino using pulseIn() and control as many accessories or attachments as you want.

Securing Connections for a Bumpy Ride

This robot will be driven among some of the bumpiest and hilly terrain that you will encounter with any of your home-made robots. My Lawn-bot typically tramples through tall grass, over wooden tree branches, through brush, into the woods, and anywhere else that I don't feel like going myself. In addition to the bumps, starting the gasoline engine on the lawnmower can ensure that any bolts or wires not secured will promptly be rattled loose. For this reason, it is a good idea to make sure your Arduino has secure connections that won't come out with a few bumps and some constant vibration.

Building a Breakout Board

Alternatively, you can build your own Arduino board with screw terminals for around $10 to $15 and a little soldering. You can either etch one of the examples in this book, create your own Arduino design in Eagle, or simply use a perforated prototyping board and jumper wires from Radio Shack for an easier approach. I have done both and they work equally well; my current Lawn-bot uses an Arduino clone built on a small piece of perf-board with a screw terminal for each pin.

I prefer to build an Arduino breakout board to use on the Lawn-bot because it gets quite a bit of use and often gets dirty. I would feel bad to see my poor Arduino Duemilanove (that has taught me so much!) getting worked as hard as I work the Lawn-bot. Plus it doesn't hurt as bad if something happens to a $12 breakout board and you have to build another one.

Note

Power the R/C receiver with +5v and GND from the Arduino supply to ensure that it always has power.

In Figure 10-23, you can see my bruised and dirty Arduino breakout board on a piece of perf-board, with 0.2-inch spacing screw terminals for each pin, and an LM7805 +5v regulator (all from Radio Shack). I had to order the Atmega328, a reset button, and the 16mHz resonator from Sparkfun.com.

This breakout board is built on perforated prototyping board, using PC board screw terminals for secure connections to each wire.

Figure 10.23. This breakout board is built on perforated prototyping board, using PC board screw terminals for secure connections to each wire.

The construction of a perf-board Arduino with screw terminals is quite basic; I soldered a 28 DIL IC socket to the center of the board and 20 screw terminals to the left and right sides of the board. Each Arduino output is connected (using jumper wire) to a screw terminal on the edge of the board. There is also a 16mHz resonator for the Atmega328 chip and a +5v regulator to provide a regulated supply voltage for the Atmega chip. I placed two capacitors into the circuit, one tied to the inputs of the LM7805 and another tied to the outputs (+5v).

The screw terminals on the bottom of the board supply power from the unregulated battery supply, whereas the top screw terminal provides access to the +5v regulated supply to power the R/C receiver from the LM7805. You can add the optional reset button shown at the top of the board; although, I have never had to reset this board. (It is easier to toggle the power switch.)

Table 10-6 shows a parts list for the Arduino breakout board.

Table 10.6. Parts List for Arduino Breakout Board

Part

Description

Price

Perforated circuit board

Radio Shack part # 276-150

$2.00

28-pin DIP IC socket

Sparkfun part # PRT-07942

$1.50

7805 voltage regulator

Sparkfun part # COM-00107

$1.25

16MHz Ceramic resonator

Sparkfun part # COM-09420.

$1.00

Nine screw terminals 2-pos

Sparkfun part # PRT-08432.

$0.95 each

Two screw terminals 3-pos

Sparkfun part # PRT-08433.

$1.00 each

Reset switch

Sparkfun part # COM-00097.

$0.35

LED w/ 330 ohm resistor

Power indicator LED.

$1.00

Two capacitors – 10uf-220uf, 16v-50v

I placed two capacitors on the board for the voltage regulator.

$1.00

Wire

Radio Shack.

$3.00

If you want to build your own Arduino breakout board, use the schematic in Figure 10-24 to make proper connections. This schematic is simplistic and does not include an FTDI programming port, so you must use a standard Arduino to program the Atmega chip; then transfer it into the breakout board's IC socket. Because this is not meant to be a test vehicle, but rather a full-time lawn robot, the breakout board likely won't need reprogramming enough to warrant a programming port.

The schematic of the Atmega breakout board

Figure 10.24. The schematic of the Atmega breakout board

Because this is not a PCB but rather a prototyping board, you need to make all connections on the board using point-to-point wiring, as shown in the schematic. When you finish, your prototyping board should look similar to the one in Figure 10-25.

Detailed view of the Arduino breakout board with descriptions

Figure 10.25. Detailed view of the Arduino breakout board with descriptions

If you would rather build a PCB for the Arduino in this project, Eagle files are available for an Arduino with screw terminals at each digital I/O pin for secure connections. In addition to having screw terminals, each Analog pin is also supplied with a +5v and GND pin for easy integration with your R/C receiver. Using female to female servo plugs, you cannot only provide the Arduino with the signals from each R/C channel, but also provide +5v and GND signals to power the R/C receiver from the regulated Arduino supply.

To download the PCB files for an Arduino clone with screw terminals and other files related to this chapter, visit https://sites.google.com/site/arduinorobotics/home/chapter10.

Now you just need a failsafe to make sure you can shut this robot down if it should get out of range or out of control.

The Failsafe

This robot is large and dangerous and must have a failsafe switch installed to enable the user to remotely disable the motors. The failsafe consists of an automotive power relay (rated 60amps, 14v), a mosfet or transistor to interface the relay with the Arduino, and an extra channel on the R/C transmitter dedicated to switching the failsafe (see Table 10-7).

Table 10.7. Failsafe Parts List

Part

Description

Price

2.4GHz radio system

Spektrum DX5e transmitter and BR6000 receiver

$110.00

Perforated circuit board

Radio Shack part # 276-150: used to build relay interface circuits

$2.00

Logic-level N-channel MOSFET with 10k pull-down $1.05 resistor Digikey part # FQP50N06L. This (logic-level) N-channel power Mosfet should D switch nearly any relay coil. Rated at 52 amps.

$1.05

Power Relay SPST

Radio Shack part # 275-001

$7.00

The channel used on the R/C system to control the failsafe should not be a control stick type that returns to center when released (like the drive channels), but instead a toggle switch type that is either on or off.

R/C Toggle Switch

The Spektrum DX5e radio transmitter and Spektrum BR6000 2.4GHz R/C system utilize a toggle switch available for use on the sixth channel of the receiver (see Figure 10-26). This toggle switch can either output one of two pulses to the R/C receiver: approximately 1000 microseconds if switched LOW and approximately 2000 microseconds if switched HIGH. If you choose to use a different 2.4GHz R/C system and there is not a usable toggle switch already installed on your transmitter, you might have to sacrifice use of another unused channel to add the toggle switch for the failsafe. If using the Spektrum BR6000 receiver, simply connect the AUX channel to the Arduino to access the failsafe signal.

CAPTION IS MISSING IN ORIGINAL FILE!!!!!!

Figure 10.26. CAPTION IS MISSING IN ORIGINAL FILE!!!!!!

The input voltage from the toggle switch on the R/C transmitter can only be either +5v or GND (as there is no potentiometer in the toggle switch), so the Servo pulse value interpreted by the R/C receiver can either be 1000 microseconds or 2000 microseconds (approximately) when read by the Arduino. This is exactly the on/off functionality you need for the failsafe switch, which is simply a wireless kill switch for the +24v supply to the motor controller using a power relay. When decoded, you need to check only the signal for being HIGH or LOW, so to speak-consider Listing 10-1.

Example 10.1. Use Single R/C Failsafe Channel to Wirelessly Switch an LED on the Arduino

// Code to read an R/C failsafe channel and turn digital pin On/Off
// Connect R/C receiver to +5v and GND from Arduino supply.
// Also connect AUX channel from R/C receiver to Arduino D2.
// If failsafe is On, LED on D13 will also turn On - otherwise LED is Off.

int ppm = 2;  // read R/C receiver from this pin
int servo_val;  // use "servo_val" to hold the pulse length
int LED_pin = 13;  // control LED on Arduino D13

void setup() {
  Serial.begin(9600); // start serial monitor
  pinMode(LED_pin, OUTPUT); // declare output
  pinMode(ppm, INPUT); // declare input
}

void loop() {

  // use pulseIn() command to read the length of the pulse on D2, with a timeout of 20mS
(20000uS)
  servo_val = pulseIn(ppm, HIGH, 20000);

  // check the pulse length to see if it is above 1600 microseconds (ie. Above neutral)
  if (servo_val > 1600){
    // if so, turn LED On
    digitalWrite(LED_pin, HIGH);
    Serial.println("Failsafe Active!");
  }
  else {
    // otherwise if signal is below 1600 uS, turn LED Off
    digitalWrite(LED_pin, LOW);
    Serial.println("Failsafe turned Off");
  }
}
// end of code

This is the exact method that to use to decode each of the digital R/C channels available from the receiver, in the main code for the Lawn-bot. Now that you know how to read the Failsafe channel from the R/C receiver and convert the pulse reading into a HIGH or LOW value on the Arduino, learn how to interface the Arduino to a high-power relay to control the failsafe, lights, lift motor, or anything else you can think of to add on.

Power Relays

The power relay from Radio Shack that I use is intended for automotive use and rated for 14vdc and 60amps; although I used it to switch 24vdc and approximately 30 to 50amps for more than a year without problems (see Figure 10-27). The coil to activate the relay consumes approximately 200mA at 12v and can be turned on using a single logic-level N-channel mosfet interfaced with the Arduino.

The Failsafe power relay used to switch the main power supply to the motor controller

Figure 10.27. The Failsafe power relay used to switch the main power supply to the motor controller

The normally open SPST power relay has four terminals: two activate the relay coil by connecting one terminal to the +12v power supply and the other terminal to the Drain pin of the N-channel mosfet, as shown in Figure 10-28. The other two terminals on the relay are the power contacts used to control the +24v power supply going to the motor controller. The relay is "normally open" because you want to make sure that it is disconnected by default, and the only way to activate it (that is, turn on the motor controller) is to bring the Arduino failsafe_relay control pin HIGH.

The power relay can be controlled by any Arduino output pin, using a simple logic-level N-channel mosfet to control the GND supply to the relay coil, as shown in the schematic in Figure 10-28. The mosfet has a built-in protection diode to keep the back-EMF produced by switching the coil, from damaging the mosfet or the Arduino output pin. If you want to use an NPN type BJT transistor to control the relay coil, you should solder an external diode to the two coil terminals of the power relay because most BJT transistors do not have internal diodes built in.

The Failsafe relay interface schematic

Figure 10.28. The Failsafe relay interface schematic

Note

The power relay is a SPST and therefore has four terminals. The two silver terminals marked 85 and 86activate the relay coil, whereas the two copper terminals marked 87 and 30 are the power contacts used to switch the positive voltage supply between the positive battery lead and the Sabertooth 2×25 +VIN terminal.

The power terminals of the relay can be reversed without issue, and the relay coil is not polarized (you can reverse the polarity to the coil and it still activates the relay), unless you add the external diode across the coil terminals. If you add the external diode, you have to apply the +12v signal to the striped end of the diode (cathode) and GND (through the N-channel mosfet) to the other end of the diode (anode).

Avoiding an R/C Failsafe

Most R/C systems have a failsafe pulse that the R/C receiver can revert to if it loses its signal from the transmitter. Most multichannel R/C equipment is made for hobby airplanes, which do not use reverse, so the R/C receiver can typically revert the throttle channel to 0% (or approximately 1000uS pulses) as a failsafe if the receiver loses its connection with the transmitter. This is because you don't want your plane flying off into the sunset at full speed if it is no longer controlled. The rest of the channels hold their last known position when the signal is lost.

This throttle failsafe creates a problem for bidirectional vehicles because the throttle channel is used for both forward and reverse. This means that when the signal is lost and the R/C receiver reverts the throttle signal to a constant 1000uS pulse, it is actually putting the motor connected to the throttle channel in full 100% reverse! You can imagine that this could be potentially dangerous if you have a running lawnmower attached to an uncontrolled bot.

To avoid this, I recommend using the 2.4gHz Spektrum BR6000 Bot receiver, specifically designed for use with robots. This receiver has a programmable failsafe for each channel, which is determined by the position of each channel during the Tx/Rx binding process. If the signal is lost between the Tx and Rx, the receiver reverts each channel to its preset value (centered). This enables you to set each of the motor drive channels to default back to neutral if the signal is lost, and setting the external Failsafe controlled by the Arduino to default off. This means that if the signal is lost or the transmitter turned off, not only are the drive signals reverted to neutral and the motors stopped, but also the failsafe channel reverts to off, which disconnects the power to the motor controller—double failsafe!

All that is left now is to make connections and load the code before showing off your new Lawn-bot to the neighborhood.

Making Connections

Several connections need to be made to get your Lawn-bot moving. First, connect the Arduino and failsafe; then connect the Sabertooth motor controller to the motors and power supply. Use Table 10-8 to make connections between the Arduino, R/C receiver, and Sabertooth motor controller.

Table 10.8. Connections to Both the Arduino and Sabertooth 2×25 Motor Controller

Connection

Description

Arduino

Sabertooth

THR – R/C receiver

For left drive motor

x

S1

AILE – R/C receiver

For bucket-lift motor

D5

x

ELE – R/C receiver

For right drive motor

x

S2

RUD – R/C receiver

For mower kill switch

D3

x

GER – R/C receiver

For headlights

D4

x

AUX – R/C receiver

For Failsafe relay

D2

x

+12v

Center tap from batteries provide 12v for Arduino and relays

+VIN

x

+24v

Positive lead from batteries

x

B+

GND

Negative lead from batteries

GND

B-

Failsafe relay

Interface Arduino output pin with N-channel mosfet that controls failsafe relay

D6

x

Mower kill switch (if used)

Interface Arduino output pin with N-channel mosfet that controls mower kill switch relay

D7

x

Lights (if used)

Interface Arduino output pin with N-channel mosfet that controls lights relay

D8

x

Lift motor up (if used)

Interface Arduino output pin with N-channel mosfet that controls SPDT lift motor up relay

D9

x

Lift motor down (if used)

Interface Arduino output pin with N-channel mosfet that controls SPDT lift motor down relay

D10

x

Left drive motor

Connects both motor terminals to the Sabertooth M1A and M1B

x

M1

Right drive motor

Connects both motor terminals to the Sabertooth M2A and M2B

x

M2

Remember to connect the GND and +5v power signals from the Arduino to the R/C receiver.

The Code

The code for this project reads four servo pulse signals from the R/C receiver and uses those values to control up to four different power relays. One of the power relays should be used as a failsafe switch for the motor controller, but the other three are available for general use. The following sections shows how to utilize these extra three channels, but for now, load the code. To better describe what happens in the code, I commented nearly every line with a brief explanation.

Listing 10-2 shows the code to control the failsafe and accessories. Download the code for this chapter and upload to your Arduino at https://sites.google.com/site/arduinorobotics/home/chapter10.

Example 10.2. This Code Reads Four R/C Channel Pulses and Converts Them into Digital Outputs to Control a Set of Power Relays

// Code 10-2 - The Lawn-bot
// Main code used to control the failsafe and accessories.
// Connect Failsafe R/C channel AUX, into Arduino D2.
// Lawnmower kill switch INPUT connects to D3
// Head-lights INPUT connects to D4
// Bucket-lift motor INPUT connects to D5
//
// OUTPUTs are listed by function
// you will need a Relay interface board for each Arduino output
// you will also need a set of SPDT relays to control the lift-motor UP/DOWN functions
// You can change uses for each of these pins to fit your design
// JD Warren 2010

int ppm1 = 2; // R/C input for failsafe channel
int ppm2 = 3; // R/C input for mower kill-switch
int ppm3 = 4; // R/C input for lights
int ppm4 = 5; // R/C input for dump-bucket lift motor - or anything else you like.

int failsafe_switch = 6; // pin used to switch Failsafe relay
int mower_kill = 7;  // pin used to switch lawnmower kill switch relay

int lights_Pin = 8;  // pin used to switch headlights relay or PWM H-bridge for brighness
control.
int bucket_lift_up = 9; // pin used to raise dump-bucket via H-bridge
int bucket_lift_down = 10; // pin used to lower dump-bucket via H-bridge

// LED pin to turn On when Failsafe is active
int ledPin1 = 13;

// variables to hold the raw R/C readings
unsigned int ppm1_val;
unsigned int ppm2_val;
unsigned int ppm3_val;
unsigned int ppm4_val;

// variables to hold the tested R/C values
unsigned int failsafe_val;

unsigned int mower_kill_val;
unsigned int lights_val;
unsigned int bucket_lift_val;

// End Variables

// Begin setup()

void setup() {
Serial.begin(9600); // turn on Serial monitor

  // Declare the OUTPUTS
  pinMode(failsafe_switch, OUTPUT);
  pinMode(mower_kill, OUTPUT);

  pinMode(lights_Pin, OUTPUT);
  pinMode(bucket_lift_up, OUTPUT);
  pinMode(bucket_lift_down, OUTPUT);

  //Failsafe LED
  pinMode(ledPin1, OUTPUT);

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

  // The failsafe should be OFF by default
  digitalWrite(failsafe_switch, LOW);

  delay(1000); // wait 1 second after power up for the R/C receiver to connect

}

// End Setup

// Begin Loop

void loop() {

  // Use pulseIn() to read each R/C input using the pulse() function created below the loop().
  pulse();


  //////////  Failsafe relay //////////
  // check to see if pulse value is between 1750 and 2000 microseconds
  if (failsafe_val > 1750 && failsafe_val < 2000) {
    // if so, activate motor-controller
    digitalWrite(failsafe_switch, HIGH);
    digitalWrite(ledPin1, HIGH);
  }
  else {
    // otherwise, deactivate motor-controller
    digitalWrite(failsafe_switch, LOW);
    digitalWrite(ledPin1, LOW);
  }


  //////////  Lawnmower kill-switch relay
  // check lawnmower kill-switch relay
  if (mower_kill_val > 1750 && mower_kill_val < 2000) {
// if value is high, activate mower kill relay
    digitalWrite(mower_kill, HIGH);
  }
  else {
    // otherwise, leave motor kill relay Off
    digitalWrite(mower_kill, LOW);
  }


  //////////  Head-lights
  // check light switch value
  if (lights_val > 1750 && lights_val < 2000) {
    // if value is high, activate lights
    digitalWrite(lights_Pin, HIGH);
  }
  else {
    // otherwise, turn lights Off
    digitalWrite(lights_Pin, LOW);
  }


  //////////  Lift motor for dump-bucket using (2) SPDT relays - one for each motor terminal.
  // Check to see if bucket_lift_val is above 1700uS pulse length
  if (bucket_lift_val > 1700) {
    // if so, lift motor Up
    digitalWrite(bucket_lift_down, LOW);
    digitalWrite(bucket_lift_up, HIGH);
  }
  // if not, check to see if the pulse is below 1300uS
  else if (bucket_lift_val < 1300) {
    // if so, lower motor Down
    digitalWrite(bucket_lift_up, LOW);
    digitalWrite(bucket_lift_down, HIGH);
  }
  // otherwise, the pulse is Neutral so stop the lift motor
  else {
    digitalWrite(bucket_lift_up, LOW);
    digitalWrite(bucket_lift_down, LOW);
  }


  // Now print the values for each R/C channel
  Serial.print(" Failsafe:  ");
  Serial.print(failsafe_val);
  Serial.print("  ");
  Serial.print(" Mower kill-switch:  ");
  Serial.print(mower_kill_val);
  Serial.print("  ");
  Serial.print(" Lights:  ");
  Serial.print(lights_val);
  Serial.print("  ");
  Serial.print(" Bucket lift:  ");
Serial.print(bucket_lift_val);
  Serial.println("  ");

}
// End of Loop


// Begin pulse() function to check each R/C input pulse

void pulse() {

  // decode and test the value for ppm1
  ppm1_val = pulseIn(ppm1, HIGH, 20000);
  // check each pulse for a valid signal
  if (ppm1 < 600 || ppm1 > 2400) {
    // if the signal is invalid, set to neutral
    failsafe_val = 1500;
  }
  else {
    // otherwise, set the failsafe_value equal to ppm1_val
    failsafe_val = ppm1_val;
  }

  // decode and test the value for ppm2
  ppm2_val = pulseIn(ppm2, HIGH, 20000);
  if (ppm2 < 600 || ppm2 > 2400) {
    mower_kill = 1500;
  }
  else {
    mower_kill = ppm2_val;
  }

  // decode and test the value for ppm3
  ppm3_val = pulseIn(ppm3, HIGH, 20000);
  if (ppm3 < 600 || ppm3 > 2400) {
    lights_val = 1500;
  }
  else {
    lights_val  = ppm3_val;
  }

  // decode and test the value for ppm4
  ppm4_val = pulseIn(ppm4, HIGH, 20000);
  if (ppm4 < 600 || ppm4 > 2400) {
    bucket_lift_val = 1500;
  }
  else {
    bucket_lift_val = ppm4_val;
  }
}
// End pulse() function
// End Code

If you plan to build the motor controllers from Chapter 8, then you should also use the code from that chapter as well to drive them. There are also several other variations of this code used for different Arduino/motor controller configurations that I used for the Lawn-bot, which are available on the book website in the Chapter 10 folder.

With the code loaded, you should test the failsafe relay first and then the Sabertooth 2×25; make sure you are in an open area with no children, pets, rose bushes, or any other valuables nearby when testing this large robot. When you are satisfied with your testing and have proven that your Lawn-bot does indeed work, you can move to the next section where you can add headlights, a dump bucket, and a lawnmower engine kill switch.

Adding Cosmetics and Accessories

Shortly after you get your Lawn-bot mowing your grass, you can begin to discover more things that it can do with only minor modifications. Because the Arduino has 20 I/O pins available, you have quite a bit of upgrade room to add some accessories to your Lawn-bot.

Be creative: I have 100 suggestions of things I could add to the Lawn-bot to make it better, so I'm sure you can think of a few things. Hopefully, the code and relay interface switches listed in this chapter can help you get your ideas to work.

The following items are just a few of the things that I did.

Painting

After I got my Lawn-bot working and cut my grass several times without any problems, I decided to paint it to keep it from rusting. I came up with a striped design using ¾-inch Scotch painters tape and three different colors of spray paint. The entire paint job cost about $15 and about 2 days of intermittent painting and taping.

I removed the electronics and spray painted the frame and mower deck primer gray with Rustoleum spray paint. I then painted the frame flat black and the mower deck bright blue, using Krylon spray paint, both with yellow accents (see Figure 10-29).

A can of brightly colored spray paint to make the Lawn-bot look nice while mowing the grass

Figure 10.29. A can of brightly colored spray paint to make the Lawn-bot look nice while mowing the grass

Headlights

The first thing I wanted to add onto my Lawn-bot was a set of headlights, so it can mow in the evening if I needed to. Also I had a few extra R/C channels and thought it would look cool, which it does (see Figure 10-30). This involved building a smaller version of the failsafe relay circuit, using a 10 amp SPST relay to switch the +12v signal to the two headlights.

Lawn-bot 400 fully painted with headlights installed-as clean as it will ever be. Notice the furry inspector that I had to deal with.

Figure 10.30. Lawn-bot 400 fully painted with headlights installed-as clean as it will ever be. Notice the furry inspector that I had to deal with.

Dump Bucket

The next thing I added was more for my back than anything else. The wheel-barrow bucket enables me to throw bags of soil, sand, mulch, or chicken food onto the Lawn-bot, and it happily carries whatever I need out to the various parts of my large backyard. Though I looked for one second-hand, I ended up buying a wheel barrow from the hardware store and removed everything but the steel bucket.

After taking some measurements and lining the bucket onto the frame to verify clearance, I welded two Gate hinges to the bottom of the steel bucket and mounted them to a frame riser bar. The frame riser bars are ½-inch diameter, 6-inch long steel bolts mounted to a 2-inch angle-iron cross-beams to hold the bucket above the frame. The bucket tilts forward with little effort and is manageable even with a full load of dirt (see Figure 10-31).

The Lawn-bot with dump bucket and linear actuator lift motor installed

Figure 10.31. The Lawn-bot with dump bucket and linear actuator lift motor installed

The next idea was of course to remotely control the dump bucket, so I found a 6amp 24vdc linear actuator motor that has a stroke of around 12 inches. The motor is used to lift the rear of the bucket and dump its contents over the front of the bot. To interface this motor to the Arduino, you can use two N-channel mosfets to activate two SPDT relays (one for each motor terminal). See Figure 10-32 for a schematic of the lift motor control circuit.

A schematic for the lift-motor circuit using two SPDT relays and two N-channel mosfets to interface the Arduino to the relay coils

Figure 10.32. A schematic for the lift-motor circuit using two SPDT relays and two N-channel mosfets to interface the Arduino to the relay coils

Lawnmower Kill-Switch

The Lawn-bot has a failsafe kill switch that disconnects the power to the motor controller, but to make the lawnmower engine turn off remotely, you need only another failsafe relay interface. Most lawnmower engines use a wire to short out the spark plug to kill the engine, so you can solder wires to both of the kill-switch contacts on the lawnmower engine and connect them to the power contact of an SPST relay.

This relay should be connected to the Arduino via a Relay interface circuit described earlier in this chapter (see Figure 10-28). I connected the channel to control this relay to the "Trainer" select toggle switch on the R/C transmitter because it is a spring loaded switch that returns to the on position after you have killed the engine. This is a nice addition because it is no fun walking over to the lawnmower and manually killing the engine.

Summary

In this chapter you built an actual helping robot that does a chore most people despise having to do. Instead of pushing a lawnmower around the yard in the hot sun, breathing in dust, and getting hit with flying debris, you can relax on the back porch under an umbrella, sipping an iced tea while your Lawn-bot does all the hard work for you.

This robot used DC gear motors from a power wheelchair and R/C control as in Chapter 8, but this robot was upgraded with several different useful items, such as high-capacity deep-cycle batteries, rugged pneumatic tires, a sturdy steel frame, a bucket for carrying materials, headlights, and a remote failsafe kill-switch to ensure this big robot can always be disabled.

By using a commercial motor controller (the Sabertooth 2×25), you can drive the bot carefree, knowing that the motor controller has over-current protection built in and can shut down if overworked to avoid damage. The Sabertooth motor controller also has a built-in processor for decoding the two main R/C signals for the drive motors, which frees the Arduino to decode as many other R/C channels as you want to add accessories for.

In the next chapter, you drop down to two wheels to make a balancing, rideable Seg-bot. This balancing scooter uses a gyroscope and accelerometer to correct any tilt from the base, enabling you to control its direction and speed by simply leaning. Add a steering potentiometer and a speed knob, and you have a robot that can amaze anyone that sees it.

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

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