aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-09-30 12:00:53 +0300
committerAvi Levkovich <avi@twine-s.com>2020-09-30 12:00:53 +0300
commitb2420e1b64c155020bd8b9355ea1135f6e4a9b36 (patch)
tree05938bf0bb21aa4aec17ef30132caddb8132e474 /Software
parentb0d3ccdbb8cd825c32a1f616223c9c391e0d1e14 (diff)
downloadTango-b2420e1b64c155020bd8b9355ea1135f6e4a9b36.tar.gz
Tango-b2420e1b64c155020bd8b9355ea1135f6e4a9b36.zip
Update VOC_Sensor Diagnostics
Diffstat (limited to 'Software')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c10
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c13
-rw-r--r--Software/Stubs Collection/stubs/ConvertFloat2Bytes.cs54
4 files changed, 64 insertions, 14 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c
index a19280b4f..e96c2367e 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c
@@ -27,10 +27,11 @@ AD5272 U40_AD5272;
double VOCLookUpTable[VOCTable_MaxLine][VOCTable_MaxColumn] =
{
- // VOC[mV] PPM
- 2500.0, -7.533 ,
- 2600.0, -2.818553027,
- 2700.0, -0.169896815,
+ //Based on VOC "sensor ppm calculation.xlsx" (see email "VOC sensor operational")
+ // VOC[mV] PPM
+ 2500.0, 0, // -7.533 , change to 0
+ 2600.0, 0.395162, // -2.818553027, change to linear value
+ 2700.0, 0.7903250,// -0.169896815, change to linear value
2800.0, 1.185487609 ,
2900.0, 1.79209246 ,
3000.0, 2.031444444 ,
@@ -303,6 +304,7 @@ uint8_t Search_Rheostat_Value_for_Air_clibration()
else
{
ReportWithPackageFilter(WasteFilter,"------------WHS: complete the rheostat calibration-----------------", __FILE__,__LINE__, gas_value, RpMessage, 0, 0);
+ Latest_Gas_Sens_PPM = VOC2PPM(gas_value); //for the first read
return OK;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.h
index b46ce7d41..d6b1e3fd5 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.h
@@ -16,6 +16,7 @@ bool WHS_WriteRdac(uint16_t value);
uint32_t Read_Gas_Sensor(); //cyclic;
uint32_t Get_latest_Gas_Sensor_value();
+double Get_latest_Gas_Sensor_PPM();
void Voc_Sensor_Zero_Calibration();
diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
index e9ec2d56a..2a243c714 100644
--- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
+++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
@@ -847,14 +847,8 @@ void DiagnosticOneMinuteCollection(void)
}
}
}
- }
-
- VOC_Sensor = (double) Get_latest_Gas_Sensor_PPM();
- DiagnosticsMonitor.n_filterdeltapressure = 1;
- DiagnosticsMonitor.filterdeltapressure = &VOC_Sensor;
- DiagnosticsMonitor.n_gassensor = 1;
- DiagnosticsMonitor.gassensor = &VOC_Sensor;
+ }
DiagnosticsMonitor.n_blowervoltage = 1;
diagvoltage = getBlowerState();
DiagnosticsMonitor.blowervoltage = &diagvoltage;
@@ -1230,9 +1224,8 @@ void SendDiagnostics(void)
DiagnosticsMonitor.n_headzone5_6heatercurrent = 1;
DiagnosticsMonitor.headzone5_6heatercurrent = HeatersCurrent[HEATER_HEAD_CURRENT_ZONE_5_6];
*/
- VOC_Sensor = (double) getGasReading();
- DiagnosticsMonitor.n_filterdeltapressure = 1;
- DiagnosticsMonitor.filterdeltapressure = &VOC_Sensor;
+ VOC_Sensor = (double) Get_latest_Gas_Sensor_PPM();//(double) getGasReading();
+
DiagnosticsMonitor.n_gassensor = 1;
DiagnosticsMonitor.gassensor = &VOC_Sensor;
diff --git a/Software/Stubs Collection/stubs/ConvertFloat2Bytes.cs b/Software/Stubs Collection/stubs/ConvertFloat2Bytes.cs
new file mode 100644
index 000000000..dc980e438
--- /dev/null
+++ b/Software/Stubs Collection/stubs/ConvertFloat2Bytes.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Text;
+using System.Linq;
+using System.Drawing;
+using System.Diagnostics;
+using System.Windows.Forms;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using Tango.PMR.Stubs;
+using Tango.Stubs;
+
+
+
+public void OnExecute(StubManager stubManager)
+{
+ //see online Floating Point to Hex Converter (with Swap endianness) :https://gregstoll.com/~gregstoll/floattohex/
+ // ----------------- option 1 -------------------------------
+ stubManager.WriteLine("--- option 1 ---");
+ float value = 5.2F;
+ var byteArray1 = new byte[4];// a single float is 4 bytes/32 bits
+ byteArray1 = BitConverter.GetBytes(value);
+
+ //print
+ for(int i =0;i<4;i++)
+ {
+ stubManager.WriteHex(byteArray1[i],2);
+ stubManager.Write(" ");
+ }
+ stubManager.WriteLine("");
+ stubManager.WriteLine("");
+
+ // ----------------- option 2 for buffer -------------------------------
+ stubManager.WriteLine("--- option 2 ---");
+ var floatArray1 = new float[] {5.2f, 1.2f, 3.7f};
+
+
+ // create a byte array and copy the floats into it...
+ var byteArray = new byte[floatArray1.Length * 4];// a single float is 4 bytes/32 bits
+ Buffer.BlockCopy(floatArray1, 0, byteArray, 0, byteArray.Length);
+
+ //print
+ for(int j =0;j<floatArray1.Length;j++)
+ {
+ for(int i =0;i<4;i++)
+ {
+ stubManager.WriteHex(byteArray[j+i],2);
+ stubManager.Write(" ");
+ }
+ stubManager.WriteLine("");
+ }
+
+
+} \ No newline at end of file