1- /* JLJ Adding Msg 19 e 20
2- Linear calibration only
3- * */
41/* Work in progress Asgard ADC Firmware Relase 0.4.0 16/01/2018
52 This is a preliminary release, work in progress. Misbehaviour is plausible.
63 AsgardADC.ino - Air Data Computer Firmware
@@ -199,7 +196,7 @@ void acquisition()
199196 if (AirDataComputer._status [AIRDC_STATUS_DELTAP] == ' 1' ) { // Differential pressure sensor present
200197 diffp.update ();
201198 // AirDataComputer._qc = diffp.pressure();
202- AirDataComputer._qc = AirDataComputer.CorrectDp (1 ,diffp.pressure ()); // Corrected Differential Pressure
199+ AirDataComputer._qc = AirDataComputer.CorrectDp (1 , diffp.pressure ()); // Corrected Differential Pressure
203200 AirDataComputer._qcRaw = diffp.pressure_Raw ();
204201 if (AirDataComputer._status [AIRDC_STATUS_TDELTAP] == ' 1' ) { // Temperature differential pressure sensor present
205202 AirDataComputer._Tdeltap = diffp.temperature ();
@@ -1001,13 +998,13 @@ endread:
1001998 // #19 - CCS–CALIBRATION_CON_SET
1002999 // --------------------------------------------------
10031000 // Example Sent -> $CCS,EXE,1,1
1004- //
1001+ // EXE Command
10051002 if (!strcmp (command, " $CCS" ))
10061003 {
1007- float SensorID, CalibMode,CalibMeasure;
1004+ float SensorID, CalibMode, CalibMeasure,CalibGain ;
10081005 if (strlen (command) < 1 ) goto endeval;
10091006 command = strtok (NULL , SEPARATOR); // Required command
1010- if (!strcmp (command, " EXE" )) { // Execute calibration command
1007+ if (!strcmp (command, " EXE" )) { // EXE Execute calibration command
10111008 command = strtok (NULL , SEPARATOR);
10121009 if (command != NULL ) {
10131010 SensorID = (atof (command)); // Read the Sensor ID value
@@ -1016,30 +1013,108 @@ endread:
10161013 CalibMode = (atof (command)); // Read required calibration mode
10171014 }
10181015 }
1016+
1017+ if (CalibMode == 1 ) { // Offset Calib
1018+ // Sospensive zero offset calibration
1019+ CalibMeasure = 0 ;
1020+ if (AirDataComputer._status [AIRDC_STATUS_DELTAP] == ' 1' ) { // Differential pressure sensor present
1021+ int maxip = 50 ; // No. of samples to calculate the average zero value
1022+ for (int ip = 0 ; ip < maxip; ip++)
1023+ {
1024+ diffp.update ();
1025+ CalibMeasure = CalibMeasure + diffp.pressure_Raw ();
1026+ delay (200 );
1027+ }
1028+ CalibMeasure = CalibMeasure / maxip;
1029+ AirDataComputer._DpZeroMeas = CalibMeasure;
1030+ }
1031+ strcpy (Answer, " $CCA," );
1032+ char f1[20 ], f2[20 ], f3[20 ];
1033+ sprintf (f1, " %.3f" , SensorID);
1034+ strcat (Answer, f1);
1035+ strcat (Answer, SEPARATOR);
1036+ sprintf (f2, " %.3f" , CalibMode);
1037+ strcat (Answer, f2);
1038+ strcat (Answer, SEPARATOR);
1039+ sprintf (f3, " %.3f" , AirDataComputer._DpZeroMeas );
1040+ strcat (Answer, f3);
1041+ goto endeval;
1042+ }
10191043 }
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 );
1044+ if (!strcmp (command, " USE" )) { // USE command
1045+ command = strtok (NULL , SEPARATOR);
1046+ if (command != NULL ) {
1047+ SensorID = (atof (command)); // Read the Sensor ID value
1048+ command = strtok (NULL , SEPARATOR);
1049+ if (command != NULL ) {
1050+ CalibMode = (atof (command)); // Read required calibration mode
1051+ }
1052+ command = strtok (NULL , SEPARATOR);
1053+ if (command != NULL ) {
1054+ CalibMeasure = (atof (command)); // Read offset value
1055+ }
1056+ command = strtok (NULL , SEPARATOR);
1057+ if (command != NULL ) {
1058+ CalibGain = (atof (command)); // Read Gain Value
1059+ }
1060+
1061+ }
1062+
1063+ if (CalibMode == 1 ) { // Offset Calibibration only
1064+ AirDataComputer._DpZeroMeas = CalibMeasure;
1065+ strcpy (Answer, " $CCA," );
1066+ char f1[20 ], f2[20 ], f3[20 ];
1067+ sprintf (f1, " %.3f" , SensorID);
1068+ strcat (Answer, f1);
1069+ strcat (Answer, SEPARATOR);
1070+ sprintf (f2, " %.3f" , CalibMode);
1071+ strcat (Answer, f2);
1072+ strcat (Answer, SEPARATOR);
1073+ sprintf (f3, " %.3f" , AirDataComputer._DpZeroMeas );
1074+ strcat (Answer, f3);
1075+ goto endeval;
1076+ }
1077+ if (CalibMode == 2 ) { // Offset Calibibration only
1078+ AirDataComputer._DpZeroMeas = CalibMeasure;
1079+ AirDataComputer._GainDp = CalibGain;
1080+ strcpy (Answer, " $CCA," );
1081+ char f1[20 ], f2[20 ], f3[20 ],f4[20 ];
1082+ sprintf (f1, " %.3f" , SensorID);
1083+ strcat (Answer, f1);
1084+ strcat (Answer, SEPARATOR);
1085+ sprintf (f2, " %.3f" , CalibMode);
1086+ strcat (Answer, f2);
1087+ strcat (Answer, SEPARATOR);
1088+ sprintf (f3, " %.3f" , AirDataComputer._DpZeroMeas );
1089+ strcat (Answer, f3);
1090+ strcat (Answer, SEPARATOR);
1091+ sprintf (f4, " %.6f" , AirDataComputer._GainDp );
1092+ strcat (Answer, f4);
1093+ goto endeval;
1094+ }
1095+
1096+
10291097 }
1030- CalibMeasure = CalibMeasure/maxip;
1031- AirDataComputer._DpZeroMeas =CalibMeasure;
1098+ if (!strcmp (command, " SEN" )) { // SEN command
1099+ command = strtok (NULL , SEPARATOR);
1100+ if (command != NULL ) {
1101+ SensorID = (atof (command)); // Read the Sensor ID value
1102+ }
1103+ AirDataComputer._DpZeroMeas = CalibMeasure;
1104+ AirDataComputer._GainDp = CalibGain;
1105+ strcpy (Answer, " $CCA," );
1106+ char f1[20 ], f3[20 ],f4[20 ];
1107+ sprintf (f1, " %.3f" , SensorID);
1108+ strcat (Answer, f1);
1109+ strcat (Answer, SEPARATOR);
1110+ sprintf (f3, " %.3f" , AirDataComputer._DpZeroMeas );
1111+ strcat (Answer, f3);
1112+ strcat (Answer, SEPARATOR);
1113+ sprintf (f4, " %.6f" , AirDataComputer._GainDp );
1114+ strcat (Answer, f4);
1115+ goto endeval;
10321116 }
1033- strcpy (Answer, " $CCA," );
1034- char f1[20 ], f2[20 ], f3[20 ];
1035- sprintf (f1, " %.3f" , SensorID);
1036- strcat (Answer, f1);
1037- strcat (Answer, SEPARATOR);
1038- sprintf (f2, " %.3f" , CalibMode);
1039- strcat (Answer, f2);
1040- strcat (Answer, SEPARATOR);
1041- sprintf (f3, " %.3f" , AirDataComputer._DpZeroMeas );
1042- strcat (Answer, f3);
1117+
10431118 goto endeval;
10441119 }
10451120
0 commit comments