Skip to content

Commit f8c440a

Browse files
author
BasicAirData
committed
ReNo
Reynolds
1 parent cc291b6 commit f8c440a

8 files changed

Lines changed: 350 additions & 24 deletions

File tree

Software/Arduino/Libraries/AirDC/AirDC.cpp

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
Refer to http:\\www.basicairdata.eu
55
*/
66
#include "AirDC.h"
7+
#include "MatrixMath.h"
78
#include <math.h>
89

910
AirDC::AirDC(int pid)
1011
{
1112
//Default parameters values
1213
_pid = pid;
14+
//Geometric
15+
_d=0.008;
1316
//Parameter values
1417
_Rho=1.225;
1518
_p=101325;
@@ -159,8 +162,9 @@ void AirDC::CAS(int mode)
159162
switch (mode)
160163
{
161164
case 1:
162-
_CAS=_IAS;
163-
_uCAS=_uIAS;
165+
//Here the calibration table should be lookup.
166+
_CAS=_IAS;
167+
_uCAS=_uIAS;
164168
break;
165169
}
166170
}
@@ -228,28 +232,95 @@ void AirDC::ISAAltitude(int mode)
228232
}
229233

230234
}
231-
void AirDC::OutputSerial(int mode){
232-
switch(mode){
233-
case 1: //Measurements only output
235+
void AirDC::OutputSerial(int mode)
234236
{
235-
//http://www.tigoe.com/pcomp/code/arduinowiring/1161/
237+
switch(mode)
238+
{
239+
case 1: //Measurements only output
240+
{
241+
//http://www.tigoe.com/pcomp/code/arduinowiring/1161/
236242
//Measurements
237243
//sprintf(_StreamOut,"$%f,%f,%f,%f\0",_p,_T,_RH,_qc);
238-
String s1(_p, 6);
239-
String s2(_T, 6);
240-
String s3(_RH, 6);
241-
String s4(_qc, 6);
242-
_StreamOut='$'+s1+','+s2+','+s3+','+s4;
244+
String s1(_p, 6);
245+
String s2(_T, 6);
246+
String s3(_RH, 6);
247+
String s4(_qc, 6);
248+
_StreamOut='$'+s1+','+s2+','+s3+','+s4;
243249
//To read string on the other side
244-
/*
245-
if (Serial.find("$")) {
246-
_p = Serial.parseFloat(); //
247-
_T = Serial.parseFloat();//
248-
_RH = Serial.parseFloat();//
249-
_qc = Serial.parseFloat();//
250-
*/
250+
/*
251+
if (Serial.find("$")) {
252+
_p = Serial.parseFloat(); //
253+
_T = Serial.parseFloat();//
254+
_RH = Serial.parseFloat();//
255+
_qc = Serial.parseFloat();//
256+
*/
257+
}
258+
}
251259
}
260+
void AirDC::PitotCorrection(int mode)
261+
{
262+
//Based on
263+
//http://basicairdata.blogspot.it/2014/07/pitot-correction-for-position-and.html
264+
switch (mode)
265+
{
266+
case 1: //Steady state(no angular acceleration) assumed for this method
267+
{
268+
float R[3][3];
269+
float PB[3][1]; //Position of probe tip in body coordinates
270+
float WB[3][1]; //Angular rates in body coordinates [p q r]'
271+
float WW[3][1];//Angular rates in wind coordinates [p q r]'
272+
float PW[3][1]; //Position of probe tip in wind ref. frame
273+
float PWDOT[3][1]; //Velocity of tip in wind ref. frame
274+
float VCorrected[3][1]; //Measured Airspeed
275+
PB[1][1]=0.5; //Installation position respect c.o.g.
276+
PB[2][1]=0;
277+
PB[3][1]=0;
278+
R[1][1]=cos(_AOA)*cos(_AOS);
279+
R[1][2]=sin(_AOS);
280+
R[1][3]=sin(_AOA)*sin(_AOS);
281+
R[2][1]=-cos(_AOA)*sin(_AOS);
282+
R[2][2]=cos(_AOS);
283+
R[2][3]=-sin(_AOA)*sin(_AOS);
284+
R[3][1]=-sin(_AOA);
285+
R[3][2]=0;
286+
R[3][3]=cos(_AOA);
287+
288+
//Calculation of Position vector in wind axes
289+
Matrix.Multiply((float*)R,(float*)PB,3,3,1,(float*)PW);
290+
//Calculation angular rates at tip in wind frame, attention low angular acceleration assumed. High rates in method 2.
291+
Matrix.Multiply((float*)R,(float*)WB,3,3,1,(float*)WW);
292+
//Calculation of velocity vector at tip in wind coordinates
293+
//Cross product WWxPW
294+
PWDOT[1][1]=WW[2][1]*PW[3][1]-WW[3][1]*PW[2][1];
295+
PWDOT[2][1]=WW[3][1]*PW[1][1]-WW[1][1]*PW[3][1];
296+
PWDOT[3][1]=WW[1][1]*PW[2][1]-WW[2][1]*PW[1][1];
297+
//Airspeed vector
298+
VCorrected[1][1]=_TAS-PWDOT[1][1];
299+
VCorrected[2][1]= -PWDOT[2][1];
300+
VCorrected[3][1]= -PWDOT[3][1];
301+
_TASPCorrected=sqrt(pow(VCorrected[1][1],2)+pow(VCorrected[2][1],2)+pow(VCorrected[3][1],2));
302+
break;
303+
}
304+
}
252305
}
306+
void AirDC::Viscosity(int mode)
307+
{
308+
switch(mode)
309+
{
310+
case 1:
311+
{
312+
//Calculate viscosity. Sutherland's formula, note that unit of measurement [Pas] is multiplied by 10e3
313+
_mu= 18.27*(291.15+120)/(_T+120)*pow((_T/291.15),(3/2));
314+
}
315+
}
316+
}
317+
void AirDC::Red(int mode)
318+
{
319+
switch(mode)
320+
{
321+
case 1:
322+
{
323+
_Re=_Rho*_TAS*_d/_mu;
324+
}
325+
}
253326
}
254-
255-

Software/Arduino/Libraries/AirDC/AirDC.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,33 @@ class AirDC
1919
void OAT(int mode);
2020
void ISAAltitude(int mode);
2121
void OutputSerial(int mode);
22+
//Correction and Auxiliary
23+
void PitotCorrection(int mode);
24+
void Viscosity(int mode);
25+
void Red(int mode);
2226
//General use
2327
int _pid;
2428
String _StreamOut;
29+
//Geometric
30+
double _d;//Reference length for Re calculation
2531
//Measurements
2632
double _p;
2733
double _T;
2834
double _RH;
2935
double _qc;
36+
double _AOA;
37+
double _AOS;
3038
//AirData
3139
double _Rho;
3240
double _IAS;
3341
double _CAS;
3442
double _TAS;
43+
double _TASPCorrected;
3544
double _M;
3645
double _TAT;
3746
double _h;
47+
double _mu;
48+
double _Re;
3849
//Measurements Uncertainty
3950
double _up;
4051
double _uT;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ void loop() {
6060
AirDataComputer.TAS(1);// Calculates the IAS, Algorithm 1
6161
AirDataComputer.Mach(1);// Calculates the Mach number, Algorithm 1
6262
AirDataComputer.OAT(1);// Calculates the Outside Air Temperature, Algorithm 1
63-
AirDataComputer.ISAAltitude(1);// Calculates the ISA altitude from static pressure, Algorithm 1
63+
//Measurment corrections and Auxiliary data
64+
AirDataComputer.PitotCorrection(1);// Calculates the ISA altitude from static pressure, Algorithm 1
65+
AirDataComputer.Viscosity(1);// Calculates the dynamic viscosity, Algorithm 1
66+
AirDataComputer.Red(1);// Calculates the ISA altitude from static pressure, Algorithm 1
6467
delay(1000); //loop delay
6568
//Visualitation
6669
AirDataComputer.OutputSerial(1);
@@ -88,4 +91,7 @@ void loop() {
8891
Serial.println(AirDataComputer._uRH); //Relative Humidity Uncertainty
8992
Serial.println(AirDataComputer._h); //Altitude
9093
Serial.println(AirDataComputer._uh); //Altitude Uncertainty
94+
Serial.println(AirDataComputer._TASPCorrected); //True Airspeed Corrected for probe position
95+
Serial.println(AirDataComputer._mu); //Viscosity mPas
96+
Serial.println(AirDataComputer._Re); //Reynolds
9197
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
AirDC -Work in Progress, no release number
22
03-12-2015 Alfa release
3+
Best Regards

0 commit comments

Comments
 (0)