Skip to content

Commit f24d1b8

Browse files
author
BasicAirData
committed
0.0.1w
TASCorrectionEnabled
1 parent 5fe8802 commit f24d1b8

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

Software/Arduino/Libraries/AirDC/AirDC.cpp

+27-33
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ AirDC::AirDC(int pid)
2020
_RH=0.0;
2121
_qc=0.0;
2222
_AOA=0.17;
23-
_AOS=0.01;
23+
_AOS=0.00;
2424
_IAS=0.0;
2525
_TASPCorrected=0.0;
2626
//Uncertainty of measurements
@@ -33,7 +33,7 @@ AirDC::AirDC(int pid)
3333
_uTAT=0.0;//To be calculated, 0 default value
3434
//Inertial Unit
3535
_Ip=0;
36-
_Iq=2.6;
36+
_Iq=3;
3737
_Ir=0;
3838
_Ipdot=0.00;
3939
_Iqdot=0.00;
@@ -330,45 +330,39 @@ void AirDC::PitotCorrection(int mode)
330330
float PW[3][1]; //Position of probe tip in wind ref. frame
331331
float PWDOT[3][1]; //Velocity of tip in wind ref. frame
332332
float VCorrected[3][1]; //Measured Airspeed
333-
PB[1][1]=0.5; //Installation position respect c.o.g.
334-
PB[2][1]=0;
335-
PB[3][1]=0;
336-
WB[1][1]=_Ip; //Angular rates . P, q, r from sensors
337-
WB[2][1]=_Iq;
338-
WB[3][1]=_Ir;
339-
340-
R[1][1]=cos(_AOA)*cos(_AOS);
341-
R[1][2]=sin(_AOS);
342-
R[1][3]=sin(_AOA)*sin(_AOS);
343-
R[2][1]=-1*cos(_AOA)*sin(_AOS);
344-
R[2][2]=cos(_AOS);
345-
R[2][3]=-1*sin(_AOA)*sin(_AOS);
346-
R[3][1]=-1*sin(_AOA);
347-
R[3][2]=0;
348-
R[3][3]=cos(_AOA);
349-
Serial.Println("Debug")
350-
Matrix.Print((float*)R,3,3,"R");
333+
PB[0][0]=0.5; //Installation position respect c.o.g.
334+
PB[1][0]=0;
335+
PB[2][0]=0;
336+
WB[0][0]=_Ip; //Angular rates . P, q, r from sensors
337+
WB[1][0]=_Iq;
338+
WB[2][0]=_Ir;
339+
//Matrix.Print((float*)PB,3,1,"PB");
340+
R[0][0]=cos(_AOA)*cos(_AOS);
341+
R[0][1]=sin(_AOS);
342+
R[0][2]=sin(_AOA)*sin(_AOS);
343+
R[1][0]=-1*cos(_AOA)*sin(_AOS);
344+
R[1][1]=cos(_AOS);
345+
R[1][2]=-1*sin(_AOA)*sin(_AOS);
346+
R[2][0]=-1*sin(_AOA);
347+
R[2][1]=0;
348+
R[2][2]=cos(_AOA);
351349

352350
//Calculation of Position vector in wind axes
353351
Matrix.Multiply((float*)R,(float*)PB,3,3,1,(float*)PW);
354352
//Calculation of angular rates at tip in wind frame. Attention, assumed low angular acceleration. High rates in another method.
353+
355354
Matrix.Multiply((float*)R,(float*)WB,3,3,1,(float*)WW);
356-
Serial.Println("Debug")
357-
Matrix.Print((float*)PW,3,1,"PW");
358-
Matrix.Print((float*)WW,3,1,"WW");
359355
//Calculation of velocity vector at tip in wind coordinates
360356
//Cross product WWxPW
361-
PWDOT[1][1]=WW[2][1]*PW[3][1]-WW[3][1]*PW[2][1];
362-
PWDOT[2][1]=WW[3][1]*PW[1][1]-WW[1][1]*PW[3][1];
363-
PWDOT[3][1]=WW[1][1]*PW[2][1]-WW[2][1]*PW[1][1];
357+
PWDOT[0][0]=WW[1][0]*PW[2][0]-WW[2][0]*PW[1][0];
358+
PWDOT[1][0]=WW[2][0]*PW[0][0]-WW[0][0]*PW[2][0];
359+
PWDOT[2][0]=WW[0][0]*PW[1][0]-WW[1][0]*PW[0][0];
364360
//Airspeed vector
365-
VCorrected[1][1]=_TAS-PWDOT[1][1];
366-
VCorrected[2][1]= -PWDOT[2][1];
367-
VCorrected[3][1]= -PWDOT[3][1];
368-
Serial.Println("Debug")
369-
Matrix.Print((float*)VCorrected,3,1,"VCorrected");
370-
// _TASPCorrected=sqrt(pow(VCorrected[1][1],2)+pow(VCorrected[2][1],2)+pow(VCorrected[3][1],2));
371-
_TASPCorrected=0;
361+
VCorrected[0][0]=_TAS-PWDOT[0][0];
362+
VCorrected[1][0]= -PWDOT[1][0];
363+
VCorrected[2][0]= -PWDOT[2][0];
364+
_TASPCorrected=sqrt(pow(VCorrected[0][0],2)+pow(VCorrected[1][0],2)+pow(VCorrected[2][0],2));
365+
//_TASPCorrected=0;
372366
break;
373367
}
374368
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
#include <AirDC.h>
88
#include <AirSensor.h>
9-
109
#define DPSENSOR 3 //Selects the differential pressure Hardware sensor see AirSensor.cpp for details on Hookup
1110
#define PSENSOR 1 //Selects the static pressure Hardware sensor see AirSensor.cpp for details on Hookup
1211

@@ -57,7 +56,7 @@ void loop() {
5756
AirDataComputer.IAS(1);// Calculates the IAS, Algorithm 1
5857
AirDataComputer.CAS(1);// Calculates the CAS, Algorithm 1
5958
AirDataComputer.TAS(1);// Calculates the IAS, Algorithm 1
60-
AirDataComputer.PitotCorrection(1);// Calculates the corrected Airspeed, Algorithm 1
59+
AirDataComputer.PitotCorrection(2);// Corrected Airspeed, Algorithm 1
6160
AirDataComputer.Mach(1);// Calculates the Mach number, Algorithm 1
6261
AirDataComputer.OAT(1);// Calculates the Outside Air Temperature, Algorithm 1
6362
AirDataComputer.ISAAltitude(1);// Calculates the ISA Altitude

Software/Arduino/Libraries/AirSensor/AirSensor.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <math.h>
88
#include <Wire.h>
99
#include <SPI.h>
10-
10+
#define DEBUG 1
1111
AirSensor::AirSensor(int pid)
1212
{
1313
//Default parameters values
@@ -105,8 +105,8 @@ 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
109-
Pread=1000;
108+
#if (DEBUG==1)
109+
Pread=469.9651;
110110
#endif
111111
out->_qc=Pread; //pa
112112
out->_uqc=50.0;//pa

0 commit comments

Comments
 (0)