@@ -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}
264307void 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 }
0 commit comments