Skip to content

Commit aa5ce9f

Browse files
author
BasicAirData
committed
22
1 parent 1246621 commit aa5ce9f

5 files changed

Lines changed: 54 additions & 5 deletions

File tree

Software/Arduino/Libraries/AirDC/AirDC.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,26 @@ void AirDC::IAS(int mode)
151151
break;
152152
}
153153
}
154+
void AirDC::CAS(int mode)
155+
{
156+
//Calibrated Airspeed
157+
//http://www.basicairdata.eu/pitot-tube.html
158+
//https://en.wikipedia.org/wiki/Equivalent_airspeed
159+
switch (mode)
160+
{
161+
case 1:
162+
_CAS=_IAS;
163+
_uCAS=_uIAS;
164+
break;
165+
}
166+
}
154167
void AirDC::TAS(int mode)
155168
{
156169
//True Airspeed
157170
//http://www.basicairdata.eu/pitot-tube.html
158171
//TAS=IAS*(rhostandard/rhoair)^0.5
159-
_TAS=_IAS*sqrt(1.225/_Rho);
160-
_uTAS= sqrt((1.225/_Rho)*pow(_uIAS,2)+ pow(0.5*_IAS*1.225/(pow(_Rho,1.5)),2)*pow(_uRho,2));
172+
_TAS=_CAS*sqrt(1.225/_Rho);
173+
_uTAS= sqrt((1.225/_Rho)*pow(_uCAS,2)+ pow(0.5*_CAS*1.225/(pow(_Rho,1.5)),2)*pow(_uRho,2));
161174
}
162175
void AirDC::Mach(int mode)
163176
{
@@ -187,15 +200,32 @@ void AirDC::OAT(int mode)
187200
//https://en.wikipedia.org/wiki/Total_air_temperature
188201
switch (mode)
189202
{
190-
case 1:
203+
case 1:
191204
{
192205
double gamma=1.4; //cp/cv
193206
//https://en.wikipedia.org/wiki/Julius_von_Mayer#Mayer.27s_relation
194207

195208
_T=_TAT/(1+(gamma-1)/2*pow(_M,2));
196209
_uT=1/(1+(gamma-1)/2*2*pow(_M,2))*_uTAT;
197210
}
211+
}
212+
198213
}
214+
void AirDC::ISAAltitude(int mode)
215+
{
216+
switch (mode)
217+
{
218+
case 1:
219+
{
220+
double Ps,h;
221+
Ps=_p/133.3223684211/25.4;//Pa to inHg Conversion
222+
//Using Goodrich 4081 Air data handbook formula
223+
_h=(pow(29.92126,0.190255)-pow(Ps,0.190255))/0.000013125214; //US atmosphere 1962
224+
//Back to SI
225+
_h=h*0.3048;
226+
_uh=0.057989724*pow(Ps,-0.809745)*258006317.725680592912*_up;
227+
}
228+
}
199229

200230
}
201231

Software/Arduino/Libraries/AirDC/AirDC.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ class AirDC
1313
AirDC(int pid);
1414
void RhoAir(int mode);
1515
void IAS(int mode);
16+
void CAS(int mode);
1617
void TAS(int mode);
1718
void Mach(int mode);
1819
void OAT(int mode);
20+
void ISAAltitude(int mode);
1921
//private:
2022
int _pid;
2123
double _p;
@@ -24,18 +26,22 @@ class AirDC
2426
double _qc;
2527
double _Rho;
2628
double _IAS;
29+
double _CAS;
2730
double _TAS;
2831
double _M;
2932
double _TAT;
33+
double _h;
3034
//uncertainty terms
3135
double _up;
3236
double _uT;
3337
double _uRH;
3438
double _uRho;
3539
double _uqc;
3640
double _uIAS;
41+
double _uCAS;
3742
double _uTAS;
3843
double _uTAT;
44+
double _uh;
3945
};
4046
#endif
4147

Software/Arduino/Libraries/AirDC/Examples/DifferentialPressureSensor/DifferentialPressureSensor.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#define DPSENSOR 3 //Selects the differential pressure Hardware sensor see AirSensor.cpp for details on Hookup
1111
#define PSENSOR 1 //Selects the static pressure Hardware sensor see AirSensor.cpp for details on Hookup
12+
#define DEBUG 1 //
1213

1314
#if DPSENSOR==1
1415
#include <Wire.h>
@@ -53,11 +54,13 @@ void loop() {
5354
AirDataSensor.ReadTAT(ptrAirDC, psensor);
5455
AirDataSensor.ReadRH(ptrAirDC, psensor);
5556
//Computation
56-
AirDataComputer.IAS(1);// Calculates the IAS, Algorithm 1
5757
AirDataComputer.RhoAir(1);// Calculates the air density, Algorithm 1
58+
AirDataComputer.IAS(1);// Calculates the IAS, Algorithm 1
59+
AirDataComputer.CAS(1);// Calculates the CAS, Algorithm 1
5860
AirDataComputer.TAS(1);// Calculates the IAS, Algorithm 1
5961
AirDataComputer.Mach(1);// Calculates the Mach number, Algorithm 1
6062
AirDataComputer.OAT(1);// Calculates the Outside Air Temperature, Algorithm 1
63+
AirDataComputer.ISAAltitude(1);// Calculates the ISA altitude from static pressure, Algorithm 1
6164
delay(1000); //loop delay
6265
//Visualitation
6366
Serial.println(dpsensor); //Prints the Selected sensor
@@ -70,6 +73,8 @@ void loop() {
7073
Serial.println(AirDataComputer._uIAS, 10); //Sends the uncertainty of IAS measurement
7174
Serial.println(AirDataComputer._Rho,4);//Sends the density of Air
7275
Serial.println(AirDataComputer._uRho, 10); //Sends the uncertainty of the density of air
76+
Serial.println(AirDataComputer._CAS); //Calibrated AirSpeed
77+
Serial.println(AirDataComputer._uCAS); //Calibrated AirSpeed uncertainty
7378
Serial.println(AirDataComputer._TAS); //True Airspeed
7479
Serial.println(AirDataComputer._uTAS); //True Airspeed uncertainty
7580
Serial.println(AirDataComputer._M,10); //Mach number
@@ -79,4 +84,6 @@ void loop() {
7984
Serial.println(AirDataComputer._uT); //Outside Temperature, Static Temperature uncertainty
8085
Serial.println(AirDataComputer._RH); //Relative Humidity
8186
Serial.println(AirDataComputer._uRH); //Relative Humidity Uncertainty
87+
Serial.println(AirDataComputer._h); //Altitude
88+
Serial.println(AirDataComputer._uh); //Altitude Uncertainty
8289
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
AirDC KEYWORD1
22
RhoAir KEYWORD2
33
IAS KEYWORD2
4-
TAS KEYWORD2
4+
CAS KEYWORD2
5+
TAS KEYWORD2
6+
Mach KEYWORD2
7+
OAT KEYWORD2
8+
ISAAltitude KEYWORD2

Software/Arduino/Libraries/AirSensor/AirSensor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
105105
raw = analogRead(analogPin);
106106
Vread=5.0/1023.0*(raw);
107107
Pread=(Vread-2.5-offsetv)*1000;
108+
#if DEBUG==1
108109
Pread=1000;
110+
#endif
109111
out->_qc=Pread; //pa
110112
out->_uqc=50.0;//pa
111113
}

0 commit comments

Comments
 (0)