Autopilot configuration reference: Difference between revisions

Jump to navigation Jump to search
Adding tags to headings; De-camel case; etc
m (→‎Structure Of a Configuration File: Template:Note → Template:Tip)
(Adding tags to headings; De-camel case; etc)
Line 6: Line 6:
This page serves as a reference for the elements of [[FlightGear]] xml [[autopilot]] configuration files. It describes all elements available within the autopilot configuration file supported in the bleeding edge [[Git]] sources. Some of the elements may not be available in the current release version of FlightGear.
This page serves as a reference for the elements of [[FlightGear]] xml [[autopilot]] configuration files. It describes all elements available within the autopilot configuration file supported in the bleeding edge [[Git]] sources. Some of the elements may not be available in the current release version of FlightGear.


The flightgear xml based autopilot system can run at FDM rate or at frame rate. Using a <autopilot> tag in your aircraft's -set.xml  
The FlightGear xml based autopilot system can run at FDM rate or at frame rate. Using a <autopilot> tag in your aircraft's -set.xml  
adds the autopilot at fdm rate, using a <property-rule> runs the same config at frame rate.
adds the autopilot at FDM rate, using a <property-rule> runs the same configuration at frame rate.


{{Systems_Modeling_Disclaimer}}
{{Systems_Modeling_Disclaimer}}
Line 15: Line 15:
For built-in runtime plotting of FlightGear properties (including FDM/Autopilot properties), check out [[FGPlot]] (available in FlightGear 2.11+).
For built-in runtime plotting of FlightGear properties (including FDM/Autopilot properties), check out [[FGPlot]] (available in FlightGear 2.11+).


== Structure Of a Configuration File ==
== Structure of a configuration file ==
Autopilot configurations live in a separate file, formatted using the well known XML syntax like so many other FlightGear files with a PropertyList node as a root element. A basic skeleton file looks like this:
Autopilot configurations live in a separate file, formatted using the well known XML syntax like so many other FlightGear files with a <code>&lt;PropertyList&gt;</code> node as a root element. A basic skeleton file looks like this:
 
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <?xml version="1.0" encoding="UTF-8"?>
  <?xml version="1.0" encoding="UTF-8"?>
Line 42: Line 43:
The location and the name of the configuration file is up to the developer. A descriptive name like 'autopilot.xml' might be a good choice. Most developers put these files into the Systems folder of the aircraft.
The location and the name of the configuration file is up to the developer. A descriptive name like 'autopilot.xml' might be a good choice. Most developers put these files into the Systems folder of the aircraft.


== Adding an Autopilot Configuration to Aircraft ==
== Adding an autopilot configuration to aircraft &lt;autopilot&gt; ==
Autopilot configuration files are added to the aircraft by adding  
Autopilot configuration files are added to the aircraft by adding
 
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
   <autopilot>
   <autopilot>
Line 50: Line 52:
</syntaxhighlight>
</syntaxhighlight>


to the  
to the
 
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <sim>
  <sim>
Line 64: Line 67:
node of your aircraft-set.xml file. Note, that more than one <autopilot> node may be present, each will create a new instance of the autopilot subsystem when running FlightGear. They run in the order of appearance under <systems>. For example, lateral and vertical autopilot modes could live in separate files, as could a yaw-damper system.
node of your aircraft-set.xml file. Note, that more than one <autopilot> node may be present, each will create a new instance of the autopilot subsystem when running FlightGear. They run in the order of appearance under <systems>. For example, lateral and vertical autopilot modes could live in separate files, as could a yaw-damper system.


== Adding a Property-rule Configuration to Aircraft ==
== Adding a property-rule configuration to aircraft &lt;property-rule&gt; ==
Property-rules can also be used in which case they will run at frame rate. You can use these to process properties so their values can be used by other systems outside of the autopilot scope (for example to create smooth animations for switches that normally have discrete values)
Property-rules can also be used in which case they will run at frame rate. You can use these to process properties so their values can be used by other systems outside of the autopilot scope (for example to create smooth animations for switches that normally have discrete values)


To achieve this load your filters configuration by adding:
To achieve this load your filters configuration by adding:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
   <property-rule n="100">  <!-- "n" needs to be >= 100 to avoid overwriting other predefined global rules (in particular the environment ones) -->
   <property-rule n="100">  <!-- "n" needs to be >= 100 to avoid overwriting other predefined global rules (in particular the environment ones) -->
Line 76: Line 80:


to the :
to the :
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <sim>
  <sim>
Line 89: Line 94:
node of your aircraft-set.xml file. Note that you can add multiple <property-rule> elements, similar to the <autopilot> as described above.
node of your aircraft-set.xml file. Note that you can add multiple <property-rule> elements, similar to the <autopilot> as described above.


== Available Elements ==
== Available elements ==
All elements may contain the attributes "include" and "alias".  
All elements may contain the attributes "include" and "alias".  
The "include" property takes a file name as a parameter. This can be used to read the document tree of an external XML file into the node containing the "include" attribute. The included file must have a PropertyList node as the root node. All nodes under this PropertyList node will be added to the node containing the "include" attribute.
The "include" property takes a file name as a parameter. This can be used to read the document tree of an external XML file into the node containing the "include" attribute. The included file must have a PropertyList node as the root node. All nodes under this PropertyList node will be added to the node containing the "include" attribute.
Line 102: Line 107:
* <flipflop>
* <flipflop>


== Common Elements Used By All Elements ==
== Common elements used by all elements ==


=== Name ===
=== Name of filter and controller &lt;name&gt; ===
The <name> element is optional, but should be added to give the controller a distinct name. It is only used in debug output.
The <name> element is optional, but should be added to give the controller a distinct name. It is only used in debug output.
<syntaxhighlight lang="xml">
  <name>NAV hold</name>
  <name>NAV hold</name>
</syntaxhighlight>


=== Feedback if disabled ===
=== Feedback &lt;feedback-if-disabled&gt; ===
The <feedback-if-disabled> element advises the controller to feed back the output property value to the active input property if the
The <feedback-if-disabled> element advises the controller to feed back the output property value to the active input property if the
condition defined in the <enable> tag evaluates to false. This is usually required for controllers like servo drivers behind a PID-controller to give that PID-controller a valid starting value when it becomes enabled. The absence of this element or anything but the word ''true'' within this element results in feedback disabled.
condition defined in the <enable> tag evaluates to false. This is usually required for controllers like servo drivers behind a PID-controller to give that PID-controller a valid starting value when it becomes enabled. The absence of this element or anything but the word ''true'' within this element results in feedback disabled.
<syntaxhighlight lang="xml">
  <feedback-if-disabled>true</feedback-if-disabled>
  <feedback-if-disabled>true</feedback-if-disabled>
</syntaxhighlight>


=== Debug ===
=== Printing debug output &lt;debug&gt; ===
If the <debug> element is present and if it contains the word ''true'', the containing controller prints out some diagnostic information on the console for each processing loop.
If the <debug> element is present and if it contains the word ''true'', the containing controller prints out some diagnostic information on the console for each processing loop.
<syntaxhighlight lang="xml">
  <debug>true</debug>
  <debug>true</debug>
</syntaxhighlight>


=== Input and Reference ===
=== Input and reference properties or values &lt;input&gt; and &lt;reference&gt; ===
Each controller has two input "lines", denoted by the tags <input> and <reference>. The arithmetic difference of these two values is used by the respective controller to compute it's output. Unfortunately due to historical reasons, the sign of input and reference is not consistent for all controllers. While the pid-controller and the pi-simple-controller compute "reference-input", the filter controller computes "input-reference". Each element is optional with a default value of zero. These elements are made of so called '''Input Values''' described further down in this document.
Each controller has two input "lines", denoted by the tags <input> and <reference>. The arithmetic difference of these two values is used by the respective controller to compute it's output. Unfortunately due to historical reasons, the sign of input and reference is not consistent for all controllers. While the pid-controller and the pi-simple-controller compute "reference-input", the filter controller computes "input-reference". Each element is optional with a default value of zero. These elements are made of so called ''input values'' described further down in this document.


Example for a simple differential amplifier, computing output = (input-reference)*2
Example for a simple differential amplifier, computing output = (input-reference)*2
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 131: Line 146:
</syntaxhighlight>
</syntaxhighlight>


=== Output ===
=== Output property &lt;output&gt; ===
The <outptu> element names the properties, the computed value should be written to. More than one <output> may be present, each named property will be assigned the computed value.
The <output> element names the properties, the computed value should be written to. More than one <output> may be present, each named property will be assigned the computed value.
 
<syntaxhighlight lang="xml">
  <output>controls/flight/elevator</output>
  <output>controls/flight/elevator</output>
</syntaxhighlight>
   
   
=== Enable ===
=== Enabling and disabling a filter &lt;enable&gt; ===
Controllers can be enabled or disabled using property values. This element <enable> may contain a <prop> and a <value> element. The controller is enabled, if the value of the named property equals the given value. This feature is considered deprecated and might go away in future releases. The preferred way of defining the enable-condition is by adding a <condition> element to the <enable> element. This <condition> follows the same syntactical rules as the one used in model animations and can model complex expression trees.
Controllers can be enabled or disabled using property values. This element <enable> may contain a <prop> and a <value> element. The controller is enabled, if the value of the named property equals the given value. This feature is considered deprecated and might go away in future releases. The preferred way of defining the enable-condition is by adding a <condition> element to the <enable> element. This <condition> follows the same syntactical rules as the one used in model animations and can model complex expression trees.
To enable a wing leveler only if the current bank angle does not exceed 30° of bank, use this condition
To enable a wing leveler only if the current bank angle does not exceed 30° of bank, use this condition
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <enable>
  <enable>
Line 153: Line 172:
</syntaxhighlight>
</syntaxhighlight>


=== Input Values ===
=== Input values ===
Input values for controllers may be specified in several notations. Values may be supplied as constants, from properties or by means of simple linear transformations. Conditions allow the selection of one of multiple input sources. The following text will use the <tt>reference</tt> element as an example but it may be substituted by any other input element like <tt>Kp</tt>, <tt>gain</tt> etc. Input values will be interpreted as double values.
Input values for controllers may be specified in several notations. Values may be supplied as constants, from properties or by means of simple linear transformations. Conditions allow the selection of one of multiple input sources. The following text will use the <tt>reference</tt> element as an example but it may be substituted by any other input element like <tt>Kp</tt>, <tt>gain</tt> etc. Input values will be interpreted as double values.


==== A constant value ====
==== A constant value &lt;value&gt; or &lt;reference&gt; ====
A constant value is defined by just adding the value as text to the input element:  
A constant value is defined by just adding the value as text to the input element:  
<syntaxhighlight lang="xml">
  <reference>
  <reference>
   <value>3.5</value>
   <value>3.5</value>
  </reference>
  </reference>
</syntaxhighlight>
The shortcut syntax is also valid:
The shortcut syntax is also valid:
<syntaxhighlight lang="xml">
  <reference>3.5</reference>
  <reference>3.5</reference>
</syntaxhighlight>


If the text can be parsed by <tt>strtod()</tt> to a double value, it will be used as a constant value, otherwise it will be interpreted as a property value (see next paragraph)
If the text can be parsed by <tt>strtod()</tt> to a double value, it will be used as a constant value, otherwise it will be interpreted as a property value (see next paragraph)
Line 168: Line 194:
==== A property value ====
==== A property value ====
To evaluate the value of a property, place the name of the property into the text element:
To evaluate the value of a property, place the name of the property into the text element:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 175: Line 202:


The shortcut syntax is also valid:
The shortcut syntax is also valid:
<syntaxhighlight lang="xml">
  <reference>/my/property</reference>
  <reference>/my/property</reference>
</syntaxhighlight>


{{note|The shortcut syntax is only valid, if neither <property> nor <value> element exists.
{{note|The shortcut syntax is only valid, if neither <property> nor <value> element exists.
Line 182: Line 211:
{{note|For backward compatibility, the notation <prop> instead of <property> is also valid but considered deprecated and might go away in future releases.}}
{{note|For backward compatibility, the notation <prop> instead of <property> is also valid but considered deprecated and might go away in future releases.}}


==== Linear transformation of the input value ====
==== Linear transformation of the input value &lt;offset&gt; ====
Input values may be scaled and shifted before they are processed by the controller using the formula <tt>y = value * scale + offset</tt>
Input values may be scaled and shifted before they are processed by the controller using the formula <tt>y = value * scale + offset</tt>
To use a celsius temperature property in a controller which expects the temperature in fahrenheit you might use
To use a Celsius temperature property in a controller which expects the temperature in Fahrenheit you might use
 
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 193: Line 223:
</syntaxhighlight>
</syntaxhighlight>


==== Periodical transformation of the input value ====
==== Periodical transformation of the input value &lt;period&gt; ====
Periodical (like angular) input values can be transformed to appear in the correct phase before they are processed by the controller by adding or substracting multiples of the period to the input value until the values is in the requested periods interval.
Periodical (like angular) input values can be transformed to appear in the correct phase before they are processed by the controller by adding or subtracting multiples of the period to the input value until the values is in the requested periods interval.
The following example converts the heading which comes in the range of [0..360] into the range of [-180..+180]. This will cause a heading of 270 to be processed as a value of -90.
The following example converts the heading which comes in the range of [0..360] into the range of [-180..+180]. This will cause a heading of 270 to be processed as a value of -90.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 206: Line 237:
</syntaxhighlight>
</syntaxhighlight>


==== Input clamping ====
==== Input clamping &lt;min&gt; and &lt;max&gt; ====
To clamp the input to a minimum value, maximum value or both, the tags <tt><min></tt> and <tt><max></tt> can be used. Clamping will occur after the linear transformation has been applied. Note the difference of input clamping to output clamping. While input clamping is applied '''before''' the signal reaches the controller, output clamping will be applied to the output signal '''after''' it has been processed.
To clamp the input to a minimum value, maximum value or both, the tags <tt><min></tt> and <tt><max></tt> can be used. Clamping will occur after the linear transformation has been applied. Note the difference of input clamping to output clamping. While input clamping is applied '''before''' the signal reaches the controller, output clamping will be applied to the output signal '''after''' it has been processed.


The following code will keep the input to the controller in the range of 60 to 80 degrees Fahrenheit:
The following code will keep the input to the controller in the range of 60 to 80 degrees Fahrenheit:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 220: Line 252:
</syntaxhighlight>
</syntaxhighlight>


==== Absolute values ====
==== Absolute values &lt;abs&gt; ====
To use the absolute (unsigned) value of the input, add <tt><abs type="bool">true</abs></tt>.
To use the absolute (unsigned) value of the input, add <tt><abs type="bool">true</abs></tt>.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 231: Line 264:
==== Recursive definition ====
==== Recursive definition ====
The elements <tt><scale></tt>, <tt><offset></tt>, <tt><min></tt> and <tt><max></tt> itself can be defined as input values. This code uses as reference the value of course-error-deg, scaled by two and an offset applied which is calculated as the product of the bank-angle-de and the property some/property which itself is limited within the range of -1.5 .. +1.5.
The elements <tt><scale></tt>, <tt><offset></tt>, <tt><min></tt> and <tt><max></tt> itself can be defined as input values. This code uses as reference the value of course-error-deg, scaled by two and an offset applied which is calculated as the product of the bank-angle-de and the property some/property which itself is limited within the range of -1.5 .. +1.5.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 246: Line 280:
</syntaxhighlight>
</syntaxhighlight>


==== Conditional input values ====
==== Conditional input values &lt;condition&gt; ====
The direct inputs of controller and filter elements support so called input value lists. This is useful, if the input should be connected to one of many separate inputs like autopilots connected to NAV1, NAV2 or the GPS. A standard <tt><condition></tt> element is allowed within an input value element. The input value list will be traversed until the first input value with a successful condition is found. The behavior is much like the switch statement in programming languages.
The direct inputs of controller and filter elements support so called input value lists. This is useful, if the input should be connected to one of many separate inputs like autopilots connected to NAV1, NAV2 or the GPS. A standard <tt><condition></tt> element is allowed within an input value element. The input value list will be traversed until the first input value with a successful condition is found. The behavior is much like the switch statement in programming languages.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <reference>
  <reference>
Line 267: Line 302:
The <tt><scale></tt>, <tt><offset></tt>, <tt><min></tt> and <tt><max></tt> elements of input values itself currently don't support input value lists.
The <tt><scale></tt>, <tt><offset></tt>, <tt><min></tt> and <tt><max></tt> elements of input values itself currently don't support input value lists.


==== Expressions ====
==== Expressions &lt;expression&gt; ====
Complex math or lookup tables may be represented using the [[Expression]] syntax. The expression has to be enclosed in <expression> tag.
Complex math or lookup tables may be represented using the [[expression]] syntax. The expression has to be enclosed in <expression> tag.


=== Output Values ===
=== Output values ===
After processing of a component, the resulting value passes a transformation stage where it can be clipped or normalized into a given period. Periodic values such as angular properties may be normalized into a given period by adding a <period> element, defining the lower and upper bounds of the period. Additionally, a maximun and a minimum value may be given which will guarantee that the output value will ever exceed a defined value.  
After processing of a component, the resulting value passes a transformation stage where it can be clipped or normalized into a given period. Periodic values such as angular properties may be normalized into a given period by adding a <period> element, defining the lower and upper bounds of the period. Additionally, a maximun and a minimum value may be given which will guarantee that the output value will ever exceed a defined value.  


Line 276: Line 311:


The following example shifts the computed value into the interval of [-180..180] thereafter being limited into the interval of [-30..30]. The following table contains some computed values and the resulting written value:
The following example shifts the computed value into the interval of [-180..180] thereafter being limited into the interval of [-30..30]. The following table contains some computed values and the resulting written value:
{| class="prettytable"
{| class="prettytable"
!computed
! computed !! written
!written
|-
|-
|-
| -350
|     -350 |10
|10
|-
|-
| -270
|     -270 |30
|30
|-
|-
| -90
|     -90 || -30
| -30
|-
|-
| -29
|     -29 || -29
| -29
|-
|-
|29
|       29 |29
|29
|-
|-
|90
|       90 |30
|30
|-
|-
|350
|     350 || -10
| -10
|}
|}
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <output>/some/property</output>
  <output>/some/property</output>
Line 312: Line 340:
</syntaxhighlight>
</syntaxhighlight>


== logic ==
== Logic controller &lt;logic&gt; ==
The logic controller provides a simple way of creating property values from the result of the condition expression in the <input> element. The condition expression is evaluated once per iteration and the result is written as a boolean value to the named output property or properties. An optional <inverted> element inverts the logic. The default is "not inverted".
The logic controller provides a simple way of creating property values from the result of the condition expression in the <input> element. The condition expression is evaluated once per iteration and the result is written as a boolean value to the named output property or properties. An optional <inverted> element inverts the logic. The default is "not inverted".


Example: output = not( ( a is true ) or ( ( b greater than c ) and ( d is true ) )
Example: output = not( ( a is true ) or ( ( b greater than c ) and ( d is true ) )
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <logic>
  <logic>
Line 333: Line 362:
</syntaxhighlight>
</syntaxhighlight>


== Flip Flop ==
== Flip flop logic &lt;flipflop&gt; ==
A flip flop is a controller that has two stable states so it can be used as a one bit memory. Four types of flip flops are implemented: '''RS''', '''JK''', '''D''' and '''T'''. All use positive logic and operate on the raising edge of the clock signal if a clock is used.
A flip flop is a controller that has two stable states so it can be used as a one bit memory. Four types of flip flops are implemented: '''RS''', '''JK''', '''D''' and '''T'''. All use positive logic and operate on the raising edge of the clock signal if a clock is used.
All input lines, including the clock line, are encoded as condition constructs.
All input lines, including the clock line, are encoded as condition constructs.
Line 341: Line 370:
{{note|Using <code><nowiki><condition></nowiki></code> tags will break the logic.}}
{{note|Using <code><nowiki><condition></nowiki></code> tags will break the logic.}}


=== RS Flip Flop ===
=== RS flip flop &lt;RS&gt; ===
This flip flop sets its output according to the set (S) or reset (R) input lines. If the set line is set, the output gets set. If the reset line is set, the output gets reset. If no line is set, the output stays unchanged. For the special case where set and reset lines are both set, two types of RS flip flops exist: for the RS flip flop (<type>RS</type>), the reset line is dominant and the output is reset. Alternatively, a SR flip flop (<type>SR</type>) has a dominant set line and the output gets set if set and reset line are set.
This flip flop sets its output according to the set (S) or reset (R) input lines. If the set line is set, the output gets set. If the reset line is set, the output gets reset. If no line is set, the output stays unchanged. For the special case where set and reset lines are both set, two types of RS flip flops exist: for the RS flip flop (<type>RS</type>), the reset line is dominant and the output is reset. Alternatively, a SR flip flop (<type>SR</type>) has a dominant set line and the output gets set if set and reset line are set.


Example: simple RS flip flop
Example: simple RS flip flop
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <flipflop>
  <flipflop>
Line 358: Line 388:
</syntaxhighlight>
</syntaxhighlight>


=== JK Flip Flop ===
=== JK flip flop &lt;JK&gt; ===
The JK flip flop is an extension of the RS flip flop. In addition to the set and reset lines of the RS flip flop it uses J, K and a clock input.
The JK flip flop is an extension of the RS flip flop. In addition to the set and reset lines of the RS flip flop it uses J, K and a clock input.
The J line serves as a clock dependent set input while the K line does the reset job. Optionally, a clock input may be provided. State changes do not occour immediately, but on the next raising edge of the clock signal. The state of J=K=true causes the output to toggle it's current state on the next raising edge of the clock signal.
The J line serves as a clock dependent set input while the K line does the reset job. Optionally, a clock input may be provided. State changes do not occour immediately, but on the next raising edge of the clock signal. The state of J=K=true causes the output to toggle it's current state on the next raising edge of the clock signal.
Line 364: Line 394:


Example: simple JK flip flop with negative edge clock
Example: simple JK flip flop with negative edge clock
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <flipflop>
  <flipflop>
Line 382: Line 413:
</syntaxhighlight>
</syntaxhighlight>


=== D Flip Flop ===
=== D flip flop &lt;D&gt; ===
The D flip flop transfers the state of the input signal '''D''' to the output line at the next raising edge of the clock signal, which is mandatory for this flip flop.
The D flip flop transfers the state of the input signal '''D''' to the output line at the next raising edge of the clock signal, which is mandatory for this flip flop.


Example: simple D flip flop with inverted output
Example: simple D flip flop with inverted output
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <flipflop>
  <flipflop>
Line 400: Line 432:
</syntaxhighlight>
</syntaxhighlight>


=== T Flip Flop ===
=== T flip flop &lt;T&gt; ===
The T flip flop toggles the state of the output signal at the next raising edge of the clock signal, which is mandatory for this flip flop.
The T flip flop toggles the state of the output signal at the next raising edge of the clock signal, which is mandatory for this flip flop.


Example: simple T flip flop
Example: simple T flip flop
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <flipflop>
  <flipflop>
Line 414: Line 447:
</syntaxhighlight>
</syntaxhighlight>


=== Monostable ===
=== Monostable flip flop &lt;monostable&gt; ===
A monostable flip flop has only one stable state which will be reentered after a well defined time. The stable state in current implementation is the output set 'false' or 0. The Monostable is an extension of the JK flip flop. Additionally to the input values defined there, an InputValue for the definition of the pulse time is mandatory.  
A monostable flip flop has only one stable state which will be reentered after a well defined time. The stable state in current implementation is the output set 'false' or 0. The Monostable is an extension of the JK flip flop. Additionally to the input values defined there, an InputValue for the definition of the pulse time is mandatory.  


Line 460: Line 493:
In this example the monostable is inverted, which means the stable state is true instead of false. The key idea here is to keep the monostable in its unstable state (false) by keeping the set line true, which is the case when /myflipflop/s is false. Then, when /myflipflop/s becomes true the set line becomes false, which causes the timer to start. When the timer expires (in this case 10 seconds) the monostable will enter its stable state (true). At any time when the set line becomes true (when /myflipflop/s becomes false) the monostable will immediately enter its unstable state (false) again, resulting in /myflipflop/output to become false immediately.
In this example the monostable is inverted, which means the stable state is true instead of false. The key idea here is to keep the monostable in its unstable state (false) by keeping the set line true, which is the case when /myflipflop/s is false. Then, when /myflipflop/s becomes true the set line becomes false, which causes the timer to start. When the timer expires (in this case 10 seconds) the monostable will enter its stable state (true). At any time when the set line becomes true (when /myflipflop/s becomes false) the monostable will immediately enter its unstable state (false) again, resulting in /myflipflop/output to become false immediately.


== filter ==
== Filters &lt;filter&gt; ==


=== Pure Gain <gain> ===
=== Pure gain filter &lt;gain&gt; ===
A gain filter multiplies the <input> value by a given factor or gain <gain> and returns the output to <output>. More than one <gain> element formatted as in [[Autopilot Configuration Reference#Input Values|Input Values]] may be present.  Within a <condition> evaluating as true the first <gain> will define the used gain.
A gain filter multiplies the <input> value by a given factor or gain <gain> and returns the output to <output>. More than one <gain> element formatted as in [[Autopilot Configuration Reference#Input Values|Input Values]] may be present.  Within a <condition> evaluating as true the first <gain> will define the used gain.


Line 474: Line 507:
</syntaxhighlight>
</syntaxhighlight>


=== First Order Low Pass Filter <exponential> ===
=== First order low pass filter &lt;exponential&gt; ===
The exponential filter is a typical [http://en.wikipedia.org/wiki/Low-pass_filter low pass filter]. The magic euler number and the associated mathematical funtion exp() plays a major role here. As the name implies, lower frequencies can pass this filter while higher frequencies are cut. The frequency where only half of the input signal reaches the output is called cutoff frequency. This cutoff frequency is defined by the parameter <filter-time> and resolves as cutoff-frequency = 1/(2*pi*cutoff-frequency).
The exponential filter is a typical [http://en.wikipedia.org/wiki/Low-pass_filter low pass filter]. The magic euler number and the associated mathematical funtion exp() plays a major role here. As the name implies, lower frequencies can pass this filter while higher frequencies are cut. The frequency where only half of the input signal reaches the output is called cutoff frequency. This cutoff frequency is defined by the parameter <filter-time> and resolves as cutoff-frequency = 1/(2*pi*cutoff-frequency).


Line 488: Line 521:
</syntaxhighlight>
</syntaxhighlight>


=== Second Order Low Pass Filter <double-exponential> ===
=== Second order low pass filter &lt;double-exponential&gt; ===
The double exponential filter is a low pass filter like the exponential filter with a steeper slope of the filter diagram. It acts basically like two chained exponential filters and it is some times called second order filter.  
The double exponential filter is a low pass filter like the exponential filter with a steeper slope of the filter diagram. It acts basically like two chained exponential filters and it is some times called second order filter.  


The configuration is the same for exponential and double-exponential filters, just the type entry differs.
The configuration is the same for exponential and double-exponential filters, just the type entry differs.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 501: Line 535:
</syntaxhighlight>
</syntaxhighlight>


=== Moving Average Filter <moving-average> ===
=== Moving average filter &lt;moving-average&gt; ===
Calculates average of specified number of values.
Calculates average of specified number of values.


Currently the average length can only be given as number of samples and not time.
Currently the average length can only be given as number of samples and not time.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 514: Line 549:
</syntaxhighlight>
</syntaxhighlight>


=== Rate Limit Filter <noise-spike> ===
=== Rate limit filter &lt;noise-spike&gt; ===
A better name for a noise spike filter would probably have been "rate limit filter". This is exactly what it does: limit the rate of change of the output value. The relevant configuration element is <max-rate-of-change> setting the maximum rate of change of the output property per second.
A better name for a noise spike filter would probably have been "rate limit filter". This is exactly what it does: limit the rate of change of the output value. The relevant configuration element is <max-rate-of-change> setting the maximum rate of change of the output property per second.


Example: A transition from 0 to 4 at the input property results in a linear increase of the output property over 8 seconds from 0 to 4 at a rate of 0.5/sec.
Example: A transition from 0 to 4 at the input property results in a linear increase of the output property over 8 seconds from 0 to 4 at a rate of 0.5/sec.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 527: Line 563:
</syntaxhighlight>
</syntaxhighlight>


=== Reciprocal Filter <reciprocal> ===
=== Reciprocal filter &lt;reciprocal&gt; ===
Compute the reciprocal (1/x) value of the input property. If x is zero, no computation is performed. The optional <gain> element may be used to scale the value. Output computes as gain divided by input.
Compute the reciprocal (1/x) value of the input property. If x is zero, no computation is performed. The optional <gain> element may be used to scale the value. Output computes as gain divided by input.


Example: compute the flight time per pound of burned fuel from the fuel flow
Example: compute the flight time per pound of burned fuel from the fuel flow
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 540: Line 577:
</syntaxhighlight>
</syntaxhighlight>


=== Derivative Filter <derivative> ===
=== Derivative filter &lt;derivative&gt; ===
Compute first time derivative of the input property, that is change per unit of time. Time is measured in seconds. A <filter-time> acts as gain and must be given because it has default 0.
Compute first time derivative of the input property, that is change per unit of time. Time is measured in seconds. A <filter-time> acts as gain and must be given because it has default 0.


Example: compute derivative of static port pressure
Example: compute derivative of static port pressure
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <filter>
  <filter>
Line 553: Line 591:
</syntaxhighlight>
</syntaxhighlight>


== PID Controller <pid-controller> ==
== PID controller &lt;pid-controller&gt; ==
The [http://en.wikipedia.org/wiki/PID_controller PID controller] is the swiss army knife of automation and this implementation is suitable for most situations. It has a builtin anti-windup logic, and usage of <max> and <min> elements for clamping the output is mandatory. The most important thing to know is that this controller 'does not' compute absolute output values but an offset from the current value of the output property. This can lead to unexpected behavior if the current value of the output property is unknown when the controller is enabled. This behavior is different to that of the pi-simple-controller.
The [http://en.wikipedia.org/wiki/PID_controller PID controller] is the swiss army knife of automation and this implementation is suitable for most situations. It has a builtin anti-windup logic, and usage of <max> and <min> elements for clamping the output is mandatory. The most important thing to know is that this controller 'does not' compute absolute output values but an offset from the current value of the output property. This can lead to unexpected behavior if the current value of the output property is unknown when the controller is enabled. This behavior is different to that of the pi-simple-controller.
The xml element creating a pid controller is <tt><pid-controller></tt>.
The xml element creating a pid controller is <tt><pid-controller></tt>.
Line 582: Line 620:
|}
|}


== PI Controller <pi-simple-controller> ==
== PI controller &lt;pi-simple-controller&gt; ==
This controller implements a PI controller. Other than the PID controller, it computes absolute output values, regardless of the value of the output property. It can by configured as an I-only, P-only or PI-controller. It has anti windup logic if <min> and <max> elements are present.
This controller implements a PI controller. Other than the PID controller, it computes absolute output values, regardless of the value of the output property. It can by configured as an I-only, P-only or PI-controller. It has anti windup logic if <min> and <max> elements are present.
The xml element creating a PI controller is <tt><pi-simple-controller></tt>
The xml element creating a PI controller is <tt><pi-simple-controller></tt>
Line 595: Line 633:
|}
|}


== Predictor <predict-simple> ==
== Predictor &lt;predict-simple&gt; ==
Estimates the future value for a given property based on its current (or averaged) rate of change.
Estimates the future value for a given property based on its current (or averaged) rate of change.


Line 609: Line 647:


Example: compute estimated speed 5 seconds ahead
Example: compute estimated speed 5 seconds ahead
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <predict-simple>
  <predict-simple>

Navigation menu