From 0b76615228d1b3e4b0af00bd41ee0c2231dd5ca8 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Tue, 28 Nov 2017 23:11:23 -0500 Subject: [PATCH] A3XX: FBW: Add high speed protection --- Nasal/FMGC.nas | 8 +-- Nasal/it-fbw.nas | 63 +++++++++++------ Systems/fbw-pitch.xml | 146 +++++++++++++++++++++++++++------------ Systems/fbw-roll-yaw.xml | 110 ++++++++++++++++++++++++++--- revision.txt | 2 +- 5 files changed, 241 insertions(+), 88 deletions(-) diff --git a/Nasal/FMGC.nas b/Nasal/FMGC.nas index 59dbc6ca..04e7509a 100644 --- a/Nasal/FMGC.nas +++ b/Nasal/FMGC.nas @@ -117,7 +117,6 @@ setlistener("/sim/signals/fdm-initialized", func { var newvertarm = getprop("/modes/pfd/fma/pitch-mode2-armed"); var thr1 = getprop("/controls/engines/engine[0]/throttle-pos"); var thr2 = getprop("/controls/engines/engine[1]/throttle-pos"); - var mmoIAS = 0; }); var FMGCinit = func { @@ -270,13 +269,8 @@ var masterFMGC = maketimer(0.2, func { } flap = getprop("/controls/flight/flap-pos"); - mmoIAS = (getprop("/instrumentation/airspeed-indicator/indicated-speed-kt") / getprop("/instrumentation/airspeed-indicator/indicated-mach")) * 0.82; if (flap == 0) { # 0 - if (mmoIAS < 350) { - setprop("/FMGC/internal/maxspeed", mmoIAS); - } else { - setprop("/FMGC/internal/maxspeed", 350); - } + setprop("/FMGC/internal/maxspeed", getprop("/it-fbw/speeds/vmo-mmo")); setprop("/FMGC/internal/minspeed", 202); } else if (flap == 1) { # 1 setprop("/FMGC/internal/maxspeed", 230); diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index 8f1e6a47..6a3d85c9 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -7,6 +7,13 @@ # If All ELACs Fail, Alternate Law +setprop("/it-fbw/roll-back", 0); +setprop("/it-fbw/spd-hold", 0); +setprop("/it-fbw/protections/overspeed", 0); +setprop("/it-fbw/protections/overspeed-roll-back", 0); +setprop("/it-fbw/speeds/vmo-mmo", 350); +var mmoIAS = 0; + var fctlInit = func { setprop("/controls/fctl/elac1", 1); setprop("/controls/fctl/elac2", 1); @@ -23,15 +30,12 @@ var fctlInit = func { setprop("/systems/fctl/fac1", 0); setprop("/systems/fctl/fac2", 0); setprop("/it-fbw/degrade-law", 0); + setprop("/it-fbw/override", 0); + setprop("/it-fbw/law", 0); + updatet.start(); + fbwt.start(); } -setprop("/it-fbw/roll-back", 0); -setprop("/it-fbw/spd-hold", 0); - -################### -# Update Function # -################### - var update_loop = func { var elac1_sw = getprop("/controls/fctl/elac1"); var elac2_sw = getprop("/controls/fctl/elac2"); @@ -158,10 +162,31 @@ var update_loop = func { setprop("/it-fbw/degrade-law", 2); } + mmoIAS = (getprop("/instrumentation/airspeed-indicator/indicated-speed-kt") / getprop("/instrumentation/airspeed-indicator/indicated-mach")) * 0.82; + if (mmoIAS < 350) { + setprop("/it-fbw/speeds/vmo-mmo", mmoIAS); + } else { + setprop("/it-fbw/speeds/vmo-mmo", 350); + } + + if (getprop("/instrumentation/airspeed-indicator/indicated-speed-kt") > getprop("/it-fbw/speeds/vmo-mmo") + 6 and getprop("/it-fbw/law") == 0) { + if (getprop("/it-fbw/protections/overspeed") != 1) { + setprop("/it-fbw/protections/overspeed", 1); + } + if (getprop("/it-autoflight/output/ap1") == 1) { + setprop("/it-autoflight/input/ap1", 0); + } + if (getprop("/it-autoflight/output/ap2") == 1) { + setprop("/it-autoflight/input/ap2", 0); + } + } else { + if (getprop("/it-fbw/protections/overspeed") != 0) { + setprop("/it-fbw/protections/overspeed", 0); + } + } } var fbw_loop = func { - var ail = getprop("/controls/flight/aileron"); if (ail > 0.4 or ail < -0.4) { @@ -172,12 +197,18 @@ var fbw_loop = func { if (getprop("/it-fbw/roll-back") == 0 and (getprop("/orientation/roll-deg") > 33.5 or getprop("/orientation/roll-deg") < -33.5)) { setprop("/it-fbw/roll-back", 1); } - } else if (ail < 0.05 and ail > -0.05) { + } else if (ail < 0.04 and ail > -0.04) { setprop("/it-fbw/roll-lim", "33"); if (getprop("/it-fbw/roll-back") == 1 and getprop("/orientation/roll-deg") <= 33.5 and getprop("/orientation/roll-deg") >= -33.5) { setprop("/it-fbw/roll-back", 0); } } + + if (ail > 0.04 or ail < -0.04) { + setprop("/it-fbw/protections/overspeed-roll-back", 0); + } else if (ail < 0.04 and ail > -0.04) { + setprop("/it-fbw/protections/overspeed-roll-back", 1); + } if (getprop("/it-fbw/override") == 0) { var degrade = getprop("/it-fbw/degrade-law"); @@ -210,19 +241,5 @@ var fbw_loop = func { } } -########################### -# Various Other Functions # -########################### - -setlistener("/sim/signals/fdm-initialized", func { - setprop("/it-fbw/override", 0); - setprop("/it-fbw/law", 0); - updatet.start(); - fbwt.start(); -}); - -########## -# Timers # -########## var updatet = maketimer(0.1, update_loop); var fbwt = maketimer(0.03, fbw_loop); diff --git a/Systems/fbw-pitch.xml b/Systems/fbw-pitch.xml index d6b09665..1ffdbce8 100644 --- a/Systems/fbw-pitch.xml +++ b/Systems/fbw-pitch.xml @@ -21,10 +21,16 @@ 1 - - /it-fbw/law - 1 - + + + /it-fbw/law + 0 + + + /it-fbw/protections/overspeed + 1 + + @@ -70,10 +76,16 @@ - - /it-fbw/law - 1 - + + + /it-fbw/law + 0 + + + /it-fbw/protections/overspeed + 1 + + @@ -86,6 +98,46 @@ + + + + + /it-fbw/law + 0 + + + /it-fbw/protections/overspeed + 1 + + + + + + + /controls/flight/elevator-input + 0.0 2.5 + -1.0 5.0 +
+ + + /orientation/pitch-deg + 29.999990 + 30.000001 +
+ + /controls/flight/elevator-input + 0-2.5 + -1-5.0 +
+
+ + /orientation/pitch-deg + 30 0 + 33-4 +
+
+
+ /it-fbw/pitch-rate @@ -280,50 +332,48 @@ - - - - /it-fbw/law - 0 - - - /it-fbw/law - 1 - - - - - - /position/gear-agl-ft - 100 - - - - /it-autoflight/output/ap1 - 1 - - - /it-autoflight/output/ap2 - 1 - - - - - - /position/gear-agl-ft - 50 - + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + + /position/gear-agl-ft + 100 + + /it-autoflight/output/ap1 - 0 + 1 /it-autoflight/output/ap2 - 0 + 1 - - - + + + + + /position/gear-agl-ft + 50 + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /orientation/roll-deg 40 @@ -346,6 +396,10 @@ /fdm/jsbsim/forces/load-factor -0.5 + + /it-fbw/protections/overspeed + 1 + diff --git a/Systems/fbw-roll-yaw.xml b/Systems/fbw-roll-yaw.xml index 48623761..989a3051 100644 --- a/Systems/fbw-roll-yaw.xml +++ b/Systems/fbw-roll-yaw.xml @@ -27,10 +27,14 @@ /it-fbw/roll-lim 33 - + /it-fbw/roll-back - 0 - + 1 + + + /it-fbw/protections/overspeed + 1 + @@ -70,10 +74,16 @@ - - /it-fbw/roll-lim - 67 - + + + /it-fbw/roll-lim + 67 + + + /it-fbw/protections/overspeed + 1 + + @@ -112,10 +122,16 @@ - - /it-fbw/roll-back - 1 - + + + /it-fbw/roll-back + 1 + + + /it-fbw/protections/overspeed + 1 + + @@ -129,6 +145,78 @@
+ + + + + /it-fbw/protections/overspeed + 1 + + + /it-fbw/protections/overspeed-roll-back + 1 + + + + + + + /controls/flight/aileron-input + -1-12.0 + 0 0.0 + 1 12.0 +
+ + + /orientation/roll-deg + -40.000001 + -39.999990 +
+ + /controls/flight/aileron-input + -112.0 + 0 0.0 +
+
+ + + /orientation/roll-deg + 39.999990 + 40.000001 +
+ + /controls/flight/aileron-input + 0 0.0 + 1-12.0 +
+
+
+
+ + + + + + /it-fbw/protections/overspeed + 1 + + + /it-fbw/protections/overspeed-roll-back + 1 + + + + + + /orientation/roll-deg + -40 25.0 + -15 10.0 + 0 0.0 + 15-10.0 + 40-25.0 +
+
+ /it-fbw/roll-rate diff --git a/revision.txt b/revision.txt index f7f5dbcb..68916742 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4041 \ No newline at end of file +4042 \ No newline at end of file