From 535b90dc450d521e9567dbed050e411f91efdc50 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 8 Aug 2018 19:12:19 +0300 Subject: fixes to the pressure calculation --- Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Software/Embedded_SW/Embedded') diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c index 6312c701e..1efce00e3 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c @@ -35,9 +35,9 @@ void Calculateinit (void) Bits_0Pascal = Vlow * 4096 / 3; // Vlow * 4096bit / 3Vref = 709.973328 bits Bits_1MPascal = VHigh * 4096 / 3; // VHigh * 4096bit / 3Vref = 3549.86646 bits - a = (Bits_1MPascal - Bits_0Pascal) / (1 - 0) ;// Mpascal/Bits = 2839.89307 + a = (1 - 0) / (Bits_1MPascal - Bits_0Pascal);// Mpascal/Bits = 0.000352125 - b = Bits_0Pascal - (a * 0 ); //709.973328 + b = 0 - (a * Bits_0Pascal ); // y = ax + b (x= Bits_0Pascal, y = 0) } float CalculateDispenserPressure (int DispenserId) @@ -58,7 +58,7 @@ float CalculateDispenserPressure (int DispenserId) if(data Date: Thu, 9 Aug 2018 09:31:12 +0300 Subject: Connect the secondary dryer heater to SSR2 . SSR3 NC --- Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Software/Embedded_SW/Embedded') diff --git a/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c b/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c index 99190e02a..d67a65b17 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c +++ b/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c @@ -37,9 +37,9 @@ uint32_t HeaterActive = 0; static GPIOIntPortMap portMap[MAX_HEATERS_NUM] = { - {DRYER_SSR2_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature + {DRYER_SSR3_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature **** Not connected **** {DRYER_SSR1_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain - {DRYER_SSR3_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary + {DRYER_SSR2_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary {DYEINGH_SSR8_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1 - Head Heater #1 - rightmost {DYEINGH_SSR7_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2 - Head Heaters #2 #3 #4 {DYEINGH_SSR6_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3 - Head Heaters #5 #6 #7 #8 -- cgit v1.3.1 From ccec0abb96ce3cfc7c0d75a78e371cef90e2b968 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Sun, 12 Aug 2018 10:35:23 +0300 Subject: Add ADC_MUX module to read the mid tank pressure sensor --- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 137 +++++++++++++++++++++ .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h | 16 +++ 2 files changed, 153 insertions(+) create mode 100644 Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c create mode 100644 Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h (limited to 'Software/Embedded_SW/Embedded') 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 new file mode 100644 index 000000000..87e41726f --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -0,0 +1,137 @@ +/* + * ADC_MUX.c + * + * Created on: Aug 12, 2018 + * Author: avi + * + * Mid tank pressure sensor. Bosch 02612300215 + */ +#include +#include +#include "include.h" +#include "inc/hw_memmap.h" +#include "inc/hw_types.h" +#include "inc/tm4c1294ncpdt.h" +#include "driverlib/gpio.h" +#include "driverlib/pin_map.h" +#include "driverlib/rom.h" +#include "driverlib/rom_map.h" +#include "driverlib/sysctl.h" +#include "driverlib/i2c.h" +#include "Drivers/I2C_Communication/I2C_Switch/I2C_Swith.h" +#include "drivers/I2C_Communication/I2C.h" + +#include "ADC_MUX.h" + +double MidTank_Pressure[8]; + +uint32_t I2C_ADC_Config(uint32_t I2C_Slave_Add,uint32_t channel ) +{ + uint32_t Status = OK; + + uint8_t Config_Buf[3]; + + Config_Buf[0] = 0x00; + Config_Buf[1] = channel; + Config_Buf[2] = 0x80; + + Status = I2C_Write(MUX_I2C_BASE, I2C_Slave_Add, Config_Buf, 3); + + return Status; +} + +uint32_t I2C_ADC_Set_For_Read_Ch(uint32_t I2C_Slave_Add ) +{ + uint32_t Status = OK; + + uint8_t SetRead = 0x02; + + Status = I2C_Write(MUX_I2C_BASE, SetRead, SetRead, 1); + + return Status; +} + + +uint32_t I2C_ADC_Read_Ch(uint32_t I2C_Slave_Add ) +{ + uint32_t VsampleInBits = 0,temp; + + uint8_t No_BytesToRead = 2; + + uint8_t I2C_Read_buf[2] = {0,0}; + + I2C_Read(MUX_I2C_BASE, I2C_Slave_Add, *I2C_Read_buf, No_BytesToRead ); + + temp = (I2C_Read_buf[0] << 8) | I2C_Read_buf[1]; + + VsampleInBits=temp & 0x0fff; + + return VsampleInBits; +} + +uint32_t Calculate_Pressure(uint32_t VsampleInBits ) +{ + double Pressure = 0; + + + + + return Pressure; +} + +uint32_t Read_MidTank_Pressure_Sensor(uint32_t MidTank_ID) +{ + uint32_t Status = OK; + uint32_t I2C_Slave_Add; + uint32_t Channel; + uint32_t VsampleInBits; + + switch(MidTank_ID) + { + case 1: + I2C_Slave_Add = 0x44; + Channel = 0x20; + break; + case 2: + I2C_Slave_Add = 0x44; + Channel = 0x08; + break; + case 3: + I2C_Slave_Add = 0x46; + Channel = 0x80; + break; + case 4: + I2C_Slave_Add = 0x46; + Channel = 0x20; + break; + case 5: + I2C_Slave_Add = 0x44; + Channel = 0x10; + break; + case 6: + I2C_Slave_Add = 0x44; + Channel = 0x04; + break; + case 7: + I2C_Slave_Add = 0x46; + Channel = 0x40; + break; + case 8: + I2C_Slave_Add = 0x46; + Channel = 0x10; + break; + default: + break; + } + + Status = I2C_ADC_Config(I2C_Slave_Add, Channel); + Status = I2C_ADC_Set_For_Read_Ch(I2C_Slave_Add); + VsampleInBits = I2C_ADC_Read_Ch(I2C_Slave_Add); + + MidTank_Pressure[MidTank_ID -1] = Calculate_Pressure(VsampleInBits); + + return Status; +} + + + diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h new file mode 100644 index 000000000..8852eef41 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h @@ -0,0 +1,16 @@ +/* + * ADC_MUX.h + * + * Created on: Aug 12, 2018 + * Author: avi + */ + +#ifndef DRIVERS_I2C_COMMUNICATION_ADC_MUX_ADC_MUX_H_ +#define DRIVERS_I2C_COMMUNICATION_ADC_MUX_ADC_MUX_H_ + + +uint32_t Read_MidTank_Pressure_Sensor(uint32_t MidTank_ID); + +#define MUX_I2C_BASE 2 + +#endif /* DRIVERS_I2C_COMMUNICATION_ADC_MUX_ADC_MUX_H_ */ -- cgit v1.3.1 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/Embedded') 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 From a4a2a94fe295f57c462eb3cd2c24c9ba512de5a6 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Sun, 12 Aug 2018 14:30:42 +0300 Subject: update ADC_MUX.c --- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 32 ++++++++++++---------- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h | 16 +++++++++-- 2 files changed, 32 insertions(+), 16 deletions(-) (limited to 'Software/Embedded_SW/Embedded') 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 be29290b4..0dbf24ac9 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 @@ -4,6 +4,7 @@ * Created on: Aug 12, 2018 * Author: avi * + * 8-Channel, I2C, 12-Bit SAR ADC with Temperature Sensor AD7291 * Mid tank pressure sensor. Bosch 02612300215 */ #include @@ -75,11 +76,12 @@ uint32_t Calculate_Pressure(uint32_t VsampleInBits ) //---- VBits -> VADC ---- - //TODO to check in the ADC data sheet!!! + //ADC 12 bit -> 4096 -> 2.5V - //ADC 12 bit -> 4096 + temp = VsampleInBits*2.5; + VADC = temp / 0xFFF; - //---- VADC -> VSensor ---- + //---- VADC -> VSensor --- //VADC = 1.96 - 10k( VSensor - 1.96) / 46.4k (from the electrical scheme) // VSensor = 0 V -> VADC = 2.3824 V @@ -105,44 +107,46 @@ uint32_t Calculate_Pressure(uint32_t VsampleInBits ) return Pressure; } -uint32_t Read_MidTank_Pressure_Sensor(uint32_t MidTank_ID) +uint32_t Read_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7 { uint32_t Status = OK; uint32_t I2C_Slave_Add; uint32_t Channel; uint32_t VsampleInBits; - switch(MidTank_ID) //TODO chnge acording to the valves!!! + assert (MidTank_ID