Frankenpilot the Homemade Autopilot

I built my own tillerpilot for my sailboat. 

I'm calling it the Frankenpilot because it's big--  as Victor Frankenstein says

"As the minuteness of the parts formed a great hindrance to my speed, I resolved, contrary to my first intention, to make the being of a gigantic stature..."

And because it is made from things lying around:

"The dissecting room and the slaughter-house furnished many of my materials; and often did my human nature turn with loathing from my occupation, whilst, still urged on by an eagerness which perpetually increased, I brought my work near to a conclusion."

picture of the autopilot

I had, laying around in my garage:

  • A broken analog tillerpilot (sensor was broken, but drive works)
  • An aircraft grade inertial measurement system (Microstrain 3DM) for a compass/gyro/tilt sensor
  • A GPS car autopilot board with an atmel microcontroller and LCD
  • A 12V speed controller
  • A LORAN navigator that came with my boat, which had a nice LCD and keyboard in a waterproof case.

My friend Bryan made a nice autopilot for his boat, and he told me his LQR control design scheme.  He also gave me his dynamic model, so I could design my own feedback controller.  His model was based on data from sailing his Ultimate 24 Max, a much lighter boat than Firebolt, but I figured it would be close enough to get started.

So with all this, how could I not build my own autopilot?

Actually, I did buy a rudder sensor from Bob of Ragtime off of the SSS forums.

I used it in the 2011 Vallejo 1-2 race, singlehanded to Vallejo.  It worked pretty well (I came in 3rd in my division on Saturday).  It had worked better in my earlier tests when it had not been so windy, it proved a bit unstable in the bigger breeze of the race.  I will be adjusting gains to fix this.  I can choose from 10 different gain settings so I should be able to find something that works.  The ram is also a bit slow, but I am not sure whether that is a showstopper or not at this point.


          -K[igain][2]*headingdot + K[igain][3]*head_error_int; //units are volts

The gains are calculated using a LQR design technique.  This was my friend Bryan's idea, and it is a nice way to go.  With LQR you can trade how fast your system responds to disturbances with how much power you put into the actuator.  If I was to sail to Hawaii the power budget would be pretty important, and I might want a minimally-steering autopilot, but in big waves I might be willing to use more power in an aggressively-steering autopilot.  I pre-calculated 10 gain sets that vary from super-low-power to very-aggressive-rudder-hammer.  Matlab makes this simple if you have a dynamic model.  I can change the gain set on the fly to whatever seems appropriate.  The igain variable in the equation above contatins the gain setting; the other index is which state the gain goes with.  I'm still working on the best gains to use, and also using logged data to create a dynamic model for my boat.

There are some modifications to the basic LQR scheme.  Since a regulator tries to drive the states to zero, heading error is used in place of the heading state (or else the autopilot would only steer North!).  The commanded heading can be changed with button presses, but it ramps from one setpoint to the next to give the boat a chance to keep up.  The integrated error is reset to zero when large heading changes are commanded, and the integration is halted if the motor is at its max voltage or the rudder is hard over.  The integration feedback is necessary to trim steady-state errors but it is destabilizing so you need to be careful with the calculations.


Here is some data from sailing the boat.

This plot shows commanded heading and actual heading as the boat sailed downwind on a gusty day.  I had a single reef in the main and the spinnaker up; I was singlehanding.  I think the oscillations are the waves making the boat turn, but I need to log the pitch and roll of the boat to see for sure.  I only tried one gain setting too-- if I had tried some more it might be clearer whether the autopilot is oscillating or the boat.  In any case, the boat steered itself just great: I was able to jibe, adjust the heading command for the wind shifts, and I let the autopilot drive the whole time.

Here's some upwind data from the same day.  I had to really work hard on the buttons to keep the boat on the wind as it shifted and the gusts came down.  I was a little overpowered with only me hiking out, and I was working the traveller and mainsheet actively to keep the boat trimmed, so the autopilot had plenty to do.  The time scale is zoomed out relative to the plot above.  The autopilot was driving the tacks you see too.

 

 

  

Random Images

remote_boxside.jpg
boxside.jpg