Prerequisites for Fly By Wire

This commit is contained in:
Joshua Davidson 2017-04-06 15:06:35 -04:00
parent 5c4317319b
commit 767916b4da
11 changed files with 637 additions and 8 deletions

View file

@ -90,6 +90,9 @@
<file>Aircraft/A320Family/Nasal/electrical.nas</file>
<file>Aircraft/A320Family/Nasal/engines.nas</file>
</systems>
<fbw>
<file>Aircraft/A320Family/Nasal/it-fbw.nas</file>
</fbw>
<itaf>
<file>Aircraft/A320Family/Nasal/it-autoflight.nas</file>
</itaf>

View file

@ -565,7 +565,7 @@ YAW MOI_________3950000______23089847_______24848934
<flight_control name="FCS: A320">
<channel name="Pitch">
<summer name="Pitch Trim Sum">
<input>/controls/flight/elevator</input>
<input>/controls/flight/elevator-fbw</input>
<input>/controls/flight/elevator-trim</input>
<clipto>
<min>-1</min>
@ -598,7 +598,7 @@ YAW MOI_________3950000______23089847_______24848934
</channel>
<channel name="Roll">
<summer name="Roll Trim Sum">
<input>/controls/flight/aileron</input>
<input>/controls/flight/aileron-fbw</input>
<input>/controls/flight/aileron-trim</input>
<clipto>
<min>-1</min>

View file

@ -83,6 +83,9 @@
<file>Aircraft/A320Family/Nasal/electrical.nas</file>
<file>Aircraft/A320Family/Nasal/engines.nas</file>
</systems>
<fbw>
<file>Aircraft/A320Family/Nasal/it-fbw.nas</file>
</fbw>
<itaf>
<file>Aircraft/A320Family/Nasal/it-autoflight.nas</file>
</itaf>

View file

@ -565,7 +565,7 @@ YAW MOI_________3950000______23089847_______24848934
<flight_control name="FCS: A320">
<channel name="Pitch">
<summer name="Pitch Trim Sum">
<input>/controls/flight/elevator</input>
<input>/controls/flight/elevator-fbw</input>
<input>/controls/flight/elevator-trim</input>
<clipto>
<min>-1</min>
@ -598,7 +598,7 @@ YAW MOI_________3950000______23089847_______24848934
</channel>
<channel name="Roll">
<summer name="Roll Trim Sum">
<input>/controls/flight/aileron</input>
<input>/controls/flight/aileron-fbw</input>
<input>/controls/flight/aileron-trim</input>
<clipto>
<min>-1</min>

View file

@ -33,6 +33,10 @@
<electrical>
<path></path>
</electrical>
<!-- Custom FBW System -->
<autopilot>
<path>Aircraft/A320Family/Systems/it-fbw.xml</path>
</autopilot>
<autopilot>
<path>Aircraft/A320Family/Systems/it-autoflight.xml</path>
</autopilot>
@ -265,6 +269,11 @@
</settings>
</it-autoflight>
<it-fbw>
<roll-deg>0</roll-deg>
<pitch-deg>0</pitch-deg>
</it-fbw>
<engines n="0">
<engine n="0">
<egt-actual type="float">0</egt-actual>

View file

@ -83,6 +83,9 @@
<file>Aircraft/A320Family/Nasal/electrical.nas</file>
<file>Aircraft/A320Family/Nasal/engines.nas</file>
</systems>
<fbw>
<file>Aircraft/A320Family/Nasal/it-fbw.nas</file>
</fbw>
<itaf>
<file>Aircraft/A320Family/Nasal/it-autoflight.nas</file>
</itaf>

View file

@ -578,7 +578,7 @@ YAW MOI_________3950000______23089847_______24848934
<flight_control name="FCS: A320">
<channel name="Pitch">
<summer name="Pitch Trim Sum">
<input>/controls/flight/elevator</input>
<input>/controls/flight/elevator-fbw</input>
<input>/controls/flight/elevator-trim</input>
<clipto>
<min>-1</min>
@ -611,7 +611,7 @@ YAW MOI_________3950000______23089847_______24848934
</channel>
<channel name="Roll">
<summer name="Roll Trim Sum">
<input>/controls/flight/aileron</input>
<input>/controls/flight/aileron-fbw</input>
<input>/controls/flight/aileron-trim</input>
<clipto>
<min>-1</min>

View file

@ -89,6 +89,9 @@
<file>Aircraft/A320Family/Nasal/electrical.nas</file>
<file>Aircraft/A320Family/Nasal/engines.nas</file>
</systems>
<fbw>
<file>Aircraft/A320Family/Nasal/it-fbw.nas</file>
</fbw>
<itaf>
<file>Aircraft/A320Family/Nasal/it-autoflight.nas</file>
</itaf>

View file

@ -578,7 +578,7 @@ YAW MOI_________3950000______23089847_______24848934
<flight_control name="FCS: A320">
<channel name="Pitch">
<summer name="Pitch Trim Sum">
<input>/controls/flight/elevator</input>
<input>/controls/flight/elevator-fbw</input>
<input>/controls/flight/elevator-trim</input>
<clipto>
<min>-1</min>
@ -611,7 +611,7 @@ YAW MOI_________3950000______23089847_______24848934
</channel>
<channel name="Roll">
<summer name="Roll Trim Sum">
<input>/controls/flight/aileron</input>
<input>/controls/flight/aileron-fbw</input>
<input>/controls/flight/aileron-trim</input>
<clipto>
<min>-1</min>

170
Nasal/it-fbw.nas Normal file
View file

@ -0,0 +1,170 @@
# A320 FBW System by Joshua Davidson (it0uchpods/411)
# V0.8
var roll_input = func {
if (getprop("/it-autoflight/output/ap1") == 0 and getprop("/it-autoflight/output/ap2") == 0 and ((getprop("/it-fbw/law") == "NORMAL") or (getprop("/it-fbw/law") == "ALTERNATE"))) {
var ail = getprop("/controls/flight/aileron");
if (ail >= 0.05 and ail < 0.15) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw + "0.01");
} else if (ail >= 0.15 and ail < 0.3) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw + "0.05");
} else if (ail >= 0.3 and ail < 0.5) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw + "0.1");
} else if (ail >= 0.5 and ail < 0.7) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw + "0.2");
} else if (ail >= 0.7 and ail <= 1) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw + "0.3");
}
if (ail <= -0.05 and ail > -0.15) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw - "0.01");
} else if (ail <= -0.15 and ail > -0.3) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw - "0.05");
} else if (ail <= -0.3 and ail > -0.5) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw - "0.1");
} else if (ail <= -0.5 and ail > -0.7) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw - "0.2");
} else if (ail <= -0.7 and ail >= -1) {
var rfbw = getprop("/it-fbw/roll-deg");
setprop("/it-fbw/roll-deg", rfbw - "0.3");
}
}
if (getprop("/it-fbw/roll-deg") >= 30) {
if (getprop("/it-fbw/law") == "NORMAL") {
if (ail > 0.4) {
if (getprop("/it-fbw/roll-deg") >= 65) {
setprop("/it-fbw/roll-deg", "65");
}
} else {
setprop("/it-fbw/roll-deg", "30");
}
}
}
if (getprop("/it-fbw/roll-deg") <= -30) {
if (getprop("/it-fbw/law") == "NORMAL") {
if (ail < -0.4) {
if (getprop("/it-fbw/roll-deg") <= -65) {
setprop("/it-fbw/roll-deg", "-65");
}
} else {
setprop("/it-fbw/roll-deg", "-30");
}
}
}
if (getprop("/gear/gear[0]/wow") == 1) {
setprop("/it-fbw/roll-deg", "0");
}
settimer(roll_input, 0.01);
}
var pitch_input = func {
if (getprop("/it-autoflight/output/ap1") == 0 and getprop("/it-autoflight/output/ap2") == 0 and ((getprop("/it-fbw/law") == "NORMAL") or (getprop("/it-fbw/law") == "ALTERNATE"))) {
var elev = getprop("/controls/flight/elevator");
if (elev >= 0.05 and elev < 0.15) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw - "0.005");
} else if (elev >= 0.15 and elev < 0.3) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw - "0.01");
} else if (elev >= 0.3 and elev < 0.5) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw - "0.05");
} else if (elev >= 0.5 and elev < 0.7) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw - "0.1");
} else if (elev >= 0.7 and elev <= 1) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw - "0.15");
}
if (elev <= -0.05 and elev > -0.15) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw + "0.005");
} else if (elev <= -0.15 and elev > -0.3) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw + "0.01");
} else if (elev <= -0.3 and elev > -0.5) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw + "0.05");
} else if (elev <= -0.5 and elev > -0.7) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw + "0.1");
} else if (elev <= -0.7 and elev >= -1) {
var pfbw = getprop("/it-fbw/pitch-deg");
setprop("/it-fbw/pitch-deg", pfbw + "0.15");
}
}
if (getprop("/it-fbw/pitch-deg") >= 15) {
if (getprop("/position/gear-agl-ft") <= 30) {
setprop("/it-fbw/pitch-deg", "15");
}
if (getprop("/it-fbw/pitch-deg") >= 30) {
if (getprop("/it-fbw/law") == "NORMAL") {
setprop("/it-fbw/pitch-deg", "30");
}
}
}
if (getprop("/it-fbw/pitch-deg") <= -15) {
if (getprop("/it-fbw/law") == "NORMAL") {
setprop("/it-fbw/pitch-deg", "-15");
}
}
if (getprop("/gear/gear[0]/wow") == 1) {
if (elev > -0.1 and elev < 0.1) {
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
}
}
settimer(pitch_input, 0.01);
}
setlistener("/it-autoflight/output/ap1", func {
if (getprop("/it-autoflight/output/ap1") == 0) {
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
}
});
setlistener("/it-autoflight/output/ap2", func {
if (getprop("/it-autoflight/output/ap2") == 0) {
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
}
});
setlistener("/it-fbw/law", func {
if (getprop("/it-fbw/law") == "NORMAL") {
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
} else if (getprop("/it-fbw/law") == "ALTERNATE") {
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
}
});
setlistener("/sim/signals/fdm-initialized", func {
setprop("/it-fbw/law", "DIRECT"); # Will be changed to NORMAL when electric system powers up, as soon as I get the FBW/FDM stable
roll_input();
pitch_input();
# print("AIRBUS FBW ... OK!") # Don't advertise until it's working! ;)
});

438
Systems/it-fbw.xml Normal file
View file

@ -0,0 +1,438 @@
<?xml version="1.0"?>
<!-- IT-AUTOFLIGHT: Fly By Wire -->
<PropertyList>
<!-- =============================================================== -->
<!-- Lateral -->
<!-- =============================================================== -->
<pid-controller>
<name>IT-FBW: ROLL</name>
<debug>false</debug>
<enable>
<condition>
<and>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
</and>
</condition>
</enable>
<input>
<property>/orientation/roll-deg</property>
</input>
<reference>
<property>/it-fbw/roll-deg</property>
</reference>
<output>
<property>/controls/flight/aileron-fbw-cmd</property>
</output>
<config>
<Kp>
<property>/it-autoflight/config/roll/kp</property>
</Kp>
<beta>1.0</beta>
<alpha>0.1</alpha>
<gamma>0.0</gamma>
<Ti>
<property>/it-autoflight/config/roll/ti</property>
</Ti>
<Td>
<property>/it-autoflight/config/roll/td</property>
</Td>
<u_min>
<property>/it-autoflight/config/roll/umin</property>
</u_min>
<u_max>
<property>/it-autoflight/config/roll/umax</property>
</u_max>
</config>
</pid-controller>
<filter>
<name>IT-FBW: ROLL OPTION</name>
<debug>false</debug>
<feedback-if-disabled>true</feedback-if-disabled>
<initialize-to>output</initialize-to>
<input>
<condition>
<and>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<greater-than>
<property>/position/gear-agl-ft</property>
<value>1</value>
</greater-than>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
</and>
</condition>
<property>/controls/flight/aileron-fbw-cmd</property>
</input>
<input>
<condition>
<or>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>1</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>1</value>
</equals>
<less-than-equals>
<property>/position/gear-agl-ft</property>
<value>1</value>
</less-than-equals>
<equals>
<property>/it-fbw/law</property>
<value>DIRECT</value>
</equals>
</or>
</condition>
<property>/controls/flight/aileron</property>
</input>
<input>
<condition>
<equals>
<property>/it-fbw/law</property>
<value>BACKUP</value>
</equals>
</condition>
<value>0</value>
</input>
<output>/controls/flight/aileron-fbw</output>
<type>noise-spike</type>
<max-rate-of-change>10</max-rate-of-change>
</filter>
<!-- =============================================================== -->
<!-- Vertical -->
<!-- =============================================================== -->
<pid-controller>
<name>IT-FBW: PITCH</name>
<debug>false</debug>
<enable>
<condition>
<and>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
</and>
</condition>
</enable>
<input>
<property>/orientation/pitch-deg</property>
</input>
<reference>
<property>/it-fbw/pitch-deg</property>
</reference>
<output>
<property>/controls/flight/elevator-fbw-cmd</property>
</output>
<config>
<Kp>
<property>/it-autoflight/config/pitch/kp</property>
</Kp>
<beta>1.0</beta>
<alpha>0.1</alpha>
<gamma>0.0</gamma>
<Ti>
<property>/it-autoflight/config/pitch/ti</property>
</Ti>
<Td>
<property>/it-autoflight/config/pitch/td</property>
</Td>
<u_min>
<property>/it-autoflight/config/pitch/umin</property>
</u_min>
<u_max>
<property>/it-autoflight/config/pitch/umax</property>
</u_max>
</config>
</pid-controller>
<filter>
<name>IT-FBW: PITCH OPTION</name>
<debug>false</debug>
<feedback-if-disabled>true</feedback-if-disabled>
<initialize-to>output</initialize-to>
<input>
<condition>
<and>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<greater-than>
<property>/position/gear-agl-ft</property>
<value>1</value>
</greater-than>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
</and>
</condition>
<property>/controls/flight/elevator-fbw-cmd</property>
</input>
<input>
<condition>
<or>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>1</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>1</value>
</equals>
<less-than-equals>
<property>/position/gear-agl-ft</property>
<value>1</value>
</less-than-equals>
<equals>
<property>/it-fbw/law</property>
<value>DIRECT</value>
</equals>
</or>
</condition>
<property>/controls/flight/elevator</property>
</input>
<input>
<condition>
<equals>
<property>/it-fbw/law</property>
<value>BACKUP</value>
</equals>
</condition>
<value>0</value>
</input>
<output>/controls/flight/elevator-fbw</output>
<type>noise-spike</type>
<max-rate-of-change>10</max-rate-of-change>
</filter>
<pid-controller>
<name>AP PITCH HELPER PLUS</name>
<debug>false</debug>
<enable>
<condition>
<and>
<greater-than>
<property>/controls/flight/elevator-fbw</property>
<value>0.1</value>
</greater-than>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
<greater-than-equals>
<property>/position/gear-agl-ft</property>
<value>50</value>
</greater-than-equals>
</and>
</condition>
</enable>
<input>
<value>0</value>
</input>
<reference>
<value>1</value>
</reference>
<output>
<property>/controls/flight/elevator-trim-cmd</property>
</output>
<config>
<Kp>0.08</Kp>
<beta>1.0</beta>
<alpha>0.1</alpha>
<gamma>0.0</gamma>
<Ti>10</Ti>
<Td>0.00001</Td>
<u_min>-1.00</u_min>
<u_max>1.00</u_max>
</config>
</pid-controller>
<pid-controller>
<name>FBW PITCH HELPER MINUS</name>
<debug>false</debug>
<enable>
<condition>
<and>
<less-than>
<property>/controls/flight/elevator-fbw</property>
<value>-0.1</value>
</less-than>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
<greater-than-equals>
<property>/position/gear-agl-ft</property>
<value>50</value>
</greater-than-equals>
</and>
</condition>
</enable>
<input>
<value>0</value>
</input>
<reference>
<value>1</value>
</reference>
<output>
<property>/controls/flight/elevator-trim-cmd</property>
</output>
<config>
<Kp>-0.08</Kp>
<beta>1.0</beta>
<alpha>0.1</alpha>
<gamma>0.0</gamma>
<Ti>10</Ti>
<Td>0.00001</Td>
<u_min>-1.00</u_min>
<u_max>1.00</u_max>
</config>
</pid-controller>
<filter>
<name>IT-FBW: PITCH TRIM FILTER</name>
<debug>false</debug>
<feedback-if-disabled>true</feedback-if-disabled>
<initialize-to>output</initialize-to>
<enable>
<condition>
<and>
<and>
<equals>
<property>/it-autoflight/output/ap1</property>
<value>0</value>
</equals>
<equals>
<property>/it-autoflight/output/ap2</property>
<value>0</value>
</equals>
<or>
<equals>
<property>/it-fbw/law</property>
<value>NORMAL</value>
</equals>
<equals>
<property>/it-fbw/law</property>
<value>ALTERNATE</value>
</equals>
</or>
<greater-than-equals>
<property>/position/gear-agl-ft</property>
<value>50</value>
</greater-than-equals>
</and>
<or>
<greater-than>
<property>/controls/flight/elevator-fbw</property>
<value>0.05</value>
</greater-than>
<less-than>
<property>/controls/flight/elevator-fbw</property>
<value>-0.05</value>
</less-than>
</or>
</and>
</condition>
</enable>
<input>
<property>/controls/flight/elevator-trim-cmd</property>
</input>
<output>/controls/flight/elevator-trim</output>
<type>noise-spike</type>
<max-rate-of-change>0.01</max-rate-of-change>
</filter>
</PropertyList>