From 7281e95ea4e88aa8f4b7fa25a687db7cf0ca0c64 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Sun, 12 Aug 2018 12:28:42 +0300 Subject: update ADC_MUX.c --- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'Software/Embedded_SW') diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c index 87e41726f..be29290b4 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -71,11 +71,37 @@ uint32_t I2C_ADC_Read_Ch(uint32_t I2C_Slave_Add ) uint32_t Calculate_Pressure(uint32_t VsampleInBits ) { - double Pressure = 0; + double Pressure = 0, temp, PKpa,PBar,VADC = 0 ,VSensor; + //---- VBits -> VADC ---- + //TODO to check in the ADC data sheet!!! + //ADC 12 bit -> 4096 + //---- VADC -> VSensor ---- + + //VADC = 1.96 - 10k( VSensor - 1.96) / 46.4k (from the electrical scheme) + // VSensor = 0 V -> VADC = 2.3824 V + + // VSensor = 10 V -> VADC = 0.2272 V + + temp = 4.94 * VADC ; + + VSensor = 11.0544 - temp; + + // ---- Vsensor -> P[KPa] ---- + + //Vsensor = 5* (0.16*P + 0.5) + + temp = VSensor - 2.5; + PKpa = temp / 0.8; + + // ---- P[Kpa] -> BAR ---- + + PBar = PKpa / 100; + + Pressure = PBar; return Pressure; } @@ -86,7 +112,7 @@ uint32_t Read_MidTank_Pressure_Sensor(uint32_t MidTank_ID) uint32_t Channel; uint32_t VsampleInBits; - switch(MidTank_ID) + switch(MidTank_ID) //TODO chnge acording to the valves!!! { case 1: I2C_Slave_Add = 0x44; -- cgit v1.3.1