Skip to content

Commit 9b9fadc

Browse files
author
JLJu
committed
Added Basic Message No 19 and No 20 implementation
Added Basic Message No 19 and No 20 implementation
1 parent f50851d commit 9b9fadc

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

Software/Microcontroller/Firmware/AsgardADC/AsgardADC.ino

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ void acquisition()
198198
// Differential Pressure sensor
199199
if (AirDataComputer._status[AIRDC_STATUS_DELTAP] == '1') { // Differential pressure sensor present
200200
diffp.update();
201-
AirDataComputer._qc = diffp.pressure();
201+
//AirDataComputer._qc = diffp.pressure();
202+
AirDataComputer._qc = AirDataComputer.CorrectDp(1,diffp.pressure()); //Corrected Differential Pressure
202203
AirDataComputer._qcRaw = diffp.pressure_Raw();
203204
if (AirDataComputer._status[AIRDC_STATUS_TDELTAP] == '1') { // Temperature differential pressure sensor present
204205
AirDataComputer._Tdeltap = diffp.temperature();
@@ -999,9 +1000,11 @@ endread:
9991000
// --------------------------------------------------
10001001
// #19 - CCS–CALIBRATION_CON_SET
10011002
// --------------------------------------------------
1003+
//Example Sent -> $CCS,EXE,1,1
1004+
//
10021005
if (!strcmp(command, "$CCS"))
10031006
{
1004-
float SensorID, CalibMode;
1007+
float SensorID, CalibMode,CalibMeasure;
10051008
if (strlen(command) < 1) goto endeval;
10061009
command = strtok (NULL, SEPARATOR); // Required command
10071010
if (!strcmp(command, "EXE")) { //Execute calibration command
@@ -1014,13 +1017,29 @@ endread:
10141017
}
10151018
}
10161019
}
1020+
//Sospensive zero offset calibration
1021+
CalibMeasure=0;
1022+
if (AirDataComputer._status[AIRDC_STATUS_DELTAP] == '1') { // Differential pressure sensor present
1023+
int maxip=50; //No. of samples to calculate the average zero value
1024+
for (int ip=0;ip<maxip;ip++)
1025+
{
1026+
diffp.update();
1027+
CalibMeasure = CalibMeasure+ diffp.pressure_Raw();
1028+
delay(200);
1029+
}
1030+
CalibMeasure = CalibMeasure/maxip;
1031+
AirDataComputer._DpZeroMeas=CalibMeasure;
1032+
}
10171033
strcpy (Answer, "$CCA,");
10181034
char f1[20], f2[20], f3[20];
10191035
sprintf(f1, "%.3f", SensorID);
10201036
strcat (Answer, f1);
10211037
strcat (Answer, SEPARATOR);
10221038
sprintf(f2, "%.3f", CalibMode);
10231039
strcat (Answer, f2);
1040+
strcat (Answer, SEPARATOR);
1041+
sprintf(f3, "%.3f", AirDataComputer._DpZeroMeas);
1042+
strcat (Answer, f3);
10241043
goto endeval;
10251044
}
10261045

Software/Microcontroller/Libraries/AirDC/AirDC.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ AirDC::AirDC(int pid)
5858
_Iq=3;
5959
_Ir=0;
6060
_c=1; //Probe calibration factor
61+
_DpZeroMeas=8192;
6162

6263
}
6364
/** Calculates the Air Density
@@ -392,6 +393,19 @@ void AirDC::CalibrationFactor(int mode)
392393
}
393394
}
394395
}
396+
/** Calculates correction factor for differential pressure measurements (SI) taken by sensorID
397+
* @param SensorID Indicates the Sensor
398+
* @param Pascal deltap measurement
399+
* @return Correction Offset [Pa]
400+
*/
401+
double AirDC::CorrectDp(int SensorID, double DpMeas)
402+
{
403+
//Hey ! We should use the SensorID!
404+
//0.93513059
405+
//0.8417479
406+
407+
return (DpMeas-(_DpZeroMeas-8192)*0.93513059);
408+
}
395409
/** Order all the data within an array
396410
* @return Void
397411
*/

Software/Microcontroller/Libraries/AirDC/AirDC.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class AirDC
7171
void Mach(int mode);
7272
void OAT(int mode);
7373
void ISAAltitude(int mode);
74+
double CorrectDp(int SensorID, double DpMeas);
7475
String OutputSerial(int mode);
7576
//Correction and Auxiliary
7677
void PitotCorrection(int mode);
@@ -138,7 +139,9 @@ class AirDC
138139
double _Ip;/**< Pitch rate*/
139140
double _Iq;/**< Roll rate*/
140141
double _Ir;/**< yaw rate*/
141-
double _c; /**Probe calibration factor*/
142+
double _c; /**<Probe calibration factor*/
143+
//Sensor Specific
144+
double _DpZeroMeas; /**<Zero measured value for differential sensor*/
142145
};
143146
#endif
144147

0 commit comments

Comments
 (0)