Howto:Design an autopilot: Difference between revisions

Jump to navigation Jump to search
Nav modes.
m (heading-hold)
(Nav modes.)
Line 343: Line 343:


Decreasing the gain of 2.5 should help, if your roll-rate is too slow.  
Decreasing the gain of 2.5 should help, if your roll-rate is too slow.  
==NAV modes==
In lateral nav mode, the primary goal of the autopilot is to intercept and maintain a certain ground track. This could be a VOR radial, a LOC course or back course or a GPS track. For most autopilots these are basically the same and it does not know anything about the source of the signal. Everything it knows is your current heading, your desired course and a course offset. And these are the properties, we need for our NAV hold mode.
Now, how does the autopilot knows which direction to steer? Lets assume you want to intercept the radial 270 of some VOR. VOR radials "radiate" away from the station, so the 270 radial points away from the station with a heading of 270degrees (which is west).Lets further assume you are somewhere south-west of the VOR station - this is between radial 180 and 270 - and you fly on a heading of 250 (this will become important later).
Now you have the most important facts at hand you need for navigation:
* Q1: Where am I?
* A1: South-west of the VOR
* Q2: Where would I want to be?
* A2: On radial 270 of the VOR
As a rule of thumb, interception of radials should occour at angles of 30° to 45°. Intercepting at angles lower than 30° takes ages to get you there, intercepting at greater than 45° angles might result in a very steep turn to not overshoot the radial. We pick 45° because I like this value most.Our next question to answer is
* Q3: Which way should I fly to get where I want to be?
* A3: To intercept the course of 270° at a 45° angle, fly 270°+45°=315°
Now that we know which way we should fly we can easily answer
* Q4: Which direction do I have to turn?
* A4: You are currently heading 250°. You want to fly heading 315°, so turn right by 65°.
That's basically all the magic about navigation. Now let's implement this in the autopilot. One part is already done: Q4/A4 is your heading-hold stage, so it's probably best to move backwards from that stage.
First, add a new, switchable input element to your heading offset computer. Just change this:
<filter>
  <name>Heading Offset Computer</name>
  <debug>false</debug>
  <type>gain</type>
  <gain>1.0</gain>
  <input>/autopilot/settings/heading-bug-deg</input>
  <reference>/orientation/heading-magnetic-deg</reference>
  <output>/autopilot/internal/heading-offset-deg</output>
  <period>
  <min>-180</min>
  <max>180</max>
  </period>
</filter>
to this (that is, adding the upper input part):
<filter>
  <name>Heading Offset Computer</name>
  <debug>false</debug>
  <type>gain</type>
  <gain>1.0</gain>
  <input>
  <condition>
    <equals>
    <property>/autopilot/locks/heading</property>
    <value>nav1-hold</value>
    </equals>
  </condition>
  <property>/autopilot/internal/intercept-heading-deg</property>
  </input>
  <input>/autopilot/settings/heading-bug-deg</input>
  <reference>/orientation/heading-magnetic-deg</reference>
  <output>/autopilot/internal/heading-offset-deg</output>
  <period>
  <min>-180</min>
  <max>180</max>
  </period>
</filter>
Now, if /autopilot/locks/heading equals "nav1-hold", the heading offset computer uses the intercept-heading-deg property as the target heading to fly.For any other value, the old heading-bug value is used. You can already test, if it works. Use the property browser to set this stage to nav-hold and enter any arbitrary value into intercept-heading-deg. Your aircraft should turn to the entered heading on the shortest path. It is crucical that this mode is stable, so spend some time again and double check.
Next, we need to compute the intercept-heading-deg automatically. This is based on the offset from the desired course with a maximum intercept angle of 45°. The [[CDI]] is our friend, it tells us about our course offset, so we use that property in our stage feeding the Heading Offset Computer.
This is a very simple stage, it just substracts a course error (which we will compute in the next stage) from our selected course and normalizes the output into the [0..360] degree interval:
<filter>
  <name>Intercept Heading Computer</name>
  <debug>false</debug>
  <type>gain</type>
  <gain>1.0</gain>
  <input>/autopilot/internal/selected-course</input>
  <reference>/autopilot/internal/course-error-deg</reference>
  <output>/autopilot/internal/intercept-heading-deg</output>
  <period>
  <min>0</min>
  <max>360</max>
  </period>
</filter>
This stage only makes sense with a preceding one computing the course error from the cdi deflection. We want something that spits out 45 for a full CDI deflection and one might think of a <gain> filter to do this. But we also want an automatic wind correction in case of cross wind. For that we also need an integrator. Because we need to compute absolute values for the output, a pi-simple-controller is our choice here:
<pi-simple-controller>
  <name>cdi-integrator</name>
  <debug>false</debug>
  <config>
  <Kp>45.0</Kp>
  <Ki>0.40</Ki>
  </config>
  <input>/autopilot/internal/cdi-deflection</input>
  <output>/autopilot/internal/course-error-deg</output>
  <min>-45.0</min>
  <max>45.0</max>
</pi-simple-controller>
It takes our CDI deflection and compares to zero (note the missing reference element which defaults to zero). The result is multiplied by Kp (45) and a value of 0.4° per second is added to the offset. The output is clipped to 45°.
You now have all stages, you need for the LNAV section. To compute the values in the correct order, they should be in the order
# cdi-integrator
# intercept heading computer
# heading offset computer


[[Category:Aircraft enhancement|Design an autopilot]]
[[Category:Aircraft enhancement|Design an autopilot]]
[[Category:Howto|Design an autopilot]]
[[Category:Howto|Design an autopilot]]

Navigation menu