From e3243b796e93f2c1ec893d19142e73a3b70b9c46 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Sun, 7 May 2017 21:34:45 -0400 Subject: [PATCH] FBW: Add Flare Mode, Auto Flap Retract with 1+F to 1, Very basig FMGC system started --- A319-100-IAE-set.xml | 3 ++ A319-100-IAE.xml | 4 +-- A320-200-IAE-set.xml | 3 ++ A320-200-IAE.xml | 4 +-- A320-main.xml | 7 ++++ A321-200-IAE-set.xml | 3 ++ A321-200-IAE.xml | 4 +-- ACJ-IAE-set.xml | 3 ++ ACJ-IAE.xml | 4 +-- AircraftConfig/acconfig.nas | 4 +++ Nasal/FMGC.nas | 29 +++++++++++++++++ Nasal/fctl.nas | 25 ++++++++++++++- Nasal/it-fbw.nas | 4 +++ Systems/hydraulics.xml | 38 +++++++++++++++------- Systems/it-fbw-b.xml | 64 +++++++++++++++++++++++++++++++++++++ Systems/it-fbw.xml | 2 +- 16 files changed, 179 insertions(+), 22 deletions(-) create mode 100644 Nasal/FMGC.nas diff --git a/A319-100-IAE-set.xml b/A319-100-IAE-set.xml index 2b73bc91..adb227ce 100644 --- a/A319-100-IAE-set.xml +++ b/A319-100-IAE-set.xml @@ -138,6 +138,9 @@ Aircraft/A320Family/Nasal/it-autoflight.nas + + Aircraft/A320Family/Nasal/FMGC.nas + Aircraft/A320Family/Nasal/thrust.nas diff --git a/A319-100-IAE.xml b/A319-100-IAE.xml index a9ded79c..5d66590c 100644 --- a/A319-100-IAE.xml +++ b/A319-100-IAE.xml @@ -499,7 +499,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 @@ -525,7 +525,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 diff --git a/A320-200-IAE-set.xml b/A320-200-IAE-set.xml index 77757c17..4decc668 100644 --- a/A320-200-IAE-set.xml +++ b/A320-200-IAE-set.xml @@ -131,6 +131,9 @@ Aircraft/A320Family/Nasal/it-autoflight.nas + + Aircraft/A320Family/Nasal/FMGC.nas + Aircraft/A320Family/Nasal/thrust.nas diff --git a/A320-200-IAE.xml b/A320-200-IAE.xml index 4bb6db6b..642dd3c5 100644 --- a/A320-200-IAE.xml +++ b/A320-200-IAE.xml @@ -499,7 +499,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 @@ -525,7 +525,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 diff --git a/A320-main.xml b/A320-main.xml index 917c534c..439e5ac0 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -334,6 +334,12 @@ 0 0 + + + + 1 + + @@ -404,6 +410,7 @@ 0.5 -0.5 0.0 + 0 0 0.1 0.1 diff --git a/A321-200-IAE-set.xml b/A321-200-IAE-set.xml index a06653a8..0fe153c2 100644 --- a/A321-200-IAE-set.xml +++ b/A321-200-IAE-set.xml @@ -131,6 +131,9 @@ Aircraft/A320Family/Nasal/it-autoflight.nas + + Aircraft/A320Family/Nasal/FMGC.nas + Aircraft/A320Family/Nasal/thrust.nas diff --git a/A321-200-IAE.xml b/A321-200-IAE.xml index 95ed4347..b1af3c54 100644 --- a/A321-200-IAE.xml +++ b/A321-200-IAE.xml @@ -499,7 +499,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 @@ -525,7 +525,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 diff --git a/ACJ-IAE-set.xml b/ACJ-IAE-set.xml index 0cdaf7d1..59b061da 100644 --- a/ACJ-IAE-set.xml +++ b/ACJ-IAE-set.xml @@ -137,6 +137,9 @@ Aircraft/A320Family/Nasal/it-autoflight.nas + + Aircraft/A320Family/Nasal/FMGC.nas + Aircraft/A320Family/Nasal/thrust.nas diff --git a/ACJ-IAE.xml b/ACJ-IAE.xml index a6a2f472..36efcc49 100644 --- a/ACJ-IAE.xml +++ b/ACJ-IAE.xml @@ -499,7 +499,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 @@ -525,7 +525,7 @@ YAW MOI_________3950000______23089847_______24848934 -33.9470 11982 - 6000 + 4480 31 3 JET-A1 diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas index 3adda25b..d3306738 100644 --- a/AircraftConfig/acconfig.nas +++ b/AircraftConfig/acconfig.nas @@ -32,6 +32,7 @@ var colddark = func { setprop("/controls/flight/flap-lever", 0); setprop("/controls/flight/flap-pos", 0); setprop("/controls/flight/flap-txt", " "); + A320.flaptimer.stop(); setprop("/controls/flight/speedbrake-arm", 0); setprop("/controls/gear/gear-down", 1); systems.elec_init(); @@ -78,6 +79,7 @@ var beforestart = func { setprop("/controls/flight/flap-lever", 0); setprop("/controls/flight/flap-pos", 0); setprop("/controls/flight/flap-txt", " "); + A320.flaptimer.stop(); setprop("/controls/flight/speedbrake-arm", 0); setprop("/controls/gear/gear-down", 1); systems.elec_init(); @@ -148,6 +150,7 @@ var taxi = func { setprop("/controls/flight/flap-lever", 0); setprop("/controls/flight/flap-pos", 0); setprop("/controls/flight/flap-txt", " "); + A320.flaptimer.stop(); setprop("/controls/flight/speedbrake-arm", 0); setprop("/controls/gear/gear-down", 1); systems.elec_init(); @@ -246,6 +249,7 @@ var takeoff = func { setprop("/controls/flight/flap-lever", 1); setprop("/controls/flight/flap-pos", 2); setprop("/controls/flight/flap-txt", "1+F"); + A320.flaptimer.start(); setprop("/controls/flight/elevator-trim", -0.15); } }); diff --git a/Nasal/FMGC.nas b/Nasal/FMGC.nas new file mode 100644 index 00000000..02a015c9 --- /dev/null +++ b/Nasal/FMGC.nas @@ -0,0 +1,29 @@ +# A320Family FMGC +# Joshua Davidson (it0uchpods) + +# Very Simple at the moment, but will evolve into a fully-fledged FMGC System. -JD + +setlistener("/gear/gear[1]/wow", func { + gearfunc(); +}); + +setlistener("/gear/gear[2]/wow", func { + gearfunc(); +}); + +var gearfunc = func { + var gear1 = getprop("/gear/gear[1]/wow"); + var gear2 = getprop("/gear/gear[2]/wow"); + var state1 = getprop("/systems/thrust/state1"); + var state2 = getprop("/systems/thrust/state2"); + var flaps = getprop("/controls/flight/flap-pos"); + if (gear1 == 1 and gear2 == 1 and (state1 == "MCT" or state1 == "TOGA") and (state2 == "MCT" or state2 == "TOGA") and flaps < 4) { + setprop("/FMGC/status/to-state", 1); + } + if (getprop("/position/gear-agl-ft") >= 55) { + setprop("/FMGC/status/to-state", 0); + } + if (gear1 == 1 and gear2 == 1 and getprop("/FMGC/status/to-state") == 0 and flaps >= 4) { + setprop("/controls/flight/elevator-trim", -0.15); + } +} \ No newline at end of file diff --git a/Nasal/fctl.nas b/Nasal/fctl.nas index bf6f3ba4..284ea0cc 100644 --- a/Nasal/fctl.nas +++ b/Nasal/fctl.nas @@ -14,6 +14,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 1); setprop("/controls/flight/flap-pos", 2); setprop("/controls/flight/flap-txt", "1+F"); + flaptimer.start(); return; } else { setprop("/controls/flight/flaps", 0.000); @@ -21,6 +22,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 1); setprop("/controls/flight/flap-pos", 1); setprop("/controls/flight/flap-txt", "1"); + flaptimer.stop(); return; } } else if (getprop("/controls/flight/flap-lever") == 1) { @@ -29,6 +31,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 2); setprop("/controls/flight/flap-pos", 3); setprop("/controls/flight/flap-txt", "2"); + flaptimer.stop(); return; } else if (getprop("/controls/flight/flap-lever") == 2) { setprop("/controls/flight/flaps", 0.645); @@ -36,6 +39,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 3); setprop("/controls/flight/flap-pos", 4); setprop("/controls/flight/flap-txt", "3"); + flaptimer.stop(); return; } else if (getprop("/controls/flight/flap-lever") == 3) { setprop("/controls/flight/flaps", 1.000); @@ -43,6 +47,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 4); setprop("/controls/flight/flap-pos", 5); setprop("/controls/flight/flap-txt", "FULL"); + flaptimer.stop(); return; } } else if (step == -1) { @@ -52,6 +57,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 3); setprop("/controls/flight/flap-pos", 4); setprop("/controls/flight/flap-txt", "3"); + flaptimer.stop(); return; } else if (getprop("/controls/flight/flap-lever") == 3) { setprop("/controls/flight/flaps", 0.596); @@ -59,6 +65,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 2); setprop("/controls/flight/flap-pos", 3); setprop("/controls/flight/flap-txt", "2"); + flaptimer.stop(); return; } else if (getprop("/controls/flight/flap-lever") == 2) { if (getprop("/velocities/airspeed-kt") <= 100) { @@ -67,6 +74,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 1); setprop("/controls/flight/flap-pos", 2); setprop("/controls/flight/flap-txt", "1+F"); + flaptimer.start(); return; } else { setprop("/controls/flight/flaps", 0.000); @@ -74,6 +82,7 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 1); setprop("/controls/flight/flap-pos", 1); setprop("/controls/flight/flap-txt", "1"); + flaptimer.stop(); return; } } else if (getprop("/controls/flight/flap-lever") == 1) { @@ -82,9 +91,23 @@ controls.flapsDown = func(step) { setprop("/controls/flight/flap-lever", 0); setprop("/controls/flight/flap-pos", 0); setprop("/controls/flight/flap-txt", " "); + flaptimer.stop(); return; } } else { return 0; } -} \ No newline at end of file +} + +var flap_autoretract = func { + if (getprop("/controls/flight/flap-pos") == 2 and getprop("/velocities/airspeed-kt") >= 185) { + setprop("/controls/flight/flaps", 0.000); + setprop("/controls/flight/slats", 0.666); + setprop("/controls/flight/flap-lever", 1); + setprop("/controls/flight/flap-pos", 1); + setprop("/controls/flight/flap-txt", "1"); + flaptimer.stop(); + } +} + +var flaptimer = maketimer(0.5, flap_autoretract); diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index 748fa1d6..80d89a84 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -64,6 +64,10 @@ var update_loop = func { } } } + + if (getprop("/it-fbw/law") == 1 and getprop("/controls/gear/gear-down") == 1 and getprop("/it-fbw/override") == 0) { + setprop("/it-fbw/law", 2); + } } ########################### diff --git a/Systems/hydraulics.xml b/Systems/hydraulics.xml index fa4513bd..7da0bfdd 100644 --- a/Systems/hydraulics.xml +++ b/Systems/hydraulics.xml @@ -68,12 +68,19 @@ - - /controls/flight/aileron-fbw - -1-0.5 - 0 0.0 - 1 0.5 -
+ + + /controls/flight/aileron-fbw + -1-0.5 + 0 0.0 + 1 0.5 +
+ + /fdm/jsbsim/fcs/flap-pos-deg + 10.0 + 50.2 +
+
/controls/flight/aileron-left-cmd @@ -150,12 +157,19 @@ - - /controls/flight/aileron-fbw - -1-0.5 - 0 0.0 - 1 0.5 -
+ + + /controls/flight/aileron-fbw + -1-0.5 + 0 0.0 + 1 0.5 +
+ + /fdm/jsbsim/fcs/flap-pos-deg + 1 0.0 + 5-0.2 +
+
/controls/flight/aileron-right-cmd diff --git a/Systems/it-fbw-b.xml b/Systems/it-fbw-b.xml index 0da6b384..1134b843 100644 --- a/Systems/it-fbw-b.xml +++ b/Systems/it-fbw-b.xml @@ -5,6 +5,70 @@ + + + + + + false + gain + 1.0 + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /position/gear-agl-ft + 50 + + + /controls/flight/flap-pos + 4 + + + /controls/engines/engine[0]/throttle + 0.65 + + + /controls/engines/engine[0]/throttle + 0.65 + + + /FMGC/status/to-state + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + + + /controls/flight/elevator + 0.15 + + + + + /controls/flight/elevator + + /controls/flight/elevator-input + + diff --git a/Systems/it-fbw.xml b/Systems/it-fbw.xml index d839eb43..b0e8615f 100644 --- a/Systems/it-fbw.xml +++ b/Systems/it-fbw.xml @@ -88,7 +88,7 @@ /it-fbw/pitch-deg - /controls/flight/elevator + /controls/flight/elevator-input -1.0 0.1 -0.7 0.05