Arduino Autopilot


I am planning on building a simple autopilot (Tiller-Pilot) to keep a small sailboat on course while I sleep.

The unit will comprise of just three main components: Arduino Duemilanove ATmega168, Fluxgate Compass Module (HMC6352) and a large Hitec RC Servo (The servo controls a small blade secondary rudder).

How would it work? I'm sailing, say, due south 180º. This is my present course that I've worked out from my chart/compass etc. I want to steer the same course while I sleep. The fluxgate compass inside my Arduino Autopilot will already know the heading! I press the button which transfers the current heading into a store in the Arduino. If the boat wanders off, then the new O/P from the Fluxgate has changed. The Arduino sends a different PWM to the servo to correct the heading until it matches the stored figure of 180º

The Servo works on 1.0 to 2.0mS PWM. Centre position (neutral) is 1.5mS and the Arduino will have to O/P 1.5mS all the time when the boat is on course.

It would need some leeway in the output so that it is not constantly moving the servo for only say. 1º change in course. Perhaps after say 2-3 mins, if it's still off course by 1º, then it could make a correction BUT I was thinking in terms of "No action" if the error is only 2º-3º or less over a short period. It may be necessary to adjust the program while actually in use using my Asus Eee PC?

I am 100% OK putting the hardware together and making it waterproof. BUT I have no idea where to start with the code. HELP! Interesting project???

Many thanks

(Diagram in next message!)



BUT I have no idea where to start with the code

You start with one simple Sketch for each piece of hardware. If you've never written a line of code before, start with the button and an LED. Have the button toggle the state of the LED. Make certain you understand "debouncing".

Then build a second Sketch that sweeps the servo from side to side. Or position the servo at specific angles.

Then a Sketch that takes readings from the compass and outputs them to the serial port.

Even if someone else writes the Sketch for you, it's very likely you will need to perform some adjustments or fix some bugs. You'll need a basic understanding of how the Sketch works to do either of these things.

Some things to consider while building your project...

  • What should happen if the boat becomes way off course? How much is "way off course"?
  • What should happen in the event of a power failure?
  • PID is very likely be a good fit for your project. Have you considered using it?
  • How will you know if pushing the button worked? Do you plan to include a display? Or some other visual indicator?

Thanks for the info Coding Badly.

In the past I’ve used Basic stamps BS-1 and BS-2 for steer searchlight beams around the sky. I just used the controllers to output step pulses (PULSEOUT) and used external drivers connected to larger stepper motors. I wrote sequences for the beams to move across the sky and also manual Joystick control. A LONG time ago! This is the first time I’ve used an Arduino and everything is new to me.

I have the controller and the Servo but still need to purchase the Fluxgate Compass module. I have tons of other components + hardware to build the unit. Also a fairly well equipped shop for cutting, drilling, spraying, even a lathe and welding gear.

I can’t answer all your questions because the unit as with other project will evolve! My original idea was to power it from a 12V 25A Golf Kart battery on-board reduced to appropriate voltages with 7805/7809 or similar voltage regulators. Alternatively, and depending on actual current drawn over a period of time, might have internal NiMH cell and a built-in solar panel. No way of knowing, depends how hard it has to work in reality. The servo draws 800mA max but only 8mA when idle (centre position).

I was trying to avoid a display but I can see it could be useful. A continuous compass reading from the Fluxgate may well be more accurate than the boat’s mechanical one and I may end up using it as the main steering compass. The display could also show the + or - number of º if there is a difference. A pizzo sounder alarm could go off for any failure especially if it’s unable to correct the course due to change in wind direction or no wind at all!

I think that I will get a Fluxgate module and set everything up on the bench and get to it as you suggest one sketch at a time.

I have my Asus Eee PC 900 with Ubuntu Linux + Arduino software talking to my controller and have played with LED’s, relays etc!

Oh, last thing. There seem to be many HMC6352 Compass Modules, like from Parallax, Modern Device, Sparkfun etc. Most seem to be the same sort of price. Anyone know of any to avoid or one that is better than the rest?


Anyone know of any to avoid or one that is better than the rest?

I can't help with that one. Hopefully, someone else is willing to provide an opinion.