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

Jump to navigation Jump to search
m
→‎/Nasal/fbw.nas: use a vector of throttles instead
m (→‎/Nasal/fbw.nas: use a vector of throttles instead)
Line 115: Line 115:
## Bank Limit Setting
## Bank Limit Setting


var banklimit = getprop("/controls/fbw/bank-limit");
me.banklimit = getprop("/controls/fbw/bank-limit");


## Position and Orientation
## Position and Orientation
Line 145: Line 145:
## Engine Throttle Positions
## Engine Throttle Positions


throttle0 = getprop("controls/engines/engine[0]/throttle");
# use a vector of throttles, this can be later on used to support more than
throttle1 = getprop("controls/engines/engine[1]/throttle");
# just two engines
var throttles = [];
throttles[0] = getprop("controls/engines/engine[0]/throttle");
throttles[1] = getprop("controls/engines/engine[1]/throttle");


## This is where the FBW actually does it's 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)
### 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)
Line 155: Line 158:


if (getprop("/systems/electrical/outputs/efis") != nil) {
if (getprop("/systems/electrical/outputs/efis") != nil) {
if ((getprop("/systems/electrical/outputs/efis") < 9) and (altitudeagl >= 200)) {
  if ((getprop("/systems/electrical/outputs/efis") < 9) and (altitudeagl >= 200)) {
setprop("/controls/fbw/active", 0);
  setprop("/controls/fbw/active", 0);
if (me.disconnectannounce == 0) {
  if (me.disconnectannounce == 0) {
screen.log.write("Fly By Wire Disconnected!", 1, 0, 0);
    screen.log.write("Fly By Wire Disconnected!", 1, 0, 0);
me.disconnectannounce = 1;
    me.disconnectannounce = 1;
} } }
  }
}
}


if (getprop("/controls/fbw/active")) {
if (getprop("/controls/fbw/active")) {
Line 230: Line 235:
### Disconnect Throttle fix if manually overridden
### Disconnect Throttle fix if manually overridden


if (throttle0 != me.throttle) {
if (throttles[0] != me.throttle) {
me.throttlefix = 0;
me.throttlefix = 0;
me.turnthrottlefix = 0;
me.turnthrottlefix = 0;
Line 241: Line 246:


if (me.turnthrottlefix == 0) {
if (me.turnthrottlefix == 0) {
me.throttleinit = throttle0;
me.throttleinit = throttles[0];
me.turnthrottlefix = 1;
me.turnthrottlefix = 1;
}
}
Line 247: Line 252:
me.targetthrottle = me.throttleinit + (me.throttleinit * math.sin(math.abs(roll * DEG2RAD)))/2;
me.targetthrottle = me.throttleinit + (me.throttleinit * math.sin(math.abs(roll * DEG2RAD)))/2;


if (me.targetthrottle > throttle0) {
if (me.targetthrottle > throttles[0]) {
throttle0 += 0.001 * fpsfix;
throttles[0] += 0.001 * fpsfix;
throttle1 += 0.001 * fpsfix;
throttles[1] += 0.001 * fpsfix;
} elsif (me.targetthrottle < throttle0) {
} elsif (me.targetthrottle < throttles[0]) {
throttle0 -= 0.001 * fpsfix;
throttles[0] -= 0.001 * fpsfix;
throttle1 -= 0.001 * fpsfix;
throttles[1] -= 0.001 * fpsfix;
}  
}  


Line 259: Line 264:
if ((roll > -5) and (roll <= 5) and (me.turnthrottlefix == 1)) {
if ((roll > -5) and (roll <= 5) and (me.turnthrottlefix == 1)) {


if (throttle0 <= me.throttleinit - 0.05) {
if (throttles[0] <= me.throttleinit - 0.05) {
throttle0 += 0.001 * fpsfix;
throttles[0] += 0.001 * fpsfix;
throttle1 += 0.001 * fpsfix;
throttles[1] += 0.001 * fpsfix;
} elsif (throttle0 > me.throttleinit + 0.05) {
} elsif (throttles[0] > me.throttleinit + 0.05) {
throttle0 -= 0.001 * fpsfix;
throttles[0] -= 0.001 * fpsfix;
throttle1 -= 0.001 * fpsfix;
throttles[1] -= 0.001 * fpsfix;
} else me.turnthrottlefix = 0;
} else me.turnthrottlefix = 0;
}
}
Line 270: Line 275:
### Reduce throttle if aircraft is faster than 250 KIAS under 10000 ft
### Reduce throttle if aircraft is faster than 250 KIAS under 10000 ft


if ((airspeedkt >= 250) and (altitudemsl <= 10000) and (throttle0 != 0) and (throttle1 != 0)) {
if ((airspeedkt >= 250) and (altitudemsl <= 10000) and (throttles[0] != 0) and (throttles[1] != 0)) {
throttle0 -= 0.001 * fpsfix;
throttles[0] -= 0.001 * fpsfix;
throttle1 -= 0.001 * fpsfix;
throttles[1] -= 0.001 * fpsfix;
me.throttlefix = 1;
me.throttlefix = 1;
}
}


if ((me.throttlefix == 1) and (airspeedkt < 245) and (altitudemsl <= 10000) and (throttle0 != 1) and (throttle1 != 1)) {
if ((me.throttlefix == 1) and (airspeedkt < 245) and (altitudemsl <= 10000) and (throttles[0] != 1) and (throttles[1] != 1)) {
throttle0 += 0.001 * fpsfix;
throttles[0] += 0.001 * fpsfix;
throttle1 += 0.001 * fpsfix;
throttles[1] += 0.001 * fpsfix;
}
}


### Adjust Throttle to stay under Vne
### Adjust Throttle to stay under Vne


if ((airspeedkt >= 350) and (altitudemsl > 10000) and (throttle0 != 0) and (throttle1 != 0)) {
if ((airspeedkt >= 350) and (altitudemsl > 10000) and (throttles[0] != 0) and (throttles[1] != 0)) {
throttle0 -= 0.001 * fpsfix;
throttles[0] -= 0.001 * fpsfix;
throttle1 -= 0.001 * fpsfix;
throttles[1] -= 0.001 * fpsfix;
me.throttlefix = 1;
me.throttlefix = 1;
}
}


if ((me.throttlefix == 1) and (airspeedkt < 340) and (altitudemsl > 10000) and (throttle0 != 1) and (throttle1 != 1)) {
if ((me.throttlefix == 1) and (airspeedkt < 340) and (altitudemsl > 10000) and (throttles[0] != 1) and (throttles[1] != 1)) {
throttle0 += 0.001 * fpsfix;
throttles[0] += 0.001 * fpsfix;
throttle1 += 0.001 * fpsfix;
throttles[1] += 0.001 * fpsfix;
}
}


### Adjust Throttle to keep from stalling
### Adjust Throttle to keep from stalling


if ((airspeedkt < 125) and (altitudeagl > 250) and (throttle0 != 1) and (throttle1 != 1)) {
if ((airspeedkt < 125) and (altitudeagl > 250) and (throttles[0] != 1) and (throttles[1] != 1)) {
throttle0 += 0.001 * fpsfix;
throttles[0] += 0.001 * fpsfix;
throttle1 += 0.001 * fpsfix;
throttles[1] += 0.001 * fpsfix;


### Also help by pushing forward on the stick
### Also help by pushing forward on the stick
Line 338: Line 343:
setprop(fcs~"rudder-fbw-output", rudderout);
setprop(fcs~"rudder-fbw-output", rudderout);


setprop("controls/engines/engine[0]/throttle", throttle0);
setprop("controls/engines/engine[0]/throttle", throttles[0]);
setprop("controls/engines/engine[1]/throttle", throttle1);
setprop("controls/engines/engine[1]/throttle", throttles[1]);


me.throttle = throttle0; # This is to find out if the pilot moved the throttle
me.throttle = throttles[0]; # This is to find out if the pilot moved the throttle


} else {
} else {

Navigation menu