Auto Pilot for Tiny Yacht

Steve,

I did look up the Pololu IMU9, and you are right it is discontinued but they have a new version V2 which is in stock.
MinIMU-9 v2 Gyro, Accelerometer, and Compass (L3GD20 and LSM303DLHC Carrier) .

Here is the PID I use.

PID_output = K1 * (heading_error) - K2 * bearing_rate

The bearing rate term is the feed back. Take the case of sailing downwind in a following sea. Lets say the following sea slews the boat 15 degrees. The GPS based system will do nothing immediately. Where as the negative bearing rate term which comes from the IMU will apply an immediate rudder correction. I like to think of it this way, the GPS tells you where you are and where you have been. The heading sensor tells you where you are going.

The LCD and keypad are not needed. a single push button to tell the A/P to steer the current course is adequate. With a keypad I can increment that +/- 1 or 10 deg. Switch to Tack mode where you can tell the A/P to turn R/L 90 deg ( or some other number).

Anyway, for what it is worth. Let me know if I can help you.

Jack

Many thanks for all the information.

A main consideration I'd not really thought about and re-think . . . . Everything is driven from two 12 V batteries* totalling 52 amps (2 X 26A) and a small solar panel. I'll mainly use the Tiller Pilot when I hope to get some sleep. I won't need the Notebook/Chart Plotter program on and can save up to 2 amps/hr while it's off. So perhaps a stand-alone Arduino Tiller Pilot is the way to go. Either with separate GPS or Compass unit.

Perhaps I'll set it up on the bench over the weekend and have a play. I need to get into the Arduino code. It's a long time since I used Basic STAMPS in automated light fittings. I'll also order a V2 Gyro/Compass unit.

*Also has to supply nav lights and radio as required.

Back soon . . . . .

Steve
http://www.aroundinten.org
http://www.calvertonweather.co.uk

PS: Haa . . just found the sketch of the packaging for the original idea. I remember it now. Was going to build in it's own re-chargeable battery pack and a solar panel!

. . . In my box of bits I've found a EM406A GPS Module attached to a shield. I really don't remember buying it but have an invoice attached to it and it appears that I got it in 2010. I wrote on the back a link to where I downloaded a bit of code for the Arduino. This is the code:

void setup()
{
Serial.begin(4800);
}

void loop()
{
if (Serial.available()) Serial.write(Serial.read());
}

I've connected the Arduino+EM406A GPS via the USB cable to my computer and loaded the above code and after clicking on "Serial monitor" (under Tools, remember to change baud rate to 4800), I do get rows of GPS data containing date/time and my location etc etc.

Tomorrow I will connect a push button and a small RC Servo for test purposes and then I will really need HELP!

Thanks all

Bye for now

Steve
http://www.aroundinten.org
http://www.calvertonweather.co.uk

you ight want to have a look at my god daughters web page

she has a rather complex but working auto system,

1 Like

Many thanks drjohnsmith. I have that link already and follow Natasha's journey! She's doing GREAT! I must read through more carefully as I've not seen her automation system.

Steve
http://www.aroundinten.org
http://www.calvertonweather.co.uk

I've now connected up the bits. For test purposes I've fitted a Global EM406A GPS on a Sparkfun shield with through connections. To digital I/O pin 9 I've connected a standard RC Servo. To digital I/O pin 3 I've connected the "SET" switch.

I've run the GPS test program and can see streams of data fly up the screen on my computer monitor.
I've run the Servo test program "Sweep" and the servo rotates back and fwd 180º

Pictures:


I've used digital pin 3 for the "Set" input. The spare un-connected wires in the picture are from Pins 2 and 4 and will be for +1º -1º if added.

H E L P !

Microyacht:
I've now connected up the bits. For test purposes I've fitted a Global EM406A GPS on a Sparkfun shield with through connections. To digital I/O pin 9 I've connected a standard RC Servo. To digital I/O pin 3 I've connected the "SET" switch.

I've run the GPS test program and can see streams of data fly up the screen on my computer monitor.
I've run the Servo test program "Sweep" and the servo rotates back and fwd 180º

Pictures:


I've used digital pin 3 for the "Set" input. The spare un-connected wires in the picture are from Pins 2 and 4 and will be for +1º -1º if added.

H E L P !

hi
You generally wont let inputs float, as it will when switch is open. You may get random levels at uC input..
A pullup/pulldown may solve this.
Using switch may produce short voltage peaks (bouncing). Solve this either by software or hardware method.

What You might want next in program is to look for the sentence(s) that contains the informations you want to use.

Ship Ohoi

regards

Many thanks janiek.

Despite what I have said, I think this project will grow and I will end up adding a keypad and LCD Display, a copy of Jack's (coyotewaits) unit. These components cost so little now. In the meantime, I've ordered some breadboards and a pack of jumpers which will make it much easier to add pull-up resistors and other components.

Steve
http://www.calvertonweather.co.uk
http://www.aroundinten.org

The arduino has internal pull-ups - see the pinmode documentation, so no need for your external resistors (at least for this purpose)

My feeling is that using the GPS to determine which way you are going, is bound to fail.

If you take a GPS and walk around with, it will calculate it's position from time to time and calculate an apparent direction you are moving based on those points. If you plot them on a map ( Google earth is the easy way ), you will see a zig-zagging series of straight lines. This would be useless for steering a yacht.

Secondly, I think it would be futile to try steering a boat without knowing which way the boat is facing. A GPS cannot tell you which way the boat is facing. A digital compass which costs about $4 will tell you which way the boat is facing. In simple terms, the boat needs to be pointing in the direction that you want to go. You can then adjust this for leeward sideways drift, currents or whatever else you like. In the short term, to control the tiller to keep the boat pointing in the direction you want to go, you need a digital compass chip, not the GPS. Then, in the medium term, you use the GPS position to compare where you are, to where you want to go, and adjust the course reference that the compass is using. I wouldn't use the GPS course heading information for anything, because it is basically useless IMHO.

Thanks for that wildbill. I have found that with many microcontrollers, even with internal pull-up R's, with un-avoidable long leads on pins, it can be a problem, cured only by the lowest value resistor that will still permit a valid difference between 0 and 1! I've been involved in electronics all my life but NOT programming!

Steve
http://www.calvertonweather.co.uk
http://www.aroundinten.org

Thanks michinyon. Before I started this, I did take the GPS from my car for a walk (Internal battery now only lasts 5 mins!). I walked down the pavement (sidewalk) for almost 1/4 mile before a bend. In compass mode, It displayed 271º almost constantly! On my return, it displayed 89º. As the battery warning light came on, I quickly completed my tests by rocking the unit to simulate waves but still trying to point the GPS forward. At worst I saw only a degree error.

My small, chubby boat won't sail much closer to the wind than 40º. Progress will be slow. A few degree error on each tack won't make a whole hell of difference. If I can get a few hours sleep from time to time, it'll be a bonus. I can make overall route error steering manually while I'm awake!

You are misunderstanding what the GPS actually does. The GPS device does not know which way you are holding it ( unless it also has some kind of compass device inside it, some do.

A GPS device inherently calculated its position. Thats all. It estimates its position roughly once a second, with an uncertainly of 2 or 3 metres.

Any estimate of the direction in which you are going, is based on the difference between successive position estimates, and GPS does this quite poorly. Often much worse than you could do for yourself by plotting successive position estimates on a piece of graph paper and then drawing a line through them.

Here's why. If you are driving in a car, or you are Usain Bolt, then each position estimate is going to be 10 or 15 metres apart. Even if your latest position estimate and the one before that, are off by 2 or 3 metres ( and often much more ), it is still fairly clear which direction you are going.

But if you are walking down the street at normal speed, or in a very small boat, the successive position estimates are closer together than the uncertainty of each estimate. Suppose a particular GPS reading estimates your position to be 2 metres in front of your actual position. Suppose you walk 1 metre forward in 1 second. The next GPS reading estimates your position to be 2 metres behind your actual new position. The GPS will conclude that you are walking at 3 metres per second, backwards. This sort of nonsense would be absolutely useless for tiller control. Worse than random.

The second reason your plan will fail, is that GPS has no idea about the orientation of the boat. You could take the sails down, and the boat could be drifting sideways in the direction that the wind or current is taking it, and your GPS course would have no idea. Controlling the tiller of a yacht is about controlling the orientation of the yacht, it is not actually controlling the direction in which you are going.

. . . I'm tied-up with storm damage after monday's battering. Back soon.

Steve

Sent from a Blackberry

Steve and others interested in Arduino based full size boat autopilots. I have been working on a marine autopilot for a 40 foot sailboat for a couple of years. Last summer the autopilot steered my boat 500 miles up the inside NW passage from Seattle to the north end of Vancouver Island and back. I have just finished putting together a YouTube video showing the boat under sail and being steered by the autopilot. The video also does a brief walk through of the hardware and operating modes.

Here is the link to the video. If anyone wants to adapt this project to their needs I'll be glad to help.

Jack Edwards

GPS can be used to adjust the tiller on a sailboat short term. As long as it's moving about 1 knot or more. The compass heading is constantly changing with each swell, where GPS does not as much. With the appropriate feedback constants and timing you can steer up and down with each swell just like a human navigator would. When the speed is less than 1 knot, this is the best solution. When the seas are more flat, and speed >1 knot, only GPS is needed. I have been sailing and designing my own autopilots for 20 years. Sometimes out in the middle of the Pacific!

When you're cruising for weeks at a time with limited battery power you would not want to use the autopilot to steer up and down each swell. Mechanical wear becomes an issue. With light winds and smooth seas it is difficult to see a consistent heading with GPS, because of the slow speed. You are correct. But then you wouldn't need an update every 1 second. You can write your own code to calculate the heading every 10 seconds instead. There are only a few conditions where GPS alone without a compass is not appropriate, rough sea state with little wind. A compass is needed. But there are also many conditions where an electronic auto pilot fails to work efficiently, regardless of the sensor. During a storm I'd prefer a Windvane.

The absolute error can be 10m. But from one second to the next the error changes by only inches. So even when you're moving slowly, the line is straight when you plot it. Data can be obtained 10x per second with a modern GPS.

No comments? I guess we're all in agreement then! :slight_smile:

coyotewaits:
Steve and others interested in Arduino based full size boat autopilots. I have been working on a marine autopilot for a 40 foot sailboat for a couple of years. Last summer the autopilot steered my boat 500 miles up the inside NW passage from Seattle to the north end of Vancouver Island and back. I have just finished putting together a YouTube video showing the boat under sail and being steered by the autopilot. The video also does a brief walk through of the hardware and operating modes.

Here is the link to the video. If anyone wants to adapt this project to their needs I'll be glad to help.

Jack Edwards Arduino Based Sailboat Autopilot #1 - YouTube

Jack Edwards

Many thanks for your work. It has inspired me to start on an autopilot for my old C&C-33-1.
One question about the Pololu:

From github: GitHub - pololu/minimu-9-ahrs-arduino: Arduino program for building an AHRS with a Pololu MinIMU-9
"When the AHRS program first starts running, it takes some readings to establish a baseline orientation, during which it expects both the roll and the pitch of the sensors to be zero. Therefore, it is important to keep the MinIMU-9 level for a few seconds after powering on or resetting the Arduino or connecting to it from a computer."

Won't this be problematic if you power up or reset the autopilot after you're already underway?

--Bob M

michinyon:
My feeling is that using the GPS to determine which way you are going, is bound to fail.

If you take a GPS and walk around with, it will calculate it's position from time to time and calculate an apparent direction you are moving based on those points. If you plot them on a map ( Google earth is the easy way ), you will see a zig-zagging series of straight lines. This would be useless for steering a yacht.

Secondly, I think it would be futile to try steering a boat without knowing which way the boat is facing. A GPS cannot tell you which way the boat is facing. A digital compass which costs about $4 will tell you which way the boat is facing. In simple terms, the boat needs to be pointing in the direction that you want to go. You can then adjust this for leeward sideways drift, currents or whatever else you like. In the short term, to control the tiller to keep the boat pointing in the direction you want to go, you need a digital compass chip, not the GPS. Then, in the medium term, you use the GPS position to compare where you are, to where you want to go, and adjust the course reference that the compass is using. I wouldn't use the GPS course heading information for anything, because it is basically useless IMHO.

What kind of GPS you use?????