John DENKER, Dave PERRY, Roy VEGARD OVESEN: altimetry fixes
This commit is contained in:
parent
3139f01083
commit
663b382b7d
3 changed files with 39 additions and 29 deletions
|
@ -41,6 +41,8 @@ file, these values will be used (they are hardcoded).
|
||||||
<name>altimeter</name>
|
<name>altimeter</name>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
<static-pressure>/systems/static/pressure-inhg</static-pressure>
|
<static-pressure>/systems/static/pressure-inhg</static-pressure>
|
||||||
|
<quantum>0</quantum>
|
||||||
|
<tau>0</tau>
|
||||||
</altimeter>
|
</altimeter>
|
||||||
|
|
||||||
<attitude-indicator>
|
<attitude-indicator>
|
||||||
|
@ -59,11 +61,13 @@ file, these values will be used (they are hardcoded).
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</dme>
|
</dme>
|
||||||
|
|
||||||
<encoder>
|
<altimeter>
|
||||||
<name>encoder</name>
|
<name>encoder</name>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
<static-pressure>/systems/static/pressure-inhg</static-pressure>
|
<static-pressure>/systems/static/pressure-inhg</static-pressure>
|
||||||
</encoder>
|
<quantum>10</quantum>
|
||||||
|
<tau>0.1</tau>
|
||||||
|
</altimeter>
|
||||||
|
|
||||||
<marker-beacon>
|
<marker-beacon>
|
||||||
<name>marker-beacon</name>
|
<name>marker-beacon</name>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<static>
|
<static>
|
||||||
<name>static</name>
|
<name>static</name>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
<tau>1</tau>
|
||||||
</static>
|
</static>
|
||||||
|
|
||||||
<vacuum>
|
<vacuum>
|
||||||
|
|
|
@ -17,6 +17,7 @@ settings = "/autopilot/KAP140/settings";
|
||||||
annunciators = "/autopilot/KAP140/annunciators";
|
annunciators = "/autopilot/KAP140/annunciators";
|
||||||
internal = "/autopilot/internal";
|
internal = "/autopilot/internal";
|
||||||
power="/systems/electrical/outputs/autopilot";
|
power="/systems/electrical/outputs/autopilot";
|
||||||
|
encoder = "/instrumentation/encoder";
|
||||||
|
|
||||||
# locks
|
# locks
|
||||||
propLocks = props.globals.getNode(locks, 1);
|
propLocks = props.globals.getNode(locks, 1);
|
||||||
|
@ -80,7 +81,6 @@ annunciatorAp = propAnnunciators.getNode("ap", 1);
|
||||||
annunciatorBeep = propAnnunciators.getNode("beep", 1);
|
annunciatorBeep = propAnnunciators.getNode("beep", 1);
|
||||||
|
|
||||||
navRadio = "/instrumentation/nav";
|
navRadio = "/instrumentation/nav";
|
||||||
encoder = "/instrumentation/encoder";
|
|
||||||
staticPort = "/systems/static";
|
staticPort = "/systems/static";
|
||||||
|
|
||||||
annunciator = annunciatorAp;
|
annunciator = annunciatorAp;
|
||||||
|
@ -106,6 +106,8 @@ altCaptured = 0;
|
||||||
valueTest = 0;
|
valueTest = 0;
|
||||||
lastValue = 0;
|
lastValue = 0;
|
||||||
newValue = 0;
|
newValue = 0;
|
||||||
|
baroOffset = 0.0;
|
||||||
|
baroChange = 1;
|
||||||
minVoltageLimit = 8.0;
|
minVoltageLimit = 8.0;
|
||||||
|
|
||||||
flasher = func {
|
flasher = func {
|
||||||
|
@ -265,7 +267,6 @@ apInit = func {
|
||||||
# settimer(altAlert, 5.0);
|
# settimer(altAlert, 5.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
apPower = func {
|
apPower = func {
|
||||||
|
|
||||||
## Monitor autopilot power
|
## Monitor autopilot power
|
||||||
|
@ -279,7 +280,7 @@ apPower = func {
|
||||||
|
|
||||||
valueTest = newValue - lastValue;
|
valueTest = newValue - lastValue;
|
||||||
# print("v_test = ", v_test);
|
# print("v_test = ", v_test);
|
||||||
if (valueTest > 0.5){
|
if (valueTest > 0.5) {
|
||||||
# autopilot just powered up
|
# autopilot just powered up
|
||||||
print("power up");
|
print("power up");
|
||||||
apInit();
|
apInit();
|
||||||
|
@ -1356,6 +1357,7 @@ baroButtonPress = func {
|
||||||
if (baroSettingUnit == pressureUnits["inHg"])
|
if (baroSettingUnit == pressureUnits["inHg"])
|
||||||
{
|
{
|
||||||
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
||||||
|
baroChange = 1;
|
||||||
|
|
||||||
annunciatorBsInhgNumber.setBoolValue(1);
|
annunciatorBsInhgNumber.setBoolValue(1);
|
||||||
annunciatorBsHpaNumber.setBoolValue(0);
|
annunciatorBsHpaNumber.setBoolValue(0);
|
||||||
|
@ -1388,14 +1390,23 @@ pow = func {
|
||||||
|
|
||||||
|
|
||||||
pressureToHeight = func {
|
pressureToHeight = func {
|
||||||
p0 = arg[1]; # [Pa]
|
#
|
||||||
p = arg[0]; # [Pa]
|
# kollsman shift due to baroSettingInhg =
|
||||||
t0 = 288.15; # [K]
|
# baroOffset = pressureToHeight(baroSettingInhg, 29.921260)
|
||||||
LR = -0.0065; # [K/m]
|
#
|
||||||
g = -9.80665; # [m/s²]
|
p0 = arg[1]; # [Pa] or (p0 and p need to have the same units)
|
||||||
Rd = 287.05307; # [J/kg K]
|
p = arg[0]; # [Pa] or (p0 and p need to have the same units)
|
||||||
|
t0 = 288.15; # [K] same as in atmosphere.?xx
|
||||||
|
LR = -0.0065; # [K/m] same as in atmosphere.?xx
|
||||||
|
g = -9.80665; # [m/s²] same as in atmosphere.?xx
|
||||||
|
Rd = 287.05307; # [J/kg K] same as in atmosphere.?xx to 8 places
|
||||||
|
ftTom = 0.3048;
|
||||||
|
coefficient = t0/LR/ftTom;
|
||||||
|
# coefficient = -145442.156;
|
||||||
|
exponent = Rd*LR/g;
|
||||||
|
# exponent = 0.1902632365;
|
||||||
|
|
||||||
z = -(t0/LR) * (1.0-pow((p/p0),((Rd*LR)/g)));
|
z = -coefficient * (1.0-pow((p/p0),exponent));
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,30 +1423,20 @@ heightToPressure = func {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
hPartial = func {
|
|
||||||
p0 = arg[1]; # Units of p0 must match units of delta p
|
|
||||||
p = arg[0]; # Units of p must match units of delta p
|
|
||||||
t0 = 288.15; # [K]
|
|
||||||
LR = -0.0065; # [K/m]
|
|
||||||
g = -9.80665; # [m/s²]
|
|
||||||
Rd = 287.05307; # [J/kg K]
|
|
||||||
gamma = (Rd*LR)/g;
|
|
||||||
|
|
||||||
z = -(t0/LR)*gamma*pow((p/p0),gamma)/p0;
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
altAlert = func {
|
altAlert = func {
|
||||||
#print("alt alert");
|
#print("alt alert");
|
||||||
# Disable button if too little power
|
# Disable button if too little power
|
||||||
if (getprop(power) < minVoltageLimit) { return; }
|
if (getprop(power) < minVoltageLimit) { return; }
|
||||||
|
|
||||||
pressureAltitude = getprop(encoder, "pressure-alt-ft");
|
pressureAltitude = getprop(encoder, "pressure-alt-ft");
|
||||||
altPressure = getprop(staticPort, "pressure-inhg");
|
|
||||||
hPartStat = hPartial(altPressure, 29.92) / 0.3048006;
|
if (baroChange) {
|
||||||
altFt = pressureAltitude + hPartStat * (baroSettingInhg - 29.92);
|
baroOffset = pressureToHeight(baroSettingInhg, 29.921260);
|
||||||
|
baroChange = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
altFt = pressureAltitude - baroOffset;
|
||||||
altDifference = abs(altPreselect - altFt);
|
altDifference = abs(altPreselect - altFt);
|
||||||
#print(altDifference);
|
|
||||||
|
|
||||||
if (altDifference > 1000)
|
if (altDifference > 1000)
|
||||||
{
|
{
|
||||||
|
@ -1506,6 +1507,7 @@ knobSmallUp = func {
|
||||||
baroSettingHpa = baroSettingInhg * 0.03386389;
|
baroSettingHpa = baroSettingInhg * 0.03386389;
|
||||||
|
|
||||||
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
||||||
|
baroChange = 1;
|
||||||
}
|
}
|
||||||
elsif (baroSettingUnit == pressureUnits["hPa"])
|
elsif (baroSettingUnit == pressureUnits["hPa"])
|
||||||
{
|
{
|
||||||
|
@ -1555,6 +1557,7 @@ knobLargeUp = func {
|
||||||
baroSettingHpa = baroSettingInhg * 0.03386389;
|
baroSettingHpa = baroSettingInhg * 0.03386389;
|
||||||
|
|
||||||
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
||||||
|
baroChange = 1;
|
||||||
}
|
}
|
||||||
elsif (baroSettingUnit == pressureUnits["hPa"])
|
elsif (baroSettingUnit == pressureUnits["hPa"])
|
||||||
{
|
{
|
||||||
|
@ -1604,6 +1607,7 @@ knobSmallDown = func {
|
||||||
baroSettingHpa = baroSettingInhg * 0.03386389;
|
baroSettingHpa = baroSettingInhg * 0.03386389;
|
||||||
|
|
||||||
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
||||||
|
baroChange = 1;
|
||||||
}
|
}
|
||||||
elsif (baroSettingUnit == pressureUnits["hPa"])
|
elsif (baroSettingUnit == pressureUnits["hPa"])
|
||||||
{
|
{
|
||||||
|
@ -1653,6 +1657,7 @@ knobLargeDown = func {
|
||||||
baroSettingHpa = baroSettingInhg * 0.03386389;
|
baroSettingHpa = baroSettingInhg * 0.03386389;
|
||||||
|
|
||||||
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
settingBaroSettingInhg.setDoubleValue(baroSettingInhg);
|
||||||
|
baroChange = 1;
|
||||||
}
|
}
|
||||||
elsif (baroSettingUnit == pressureUnits["hPa"])
|
elsif (baroSettingUnit == pressureUnits["hPa"])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue