aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-12-04 14:59:47 +0200
committerAvi Levkovich <avi@twine-s.com>2018-12-04 14:59:47 +0200
commita7377ec0dd85367606e7f53353df018b68c12e4c (patch)
tree4e3f776eac5ddfef686a21fb8449ecc5566a69ec /Software/Embedded_SW
parent3a8e3bd61c9ced641deeae3efabeaa9d3d3592ff (diff)
downloadTango-a7377ec0dd85367606e7f53353df018b68c12e4c.tar.gz
Tango-a7377ec0dd85367606e7f53353df018b68c12e4c.zip
update MidTank Pressure logic return Liquid volume in litters
Diffstat (limited to 'Software/Embedded_SW')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c62
1 files changed, 49 insertions, 13 deletions
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 f2fae93da..1d346a50d 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,7 +71,7 @@ uint32_t I2C_ADC_Read_Ch(uint32_t I2C_Slave_Add )
return VsampleInBits;
}
-
+/*
double Calculate_Pressure(uint32_t VsampleInBits )
{
double Pressure = 0.0, temp, PKpa,PBar,VADC = 0.0 ,VSensor;
@@ -93,14 +93,14 @@ double Calculate_Pressure(uint32_t VsampleInBits )
temp = 4.64 * VADC ;
VSensor = 11.0544 - temp;
-/*
- // ---- Vsensor -> P[KPa] ----
- //Vsensor = 5* (0.16*P + 0.5)
+// // ---- Vsensor -> P[KPa] ----
+//
+// //Vsensor = 5* (0.16*P + 0.5)
+//
+// temp = VSensor - 2.5;
+// PKpa = temp / 0.8;
- temp = VSensor - 2.5;
- PKpa = temp / 0.8;
-*/
// ---- Vsensor -> P[KPa] ----
//Vsensor = (17/18)*P + (103/45) p1[v] = 0.4V p1[kpa] = -2kpa, p2[v] = 4.65V p2[kpa] = 2.5kpa
double b = 103.0/45.0;
@@ -117,6 +117,42 @@ double Calculate_Pressure(uint32_t VsampleInBits )
Pressure = PBar;
return Pressure;
}
+*/
+
+double Calculate_Pressure(uint32_t VsampleInBits )
+{
+ double temp, VADC = 0.0 ,PKpa,VSensor,HighMeter,LiquidLitter;
+
+ //---- VBits -> VADC ----
+
+ //ADC 12 bit -> 4096 -> 2.5V
+
+ temp = VsampleInBits*2.5;
+ VADC = temp / 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
+
+ VSensor = (1.96- VADC) * 4.64 + 1.96;
+
+ // ---- Vsensor -> P[KPa] ----
+
+ //Vsensor = 5* (0.16*P + 0.5)
+
+ PKpa = ((VSensor/5)-0.5)/(0.16/1);
+
+ // ---- P[KPa] -> HighMeter ----
+ HighMeter = (PKpa * 1000.0) / (1060.0 *9.81);
+
+ // ---- HighMeter -> LiquidLitter ----
+ LiquidLitter = 3.1415*((0.11 - 0.0126) / 2.0) * ((0.11 - 0.0126) / 2.0) * HighMeter * 1000.0;
+
+ return LiquidLitter;
+}
+
uint32_t Read_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7
{
@@ -133,27 +169,27 @@ uint32_t Read_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7
I2C_Slave_Add = 0x44;
Channel = 0x20;
break;
- case MIDTANK_2:
+ case MIDTANK_5:
I2C_Slave_Add = 0x44;
Channel = 0x10;
break;
- case MIDTANK_3:
+ case MIDTANK_2:
I2C_Slave_Add = 0x44;
Channel = 0x08;
break;
- case MIDTANK_4:
+ case MIDTANK_6:
I2C_Slave_Add = 0x44;
Channel = 0x04;
break;
- case MIDTANK_5:
+ case MIDTANK_3:
I2C_Slave_Add = 0x46;
Channel = 0x80;
break;
- case MIDTANK_6:
+ case MIDTANK_7:
I2C_Slave_Add = 0x46;
Channel = 0x40;
break;
- case MIDTANK_7:
+ case MIDTANK_4:
I2C_Slave_Add = 0x46;
Channel = 0x20;
break;