Skip to content

Commit 1246621

Browse files
author
BasicAirData
committed
Init
1 parent 6b4027a commit 1246621

9 files changed

Lines changed: 113 additions & 14 deletions

File tree

Software/Arduino/Libraries/AirDC/AirDC.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ AirDC::AirDC(int pid)
2020
//Uncertainty of measurements
2121
_uRho=0.0; //To be calculated, 0 default value
2222
_up=5.0;
23-
_uT=0.8;
23+
_uT=0; //To be calculated
2424
_uRH=0.05;
2525
_uqc=5.0;
2626
_uIAS=0.0;//To be calculated, 0 default value
27+
_uTAT=0.0;//To be calculated, 0 default value
2728
}
2829
//RhoAir(Pressure,Temperature,Relative Humidity,mode)
2930
//Mode 1 is the default BasicAirData routine
@@ -158,3 +159,44 @@ void AirDC::TAS(int mode)
158159
_TAS=_IAS*sqrt(1.225/_Rho);
159160
_uTAS= sqrt((1.225/_Rho)*pow(_uIAS,2)+ pow(0.5*_IAS*1.225/(pow(_Rho,1.5)),2)*pow(_uRho,2));
160161
}
162+
void AirDC::Mach(int mode)
163+
{
164+
switch (mode)
165+
{
166+
case 1:
167+
{
168+
// http://www.basicairdata.eu/air-properties.html
169+
// https://en.wikipedia.org/wiki/Julius_von_Mayer#Mayer.27s_relation
170+
double gamma=1.4; // cp/cv;
171+
double R,Ma,Rair;
172+
R=8314.459848; // J/K/mol
173+
Ma=0.0289645; //Kg/mol Molecular mass of dry air
174+
Rair=R/Ma;
175+
_M=_TAS/(sqrt(gamma*Rair*_T));
176+
break;
177+
}
178+
179+
}
180+
181+
}
182+
183+
void AirDC::OAT(int mode)
184+
{
185+
//Outside Air Temperature
186+
//http://www.basicairdata.blogspot.it/2013/05/resistance-temperature-detectors-for.html
187+
//https://en.wikipedia.org/wiki/Total_air_temperature
188+
switch (mode)
189+
{
190+
case 1:
191+
{
192+
double gamma=1.4; //cp/cv
193+
//https://en.wikipedia.org/wiki/Julius_von_Mayer#Mayer.27s_relation
194+
195+
_T=_TAT/(1+(gamma-1)/2*pow(_M,2));
196+
_uT=1/(1+(gamma-1)/2*2*pow(_M,2))*_uTAT;
197+
}
198+
}
199+
200+
}
201+
202+

Software/Arduino/Libraries/AirDC/AirDC.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ class AirDC
1414
void RhoAir(int mode);
1515
void IAS(int mode);
1616
void TAS(int mode);
17+
void Mach(int mode);
18+
void OAT(int mode);
1719
//private:
1820
int _pid;
19-
double _Rho;
2021
double _p;
2122
double _T;
2223
double _RH;
2324
double _qc;
25+
double _Rho;
2426
double _IAS;
2527
double _TAS;
28+
double _M;
29+
double _TAT;
2630
//uncertainty terms
2731
double _up;
2832
double _uT;
@@ -31,6 +35,7 @@ class AirDC
3135
double _uqc;
3236
double _uIAS;
3337
double _uTAS;
38+
double _uTAT;
3439
};
3540
#endif
3641

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,19 @@ void setup() {
4747
void loop() {
4848
AirDC *ptrAirDC;
4949
ptrAirDC = &AirDataComputer;
50+
//Measurements
5051
AirDataSensor.ReadDifferentialPressure(ptrAirDC, dpsensor);
5152
AirDataSensor.ReadStaticPressure(ptrAirDC, psensor);
53+
AirDataSensor.ReadTAT(ptrAirDC, psensor);
54+
AirDataSensor.ReadRH(ptrAirDC, psensor);
55+
//Computation
5256
AirDataComputer.IAS(1);// Calculates the IAS, Algorithm 1
5357
AirDataComputer.RhoAir(1);// Calculates the air density, Algorithm 1
5458
AirDataComputer.TAS(1);// Calculates the IAS, Algorithm 1
59+
AirDataComputer.Mach(1);// Calculates the Mach number, Algorithm 1
60+
AirDataComputer.OAT(1);// Calculates the Outside Air Temperature, Algorithm 1
5561
delay(1000); //loop delay
62+
//Visualitation
5663
Serial.println(dpsensor); //Prints the Selected sensor
5764
Serial.println(psensor); //Prints the Selected sensor
5865
Serial.println(AirDataComputer._qc); //Differential pressure reading
@@ -65,4 +72,11 @@ void loop() {
6572
Serial.println(AirDataComputer._uRho, 10); //Sends the uncertainty of the density of air
6673
Serial.println(AirDataComputer._TAS); //True Airspeed
6774
Serial.println(AirDataComputer._uTAS); //True Airspeed uncertainty
75+
Serial.println(AirDataComputer._M,10); //Mach number
76+
Serial.println(AirDataComputer._TAT,4); //Total Air Temperature
77+
Serial.println(AirDataComputer._uTAT); //Total Air Temperature uncertainty
78+
Serial.println(AirDataComputer._T,4); //Outside Temperature, Static Temperature
79+
Serial.println(AirDataComputer._uT); //Outside Temperature, Static Temperature uncertainty
80+
Serial.println(AirDataComputer._RH); //Relative Humidity
81+
Serial.println(AirDataComputer._uRH); //Relative Humidity Uncertainty
6882
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AirDC
2+
03-12-2015 Alfa release
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Update uncertainty of OAT. Now considers only TAT measurement uncertainty.
2+
Add calculation of molecular weigth for moist air.
3+
Add calculation of gamma (cp/cv)
4+
Compensate Relative Humidity dynamic

Software/Arduino/Libraries/AirSensor/AirSensor.cpp

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
1717
{
1818
switch (sensor)
1919
{
20-
case 1 :{
21-
//Sensor one is I2C HLCA12X5
20+
case 1 :
21+
{
22+
//Sensor one is I2C HLCA12X5
2223
//http://www.first-sensor.com/cms/upload/datasheets/DS_Standard-HCLA_E_11629.pdf
2324
//Basic software for HLCA12X5 from Sensortechnics/First
2425
// Pressure - Sensor output hex/dec
@@ -41,9 +42,9 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
4142
out->_qc=rawdata; //pa
4243
out->_uqc=10.0;//pa
4344
}
44-
break;
45+
break;
4546
case 2 :
46-
{
47+
{
4748
/*
4849
Differential Pressure sensor LDES205U by FirstSensor/SensorThecnics
4950
This sensor uses SPI
@@ -87,10 +88,10 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
8788
rawpressure=result*sensorgain;
8889
out->_qc=rawpressure; //pa
8990
out->_uqc=5.0;//pa
90-
}
91-
break; //Sensor two is SPI
91+
}
92+
break; //Sensor two is SPI
9293
case 3 :
93-
{
94+
{
9495
//MPXV7002 Sensor
9596
//Wire the Arduino Uno and MPXV7002 (That sensor is mounted on HobbyKing Pitot Board) in this way
9697
//MPXV7002 <-> Arduino Uno
@@ -107,8 +108,8 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
107108
Pread=1000;
108109
out->_qc=Pread; //pa
109110
out->_uqc=50.0;//pa
110-
}
111-
break;
111+
}
112+
break;
112113
}
113114
}
114115

@@ -124,4 +125,29 @@ void AirSensor::ReadStaticPressure(AirDC *out,int sensor)
124125
}
125126
}
126127
}
128+
void AirSensor::ReadTAT(AirDC *out,int sensor)
129+
{
130+
switch (sensor)
131+
{
132+
case 1 :
133+
{
134+
//Total Air Temperature Sensor
135+
//http://www.basicairdata.blogspot.it/2013/05/resistance-temperature-detectors-for.html
136+
out->_TAT=288.15;
137+
out->_uTAT=1;
138+
break;
139+
}
140+
}
141+
}
142+
void AirSensor::ReadRH(AirDC *out,int sensor){
143+
switch (sensor)
144+
{
145+
case 1 :
146+
{
147+
out->_RH=0.5;
148+
out->_uRH=0.05;
149+
break;
150+
}
151+
}
127152

153+
}

Software/Arduino/Libraries/AirSensor/AirSensor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class AirSensor
1212
{
1313
public:
1414
AirSensor(int pid);
15-
void ReadDifferentialPressure(AirDC *out,int mode);
16-
void ReadStaticPressure(AirDC *out,int mode);
15+
void ReadDifferentialPressure(AirDC *out,int sensor);
16+
void ReadStaticPressure(AirDC *out,int sensor);
17+
void ReadTAT(AirDC *out,int sensor);
18+
void ReadRH(AirDC *out,int sensor);
1719
int _pid;
1820
};
1921
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AirSensor
2+
03-12-2015 Alfa release
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
AirSensor KEYWORD1
22
ReadDifferentialPressure KEYWORD2
3-
ReadStaticPressure KEYWORD2
3+
ReadStaticPressure KEYWORD2
4+
ReadTAT KEYWORD2
5+
ReadRH KEYWORD2

0 commit comments

Comments
 (0)