From 7dfd9f15ff8e92c7da71f0046d77fdcb869aa1cc Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Thu, 30 Dec 2021 13:46:35 +0000 Subject: [PATCH] APU: make the code shutting down the APU after 0.2 seconds of power loss more resilient, uisng JSBSim --- Nasal/Systems/APU.nas | 31 ++--- Systems/a320-apu.xml | 275 +++++++++++++++++++++++------------------- 2 files changed, 161 insertions(+), 145 deletions(-) diff --git a/Nasal/Systems/APU.nas b/Nasal/Systems/APU.nas index 0ec3635c..919c9cf6 100644 --- a/Nasal/Systems/APU.nas +++ b/Nasal/Systems/APU.nas @@ -273,24 +273,6 @@ var APU = { me.autoStop(); } - if (systems.ELEC.Bus.dcBat.getValue() < 25) { - if (!me._powerLost) { - me._powerLost = 1; - settimer(func() { - if (me._powerLost) { - if (me.GenericControls.starter.getValue()) { - me.GenericControls.starter.setValue(0); - } - if (me.state != 0) { - me.autoStop(); - } - } - }, 0.2); - } - } else { - me._powerLost = 0; - } - if (systems.ELEC.EmerElec.getValue() == 1 and (systems.ELEC.EmerElec45.getValue() != 1 and systems.ELEC.Source.EmerGen.voltsRelay.getValue() < 110)) { me.inhibitEMERELEC = 1; } else { @@ -316,6 +298,19 @@ var APUController = { } }; +setlistener("/systems/apu/shutdown-power-loss", func(val) { + if (APUController.APU != nil) { + if (val.getBoolValue()) { + if (APUController.APU.GenericControls.starter.getValue()) { + APUController.APU.GenericControls.starter.setValue(0); + } + if (APUController.APU.state != 0) { + APUController.APU.autoStop(); + } + } + } +}, 0, 0); + var _masterTime = 0; setlistener("/controls/apu/master", func() { if (APUController.APU != nil) { diff --git a/Systems/a320-apu.xml b/Systems/a320-apu.xml index f6ad2161..f4ae5c9c 100644 --- a/Systems/a320-apu.xml +++ b/Systems/a320-apu.xml @@ -7,52 +7,52 @@ - + - - - - - /controls/pneumatics/switches/apu - 1 - - 252 - 0 - - - - - - - - - - /systems/electrical/relay/apu-glc/output - 110 - - 132 - 0 - - - - - - - - - /systems/apu/electrical-load-kw - /systems/apu/bleed-load-kw - - 400 - - - - - - /systems/apu/apu-load-cmd - 0.01 - - + + + + + /controls/pneumatics/switches/apu + 1 + + 252 + 0 + + + + + + + + + + /systems/electrical/relay/apu-glc/output + 110 + + 132 + 0 + + + + + + + + + /systems/apu/electrical-load-kw + /systems/apu/bleed-load-kw + + 400 + + + + + + /systems/apu/apu-load-cmd + 0.01 + + /engines/engine[2]/n1 1 @@ -60,60 +60,60 @@ - - - /systems/apu/apu-load - 50 - - - - - /engines/engine[2]/n1 - 0.5 - - - /systems/apu/dn-dt - 0 - - - - /engines/engine[2]/n1 - - 5.0 20.0 - 8.0 45.0 - 10.0 120.0 - 12.0 225.0 - 18.0 430.0 - 25.0 500.0 - 27.0 560.0 - 30.0 720.0 - 35.0 785.0 - 40.0 800.0 - 45.0 795.0 - 50.0 785.0 - 60.0 755.0 - 75.0 645.0 - 90.0 520.0 - 100.0 415.0 - -
- - /engines/engine[2]/n1 - - 2.0 200.0 - 8.0 220.0 - 12.0 225.0 - 18.0 240.0 - 30.0 250.0 - 50.0 265.0 - 60.0 295.0 - 75.0 380.0 - 90.0 410.0 - 100.0 415.0 - -
-
-
+ + + /systems/apu/apu-load + 50 + + + + + /engines/engine[2]/n1 + 0.5 + + + /systems/apu/dn-dt + 0 + + + + /engines/engine[2]/n1 + + 5.0 20.0 + 8.0 45.0 + 10.0 120.0 + 12.0 225.0 + 18.0 430.0 + 25.0 500.0 + 27.0 560.0 + 30.0 720.0 + 35.0 785.0 + 40.0 800.0 + 45.0 795.0 + 50.0 785.0 + 60.0 755.0 + 75.0 645.0 + 90.0 520.0 + 100.0 415.0 + +
+ + /engines/engine[2]/n1 + + 2.0 200.0 + 8.0 220.0 + 12.0 225.0 + 18.0 240.0 + 30.0 250.0 + 50.0 265.0 + 60.0 295.0 + 75.0 380.0 + 90.0 410.0 + 100.0 415.0 + +
+
+
@@ -137,31 +137,31 @@ - - + + - - - 1.0 - - /systems/apu/apu-load - 0.3 - - - - /systems/apu/oil/oil-pressure-psi - - 0 0 - 25 135 - 35 105 - 55 85 - -
- - /engines/engine[2]/n1 - 100 - -
+ + + 1.0 + + /systems/apu/apu-load + 0.3 + + + + /systems/apu/oil/oil-pressure-psi + + 0 0 + 25 135 + 35 105 + 55 85 + +
+ + /engines/engine[2]/n1 + 100 + +
@@ -170,10 +170,10 @@ /systems/apu/oil/level-l - - /engines/engine[2]/n1 - 100 - + + /engines/engine[2]/n1 + 100 + /systems/apu/oil/allow-oil-consumption -0.00000131437 simulation/channel-dt @@ -182,6 +182,27 @@ /systems/apu/oil/level-l
+ + + + + /systems/electrical/bus/dc-bat lt 25 + + + + + /systems/apu/shutdown-power-loss-cmd + 5 + 100 + + + + + + /systems/apu/shutdown-power-loss-timer eq 1 + + +