aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-08 15:57:33 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-08 15:57:33 +0300
commita610818fef1bafdd75ab904d19fa7f206942ce97 (patch)
tree0f0b603c0f0b57f01b6f8bd7abddd17b9f595b55 /Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
parent44e723b21ebb3d1d1439dff9b90881595098ac4b (diff)
downloadTango-a610818fef1bafdd75ab904d19fa7f206942ce97.tar.gz
Tango-a610818fef1bafdd75ab904d19fa7f206942ce97.zip
save time on pressure calculation - make constant calculations on init
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
index 0c3d8c9e4..374ab444f 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
@@ -26,6 +26,20 @@ float GetDispenserPressure(int DispenserId)
{
return DispenserPressure[DispenserId];
}
+float Vlow,VHigh,Bits_0Pascal,Bits_1MPascal,a,b;
+void Calculateinit (void)
+{
+ Vlow = 0.004 * 130; // 4mA*130ohm = 0.52 V(0 Pascal)
+ VHigh = 0.020 *130; // 20mA*130ohm = 2.6V (1M Pascal)
+
+ Bits_0Pascal = Vlow * 4096 / 3; // Vlow * 4096bit / 3Vref = 709.973328 bits
+ Bits_1MPascal = VHigh * 4096 / 3; // VHigh * 4096bit / 3Vref = 3549.86646 bits
+
+ a = (1 - 0) / (Bits_1MPascal - Bits_0Pascal);// Mpascal/Bits = 0.000352125
+
+ b = 0 - (a * Bits_0Pascal );
+
+}
float CalculateDispenserPressure (int DispenserId)
{
unsigned short data = 0;
@@ -39,17 +53,6 @@ float CalculateDispenserPressure (int DispenserId)
temp /= 4096;
DispenserPressure[DispenserId] = 3000 - temp;
*/
-
- 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 = 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 = 0.000352125
-
- float b = 0 - (a * Bits_0Pascal );
-
data = ADC_GetReading(DispenserIdToPressureSensorId[DispenserId]);
if(data<Bits_0Pascal)