Skip to content

Commit 78e3d2e

Browse files
author
BasicAirData
committed
Unc
Check uncertainty of altitude
1 parent 717ba95 commit 78e3d2e

5 files changed

Lines changed: 85 additions & 21 deletions

File tree

Software/Arduino/Libraries/AirDC/AirDC.cpp

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ AirDC::AirDC(int pid)
2020
_RH=0.0;
2121
_qc=0.0;
2222
_AOA=0.17;
23-
_AOS=0;
23+
_AOS=0.01;
2424
_IAS=0.0;
25+
_TASPCorrected=0.0;
2526
//Uncertainty of measurements
2627
_uRho=0.0; //To be calculated, 0 default value
2728
_up=5.0;
@@ -231,25 +232,27 @@ void AirDC::ISAAltitude(int mode)
231232
_h=(pow(29.92126,0.190255)-pow(Ps,0.190255))*76189.2339431570; //US atmosphere 1962
232233
//Back to SI
233234
_h=_h*0.3048;
234-
_uh=0.057989724*pow(Ps,-0.809745)*258006317.725680592912*_up;
235+
//76189.2339431570*(_p*0.000295299875080277)^0.190255
236+
_uh=4418.19264813511*pow(Ps,-0.809745)*_up*0.000295299875080277;
235237
}
236238
}
237239

238240
}
239-
void AirDC::OutputSerial(int mode)
241+
String AirDC::OutputSerial(int mode)
240242
{
243+
String StreamOut;
241244
switch(mode)
242245
{
243-
case 1: //Measurements only output
246+
case 1: //Measurements output
244247
{
245-
//http://www.tigoe.com/pcomp/code/arduinowiring/1161/
246-
//Measurements
247-
//sprintf(_StreamOut,"$%f,%f,%f,%f\0",_p,_T,_RH,_qc);
248+
//_p,_T,_RH,_qc,AOA,AOS
248249
String s1(_p, 6);
249250
String s2(_T, 6);
250251
String s3(_RH, 6);
251252
String s4(_qc, 6);
252-
_StreamOut='$'+s1+','+s2+','+s3+','+s4;
253+
String s5(_AOA, 6);
254+
String s6(_AOS, 6);
255+
StreamOut='$'+s1+','+s2+','+s3+','+s4+','+s5+','+s6;
253256
//To read string on the other side
254257
/*
255258
if (Serial.find("$")) {
@@ -258,7 +261,47 @@ void AirDC::OutputSerial(int mode)
258261
_RH = Serial.parseFloat();//
259262
_qc = Serial.parseFloat();//
260263
*/
264+
break;
261265
}
266+
case 2: //Air data output
267+
//_Rho,_IAS,_CAS,_TAS,_TASPCorrected,_M,_TAT,_h,_mu,_Re
268+
{
269+
String s1(_Rho, 6);
270+
String s2(_IAS, 6);
271+
String s3(_CAS, 6);
272+
String s4(_TAS, 6);
273+
String s5(_TASPCorrected, 6);
274+
String s6(_M, 6);
275+
String s7(_TAT, 6);
276+
String s8(_h, 6);
277+
String s9(_mu, 6);
278+
String s10(_Re, 6);
279+
StreamOut='$'+s1+','+s2+','+s3+','+s4+','+s5+','+s6+','+s7+','+s8+','+s9+','+s10;
280+
break;
281+
}
282+
case 3: //Measurements uncertainty output
283+
//_up,_uT,_uRH,_uqc
284+
{
285+
String s1(_up, 6);
286+
String s2(_uT, 6);
287+
String s3(_uRH, 6);
288+
String s4(_uqc, 6);
289+
StreamOut='$'+s1+','+s2+','+s3+','+s4;
290+
break;
291+
}
292+
case 4: //Air data uncertainty output
293+
//_uRho,_uIAS,_uCAS,_uTAS,_uTAT,_uh;
294+
{
295+
String s1(_uRho, 6);
296+
String s2(_uIAS, 6);
297+
String s3(_uCAS, 6);
298+
String s4(_uTAS, 6);
299+
String s5(_uTAT, 6);
300+
String s6(_uh, 6);
301+
StreamOut='$'+s1+','+s2+','+s3+','+s4+','+s5+','+s6;
302+
break;
303+
}
304+
return StreamOut;
262305
}
263306
}
264307
void AirDC::PitotCorrection(int mode)
@@ -267,7 +310,12 @@ void AirDC::PitotCorrection(int mode)
267310
//http://basicairdata.blogspot.it/2014/07/pitot-correction-for-position-and.html
268311
switch (mode)
269312
{
270-
case 1: //Steady state(no angular acceleration) assumed for this method
313+
case 1: //No_compensation
314+
{
315+
_TASPCorrected=_TAS;
316+
break;
317+
}
318+
case 2: //Steady state(no angular acceleration) assumed for this method
271319
{
272320
float R[3][3];
273321
float PB[3][1]; //Position of probe tip in body coordinates
@@ -279,6 +327,10 @@ void AirDC::PitotCorrection(int mode)
279327
PB[1][1]=0.5; //Installation position respect c.o.g.
280328
PB[2][1]=0;
281329
PB[3][1]=0;
330+
WB[1][1]=0.5; //Angular rates . P, q, r from sensors
331+
WB[2][1]=0.5;
332+
WB[3][1]=0.5;
333+
282334
R[1][1]=cos(_AOA)*cos(_AOS);
283335
R[1][2]=sin(_AOS);
284336
R[1][3]=sin(_AOA)*sin(_AOS);
@@ -302,7 +354,8 @@ void AirDC::PitotCorrection(int mode)
302354
VCorrected[1][1]=_TAS-PWDOT[1][1];
303355
VCorrected[2][1]= -PWDOT[2][1];
304356
VCorrected[3][1]= -PWDOT[3][1];
305-
_TASPCorrected=sqrt(pow(VCorrected[1][1],2)+pow(VCorrected[2][1],2)+pow(VCorrected[3][1],2));
357+
// _TASPCorrected=sqrt(pow(VCorrected[1][1],2)+pow(VCorrected[2][1],2)+pow(VCorrected[3][1],2));
358+
_TASPCorrected=0;
306359
break;
307360
}
308361
}

Software/Arduino/Libraries/AirDC/AirDC.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ class AirDC
1818
void Mach(int mode);
1919
void OAT(int mode);
2020
void ISAAltitude(int mode);
21-
void OutputSerial(int mode);
21+
String OutputSerial(int mode);
2222
//Correction and Auxiliary
2323
void PitotCorrection(int mode);
2424
void Viscosity(int mode);
2525
void Red(int mode);
2626
//General use
2727
int _pid;
28-
String _StreamOut;
2928
//Geometric
3029
double _d;//Reference length for Re calculation
3130
//Measurements

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,22 @@ void loop() {
5757
AirDataComputer.IAS(1);// Calculates the IAS, Algorithm 1
5858
AirDataComputer.CAS(1);// Calculates the CAS, Algorithm 1
5959
AirDataComputer.TAS(1);// Calculates the IAS, Algorithm 1
60+
AirDataComputer.PitotCorrection(1);// Calculates the corrected Airspeed, Algorithm 1
6061
AirDataComputer.Mach(1);// Calculates the Mach number, Algorithm 1
6162
AirDataComputer.OAT(1);// Calculates the Outside Air Temperature, Algorithm 1
6263
AirDataComputer.ISAAltitude(1);// Calculates the ISA Altitude
63-
//Measurment corrections and Auxiliary data
64-
AirDataComputer.PitotCorrection(1);// Calculates the corrected Airspeed, Algorithm 1
64+
//Auxiliary data
6565
AirDataComputer.Viscosity(1);// Calculates the dynamic viscosity, Algorithm 1
6666
AirDataComputer.Red(1);// Calculates the ISA altitude from static pressure, Algorithm 1
67-
delay(1000); //loop delay
68-
//Visualitation
69-
AirDataComputer.OutputSerial(1);
70-
Serial.println(AirDataComputer._StreamOut); // Prints measurements
71-
Serial.println(dpsensor); //Prints the Selected sensor
67+
delay(2000); //loop delay
68+
//Data Output
69+
Serial.println(AirDataComputer.OutputSerial(1)); // Measurements
70+
Serial.println(AirDataComputer.OutputSerial(2)); // Air Data
71+
Serial.println(AirDataComputer.OutputSerial(3)); // Measurements uncertainty
72+
Serial.println(AirDataComputer.OutputSerial(4)); // Measurements uncertainty
73+
}
74+
75+
/* Serial.println(dpsensor); //Prints the Selected sensor
7276
Serial.println(psensor); //Prints the Selected sensor
7377
Serial.println(AirDataComputer._qc); //Differential pressure reading
7478
Serial.println(AirDataComputer._uqc, 10); //Uncertainty of differential pressure measurement
@@ -93,5 +97,4 @@ void loop() {
9397
Serial.println(AirDataComputer._uh); //Altitude Uncertainty
9498
Serial.println(AirDataComputer._TASPCorrected); //True Airspeed Corrected for probe position
9599
Serial.println(AirDataComputer._mu,10); //Viscosity Pas
96-
Serial.println(AirDataComputer._Re); //Reynolds
97-
}
100+
Serial.println(AirDataComputer._Re); //Reynolds*/

Software/Arduino/Libraries/AirDC/TODO.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ Add calculation of molecular weigth for moist air.
33
Add explicit calculation of gamma (cp/cv)
44
Compensate Relative Humidity sensor dynamic
55
Add SD Card enable Air Data Computer Example
6+
7+
CHECK/VALIDATE
8+
Pitot Position, angular rates, correction routine
9+
Viscosity
10+
Specific gravity
11+
Altitude uncertainty

Software/Arduino/Libraries/AirSensor/AirSensor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Created by J. Larragueta, December 3, 2015.
44
Refer to http:\\www.basicairdata.eu
55
*/
6+
#define DEBUG 1
67
#include "AirSensor.h"
78
#include <math.h>
89
#include <Wire.h>
@@ -105,7 +106,9 @@ void AirSensor::ReadDifferentialPressure(AirDC *out,int sensor)
105106
raw = analogRead(analogPin);
106107
Vread=5.0/1023.0*(raw);
107108
Pread=(Vread-2.5-offsetv)*1000;
109+
#if DEBUG==1
108110
Pread=1000;
111+
#endif // DEBUG
109112
out->_qc=Pread; //pa
110113
out->_uqc=50.0;//pa
111114
}

0 commit comments

Comments
 (0)