20,741
edits
m (→/Nasal/fbw.nas) |
m (→/Nasal/fbw.nas: use a vector of throttles instead) |
||
Line 115: | Line 115: | ||
## Bank Limit Setting | ## Bank Limit Setting | ||
me.banklimit = getprop("/controls/fbw/bank-limit"); | |||
## Position and Orientation | ## Position and Orientation | ||
Line 145: | Line 145: | ||
## Engine Throttle Positions | ## Engine Throttle Positions | ||
# use a vector of throttles, this can be later on used to support more than | |||
# 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 | ## 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 ( | 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 = | 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 > | if (me.targetthrottle > throttles[0]) { | ||
throttles[0] += 0.001 * fpsfix; | |||
throttles[1] += 0.001 * fpsfix; | |||
} elsif (me.targetthrottle < | } elsif (me.targetthrottle < throttles[0]) { | ||
throttles[0] -= 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 ( | if (throttles[0] <= me.throttleinit - 0.05) { | ||
throttles[0] += 0.001 * fpsfix; | |||
throttles[1] += 0.001 * fpsfix; | |||
} elsif ( | } elsif (throttles[0] > me.throttleinit + 0.05) { | ||
throttles[0] -= 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 ( | if ((airspeedkt >= 250) and (altitudemsl <= 10000) and (throttles[0] != 0) and (throttles[1] != 0)) { | ||
throttles[0] -= 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 ( | if ((me.throttlefix == 1) and (airspeedkt < 245) and (altitudemsl <= 10000) and (throttles[0] != 1) and (throttles[1] != 1)) { | ||
throttles[0] += 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 ( | if ((airspeedkt >= 350) and (altitudemsl > 10000) and (throttles[0] != 0) and (throttles[1] != 0)) { | ||
throttles[0] -= 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 ( | if ((me.throttlefix == 1) and (airspeedkt < 340) and (altitudemsl > 10000) and (throttles[0] != 1) and (throttles[1] != 1)) { | ||
throttles[0] += 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 ( | if ((airspeedkt < 125) and (altitudeagl > 250) and (throttles[0] != 1) and (throttles[1] != 1)) { | ||
throttles[0] += 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", | setprop("controls/engines/engine[0]/throttle", throttles[0]); | ||
setprop("controls/engines/engine[1]/throttle", | setprop("controls/engines/engine[1]/throttle", throttles[1]); | ||
me.throttle = | me.throttle = throttles[0]; # This is to find out if the pilot moved the throttle | ||
} else { | } else { |