This article is now outdated! The autopilot has been finished and installed. Read the full write-up here:

There were many problems with my previous autopilot, the biggest of which was lack of manual override. Since then, I’ve completely redesigned the circuit, code, and integrated the autopilot into a brand new boat! This new prototype has had one successful test; I was able to steer the boat into the middle of a pond, engage the autopilot, have the boat go to three way-points, then come back to the shore.

New Circuit Design:


I decided to incorporate two AtMega328’s into my new circuit. The previous autopilot used only one chip (from an Arduino Uno) and could only turn the rudder at about 4Hz; the frequency of the GPS. In order to make the autopilot more responsive, the first chip decodes the NMEA data from the GPS, then sends the location via Bill Porter’s EasyTransfer Library to the other chip.

The second chip uses the GPS location and the compass bearing to calculate the speed of the motors. This happens at about 50Hz, which is much faster than the GPS. For the motor speed, 0 = motor off, 255 = max speed. These two values (one for each motor) are then used to control two N-Channel MOSFETs, which in turn are connected to the two motors of the boat.

There is also an HK-GT2B receiver attached to the second chip. The AtMega senses pulses via the pulseIn() function. If there is a signal, the chip disables the autopilot and uses the input from the controller instead.

This circuit has proved itself to be very simple and robust, but I had several issues with implementation:

Firstly: the 12v battery is too much for the 5v linear regulators. The regulators dissipate heat, a lot of heat. The heat-sinks did not help much, and I didn’t have the patience to make/order a switch-mode power supply, so I decided to use a 7.4v Ni-MH battery instead. Lower input voltage means less voltage difference, thus less heat dissipated.

Secondly: the N-Channel MOSFETs drew too much current from the AtMega, causing the chip to reset and keep the motors at full speed. I added a current limiting resistor and the motors never got stuck again. See diagram below for the simple motor drive:

New RC Boat (Victim):


This new boat is much, much better than the air-boat I constructed to test my last autopilot. I bought it for $0.01 from eBay. Shipping was $20 though, but hey, it was first class shipping. It got to my house in about three days. I wasn’t too impressed with the quality of the boat though. The only thing that actually worked were the motors and the battery it came with. I salvaged two MOSFETs from the receiver.

One thing I noticed was that the motors created a huge EM field, which messed with the compass in the initial tests. To counteract this I moved the compass up to the front of the boat. You can see a faint outline of the compass mount in the image above.

New Code:


One of the main changes in code is the addition of a manual override. I wrote a simple while loop that basically returns the values from the controller (if there are values):

while (pulseIn(5, HIGH, 100000) > 0){
int throttle = pulseIn(4, HIGH, 20000);
int steer = pulseIn(5, HIGH, 20000);
if (throttle > 1000 && steer > 1000) {
Override(throttle, steer);

These values then go to the override function, which takes the throttle and the steering and mixes them into two motors. The output for left and right have a max of 255 (the max output of the analogWrite()).

Download all of the code here:

First Real Test:


I would consider the most recent autopilot test to be a total success; I did not have to rescue the boat 🙂 ! I used the override to steer the boat to the center of the pond, then engaged the autopilot by turning off the controller. The autopilot then traveled to the three pre-programmed way-points, then lost the GPS lock and turned off.

The boat lost the GPS lock three more times before I examined the circuit. I found that one of the LEDs near the GPS was glowing yellow (instead of flashing). I’m beginning to sense that there is something wrong with the circuit I made, but for now I am glad I did not have to rescue the boat.

I noticed that the boat began to zig-zag at one point. The compass I am using (the HMC5883L) is not tilt-compensated. I’m planning to add a tilt compensating compass, one that uses an accelerometer.


Next Steps:

The next steps for this project include:

  • Adding a tilt compensating compass
  • Adding a SD Card for location logging
  • Fixing the second chip (so that the GPS lock stays)
  • More testing!

I’m also planning to write a really large write-up on autopilots for the Instructables Move It Contest. I’m going to include basic and advanced autopilot theory, all three of my prototypes, and a full set of instructions on this latest version.