From 4be083fcfb234db69b69e74827f75715d7ed1870 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Tue, 24 Jul 2018 18:52:36 -0400 Subject: [PATCH 1/3] Control: Update FMGC altitude and heading control to V3.2 --- Nasal/FMGC-b.nas | 92 +++-------------------- Systems/fmgc-drivers.xml | 149 +++++++++++++++++++++++++++++--------- Systems/fmgc-pitch.xml | 52 ++++++++++--- Systems/fmgc-roll-yaw.xml | 2 +- 4 files changed, 169 insertions(+), 126 deletions(-) diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 0d1c6d5e..ef9ef1e2 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -13,17 +13,14 @@ setprop("/it-autoflight/internal/heading-deg", getprop("/orientation/heading-mag setprop("/it-autoflight/internal/track-deg", getprop("/orientation/track-magnetic-deg")); setprop("/it-autoflight/internal/vert-speed-fpm", 0); setprop("/it-autoflight/internal/heading-error-deg", 0); -setprop("/it-autoflight/internal/heading-5-sec-ahead", 0); -setprop("/it-autoflight/internal/altitude-5-sec-ahead", 0); +setprop("/it-autoflight/internal/heading-predicted", 0); +setprop("/it-autoflight/internal/altitude-predicted", 0); setprop("/it-autoflight/internal/lnav-advance-nm", 1); setlistener("/sim/signals/fdm-initialized", func { var trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt"); var locdefl = getprop("/instrumentation/nav[0]/heading-needle-deflection-norm"); var signal = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm"); - var VS = getprop("/velocities/vertical-speed-fps"); - var TAS = getprop("/velocities/uBody-fps"); - var FPangle = 0; var gear1 = getprop("/gear/gear[1]/wow"); var gear2 = getprop("/gear/gear[2]/wow"); var gnds_mps = 0; @@ -40,6 +37,7 @@ setlistener("/sim/signals/fdm-initialized", func { var R = 0; var dist_coeff = 0; var turn_dist = 0; + var vsnow = 0; }); var APinit = func { @@ -293,7 +291,7 @@ var lateral = func { setprop("/it-autoflight/input/lat-arm", 0); setprop("/it-autoflight/output/loc-armed", 0); setprop("/it-autoflight/output/appr-armed", 0); - var hdg5sec = math.round(getprop("/it-autoflight/internal/heading-5-sec-ahead")); + var hdg5sec = math.round(getprop("/it-autoflight/internal/heading-predicted")); setprop("/it-autoflight/input/hdg", hdg5sec); setprop("/it-autoflight/output/lat", 0); setprop("/it-autoflight/mode/lat", "HDG"); @@ -369,7 +367,7 @@ var vertical = func { } else { setprop("/it-autoflight/mode/arm", " "); } - var alt5sec = math.round(getprop("/it-autoflight/internal/altitude-5-sec-ahead"), 500); + var alt5sec = math.round(getprop("/it-autoflight/internal/altitude-predicted"), 100); setprop("/it-autoflight/input/alt", alt5sec); setprop("/it-autoflight/internal/alt", alt5sec); thrustmode(); @@ -456,11 +454,9 @@ var vertical = func { setprop("/it-autoflight/mode/arm", " "); } } else if (vertset == 5) { - fpa_calc(); alandt.stop(); alandt1.stop(); mng_sys_stop(); - fpa_calct.start(); setprop("/it-autoflight/output/appr-armed", 0); var altinput = getprop("/it-autoflight/input/alt"); setprop("/it-autoflight/internal/alt", altinput); @@ -659,18 +655,6 @@ var alt_on = func { minmaxtimer.start(); } -var fpa_calc = func { - VS = getprop("/velocities/vertical-speed-fps"); - TAS = getprop("/velocities/uBody-fps"); - if (TAS < 10) TAS = 10; - if (VS < -200) VS =-200; - if (abs(VS/TAS) <= 1) { - FPangle = math.asin(VS/TAS); - FPangle *=90; - setprop("/it-autoflight/internal/fpa", FPangle); - } -} - setlistener("/it-autoflight/input/kts-mach", func { var ias = getprop("/it-autoflight/input/spd-kts") or 0; var mach = getprop("/it-autoflight/input/spd-mach") or 0; @@ -746,59 +730,29 @@ var updateTimers = func { var vertm = getprop("/it-autoflight/output/vert"); if (vertm == 1) { altcaptt.start(); - fpa_calct.stop(); } else if (vertm == 4) { altcaptt.start(); - fpa_calct.stop(); } else if (vertm == 5) { altcaptt.start(); } else if (vertm == 7) { altcaptt.start(); - fpa_calct.stop(); } else if (vertm == 8) { altcaptt.stop(); - fpa_calct.stop(); } else if (vertm == 9) { altcaptt.start(); - fpa_calct.stop(); } else { altcaptt.stop(); - fpa_calct.stop(); } } else { altcaptt.start(); - fpa_calct.stop(); } } # Altitude Capture var altcapt = func { - var vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - if ((vsnow >= 0 and vsnow < 500) or (vsnow < 0 and vsnow > -500)) { - setprop("/it-autoflight/internal/captvs", 100); - setprop("/it-autoflight/internal/captvsneg", -100); - } else if ((vsnow >= 500 and vsnow < 1000) or (vsnow < -500 and vsnow > -1000)) { - setprop("/it-autoflight/internal/captvs", 200); - setprop("/it-autoflight/internal/captvsneg", -200); - } else if ((vsnow >= 1000 and vsnow < 1500) or (vsnow < -1000 and vsnow > -1500)) { - setprop("/it-autoflight/internal/captvs", 300); - setprop("/it-autoflight/internal/captvsneg", -300); - } else if ((vsnow >= 1500 and vsnow < 2000) or (vsnow < -1500 and vsnow > -2000)) { - setprop("/it-autoflight/internal/captvs", 400); - setprop("/it-autoflight/internal/captvsneg", -400); - } else if ((vsnow >= 2000 and vsnow < 3000) or (vsnow < -2000 and vsnow > -3000)) { - setprop("/it-autoflight/internal/captvs", 600); - setprop("/it-autoflight/internal/captvsneg", -600); - } else if ((vsnow >= 3000 and vsnow < 4000) or (vsnow < -3000 and vsnow > -4000)) { - setprop("/it-autoflight/internal/captvs", 900); - setprop("/it-autoflight/internal/captvsneg", -900); - } else if ((vsnow >= 4000 and vsnow < 5000) or (vsnow < -4000 and vsnow > -5000)) { - setprop("/it-autoflight/internal/captvs", 1200); - setprop("/it-autoflight/internal/captvsneg", -1200); - } else if ((vsnow >= 5000) or (vsnow < -5000)) { - setprop("/it-autoflight/internal/captvs", 1500); - setprop("/it-autoflight/internal/captvsneg", -1500); - } + vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); + setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 50)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 50)); if ((getprop("/it-autoflight/output/fd1") == 1 or getprop("/it-autoflight/output/fd2") == 1 or getprop("/it-autoflight/output/ap1") == 1 or getprop("/it-autoflight/output/ap2") == 1) and getprop("/it-autoflight/output/vert") != 9) { var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); var alt = getprop("/it-autoflight/internal/alt"); @@ -1216,32 +1170,9 @@ var mng_des_fpm = func { # Managed Capture var mng_altcapt = func { - var vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - if ((vsnow >= 0 and vsnow < 500) or (vsnow < 0 and vsnow > -500)) { - setprop("/it-autoflight/internal/captvs", 100); - setprop("/it-autoflight/internal/captvsneg", -100); - } else if ((vsnow >= 500 and vsnow < 1000) or (vsnow < -500 and vsnow > -1000)) { - setprop("/it-autoflight/internal/captvs", 200); - setprop("/it-autoflight/internal/captvsneg", -200); - } else if ((vsnow >= 1000 and vsnow < 1500) or (vsnow < -1000 and vsnow > -1500)) { - setprop("/it-autoflight/internal/captvs", 300); - setprop("/it-autoflight/internal/captvsneg", -300); - } else if ((vsnow >= 1500 and vsnow < 2000) or (vsnow < -1500 and vsnow > -2000)) { - setprop("/it-autoflight/internal/captvs", 400); - setprop("/it-autoflight/internal/captvsneg", -400); - } else if ((vsnow >= 2000 and vsnow < 3000) or (vsnow < -2000 and vsnow > -3000)) { - setprop("/it-autoflight/internal/captvs", 600); - setprop("/it-autoflight/internal/captvsneg", -600); - } else if ((vsnow >= 3000 and vsnow < 4000) or (vsnow < -3000 and vsnow > -4000)) { - setprop("/it-autoflight/internal/captvs", 900); - setprop("/it-autoflight/internal/captvsneg", -900); - } else if ((vsnow >= 4000 and vsnow < 5000) or (vsnow < -4000 and vsnow > -5000)) { - setprop("/it-autoflight/internal/captvs", 1200); - setprop("/it-autoflight/internal/captvsneg", -1200); - } else if ((vsnow >= 5000) or (vsnow < -5000)) { - setprop("/it-autoflight/internal/captvs", 1500); - setprop("/it-autoflight/internal/captvsneg", -1500); - } + vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); + setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 50)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 50)); var MNGalt = getprop("/it-autoflight/internal/mng-alt"); var MCPalt = getprop("/it-autoflight/internal/alt"); var MNGdif = abs(MNGalt - MCPalt); @@ -1325,7 +1256,6 @@ var minmaxtimer = maketimer(0.5, minmax); var alandt = maketimer(0.5, aland); var alandt1 = maketimer(0.5, aland1); var reduct = maketimer(0.5, toga_reduc); -var fpa_calct = maketimer(0.1, fpa_calc); var ap_varioust = maketimer(1, ap_various); var mng_maint = maketimer(0.5, mng_main); var mng_altcaptt = maketimer(0.5, mng_altcapt); diff --git a/Systems/fmgc-drivers.xml b/Systems/fmgc-drivers.xml index db4dab87..d6a4ba14 100644 --- a/Systems/fmgc-drivers.xml +++ b/Systems/fmgc-drivers.xml @@ -14,41 +14,6 @@ - - HEADING 5 SECONDS AHEAD - false - - - - /it-autoflight/input/trk - 0 - - - /it-autoflight/internal/heading-deg - - - - - /it-autoflight/input/trk - 1 - - - /it-autoflight/internal/track-deg - - /it-autoflight/internal/heading-5-sec-ahead - 5.0 - 0.0 - - - - ALTITUDE 5 SECONDS AHEAD - false - /instrumentation/altimeter/indicated-altitude-ft - /it-autoflight/internal/altitude-5-sec-ahead - 5.0 - 0.0 - - IAS 5 SECOND PREDICTOR false @@ -702,6 +667,120 @@ 0 + + HEADING PREDICTOR STAGE 1 + false + gain + 1.0 + + + + /it-autoflight/input/trk + 0 + + + + +
+ /orientation/roll-deg + 1.8 +
+ /it-autoflight/internal/heading-deg +
+
+ + + + + /it-autoflight/input/trk + 1 + + + + +
+ /orientation/roll-deg + 1.8 +
+ /it-autoflight/internal/track-deg +
+
+ + /it-autoflight/internal/heading-predicted-cmd +
+ + + HEADING PREDICTOR STAGE 2 + false + gain + 1.0 + + + + /it-autoflight/internal/heading-predicted-cmd + 360 + + + + + /it-autoflight/internal/heading-predicted-cmd + 360 + + + + + + + /it-autoflight/internal/heading-predicted-cmd + 1 + + + + + /it-autoflight/internal/heading-predicted-cmd + 360 + + + + /it-autoflight/internal/heading-predicted-cmd + /it-autoflight/internal/heading-predicted + + + + ALTITUDE PREDICTOR + false + gain + 1.0 + + + +
+ /it-autoflight/internal/vert-speed-fpm + 5 +
+ /instrumentation/altimeter/indicated-altitude-ft +
+
+ + /it-autoflight/internal/altitude-predicted +
+ + + INTERNAL FPA COMPUTER + false + gain + 1.0 + + + + /orientation/pitch-deg + /orientation/alpha-deg + + + + /it-autoflight/internal/fpa + + diff --git a/Systems/fmgc-pitch.xml b/Systems/fmgc-pitch.xml index 9548e096..acfbe56b 100644 --- a/Systems/fmgc-pitch.xml +++ b/Systems/fmgc-pitch.xml @@ -18,10 +18,11 @@ ALTITUDE CAPTURE/HOLD false gain + -5 - /it-autoflight/internal/altitude-5-sec-ahead + /instrumentation/altimeter/indicated-altitude-ft -2 @@ -44,7 +45,6 @@ /it-autoflight/internal/mng-alt - -8 /it-autoflight/internal/target-fpm @@ -97,12 +97,20 @@ /it-autoflight/internal/target-fpm-d - 120 + + + + /velocities/mach + 0.2120 + 0.9340 +
+
+
1.0 0.1 0.0 - 1.0 - 0.00001 + 2.0 + 0.002 @@ -563,7 +571,13 @@ 6 - 0.0017 + + + /velocities/mach + 0.20.0029 + 0.90.0010 +
+
@@ -574,7 +588,7 @@ 0.0055 - 3.0 + 2.5 0.0001 @@ -583,7 +597,17 @@ 6 - -10 + + + + /orientation/pitch-deg + -10-5 + 0 0 + 3035 +
+ 5 +
+
@@ -607,7 +631,17 @@ - 30 + + + + /orientation/pitch-deg + -10-15 + 0 0 + 30 25 +
+ 5 +
+
diff --git a/Systems/fmgc-roll-yaw.xml b/Systems/fmgc-roll-yaw.xml index 94d47db9..662a5d59 100644 --- a/Systems/fmgc-roll-yaw.xml +++ b/Systems/fmgc-roll-yaw.xml @@ -61,7 +61,7 @@ /it-autoflight/internal/target-roll-deg - -1.3 + -1.8 -0.000001 /it-autoflight/internal/bank-limit From e9a3dded3ef4de638c1898e320d09d93a6682163 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Tue, 24 Jul 2018 19:00:21 -0400 Subject: [PATCH 2/3] Control: Update FMGC altitude and heading control to V3.2 --- Nasal/FMGC-b.nas | 8 ++++---- revision.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index ef9ef1e2..3bc66087 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -751,8 +751,8 @@ var updateTimers = func { # Altitude Capture var altcapt = func { vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 50)); - setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 50)); + setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 100)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 100)); if ((getprop("/it-autoflight/output/fd1") == 1 or getprop("/it-autoflight/output/fd2") == 1 or getprop("/it-autoflight/output/ap1") == 1 or getprop("/it-autoflight/output/ap2") == 1) and getprop("/it-autoflight/output/vert") != 9) { var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); var alt = getprop("/it-autoflight/internal/alt"); @@ -1171,8 +1171,8 @@ var mng_des_fpm = func { # Managed Capture var mng_altcapt = func { vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 50)); - setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 50)); + setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 100)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 100)); var MNGalt = getprop("/it-autoflight/internal/mng-alt"); var MCPalt = getprop("/it-autoflight/internal/alt"); var MNGdif = abs(MNGalt - MCPalt); diff --git a/revision.txt b/revision.txt index 7e6bab41..416e8e4f 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4606 \ No newline at end of file +4610 \ No newline at end of file From 76683730a62cb32406fd43153b20fae7264a0061 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Tue, 24 Jul 2018 20:02:48 -0400 Subject: [PATCH 3/3] Control: Fix AP capture problems when descending --- Nasal/FMGC-b.nas | 8 ++++---- revision.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 3bc66087..6be8a027 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -751,8 +751,8 @@ var updateTimers = func { # Altitude Capture var altcapt = func { vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 100)); - setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 100)); + setprop("/it-autoflight/internal/captvs", math.round(abs(vsnow) / 5, 100)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(abs(vsnow) / 5, 100)); if ((getprop("/it-autoflight/output/fd1") == 1 or getprop("/it-autoflight/output/fd2") == 1 or getprop("/it-autoflight/output/ap1") == 1 or getprop("/it-autoflight/output/ap2") == 1) and getprop("/it-autoflight/output/vert") != 9) { var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); var alt = getprop("/it-autoflight/internal/alt"); @@ -1171,8 +1171,8 @@ var mng_des_fpm = func { # Managed Capture var mng_altcapt = func { vsnow = getprop("/it-autoflight/internal/vert-speed-fpm"); - setprop("/it-autoflight/internal/captvs", math.round(vsnow / 5, 100)); - setprop("/it-autoflight/internal/captvsneg", -1 * math.round(vsnow / 5, 100)); + setprop("/it-autoflight/internal/captvs", math.round(abs(vsnow) / 5, 100)); + setprop("/it-autoflight/internal/captvsneg", -1 * math.round(abs(vsnow) / 5, 100)); var MNGalt = getprop("/it-autoflight/internal/mng-alt"); var MCPalt = getprop("/it-autoflight/internal/alt"); var MNGdif = abs(MNGalt - MCPalt); diff --git a/revision.txt b/revision.txt index 416e8e4f..e45a74e6 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4610 \ No newline at end of file +4611 \ No newline at end of file