Howto:Implement a Fly-By-Wire System for Airliners: Difference between revisions

m
→‎/Nasal/fbw.nas: use a separate method to check if power is on
m (→‎/Nasal/fbw.nas: use a separate update_ailerons() method)
m (→‎/Nasal/fbw.nas: use a separate method to check if power is on)
Line 134: Line 134:
## Position and Orientation
## Position and Orientation


var altitudeagl = getprop("/position/altitude-agl-ft");
me.altitudeagl = getprop("/position/altitude-agl-ft");


var altitudemsl = getprop("/position/altitude-ft");
var altitudemsl = getprop("/position/altitude-ft");
Line 169: Line 169:
## This is where the FBW actually does its job ;)
## This is where the FBW actually does its job ;)


### The Fly-by--wire only works when it is active. In the Boeing 787, pilots have the option to disable fly-by-wire and use power-by-wire* in case of emergencies. The Fly By Wire Configuration includes: On/Off, Bank Limit and Rudder Control. The FBW Configs can be set in the FBW CONFIG Page in the CDU(s)
me.check_if_active();
 
## Turn on Fly By Wire only if we have power
 
if (getprop("/systems/electrical/outputs/efis") != nil) {
  if ((getprop("/systems/electrical/outputs/efis") < 9) and (altitudeagl >= 200)) {
  setprop("/controls/fbw/active", 0);
  if (me.disconnectannounce == 0) {
    screen.log.write("Fly By Wire Disconnected!", 1, 0, 0);
    me.disconnectannounce = 1;
  }
}
}


if (getprop("/controls/fbw/active")) {
if (getprop("/controls/fbw/active")) {
Line 219: Line 207:
}
}


if ((airspeedkt >= 220) and (altitudeagl >= 3500)) {
if ((airspeedkt >= 220) and (me.altitudeagl >= 3500)) {
setprop("/controls/fbw/autostable", 1);
setprop("/controls/fbw/autostable", 1);
} else {
} else {
Line 300: Line 288:
### Adjust Throttle to keep from stalling
### Adjust Throttle to keep from stalling


if ((airspeedkt < 125) and (altitudeagl > 250) and (throttles[0] != 1) and (throttles[1] != 1)) {
if ((airspeedkt < 125) and (me.altitudeagl > 250) and (throttles[0] != 1) and (throttles[1] != 1)) {
throttles[0] += 0.001 * me.fpsfix;
throttles[0] += 0.001 * me.fpsfix;
throttles[1] += 0.001 * me.fpsfix;
throttles[1] += 0.001 * me.fpsfix;
Line 404: Line 392:
       }
       }


},
    check_if_active : func {
### The Fly-by--wire only works when it is active. In the Boeing 787, pilots have the option to disable fly-by-wire and use power-by-wire* in case of emergencies. The Fly By Wire Configuration includes: On/Off, Bank Limit and Rudder Control. The FBW Configs can be set in the FBW CONFIG Page in the CDU(s)
## Turn on Fly By Wire only if we have power
if (getprop("/systems/electrical/outputs/efis") != nil) {
  if ((getprop("/systems/electrical/outputs/efis") < 9) and (me.altitudeagl >= 200)) {
  setprop("/controls/fbw/active", 0);
  if (me.disconnectannounce == 0) {
    screen.log.write("Fly By Wire Disconnected!", 1, 0, 0);
    me.disconnectannounce = 1;
  }
}
}
},
},
     reset : func {
     reset : func {