aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-07-31 10:06:29 +0300
committerAvi Levkovich <avi@twine-s.com>2018-07-31 10:06:29 +0300
commit90b65a54cd28ee8b0d908c86795a7096c4073e83 (patch)
tree0527efed7076b4b79113a76b1e6b8cbdf6b9ef34 /Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
parent4ff8fc0265f11be7b73548e36c7ee3d1debfb8e4 (diff)
downloadTango-90b65a54cd28ee8b0d908c86795a7096c4073e83.tar.gz
Tango-90b65a54cd28ee8b0d908c86795a7096c4073e83.zip
update the CalculateDispenserPressure function
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
index 8a51bc210..f2901ad84 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
@@ -36,29 +36,33 @@ float CalculateDispenserPressure (int DispenserId)
DispenserPressure[DispenserId] = 3000 - temp;
*/
- float Vlow = 0.004 * 130; // 4mA*130ohm (0 Pascal)
- float VHigh = 0.020 *130; // 20mA*130ohm (1M Pascal)
+ float Vlow = 0.004 * 130; // 4mA*130ohm = 0.52 V(0 Pascal)
+ float VHigh = 0.020 *130; // 20mA*130ohm = 2.6V (1M Pascal)
- float Bits_0Pascal = Vlow * 4096 / 3; // Vlow * 4096bit / 3Vref
- float Bits_1MPascal = VHigh * 4096 / 3; // VHigh * 4096bit / 3Vref
+ float Bits_0Pascal = Vlow * 4096 / 3; // Vlow * 4096bit / 3Vref = 709.973328 bits
+ float Bits_1MPascal = VHigh * 4096 / 3; // VHigh * 4096bit / 3Vref = 3549.86646 bits
- float a = (1 - 0) / (Bits_1MPascal - Bits_0Pascal);// Mpascal/Bits
+ float a = (1 - 0) / (Bits_1MPascal - Bits_0Pascal);// Mpascal/Bits = 0.000352125
+
+ float b = 0 - (a * Bits_0Pascal );
data = ADC_GetReading(DispenserIdToPressureSensorId[DispenserId]);
- temp = Bits_1MPascal - data;
+ if(data<Bits_0Pascal)
+ data = Bits_0Pascal;//40mA 0Bar
- temp = a * temp;
+ temp = a * data + b;
- DispenserPressure[DispenserId] = 1 - temp; // [Mpascal] ( 1 Mpascal = 10 Bar )
+ DispenserPressure[DispenserId] = temp; // [Mpascal] ( 1 Mpascal = 10 Bar )
//unmark one of them to convert from Mpascal to :
//-----------------------------------
- //DispenserPressure[DispenserId] / = 1000000; //Pascal
+ //DispenserPressure[DispenserId] /= 1000000; //Pascal
//DispenserPressure[DispenserId] *=10; //Bar;
+ DispenserPressure[DispenserId] *=10000000; //uBar;
//DispenserPressure[DispenserId] *=145.0377; //PSI;
- return( DispenserPressure[DispenserId]);
+ return(DispenserPressure[DispenserId]);
}