About
Robotics
Old Projects
Photo Gallery
House
Motors
My other sites
Youtube
The Lawnbot400

This project has been in my brain for a while now, so it seemed appropriate to try. It is basically a metal frame with wheels, and a push-lawnmower hanging from the metal frame. Attach 2 big electric motors, a car battery, and some home-brewed electronics, and you have this page.

The main materials so far:

1. (2) 300w wheelchair motors (Ebay = $75 total)
2. (6) 3' pieces of angle iron (Home Depot)
3. a bunch of bolts (3/8"-1/2" diameter, Home Depot)
4. 10' of roller chain (All Electronics)
5. (2) wheel sprockets and (2) drive sprockets (All Electronics = $8/ea, $2/ea)
6. a car battery
7. an Arduino
8. 2-channel full H-bridge capable of handling at least 25amps/channel at 12vdc.
9. (4) wheels (Harbor Freight Tools = $12 each)
10. 5/8" threaded rod (3' long) (Home Depot)

If you want to view any of the files related to this project, please go to Electronics >> Arduino Code.


Power
To power the mower, I have 2 big electric brushless DC motors. They can consume upwards of 25 amps when fully loaded. I need to control the mower via a remote so I can tell it what to do. I could use 2 relays to have on/off capabilities, but I would rather have full speed control in both directions, so I need an H-bridge.


H-bridge
This is the h-bridge motor driver. The board currently uses (2) FQP50N06 n-channel and (2) FQP47P06 p-channel complementary Mosfets rated at 47amps. I have tested the board with several different motors including the wheelchair motors intended for it and it drove them without heating up at all. So I can say with confidence that it can handle at least 5 amps with no heatsinks (though heatsinks are in order).

Here is a eagle schematic for 1 side of the circuit (the board pictured contains 2 of these):


How an H-bridge works
Basically, the 2 mosfets on the left allow for the left motor pole to either be connected to the positive wire (+) or the negative wire (-). The 2 mosfets on the right allow for the right motor pole to receive either (+) or (-). So if you just turn on Q1, the left motor pole gets (+) voltage... if you then opened Q4, the other motor pole gets (-) voltage or grounded and you would see the motor start turning in one direction. If you then turned off Q1 and Q4 and turned on Q2 and Q3, you would see the motor spin in the other direction. You want to turn on the P-channel mosfet of one side and the N-channel of the OTHER side to allow the motor to spin. This give the first side a positive signal and the other side a negative signal. You do NOT want to open both of the switches on the same side as this will create a condition called "shoot-through" which means you shorted out your circuit through the mosfet switches... which usually means they go up in smoke.

Electricity... All about the Heat
With electronics, anytime there is electricity, there is heat. Anytime any electical signal is transmitted, it is generating heat (even though it may be a very small amount). Heat is also bad for electronics, generally speaking. You probably know that if you are dealing with a small amount of electrical current, you can vary the output amount from 0-100% with a potentiometer (a volume knob). We can't use a Potentiometer (or variable resistor) to control motor speed because it is just resisting the electrical current, which means it is transferring the excess into heat... which is bad. Often electricity is related to water flow. So you might think of a potentiometer as a water valve, and the more electrical current (or pressure in water terms) that is being held back from going through the potentiometer, the more heat that is generated. If heat is being generated by a resistor or potentiometer, it is battery life being WASTED! Draining your battery by dissipating the heat that would have gone to drive your motor. If the resistor is not rated for the current passing through it, it will melt and fail. For these reasons, this is not a good approach to controlling the flow of high electrical current (like the 20 amps that will be going to our motors).

PWM Explained
To avoid wasting heat, we use a different approach. No resistance, just regulating the amount of time that the h-bridge is turned on. Using something called Pulse Width Modulation (PWM) means that instead of turning the mosfets on all the time or off all the time, you turn the mosfets ON and OFF really, really, really fast. If you do this such that you turn it ON for 1 second and then OFF for 1 second over and over again, you would see the motor "pulsing" on and off right? This would let the motor have power 1/2 of the time thereby making it spin with less overall power (you might say 1/2 the power). Well lets say you do this ON for 1 millisecond, then OFF for 1 millisecond, over and over again. Now it is still only on 1/2 the time, but the time-frame (or frequency as it's called) has become MUCH smaller (...or in terms of frequency, it got much higher), thereby less noticeable to your naked eye. It no longer appears to be "pulsing", but instead just appears to be going at 1/2 the speed as if you had the motor hooked straight up to the full power supply. Actually a similar phenomenom occurs in almost every light bulb and power outlet in the world. The frequency of the AC power in your wall sockets is 60Hz (if you live in the USA), meaning that the wire goes from 0 volts to approximately 220 volts, 60 times every second, or 60 Hertz (Hz). This gives you an effective average of 110volts at your wall outlet at any time. PWM frequencies can be more like 25kHz!!! You can imagine that if the motor or light is being turned on and off 25,000 times/second, there will be no noticeable "pulsing" and changing the speed will appear very smooth. Also, since it is always either fully ON or fully OFF, no (or very little) electricity is wasted.

Look at this chart to see a graphical explanation:

Control
The control system is to be a typical 6-channel Remote control transmitter/receiver setup that you might use in an RC car or boat. The signal generated by the RC receiver (Rx) is called PPM (pulse position modulation). This signal needs to be interpreted into a PWM (pulse width modulation) value to drive the H-bridge. To do this, we use the Arduino as a middle man.

I control the RC transmitter (Tx) ----> Arduino receives signal, translates to PWM value ----> H-bridge receives PWM, drives motors.

This sounds easy, but finding a motor contoller (h-bridge) that can handle 25 amps is either difficult or expensive. The cheapest single H-bridge that would work was the Simple-H controller that handles 25 amps but it is $80 per bridge and I need 2 full bridges = $160! The cheapest dual full h-bridge that I could find was the Sabertooth 2x25 which is nice looking and has the RC interface built in, but it runs $120. The models they use in battlebot wars are around $300!

So, after a lot of research and about $50 worth of parts, I built a dual full h-bridge with an RC interface that can handle over 25amps, hooray for the lawnbot.

Here is a preview of what it should look like.



7-27-09, First test drive:

After a long time, everything was finally ready to test. So a friend came over and helped me get everything connected for the first run. I hooked everything up and turned it on... no smoke. Tried driving it forward and it worked. I had hooked up the motor wires backward on one of the motors, so it was doing a zero-turn donut when I pushed both sticks forward. After connecting the motor wires correctly, I realized that the input lines were also backward when I noticed that the left control stick moved the right wheel... but I was happy enough that it was working to leave that for now. So I drove it up to the mailbox, albeit a bit slow (the battery hadn't been charged in over a month... oops), but it still made it around the front yard once before doing a hard stop down the driveway. Still no smoke. I check the Mosfets to see if they are overheating and they are only slightly warm. So, a few more donuts down by the garage and then I got a bad idea. Why not see if it will carry me? After standing on it I push both sticks forward for just a second and almost fall off. So trying again very slowly and steadily.... POOF! Smoke comes out of the motor driver board. HAHAHA, I mean, oops:


A burned power trace on the back of the PCB. Yeah, so those little traces on the PCB's from Radio Shack are obviously meant for running logic chips and such... not 20amp motors. I am not about to throw away my motor driver board, so I decided to start soldering every trace that carries any sizeable amount of current. Now before I put it back together, I decided to build a convenient platform for the 2 interface boards to sit on, a toggle switch to turn it off easily, and a power block to keep the wires neat. So then it gets mounted back onto the chassis for another test run. Also, I read a bit about capacitors reecently and decided to add a few to each board for kicks.


After reconnecting everything and testing the boards with the Mosfets taken out, it all powers up fine. So turn it off, reinstall mosfets, and now its ready. But this time it wasn't so smooth. I dropped a mosfet to the concrete when I was trying to install it on the board... not thinking much of it until I turned on the power and it started smoking. Ouch. Oh well, I turned on the power again to see what would happen. Everything sat still, all the appropriate lights on... when I tried to run it forward (assuming the other side of the H-bridge would still work), the other motor started to turn, but as I applied power to it, smoke came out from under the driver board again.

Turns out I missed a trace when I was soldering them all up. AAAARGHGH.... Now it is dismantled again and ready for soldering.


8-7-09, Eagle Schematic:

So the H-bridge board is probably dead. I can only get 1 motor light to work on each channel... I apparently fried something. So now I'm going to try to etch my own PCB which should be smaller and easier to use. Here is a .jpg of the eagle board file.


8-8-09, PCB Etching:

I etched the pcb tonight. Here are some pics:

This run only transferred halfway. I am using magazine paper to print onto because I am too impatient to wait on the proper toner transfer paper which has to be ordered on the internet.

I used an iron on high, the copper clad, a green scotch sponge pad to clean the copper (not the steel wool shown... too rough), the print onto the magazine paper, and a piece of wax paper to put on top of the magazine paper. The copper clad gets to sit on a 1"x6" (untreated, you don't want moisture in the wood) so it sits flat and even. Push hard for 3-4 minutes, lifting and moving, making sure to get every spot with the iron. Try not to slide the iron, as it will smear the tracks (which I did, and you will see).

...smeared tracks.

Cleaned up the smeared tracks with a very small flat-head screwdriver by scraping the toner off of where it was not supposed to be touching.

Dipping the boards into the Radio Shack PCB ethchant solution, also bought an air pump and hose to help etch the bottom of the board.

Etched... some copper around the edges wouldn't come off, but it was far enough from the important stuff to just lightly sand off. This turned out nice.

Starting to wipe off the toner with Acetone and a napkin. It comes right off and shows the clean copper underneath.

All done. I feel like this is one of those things I hoped I wouldn't have to do, but am glad that I now have.


8-15-09, Time for Testing:

All of the parts came in from Digikey and are now soldered into place. I was concerned that since the spacing between the PCB traces was so small, the solder might have trouble pooling across tracks. That didn't happen at all, it stayed right where it was supposed to and everything went very smoothly. After I soldered everything together, I tested it and it worked nicely. The only thing I notice that is not great, was that I tied the motor indicator LED's each into ground from their respective motor terminals, this causes the voltage on each motor terminal to be referenced to ground, instead of the other motor terminal. This causes both indicator led's to light up when any voltage difference is present. This is easily changed in the next pcb etching. For now, I don't care, as long as it works.

Check out the video of the 2nd test drive:

this will be replaced by the SWF.


9-12-09, Too slow

I am now able to drive the frame around without any hassle, thanks to the toggle switch. I have only recharged the battery once since I started all this a few months ago and it hasn't ever dropped below 11 volts. However, while it has plenty of current capacity, the voltage is only running the motors at half of their intended speed. Plus the small gear on the motor mated to the much larger gear on the wheel decreases the RPM that the motor shaft spins at by about one half... so if the motor is spinning at 100 RPM, the wheel is only spinning at 50 RPM (appx.). In turn, the bot is super slow. And the 12 volts isn't quite enough to push the motors up a large hill... it just slows down to a stall.

The only larger than 12v power supply I had on hand was a Ryobi 18v drill battery, so I wired it up and it ran MUCH faster than before, which is awesome. While 18vdc is probably enough to mow the grass on my back yard, I think running it at 24vdc will allow me to run it at 60% most of the time, and when I need to go up a big hill, it will have a little extra power remaining. I also installed a fuse between the battery and boards so I could see how many amps the motors were drawing. It blew a 5amp fuse, then a 10amp going up a hill. The 15amp held strong at 12v, but blew going up a hill at 18v. A 20amp fuse is golden, seriously. I found a 12v 7Ah lead-acid battery, so I plan on getting another one to match it and running them at 24vdc. The mosfets gates can handle +/-25v, so it will be close to the threshold. But I'm gonna try it.

I also have my new design nearly finished. It is a multiple mosfet dual full h-bridge that is an integrated Arduino shield and some R/C receivers like mine can plug directly onto it. So you plug your power to the board from batteries, then the 2 motors, set some jumpers to route the signals to the desired Arduino pins, and plug the Arduino and R/C receiver onto the h-bridge (or use servo plug wires for r/c rx). Unlike the previous h-bridge board that only had 4 mosfets for each bridge, this board can be populated with up to 16 mosfets for each bridge (32 total mosfets on the board), and also has clearance for tab-soldered heatsinks. These mosfets will be driven by 2 mosfet driver chips per bridge. The voltage max will be 25 volts and the current max should be around 25 amps continuous (like for an hour mowing the whole yard). I will post pictures when I get this one transferred to copper.

Here is a pic of the eagle .brd file:


10-18-09, Detoured

I decided not to use the above design for a motor driver board because it was a bit too complex for me to want to try it yet. So I designed another h-bridge with 3 mosfets in each leg instead of the 4 that were going to be in the above board. This is still 3x as many as were in the first driver board, so it gets rid of heat much better. This design is basically a beefed up version of the first driver board.

It uses 2n7000 n-channel mosfets to switch the P-channel power mosfets on the high-side, and the N-channel power mosfets are logic level and driven straight from the microcontroller (which hasn't caused any problems yet). I used a bussed resistor network chip to deliver an equal signal current to each mosfet gate. There are pull-up/down on each mosfet gate to protect them from floating. I also dropped the direction lights on the motor terminals to save space. Everything is crammed in there, but it all fits and nothing is touching that shouldn't be. Here are the .sch and .brd files for Eagle and a few pics:


11-20-09: Entered contest, added failsafe

I created an Instructable for instructables.com on the Lawnbot400 detailing how I put it together and showing how one might build an R/C mower like it. I posted it on a Friday night and it was featured on the website an hour later. The next morning I got a call from a friend that said it was featured on Hackaday.com which was cool. It was very well-received by everyone on the web so I entered it into an Arduino contest on instructables.com.

The thing everyone kept complaining about was the lack of a good Failsafe in case the mower got out of control or out of range. So I wrote a little more code and added another Atmega168 microcontroller that is used to turn ON/OFF a 60amp relay that controls the power to the motor-controller.

I decided against using Interrupts in this code, because they trigger every 20ms on a Servo signal, which is about 50 times per second. This is a lot to process and sometimes has unwanted signals coming in from the R/C receiver due to interference. These unwanted signals are no problem for the driving of the motors, because the motor control lines are using PWM on solid-state Mosfets which were made for fast switching, if the bad signal causes a single dropped "frame" (or 1 update out of the 50 each second..) it is not even noticeable. However, while controlling the motor power Relay, a dropped frame will cause the relay to switch OFF for 1 frame, which takes the Relay a second to fully switch from ON to OFF and back again. So this is really bad when a random unwanted signal is killing all power to the motordriver for a second here and there.

What to do? Well, back when I started working on decoding PPM servo signals with the Arduino, the easiest way to do it was to use a method called PulseIn, which when called, waited for a pulse to start and recorded it's length and stored the value to a variable. This pulse length can then be decoded to a directional PWM value within the code. The neat thing is that PulseIn can be used on any pin. The bad part is that it takes a lot of processing power to run a pulseIn. It was not practical to use for speed control (where high-frequency updates provide very smooth acceleration), because the high-frequency updates slow the code down to a crawl and speed control is very very choppy.

But, if you use PulseIn sparingly, you can call it whenever or wherever you want in the code and collect a sample of that channel's reading any time you want. So I set my code to call PulseIn every 500ms (or twice every second) which still allows plenty of time in the code to run the other functions. Also, this keeps the update period for that channel within safe operating conditions. For example, if I end up out of range, it will only take 1/2 second before the code updates, realizes there is no signal when it tries to PulseIn on that channel, and shuts the power off to the motor-controller which will render the Lawnbot400 motionless until a proper signal is received again.

The beauty of using a polling method is that I only collect a servo reading when I need to and if there is no signal available when I call for it, the microcontroller shuts the motor power off. I can also switch the motor power ON or OFF manually as I wish. Also if the remote is turned off, the motor power is killed. I think this will suffice.