Automatic pilot for motorboat with Arduino
1. A brief introduction
I’m actually developing an automatic pilot for my own motorboat. Just to avoid being at the wheel for hours in long travels. Commercial products are far away too expensive and this project gives me an opportunity to get hands on Arduino platform.
The goal of the solution is simple, make the motorboat follow a course or either a waypoint. There are a few ways to set up a course, either introducing the course by hand or navigating in a direction and pressing a button to lock the actual course. For those methods there is a keypad an LCD display that lets user see and introduce data navigating through a set of menus and functions. There is also possible to use a function in the Garmin GPS installed in my boat called “Navigation” where a waypoint is selected. The course is calculated by the GPS and data is passed to Arduino through an RS232 to TTL converter in the NMEA (National Marine Electronic Association) sentence protocol. This last option gives a more accurate navigation as course to destination waypoint is always recalculated despite of derivation caused by currents and winds.
Once course is setup the piece of logic calculates the difference between the actual course and the desired course and establishes a position for the helm to correct it. I have used a wiper motor driven by an H bridge acting over the wheel to move helm. There is a potentiometer in the axis of the helm to give feedback of its actual position so the motor acting over the wheel does not need to be accurate. Wiper motor turns and acts over the wheel until the desired helm position is acquired. Helm position is calculated every loop of the piece of software. This results in the boat turning towards the desired course until it is reached. The helm gradually returns to its centred position as the boat acquires the right course
This is the list of components I used for my project. They are all very cheap and easy to find in Amazon or eBay.
Arduino starter Kit clone named Funduino: 51€
The kit contains the main board, plus a set of components, cabling, buttons, a breadboard to get started with the platform. Learning to use this platform is very easy. Adafruit has a full set of lessons that will guide you through that process form the very basics to more complex setups.
RS 232 to TTL converter: 4€
This interface will be used to convert RS 232 data signals coming from an external GPS into TTL signals so the Serial ports of the Arduino can handle it.
Double H Bridge: 5€
This component is a driver motor. It can control a stepper motor or a DC motor. In our case it will control the wiper motor turn direction.
Wiper motor: 12€
A Nissan Micra wiper motor. Second hand from scrapping.
LCD display with integrated buttons: 9€
The LCD display and buttons are the user interface. They are used to view and input data.
Triple axis magnetometer: 4€
The magnetometer measures the magnetic field of earth. It can be used to determine to where it is oriented an thus the course of the boat.
3. Software libraries
For each of the components I used there are libraries available from the Arduino community. They will make the use and integration of this components in the logic very straightforward. There is also a library to fetch and process sentences received from GPS in the NMEA protocol. Some of those libraries are delivered with the arduino developement platform as “IRremote.h”, to use Infrared remote controls, or Servo.h, to control a servo, and some others are found in the Arduino community. This is the full list of libraries I used:
IRRemote: to use a remote control provided in the Funduino Starter Kit or any other TV/HiFi standard remote control.
Servo: this one has been used in the developement phase to simulate the position of helm. In the final solution no servo is used but a wiper motor.
DCmotor: this library is used to control the double h bridge. It grants the ability to make the wiper motor move forward and backwards.
LiquidCrystal: this library is used to print data in the LCD screen.
TinyGPS++: This library is used to fetch data form the GPS.
EEPROM: this library will be used to store data in the Arduino persistent memory.
The next schema shows how to connect Garmin GPS to an RS 232 connector. The RS 232 connector will be connected to the RS232 to TTL converter. The RS232 to TTL converter will be connected to one of the Serial ports of the Arduino board:
For testing pourposes, to emulate data sent by GarminGPS, as it can’t be unplugged from the boat, I used RealTerm and an USB to RS232 converter. With RealTerm is possible to send data to Serial port reading from a text file. The text file contains NMEA sentences. Here a photo with the connection of the USB to RS232 adapter and the RS232 to TTL converter:
This is an example of the text file emulating the data stream coming from the GPS:
Documentantion about NMEA protocol can be found on this web:
The last column of each NMEA sentence is a checksum so it has to be calculated as the TinyGPS++ library will discard wrong lines. In this website we can calculate the checksum:
5. Some photos
This are some photos illustrating the evolution of the project:
The developement process.
Mechanical testing. This belt was a bad option. But with this mounting I could test position feedback.
This is the final mechanical instalation. A rocker arm with the wiper motor on top which rests on the rudder and makes pressure on it by its own weight. There is no reductive but wiper motor own. It has enough strenght to move the rudder. The wheel directly connected to wiper motor axis is coated with rubber to better the grip with the rudder.
The board mounted on a wooden board. In detail the input and output connections. The conection to the potentiomenter for feedback, the RS232 for GPS data and the connection to the double H bridge motor controller. Some leds indicating the state. A beep for alerts. The IR receiver for controlling the boat with an RC, yess an RC 🙂
Testing the whole thing in a real navigation situation. The solution responds quite well after 2 or 3 tests. But it still needs to be fine tuned.