Social Icons

Pages

Friday 24 January 2014

The Arduino autopilot that Jack built


Autopilot kit for sale. Only $350, some assembly required. Jack Edwards, a mechanical, engineer, loom builder (yes as in weaving), and many other things in his professional career has built a functioning Ardunio based sail boat auto pilot system. The little Ardunios have piloted his aptly named boat the Wile E. Coyote over 400 miles this summer using both heading, and GPS track mode with cross track error correction. There are some chores left to complete such as wind instrument integration, but it's an impressive success with such a tiny capital outlay. 


Jack's boat is a 1983 Robert Perry designed 40 Nordic Yachts sloop with a vintage (1986) Wagner compass steer autopilot. So why build an Ardunio based system?

In Jack's words, "I always wanted to have an autopilot with modern capabilities and thought about building one using PC based programming but couldn't figure out how to handle the interfaces with inputs and outputs. About three years ago my son showed me an Ardunio a friend had loaned him. Wow, that was exciting and now I have it to a point where it is a working system."

Although functioning, parts of it are still packaged in a prototypical way. From small cardboard encased electronic prototype acorns, mighty oak autopilots grow. You can watch this video of Jack showing it operating and discussing it here.


The elements in Jack's autopilot, are the same as found in any autopilot. We have a computer processor. In this case he is using two Ardunio Megas. One for the GPS processing, and the second one for everything else.

There is a display to view data, and a DC motor drive system for the hydraulic pump. A nine degree of freedom IMU (Inertial Measurement Unit) with a magnetometer, gyro, and accelerometer along with a rudder position sensor.


The block diagram shows the primary components and their basic connections. The left side Ardunio has the GPS interfaced to one of its four serial ports.

The other Arduino is handling the data from the IMU, rudder reference, DC hydraulic motor drive, and the data display. The two Ardunios communicate with each other using serial data ports, and a fast software routine called "Easy Transfer".


The Ardunios are 2560 Megas. The one I purchased from Sparkfun cost me $62.10 with shipping.

Don't let the small 4" x 2" size fool you. There is considerable computing horse power in this little board. 16 analog inputs, 54 digital input and output pins, 14 of which can be used as PWM (Pulsed Width Modulated) outputs. Add to this 4 serial ports USB port, and a 16 MHz clock, all driven by an Amtel AT2560 RISC (Reduced Instruction Set Computer) processor.

The quarter sized Pololu IMU is the heading compass. It has a retail price of about $40.00. Like any digital heading compass on a boat it needs to be located about a meter away from any ferrous metals, and requires initial calibration.

Jack used a Honeywell hall effect sensor to build the rudder reference. As the rudder turns, the shaft in the sensor rotates, and the voltage changes. The voltage output varies from .5VDC to 4.5 VDC.

This voltage range covers up to ninety degrees of rudder movement (+-45 degrees). So a reading of 2.5 volts would mean the rudder is centered. The rudder sensor voltage readings are read by the analog inputs on the Ardunio. The rudder centered is at 2.5 volts.

For $18.00 you can have a data display from Adafruit. It's 20 characters wide, by 4 rows, and you can create up to 8 special symbols. This is available for a couple of dollars more in a variety of LED colors. It has PWM adjustable dimming capability, and contrast control.



Jack's boat has a Wagner heading steer only autopilot. Translated this means the autopilot will keep the bow pointed to a compass heading but can't compensate for currents, winds, or waves that are all shoving on the boat. The existing Wagner hydraulic pump on the boat, is being used in the system. The Wagner pump is a 12VDC (PV100-12-TR) and draws 11 amps. This is not unlike a Raymarine Type 1 hydraulic autopilot pump.

The difference in this system is the solenoid valve that when open allows manual steering, and when closed the pump does the steering. The pump is managed with a Pololu Qik 2s12v10 serial DC motor controller.

"Its only possible because I'm standing on the shoulders of giants." Robert Huiteme.

Jack, like Robert is also standing on the shoulders of giants. Ardunio software is open source and is licensed under Creative Commons. This means a vast array of software is available for free use with attribution. For example in Jack's software module A_GPS routine that is parsing the NMEA sentence RMC (position, speed, track) you see the line "GPS Reading based on code by Igor Gonzalez Martin. 05-04-2007." Instead of having to start from scratch, there was existing software that could be just tweaked, if needed at all to use. This is the miracle of the open source community. In the case of a marine autopilot there was a lot of existing usable code, but a good chunk Jack had to write himself.

Looking at the diagram above you will recognize a lot of the acronyms such as COG (Course Over Ground). There are a couple that your chart plotter doesn't typically show you. They are BOD (Bearing Origin to Destination) and CTS (course to steer).

BOD is a NMEA 0183 sentence that has the origin and destination waypoints, and the bearing between them to the destination. CTS is the direction you need to steer to get back on your original course line.

Rule one! Your autopilot is not allowed to just make up a new bearing to get to the waypoint. It's supposed to keep you on your original course line (BOD). CTS is not the direction the bow is pointing, but the direction you want to travel in. As an example, a sailboat may have to crab upwind to maintain the desired course.

This is done by calculating a XTE (Cross Track Error) correction factor that is added or subtracted from the existing bearing to waypoint. Using this correction a new heading can be derived to take you towards your original course. I've simplified this a lot, but this is a tricky bit of calculating software.

The system is operational. It steers by compass heading (Button 1), GPS steering to waypoint (Button 2), adjustable tack mode (button 3), and yet to be completed wind angle steer (Button 4). The system can also make incremental changes to the heading direction, has a helm data display, and control pendant. There is also gain and a form of response rate control (less pump usage). 

There are still some things not yet completed, and assorted minor software issues. Jack has Raymarine wind instruments that speak Seatalk. Rather than write a routine from scratch to parse Seatalk, I have a Raymarine Seatalk to NMEA converter lying around someplace that I'm going to send him. This will speed up development of this wind integration portion of the system.

When running a route, the vessel doesn't start the turn until you have arrived at the waypoint, and this can cause a overshoot on the next leg when turn angles are large. It corrects itself, but it would be better, if the turn started prior to waypoint arrival. There have also been some intermittent system freezes when a new route has been completed, and there are also some issues with the GPS's 1 second update speed. Some of this might be correctable with a faster 10Hz GPS. Have no doubts, that Jack is a persistent guy, and these warts will be found, and removed.

Jack has done an amazing job, and I think he is now one of the "Giants" others can stand on the shoulders of. The project continues on, and it proves it's feasible to do this with the same capabilities of mainstream commercial autopilots, at a fraction of the cost. Jack is also the only person I'm aware of who has gone this far in the development of a Ardunio based marine autopilot system. For those who are interested in pursing this type of activity, there is now a substantial library of software and hardware details  in his Dropbox site you can use to start with. I will provide the link below.

Jack is now so far along in his development his software, like all autopilot manufacturers he now has a disclaimer splash screen, and I think this speaks volumes about Jack's efforts.

"This software was developed as an experiment by the author to provide an auto pilot for his boat. It is made available to others who want to develop a Do It Yourself autopilot. The User accepts all responsibility for the safe operation of the boat recognizing that hardware and software errors can occur. The User also acknowledges that it is their responsibility to safely wire and install the autopilot components in accordance with appropriate codes and standards, and understand the system capabilities."

I now have an Ardunio Mega. I couldn't live without one after writing so much about them. It's huge fun to play with, for me at any rate. I think the first real project will be to make the "Digital Magic Eight Ball". This will give me some experience with writing to a display, and you can bet it will have some interesting prognostications. The second project is to make a sailboat wind instrument with a display for under $200 using the Peet Bros. anemometer. Robert Huiteme has written most of the code, and the balance I can figure out myself. It's good to have broad shoulders to stand on.

Jack Edwards Ardunio marine autopilot drop box link. You will also find his email link there.

The software requires Ardunio's IDE system to view. You can download it for free here. It is available for Windows, Mac OSx, and Linux 32/64 bit operating systems.

The wiring diagrams require Fritzing software to see, and it's free from here.

Product phot0s are from the Pololu and Sparkfun websites.

All other diagrams and photos are by Jack Edwards.

No comments:

Post a Comment