Share post
You already know that with such a title that the answer is going to be VERY. but that is a boring outcome alone, so I will add a lot more context. I want to add a few curse words, but you’ll just have to use your imagination in the appropriate parts. Be aware, there is no happy solution here, and no ending as of yet.
But why bother?
Well you might remember that I have a sailboat. In having a sailboat you will come to learn there is a multitude of equipment available to help you sail efficiently. In no particular order our boat has:
- a GPS
- an Autopilot
- a VHF Radio
And remember, I am an engineer which means I need to make things more complicated even if it doesn’t help, so I immediately started messing with all of it and trying to get all the devices to talk to each other. Because I am insane, clearly.
No, the real reason is we wanted to be able to start preparing for a more comfortable, longer journey. This means having automation reduce our workload. I also used to fly planes and skydive back in the United States. There is the idea in training for those activities that high workload leads to pilot errors that accumulate and can result in incidents or accidents. I like to apply this to many things in life, and in my eyes a sailboat is no different.
The goal is to be able to sail solo and to do that I need to also be able to pilot the boat from anywhere if needed. For that I do have a pretty neat app that I made that can fudge location and ship data to make an autopilot steer for me… but that brings me to the main issue at hand in this post…
A broken Autopilot
Broken is not really the right term. We have an autopilot that mounts to the tiller of our boat (the stick that we steer with). It works in manual mode, where you can hit buttons and make the actuator move to adjust steering direction. However, what we really wanted was for the navigation function to work. This means that you could theoretically put in some coordinates in the GPS and it could “talk” to the autopilot and tell it to adjust course and how.
We first looked at the hardware and wiring to see if something was missing. You might remember the mess of wires I went through to fix things in a previous post, well wires that WEREN’T there were the ones that allow the GPS to talk to the autopilot. Great. Easy fix right? Well unfortunately not for some frustrating reasons. Manuals are impossible to find online for boating equipment. I don’t know why this is, but it’s all paywalled, or in some obscure forum post that requires a new login account
I was lucky enough however to find some documentation on the hardware in a service manual that helped me find out the right connections. I also had some cable that let me attach this to our GPS for testing.
I thought this would fix it, and we took off on a sailing adventure to try things out. Buuuut the autopilot quickly showed it wasn’t working. We knew this because it would go into NAV mode, and then scream at us by beeping loudly and then turning us into a random direction.
Sounds scary, but since as a cruising sailboat we never really go more than 4 knots average, this is not a big deal. Just take off the autopilot and correct with some minor embarrassment.
NMEA and me
So coming back to the whole not having a manual issue, well I managed to find one online for my model of autopilot we had, and it was a breath of fresh air, because it also showed us that there were certain messages it needed to work properly. This was my first introduction to the National Marine Electronics Association. They designed this protocol that ship equipment uses to talk to each other. For example, if your GPS needs to talk to your radio for some reason, this is the way it would do that. NMEA protocols come in two flavors, NMEA 0183, and NMEA 2000.
NMEA 0183 – the easy stuff
This is easy, because it’s basically messages just written as plan messages you can read as a human. It didn’t take long to hook into the GPS and confirm that things looked good. All it took was a small raspberry pi you can buy for about 500 SEK (~$50 USD) and some programming, which hey I can do that. An example of what you see is:
$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
Sparing ugly details, this is just telling some information about where you’re going and how far off you are. This all made sense and it seemed like this part was working. I could also see that the messages seemed to make sense for what I put into the GPS so that was great, except not because things working great means you need to diagnose further. Annoying.
To go further I had to learn that the internal compass in the autopilot might be the issue. I read somewhere that our autopilot could take information from a separate compass source. This makes sense to me as you might have some local interference like Bob and his giant boombox speakers throwing off the magnetic readings. Thanks, Bob!
I read up some more on this and it turned out there is a message type in NMEA 0183 to send your ship’s compass direction (heading as it is called) to other devices. However, it seemed that this is something that the lovely makers of our autopilot did not want to use, and they instead opted for only allowing that specific information to be given via the “modern” (late 1990s) protocol called NMEA 2000. Remember, the autopilot’s navigation data was sent with the protocol I described above so I was super confused why this would be the case.
NMEA 2000
Sounds easy enough right? I mean you just need to look at the data like with NMEA 0183 right? Well it turns out that it’s just a bunch of 1’s and 0’s that can’t be read by a human. This is common to save some bandwidth in older or more hardened systems since you want to send as little data as possible, so I thought “Okay I just need to know the message formats.”
Did I mention you need to pay 40.000 SEK ($4000 USD) to buy some example data mappings to know what message data contains which fields? No? Cool because that would be insane right? haha ha.
Anyway I still haven’t figured this out. I did get so far as to use a few open source tools to help me figure it out, and there are some cool people doing a lot of good work to help understand all the messages that are out there and in use:
- https://canboat.github.io/canboat/canboat.html is a site I have used to help get some understanding of how to format the binary messages and headers
- https://kvaser.com/wp-content/uploads/2014/08/nmeacan.pdf is a good description of the overarching design of the protocol, though it does miss on what data messages can be used
Overall I am always disappointed in this sort of closed environment, but I did hear boat tax was a thing. I always wonder how different the internet would be if it cost anyone $4000 USD just to learn what a URL was or how to make a small program just for fun while learning.
Next Steps
Our autopilot is still broken, but I have GRAND plans for it, so I am not giving up. I will be taking a crack at decoding NMEA2000 and getting my small raspberry PI to talk to the autopilot and give it fake compass data if it’s the last thing I do. However, since it is painful to go to the boat and not beat the powers that be at understanding this stuff, I did start playing more locally with some of the open source tools that seem to work for others.
My hope is I can reverse engineer some of their work or even contribute to them since I do think getting devices to communicate to each other is a massive safety win and something I think anyone with some basic programming or electrical skills should be able to do.
I hope to make a post soon about how this is now working.