homemade autopilot

Discussion in 'OnBoard Electronics & Controls' started by bertho, Nov 8, 2009.

  1. Dave911
    Joined: Aug 2011
    Posts: 70
    Likes: 2, Points: 0, Legacy Rep: 16
    Location: Indiana

    Dave911 Junior Member

    Pictures

    Attached are a couple of pictures to clarify what I am talking about.
    I got this Android app talking to the PLC the night before last.
    Last night I created a couple of screens and these are linked to the PLC.
    I also put some rudimentary code into the PLC.
    Note that this Android app can talk via multiple protocols to multiple devices. Each screen can have a different driver loaded. So on one page you could be talking to an Arduino via Modbus TCP (I think the Arduino can do that?), the next screen could be talking to a Siemens PLC similar to this one, etc. Not bad for $7 on Google Play.. :)
    I'm going with the Siemens PLC for now for a couple of reasons. I use them frequently in my day job, so I am very familiar with them. I have one on hand. This PLC draws very little power, sub 10 watts. This PLC supports Structured Text (ST) programming which is very "Pascal like" and is a standard. ST programming can contain common logic statements including if and case statements etc that will make implementing some advanced control loops possible beyond standard PID etc. Ladder logic has its limits when doing complex code. I have found that Standard PID loops are not the best for Autopilot control. I'm trying to figure out how to approach this in a better way. The aerial drone guys have pretty much nailed autopilot control for those things but a lot of that is not suitable for controlling a boat. I should point out that I am talking about controlling a sailboat, which is a lot different than controlling a power boat. When you turn a powerboat via the rudder, the speed of the boat does not change appreciably. Not so with a sailboat. Same with running downwind. Running downwind with a powerboat is pointing the bow downwind. When running downwind with a sailboat the boat dynamics get really screwy which really tests an autopilot. I'm certain that some boats cannot be sailed straight downwind with an autopilot. I had a boat that was almost uncontrollable downwind with me at the tiller. I had to fight to keep the boat from broaching in 4ft seas. The boat was a 29 ft sloop. However if I ran slightly off the wind, everything was fine. I have been told that several IOR sailboat hulls designs were like this.

    Anyway if anyone can point to some proven boat autopilot control loop algorithms written in any language, I would really appreciate it! I'm going to make all of this opensource and publish the code as I did with my previous design using the Automation Direct (Koyo) Click PLC. I would also be interested in old Autohelm code for the original wheel pilots as well. If you have some proprietary code and can't send it to me, just tell me how it works. I should be able to program it off of a description. For many points of sail the old Autohelm units still work surprisingly well even without tiller feedback. The motor hunts a lot, but it works.
     

    Attached Files:


  2. Dave911
    Joined: Aug 2011
    Posts: 70
    Likes: 2, Points: 0, Legacy Rep: 16
    Location: Indiana

    Dave911 Junior Member

    I don't know if this article has been mentioned in this thread. But I don't think so.

    http://themarineinstallersrant.blogspot.com/2013/12/the-arduino-autopilot-that-jack-built.html

    The source code is still available on Ed's Dropbox account and I was able to clone it to my account. I downloaded the Arduino files. Clearly still a work in progress. Still, if you want to go the Arduino route it is probably a really good place to start. I was really looking for his autopilot algorithm and it is all there and he explains what he does.

    Basically it is this.

    PID_Output = Gain1 *( Gain2 * Heading_Error

    Gain 3*Bearing_Rate
    )
    )
    where:
    Heading_Error
    = Heading_to_Steer

    Heading (from the compass) (proportional term).
    Bearing_Rate is the time rate of change of the compass he
    ading in the horizontal plane
    (differential term).

    I think if you have a full keel sailboat this routine might be sufficient. If you want to do an autopilot for a motorboat, it should be fine. For a higher performance sailboat/less directionally stable boat (Short Fin keel, spade rudder etc); The problem with this routine is that it can easily go unstable. If you crank up the gain to get a quick response, then you get a quick response all of the time, now matter how far off course you are. And that is really the problem with using a PID routine. You end up putting in all kinds of additional code around the PID to limit its action or compensate for its inaction.
     
Loading...
Similar Threads
  1. Deering
    Replies:
    2
    Views:
    1,811
  2. Bumbleguy
    Replies:
    3
    Views:
    3,316
  3. missinginaction
    Replies:
    1
    Views:
    5,010
  4. sv alexandra
    Replies:
    2
    Views:
    3,486
  5. missinginaction
    Replies:
    1
    Views:
    1,964
  6. missinginaction
    Replies:
    2
    Views:
    2,099
  7. Jdawg
    Replies:
    9
    Views:
    2,623
  8. Tony.R
    Replies:
    0
    Views:
    2,119
  9. Steve W
    Replies:
    0
    Views:
    1,764
  10. cal_d_44
    Replies:
    0
    Views:
    2,116
Forum posts represent the experience, opinion, and view of individual users. Boat Design Net does not necessarily endorse nor share the view of each individual post.
When making potentially dangerous or financial decisions, always employ and consult appropriate professionals. Your circumstances or experience may be different.