<?xml version="1.0"?>

<!-- S-TEC Fifty Five X Autopilot System -->
<!-- Copyright (c) 2022 Josh Davidson (Octal450) -->

<PropertyList>
	
	<!-- NAV Switching -->
	<logic>
		<name>HSI Equipped</name> <!-- Goes to true for custom sources -->
		<input>
			<or>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped-1</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped-2</property>
						<value>1</value>
					</equals>
				</and>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>2</value>
				</equals>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>3</value>
				</equals>
			</or>
		</input>
		<output>/it-stec55x/settings/hsi-equipped</output>
	</logic>
	
	<filter>
		<name>Nav Needle Deflection</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>0</value>
				</equals>
			</condition>
			<property>/instrumentation/nav[0]/heading-needle-deflection</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>1</value>
				</equals>
			</condition>
			<property>/instrumentation/nav[1]/heading-needle-deflection</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>2</value>
				</equals>
			</condition>
			<property>/it-stec55x/custom-nav/nav-needle-1</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>3</value>
				</equals>
			</condition>
			<property>/it-stec55x/custom-nav/nav-needle-2</property>
		</input>
		<input>0</input>
		<output>/it-stec55x/nav/nav-needle</output>
	</filter>
	
	<filter>
		<name>G/S Needle Deflection</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>0</value>
				</equals>
			</condition>
			<property>/instrumentation/nav[0]/gs-needle-deflection</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>1</value>
				</equals>
			</condition>
			<property>/instrumentation/nav[1]/gs-needle-deflection</property>
		</input>
		<input>0</input>
		<output>/it-stec55x/nav/gs-needle</output>
	</filter>
	
	<logic>
		<name>Nav In Range</name>
		<input>
			<or>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[0]/in-range</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[1]/in-range</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>2</value>
					</equals>
					<equals>
						<property>/it-stec55x/custom-nav/in-range-1</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>3</value>
					</equals>
					<equals>
						<property>/it-stec55x/custom-nav/in-range-2</property>
						<value>1</value>
					</equals>
				</and>
			</or>
		</input>
		<output>/it-stec55x/nav/in-range</output>
	</logic>
	
	<logic>
		<name>Nav Is LOC</name>
		<input>
			<or>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[0]/nav-loc</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[1]/nav-loc</property>
						<value>1</value>
					</equals>
				</and>
			</or>
		</input>
		<output>/it-stec55x/nav/is-loc</output>
	</logic>
	
	<logic>
		<name>Nav Has G/S</name>
		<input>
			<or>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[0]/has-gs</property>
						<value>1</value>
					</equals>
				</and>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/instrumentation/nav[1]/has-gs</property>
						<value>1</value>
					</equals>
				</and>
			</or>
		</input>
		<output>/it-stec55x/nav/has-gs</output>
	</logic>
	
	<filter>
		<name>Nav Course</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped-1</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<property>/instrumentation/nav[0]/radials/selected-deg</property>
		</input>
		<input>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/input/nav-selector</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped-2</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<property>/instrumentation/nav[1]/radials/selected-deg</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>2</value>
				</equals>
			</condition>
			<property>/it-stec55x/custom-nav/nav-course-1</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/nav-selector</property>
					<value>3</value>
				</equals>
			</condition>
			<property>/it-stec55x/custom-nav/nav-course-2</property>
		</input>
		<input>/it-stec55x/input/hdg</input>
		<output>/it-stec55x/nav/nav-course</output>
	</filter>
	
	<filter>
		<name>Nav Course Reciprocal Stage 1</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<expression>
				<sum>
					<property>/it-stec55x/nav/nav-course</property>
					<value>180</value>
				</sum>
			</expression>
		</input>
		<output>/it-stec55x/nav/nav-course-reciprocal-cmd</output>
	</filter>
	
	<filter>
		<name>Nav Course Reciprocal State 2</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<greater-than-equals>
					<property>/it-stec55x/nav/nav-course-reciprocal-cmd</property>
					<value>360.5</value>
				</greater-than-equals>
			</condition>
			<expression>
				<dif>
					<property>/it-stec55x/nav/nav-course-reciprocal-cmd</property>
					<value>360</value>
				</dif>
			</expression>
		</input>
		<input>
			<condition>
				<less-than>
					<property>/it-stec55x/nav/nav-course-reciprocal-cmd</property>
					<value>0.5</value>
				</less-than>
			</condition>
			<expression>
				<sum>
					<property>/it-stec55x/nav/nav-course-reciprocal-cmd</property>
					<value>360</value>
				</sum>
			</expression>
		</input>
		<input>/it-stec55x/nav/nav-course-reciprocal-cmd</input>
		<output>/it-stec55x/nav/nav-course-reciprocal</output>
	</filter>
	
	<filter>
		<name>Nav Course Error</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/output/roll</property>
						<value>6</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<property>/it-stec55x/nav/nav-course-reciprocal</property>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>
			<condition>
				<or>
					<equals>
						<property>/it-stec55x/output/roll</property>
						<value>1</value>
					</equals>
					<and>
						<equals>
							<property>/it-stec55x/output/roll</property>
							<value>6</value>
						</equals>
						<equals>
							<property>/it-stec55x/settings/hsi-equipped</property>
							<value>0</value>
						</equals>
					</and>
				</or>
			</condition>
			<property>/it-stec55x/nav/nav-course</property>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>0</input>
		<output>/it-stec55x/nav/nav-course-error</output>
		<period>
			<min>-180</min>
			<max>180</max>
		</period>
	</filter>
	
	<filter>
		<name>Static Port</name> <!-- Do NOT tie into aircraft static system, requires its own dedicated port -->
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<property-path>/it-stec55x/settings/static-port-path</property-path>
		</input>
		<output>/it-stec55x/internal/static-pressure</output>
	</filter>
	
	<!-- Roll Axis -->
	<filter>
		<name>Target Intercept Angle P</name>
		<type>gain</type>
		<gain>12.5</gain>
		<input>
			<expression>
				<product>
					<property>/it-stec55x/nav/nav-needle</property>
					<property>/it-stec55x/internal/nav-gain</property>
				</product>
			</expression>
		</input>
		<output>/it-stec55x/internal/intercept-angle-p</output>
		<min>-45</min>
		<max>45</max>
	</filter>
	
	<filter>
		<name>Target Intercept Angle I</name> <!-- Integrate to cancel steady state error only if stabilized and captured -->
		<type>integrator</type>
		<gain>0.05</gain>
		<input>
			<condition>
				<and>
					<or>
						<equals>
							<property>/it-stec55x/output/roll</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-stec55x/output/roll</property>
							<value>6</value>
						</equals>
					</or>
					<less-than-equals>
						<property>/it-stec55x/nav/nav-course-error</property>
						<value>10</value>
					</less-than-equals>
					<greater-than-equals>
						<property>/it-stec55x/nav/nav-course-error</property>
						<value>-10</value>
					</greater-than-equals>
					<less-than-equals>
						<property>/it-stec55x/nav/nav-needle</property>
						<value>1</value>
					</less-than-equals>
					<greater-than-equals>
						<property>/it-stec55x/nav/nav-needle</property>
						<value>-1</value>
					</greater-than-equals>
				</and>
			</condition>
			<expression>
				<product>
					<property>/it-stec55x/nav/nav-needle</property>
					<property>/it-stec55x/internal/nav-gain</property>
				</product>
			</expression>
		</input>
		<input>
			<expression>
				<product>
					<value>-75.0</value>
					<property>/it-stec55x/internal/intercept-angle-i</property>
				</product>
			</expression>
		</input>
		<output>/it-stec55x/internal/intercept-angle-i</output>
		<u_min>-5</u_min>
		<u_max>5</u_max>
	</filter>
	
	<filter>
		<name>Target Intercept Angle D</name>
		<type>derivative</type>
		<input>
			<expression>
				<product>
					<property>/it-stec55x/nav/nav-needle</property>
					<property>/it-stec55x/internal/nav-gain</property>
				</product>
			</expression>
		</input>
		<reference>0</reference>
		<output>/it-stec55x/internal/intercept-angle-d</output>
		<filter-time>45</filter-time>
		<min>-45</min>
		<max>45</max>
	</filter>
	
	<filter>
		<name>Target Intercept Angle</name> <!-- Sum the above 3 controllers to make a manual PID controller -->
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<expression>
				<sum>
					<property>/it-stec55x/internal/intercept-angle-p</property>
					<property>/it-stec55x/internal/intercept-angle-i</property>
					<property>/it-stec55x/internal/intercept-angle-d</property>
				</sum>
			</expression>
		</input>
		<output>/it-stec55x/internal/intercept-angle</output>
		<min>-45</min>
		<max>45</max>
	</filter>
	
	<filter> <!-- GPS would provides this, not the autopilot, but lets leave it in this file for ease of implementation -->
		<name>GPS Error Deg</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<expression>
				<sum>
					<property>/autopilot/route-manager/wp[0]/true-bearing-deg</property>
					<difference>
						<property>/orientation/heading-magnetic-deg</property>
						<property>/orientation/track-magnetic-deg</property>
					</difference>
					<product>
						<property>/orientation/heading-deg</property>
						<value>-1</value>
					</product>
				</sum>
			</expression>
		</input>
		<output>/it-stec55x/internal/gps-error-deg</output>
		<period>
			<min>-180</min>
			<max>180</max>
		</period>
	</filter>
	
	<filter>
		<name>Heading/Nav Error Deg</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/roll</property>
					<value>0</value>
				</equals>
			</condition>
			<property>/it-stec55x/input/hdg</property>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/roll</property>
					<value>1</value>
				</equals>
			</condition>
			<expression>
				<sum>
					<property>/it-stec55x/nav/nav-course</property>
					<property>/it-stec55x/internal/intercept-angle</property>
				</sum>
			</expression>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/output/roll</property>
						<value>6</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<expression>
				<sum>
					<property>/it-stec55x/input/hdg</property>
					<product>
						<property>/it-stec55x/internal/intercept-angle</property>
						<value>-1.0</value>
					</product>
				</sum>
			</expression>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/output/roll</property>
						<value>6</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/hsi-equipped</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<expression>
				<sum>
					<property>/it-stec55x/nav/nav-course-reciprocal</property>
					<product>
						<property>/it-stec55x/internal/intercept-angle</property>
						<value>-1.0</value>
					</product>
				</sum>
			</expression>
			<offset>
				<property>/instrumentation/heading-indicator/indicated-heading-deg</property>
				<scale>-1.0</scale>
			</offset>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/roll</property>
					<value>2</value>
				</equals>
			</condition>
			<property>/it-stec55x/internal/gps-error-deg</property>
		</input>
		<input>0</input>
		<output>/it-stec55x/internal/heading-error-deg</output>
		<period>
			<min>-180</min>
			<max>180</max>
		</period>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: Target Turn Rate</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/roll</property>
					<value>5</value>
				</equals>
			</condition>
			<property>/it-stec55x/internal/man-turn-rate</property>
		</input>
		<input>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/roll</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<expression>
				<table>
					<property>/it-stec55x/internal/heading-error-deg</property>
					<entry><ind>-30</ind><dep>-1.0</dep></entry>
					<entry><ind> -5</ind><dep>-0.2</dep></entry>
					<entry><ind>  5</ind><dep> 0.2</dep></entry>
					<entry><ind> 30</ind><dep> 1.0</dep></entry>
				</table>
			</expression>
		</input>
		<input>0</input>
		<output>/it-stec55x/internal/target-turn-rate</output>
		<min>/it-stec55x/internal/min-turn-rate</min>
		<max>/it-stec55x/internal/max-turn-rate</max>
	</filter>
	
	<predict-simple>
		<name>Turn Rate Predictor</name>
		<debug>false</debug>
		<input>/instrumentation/turn-indicator/indicated-turn-rate</input>
		<output>/it-stec55x/internal/predicted-turn-rate</output>
		<seconds>2.0</seconds>
		<filter-gain>0.0</filter-gain>
	</predict-simple>
	
	<filter>
		<name>System Command: Target Turn Rate Filter</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<input>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/roll</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<property>/it-stec55x/internal/target-turn-rate</property>
		</input>
		<input>/it-stec55x/internal/predicted-turn-rate</input>
		<output>/it-stec55x/internal/turn-rate-cmd</output>
		<max-rate-of-change>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/roll</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<value>0.2</value>
		</max-rate-of-change>
		<max-rate-of-change>10</max-rate-of-change>
	</filter>
	
	<pid-controller>
		<name>System Command: Roll PID</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/roll</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-roll-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/it-stec55x/internal/turn-rate-cmd</input>
		<reference>/it-stec55x/internal/predicted-turn-rate</reference>
		<output>/it-stec55x/internal/aileron-pid</output>
		<config>
			<Kp>-0.08</Kp>
			<Ti>3.5</Ti>
			<Td>0.15</Td>
			<u_min>-0.25</u_min>
			<u_max>0.25</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>System Command: Roll Output Internal</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<input>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/roll</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-roll-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<expression>
				<product>
					<property>/it-stec55x/internal/aileron-pid</property>
					<property>/it-stec55x/settings/gain-roll</property>
				</product>
			</expression>
		</input>
		<input>/controls/flight/aileron</input>
		<output>/it-stec55x/internal/aileron</output>
		<max-rate-of-change>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/roll</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-roll-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<value>0.09</value>
		</max-rate-of-change>
		<max-rate-of-change>10</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Roll Output Generic</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/roll</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-roll-power</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/use-controls-flight</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>
			<expression>
				<product>
					<property>/it-stec55x/internal/aileron-pid</property>
					<property>/it-stec55x/settings/gain-roll</property>
				</product>
			</expression>
		</input>
		<output>/controls/flight/aileron</output>
		<max-rate-of-change>0.09</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Aileron Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<or>
					<equals>
						<property>/it-stec55x/output/roll</property>
						<value>-1</value>
					</equals>
					<not-equals>
						<property>/it-stec55x/internal/servo-roll-power</property>
						<value>1</value>
					</not-equals>
				</or>
			</condition>
		</enable>
		<input>
			<expression>
				<div>
					<property>/controls/flight/aileron</property>
					<property>/it-stec55x/settings/gain-roll</property>
				</div>
			</expression>
		</input>
		<output>/it-stec55x/internal/aileron-pid</output>
		<min>-0.25</min>
		<max>0.25</max>
	</filter>
	
	<!-- Pitch Axis -->
	<filter>
		<name>Static Pressure 20FT Delta</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<expression>
				<table>
					<property>/it-stec55x/input/alt</property>
					<entry><ind>32.148</ind><dep>0.022600</dep></entry> <!-- -2000 -->
					<entry><ind>31.018</ind><dep>0.021940</dep></entry> <!-- -1000 -->
					<entry><ind>29.921</ind><dep>0.021300</dep></entry> <!-- 0 -->
					<entry><ind>28.856</ind><dep>0.020700</dep></entry> <!-- 1000 -->
					<entry><ind>27.821</ind><dep>0.020080</dep></entry> <!-- 2000 -->
					<entry><ind>26.817</ind><dep>0.019500</dep></entry> <!-- 3000 -->
					<entry><ind>25.842</ind><dep>0.018920</dep></entry> <!-- 4000 -->
					<entry><ind>24.896</ind><dep>0.018360</dep></entry> <!-- 5000 -->
					<entry><ind>23.978</ind><dep>0.017800</dep></entry> <!-- 6000 -->
					<entry><ind>23.088</ind><dep>0.017260</dep></entry> <!-- 7000 -->
					<entry><ind>22.225</ind><dep>0.016740</dep></entry> <!-- 8000 -->
					<entry><ind>21.388</ind><dep>0.016220</dep></entry> <!-- 9000 -->
					<entry><ind>20.577</ind><dep>0.014764</dep></entry> <!-- 10000 -->
					<entry><ind>16.886</ind><dep>0.012544</dep></entry> <!-- 15000 -->
					<entry><ind>13.750</ind><dep>0.010584</dep></entry> <!-- 20000 -->
					<entry><ind>11.104</ind><dep>0.008874</dep></entry> <!-- 25000 -->
					<entry><ind>8.8855</ind><dep>0.007379</dep></entry> <!-- 30000 -->
					<entry><ind>8.1475</ind><dep>0.006831</dep></entry> <!-- 32000 -->
				</table>
			</expression>
		</input>
		<output>/it-stec55x/internal/static-20ft-delta</output>
	</filter>

	<filter>
		<name>Pressure Lag</name>
		<debug>false</debug>
		<type>exponential</type>
		<input>/it-stec55x/internal/static-pressure</input>
		<output>/it-stec55x/internal/static-pressure-lag</output>
		<filter-time>0.04</filter-time>
	</filter>
	
	<filter>
		<name>Pressure Rate Computer</name>
		<debug>false</debug>
		<type>derivative</type>
		<input>/it-stec55x/internal/static-pressure-lag</input>
		<output>/it-stec55x/internal/pressure-rate-raw</output>
		<filter-time>1.0</filter-time>
	</filter>

	<filter>
		<name>Pressure Rate Lag</name>
		<debug>false</debug>
		<type>double-exponential</type>
		<input>/it-stec55x/internal/pressure-rate-raw</input>
		<output>/it-stec55x/internal/pressure-rate</output>
		<filter-time>0.04</filter-time>
	</filter>
	
	<predict-simple>
		<name>Vertical Speed Predictor</name>
		<debug>false</debug>
		<input>
			<expression> <!-- Pressure Rate to Vertical Speed FPM -->
				<product>
					<property>/it-stec55x/internal/pressure-rate</property>
					<value>-58000</value>
				</product>
			</expression>
		</input>
		<output>/it-stec55x/internal/predicted-vertical-speed</output>
		<seconds>2.0</seconds>
		<filter-gain>0.1</filter-gain>
	</predict-simple>
	
	<filter>
		<name>Vertical Speed Inactive Sync</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<and>
					<not-equals>
						<property>/it-stec55x/output/pitch</property>
						<value>1</value>
					</not-equals>
					<not-equals>
						<property>/it-stec55x/internal/powerup-test</property>
						<value>1</value>
					</not-equals>
				</and>
			</condition>
		</enable>
		<input>
			<expression>
				<product>
					<floor>
						<div>
							<sum>
								<product>
									<property>/it-stec55x/internal/pressure-rate</property>
									<value>-58000</value>
								</product>
								<value>50</value>
							</sum>
							<value>100</value>
						</div>
					</floor>
					<value>100</value>
				</product>
			</expression>
		</input>
		<output>/it-stec55x/input/vs</output>
		<min>-1600</min>
		<max>1600</max>
	</filter>
	
	<filter>
		<name>Vertical Speed Absolute Value</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<expression>
				<abs><property>/it-stec55x/input/vs</property></abs>
			</expression>
		</input>
		<output>/it-stec55x/input/vs-abs</output>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: Altitude Capture/Hold</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>3625</gain>
		<input>/it-stec55x/internal/static-pressure</input>
		<reference>
			<expression>
				<sum>
					<property>/it-stec55x/input/alt</property>
					<property>/it-stec55x/input/alt-offset</property>	
				</sum>
			</expression>
		</reference>
		<output>/it-stec55x/internal/alt-vs</output>
		<min>-400</min>
		<max>400</max>
	</filter>
	
	<filter>
		<name>Vertical Speed G/S Sync</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not-equals>
					<property>/it-stec55x/output/pitch</property>
					<value>2</value>
				</not-equals>
			</condition>
		</enable>
		<input>
			<expression>
				<product>
					<property>/it-stec55x/internal/pressure-rate</property>
					<value>-58000</value>
				</product>
			</expression>
		</input>
		<output>/it-stec55x/internal/gs-vs</output>
		<min>-1200</min>
		<max>50</max>
	</filter>
	
	<predict-simple>
		<name>G/S Needle Predictor</name>
		<debug>false</debug>
		<input>/it-stec55x/nav/gs-needle</input>
		<output>/it-stec55x/internal/predicted-gs-needle</output>
		<seconds>1.0</seconds>
		<filter-gain>0.1</filter-gain>
	</predict-simple>
	
	<pid-controller>
		<name>IT-CONTROLLER: G/S</name>
		<debug>false</debug>
		<enable>
			<condition>
				<equals>
					<property>/it-stec55x/output/pitch</property>
					<value>2</value>
				</equals>
			</condition>
		</enable>
		<input>/it-stec55x/internal/predicted-gs-needle</input>
		<reference>0</reference>
		<output>/it-stec55x/internal/gs-vs</output>
		<config>
			<Kp>-400</Kp>
			<Ti>20.0</Ti>
			<Td>0.001</Td>
			<u_min>-1200</u_min>
			<u_max>50</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>IT-CONTROLLER: Vertical Speed Switch</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/pitch</property>
					<value>0</value>
				</equals>
			</condition>
			<property>/it-stec55x/internal/alt-vs</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/output/pitch</property>
					<value>2</value>
				</equals>
			</condition>
			<property>/it-stec55x/internal/gs-vs</property>
		</input>
		<input>/it-stec55x/input/vs</input>
		<output>/it-stec55x/internal/vs</output>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: Vertical Speed Filter</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<input>/it-stec55x/internal/vs</input>
		<output>/it-stec55x/internal/vs-slow</output>
		<max-rate-of-change>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/pitch</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<value>200</value>
		</max-rate-of-change>
		<max-rate-of-change>2000</max-rate-of-change>
	</filter>
	
	<pi-simple-controller>
		<name>IT-CONTROLLER: Acceleration PI</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/it-stec55x/internal/vs-slow</input>
		<reference>/it-stec55x/internal/predicted-vertical-speed</reference>
		<output>/it-stec55x/internal/target-accel</output>
		<config>
			<Kp>-0.00015</Kp>
			<Ki>-0.000011</Ki>
			<min>-0.1</min>
			<max>0.1</max>
		</config>
	</pi-simple-controller>
	
	<filter>
		<name>System Command: Internal G Acceleration</name>
		<type>double-exponential</type>
		<input>
			<expression>
				<difference>
					<property>/accelerations/pilot-g</property>
					<product>
						<abs><property>/instrumentation/turn-indicator/indicated-turn-rate</property></abs>
						<value>0.05</value>
					</product>
				</difference>
			</expression>
		</input>
		<output>/it-stec55x/internal/g-damped</output>
		<filter-time>0.02</filter-time>
	</filter>
	
	<filter>
		<name>System Command: Target Acceleration</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<expression>
				<sum>
					<property>/it-stec55x/internal/target-accel</property>
					<value>1</value>
				</sum>
			</expression>
		</input>
		<input>/it-stec55x/internal/g-damped</input>
		<output>/it-stec55x/internal/accel-cmd</output>
	</filter>
	
	<pid-controller>
		<name>System Command: Elevator PI</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/it-stec55x/internal/accel-cmd</input>
		<reference>/it-stec55x/internal/g-damped</reference>
		<output>/it-stec55x/internal/elevator-pi</output>
		<config>
			<Kp>0.16</Kp>
			<Ti>0.5</Ti>
			<Td>0.0</Td> <!-- No -->
			<u_min>-0.25</u_min>
			<u_max>0.25</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>System Command: Pitch Output Internal</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<input>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<expression>
				<product>
					<property>/it-stec55x/internal/elevator-pi</property>
					<property>/it-stec55x/settings/gain-pitch</property>
				</product>
			</expression>
		</input>
		<input>/controls/flight/elevator</input>
		<output>/it-stec55x/internal/elevator</output>
		<max-rate-of-change>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
			<value>0.09</value>
		</max-rate-of-change>
		<max-rate-of-change>10</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Pitch Output Generic</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-stec55x/settings/use-controls-flight</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>
			<expression>
				<product>
					<property>/it-stec55x/internal/elevator-pi</property>
					<property>/it-stec55x/settings/gain-pitch</property>
				</product>
			</expression>
		</input>
		<output>/controls/flight/elevator</output>
		<max-rate-of-change>0.09</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Elevator Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<or>
					<equals>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</equals>
					<not-equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</not-equals>
				</or>
			</condition>
		</enable>
		<input>
			<expression>
				<div>
					<property>/controls/flight/elevator</property>
					<property>/it-stec55x/settings/gain-pitch</property>
				</div>
			</expression>
		</input>
		<output>/it-stec55x/internal/elevator-pi</output>
		<min>-0.25</min>
		<max>0.25</max>
	</filter>
	
	<filter>
		<name>System Command: Automatic Elevator Trim</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/pitch</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/internal/servo-pitch-power</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-stec55x/input/electric-trim-sw</property>
						<value>1</value>
					</equals>
					<greater-than-equals>
						<property>/systems/electrical/outputs/electrim</property>
						<value>8</value>
					</greater-than-equals>
					<or>
						<equals>
							<property>/it-stec55x/annun/up</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-stec55x/annun/dn</property>
							<value>1</value>
						</equals>
					</or>
				</and>
			</condition>
		</enable>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/annun/dn</property>
					<value>1</value>
				</equals>
			</condition>
			<value>1</value>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/annun/up</property>
					<value>1</value>
				</equals>
			</condition>
			<value>-1</value>
		</input>
		<output>/controls/flight/elevator-trim</output>
		<max-rate-of-change>
			<expression>
				<table>
					<abs><property>/it-stec55x/internal/elevator</property></abs>
					<entry><ind>0.025</ind><dep>0.005</dep></entry>
					<entry><ind>0.100</ind><dep>0.060</dep></entry>
				</table>
			</expression>
		</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Manual Elevator Trim</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/it-stec55x/input/electric-trim-sw</property>
						<value>1</value>
					</equals>
					<greater-than-equals>
						<property>/systems/electrical/outputs/electrim</property>
						<value>8</value>
					</greater-than-equals>
					<or>
						<equals>
							<property>/it-stec55x/input/man-trim</property>
							<value>-1</value>
						</equals>
						<equals>
							<property>/it-stec55x/input/man-trim</property>
							<value>1</value>
						</equals>
					</or>
				</and>
			</condition>
		</enable>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/man-trim</property>
					<value>1</value>
				</equals>
			</condition>
			<value>1</value>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-stec55x/input/man-trim</property>
					<value>-1</value>
				</equals>
			</condition>
			<value>-1</value>
		</input>
		<output>/controls/flight/elevator-trim</output>
		<max-rate-of-change>0.06</max-rate-of-change>
	</filter>
	
	<!-- Yaw Axis (Optional Yaw Damper) -->
	<filter>
		<name>Internal Yaw Rate Sensor Low-Pass</name>
		<debug>false</debug>
		<type>exponential</type>
		<input>/orientation/r-body</input>
		<output>/it-stec55x/internal/yaw-rate-low</output>
		<filter-time>0.08</filter-time>
	</filter>
	
	<filter>
		<name>Internal Yaw Rate Sensor High-Pass</name>
		<debug>false</debug>
		<type>high-pass</type>
		<input>/it-stec55x/internal/yaw-rate-low</input>
		<output>/it-stec55x/internal/yaw-rate-high</output>
		<filter-time>0.03</filter-time>
	</filter>
	
	<filter>
		<name>System Command: Yaw Damper</name>
		<type>gain</type>
		<gain>7.161975</gain> <!-- RAD2DEG * 0.125 -->
		<input>/it-stec55x/internal/yaw-rate-high</input>
		<output>/it-stec55x/internal/rudder-p</output>
		<min>-0.1</min>
		<max>0.1</max>
	</filter>
	
	<filter>
		<name>System Command: Yaw Output Internal</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<input>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/yaw</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<expression>
				<sum>
					<product>
						<property>/it-stec55x/internal/rudder-p</property>
						<property>/it-stec55x/settings/gain-yaw</property>
					</product>
					<product>
						<property>/it-stec55x/input/yaw-damper-trim</property>
						<value>0.25</value>
					</product>
				</sum>
			</expression>
		</input>
		<input>0</input>
		<output>/it-stec55x/internal/rudder</output>
		<max-rate-of-change>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/yaw</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<value>0.09</value>
		</max-rate-of-change>
		<max-rate-of-change>10</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Yaw Output Generic</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<and>
					<greater-than>
						<property>/it-stec55x/output/yaw</property>
						<value>-1</value>
					</greater-than>
					<equals>
						<property>/it-stec55x/settings/use-controls-flight</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>
			<expression>
				<sum>
					<product>
						<property>/it-stec55x/internal/rudder-p</property>
						<property>/it-stec55x/settings/gain-yaw</property>
					</product>
					<product>
						<property>/it-stec55x/input/yaw-damper-trim</property>
						<value>0.25</value>
					</product>
				</sum>
			</expression>
		</input>
		<output>/controls/flight/rudder</output>
		<max-rate-of-change>0.09</max-rate-of-change>
	</filter>
	
	<!-- Flight Director -->
	<filter>
		<name>FD: Roll</name>
		<type>exponential</type>
		<input>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/roll</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<expression>
				<product>
					<difference>
						<property>/it-stec55x/internal/predicted-turn-rate</property>
						<property>/it-stec55x/internal/target-turn-rate</property>
					</difference>
					<value>7.5</value>
				</product>
			</expression>
		</input>
		<input>0</input>
		<output>/it-stec55x/output/fd-roll</output>
		<filter-time>0.08</filter-time>
		<min>-30</min>
		<max>30</max>
	</filter>
	
	<filter>
		<name>FD: Pitch</name>
		<type>exponential</type>
		<input>
			<condition>
				<greater-than>
					<property>/it-stec55x/output/pitch</property>
					<value>-1</value>
				</greater-than>
			</condition>
			<expression>
				<product>
					<difference>
						<product>
							<property>/it-stec55x/internal/pressure-rate</property>
							<value>-58000</value>
						</product>
						<property>/it-stec55x/internal/vs</property>
					</difference>
					<value>0.003</value>
				</product>
			</expression>
		</input>
		<input>0</input>
		<output>/it-stec55x/output/fd-pitch</output>
		<filter-time>0.08</filter-time>
		<min>-15</min>
		<max>15</max>
	</filter>

</PropertyList>
