diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-02-19 10:32:48 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-02-19 10:32:48 +0200 |
| commit | 685b1da155bda741a3378a1c19a04ffd110a0a33 (patch) | |
| tree | e38a3740bf4727dfa9368c6010c6cd55d6910ffb /Software/Embedded_SW/Embedded | |
| parent | 94fccc66fd2b8b6aed1371546dfd8cef68d5e60d (diff) | |
| parent | bb51ac752b58b3d64e86a8150e7a9b1f5749e379 (diff) | |
| download | Tango-685b1da155bda741a3378a1c19a04ffd110a0a33.tar.gz Tango-685b1da155bda741a3378a1c19a04ffd110a0a33.zip | |
merge conflict
Diffstat (limited to 'Software/Embedded_SW/Embedded')
28 files changed, 421 insertions, 892 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 873c89b7e..e8d7f6f58 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -280,16 +280,22 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) Fresult = FR_DENIED; else { - Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER); - Fresult = f_open(DownloadFileHandle,request->filename,FA_READ ); - if (Fresult == FR_OK) + if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) { - response.has_maxchunklength = true; - response.maxchunklength = MAX_CHUNK_LENGTH; - strcpy(FileHandleChar, "1234"); - response.downloadid = FileHandleChar; //supporting only single file at each time. + Fresult = f_open(DownloadFileHandle,request->filename,FA_READ ); + if (Fresult == FR_OK) + { + response.has_maxchunklength = true; + response.maxchunklength = MAX_CHUNK_LENGTH; + strcpy(FileHandleChar, "1234"); + response.downloadid = FileHandleChar; //supporting only single file at each time. + Report("data request", __FILE__, 1234, MAX_CHUNK_LENGTH, RpWarning, (int)fno->fsize, 0); + } + else + { + Semaphore_post(FFS_Sem); + } } - } } @@ -323,10 +329,11 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) Buffer = my_malloc (MAX_CHUNK_LENGTH); if (Buffer != NULL) { - Fresult = f_read(SentFileHandle,Buffer,2000,&ReadBytes ); + Fresult = f_read(SentFileHandle,Buffer,MAX_CHUNK_LENGTH,&ReadBytes ); if(Fresult != FR_OK) { - LOG_ERROR (Fresult,"f_write error"); + LOG_ERROR (Fresult,"f_read error"); + Semaphore_post(FFS_Sem); } else { @@ -334,6 +341,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) response.buffer.len = ReadBytes; response.buffer.data = Buffer; FileSentLength += ReadBytes; + Report("sending data to MS", __FILE__, ReadBytes, FileSentLength, RpWarning, (int)FileLength, 0); if (FileSentLength == FileLength) { REPORT_MSG (FileSentLength,"file download ended successfully"); diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 32e149968..716ae7fe4 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -26,9 +26,8 @@ #define USE_POWERSTEP01 //#define SPECIAL_DISPENSERS -#define Use_Head_Card //for real card only -#define Use_WHS_Card //for real card only -//#define Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 +//#define Use_Head_Card //for real card only +//#define Use_WHS_Card //for real card only #define I2C_2_Data_Transfer_Rate_400kbps #define I2C_3_Data_Transfer_Rate_400kbps// Head card + WHS card diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index f182ec09c..1684b1dcc 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -539,7 +539,10 @@ uint32_t ActivateHeadMagnet() F2_CTRL = F2_CTRL_Reg.ushort; if (isMotorConfigured(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM)) { - MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_CLOSE ); + if (MotorDriverResponse[HARDWARE_MOTOR_TYPE__MOTO_RLOADARM].DriverType == CombinrdMotDriver) + MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_OPEN ); + else + MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_CLOSE ); } } MagnetControlId = AddControlCallback(NULL, MagnetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); @@ -566,7 +569,10 @@ uint32_t DeActivateHeadMagnet() Report("DeActivateHeadMagnet - open the lid magnet",__FILE__,__LINE__,(int)HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,RpWarning,(int)DH_LID_CLOSE,0); if (isMotorConfigured(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM)) { - MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_OPEN ); + if (MotorDriverResponse[HARDWARE_MOTOR_TYPE__MOTO_RLOADARM].DriverType == CombinrdMotDriver) + MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_CLOSE ); + else + MotorGoTo(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM,DH_LID_OPEN ); //MotorGotoWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RLOADARM, DH_LID_OPEN, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADARM], NULL,1000); } F2_CTRL_Reg.ushort |= SPARE_SSR13_CTRL; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index a23e405dc..43dea9e24 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -480,15 +480,13 @@ void FPGA_SetMotorsInit() { uint8_t i=0; - #ifdef USE_POWERSTEP01 //since powerstep in stby on powerup) - F1_Moto_Driver_NSTBYRST1 = 0xFFFF; - F1_Moto_Driver_NSTBYRST2 = 0xFFFF; - F2_Moto_Driver_NSTBYRST1 = 0xFFFF; - F3_Moto_Driver_NSTBYRST1 = 0xFFFF; + F1_Moto_Driver_NSTBYRST1 = 0xFFFF; + F1_Moto_Driver_NSTBYRST2 = 0xFFFF; + F2_Moto_Driver_NSTBYRST1 = 0xFFFF; + F3_Moto_Driver_NSTBYRST1 = 0xFFFF; - SysCtlDelay(120000);//1mSec - #endif + SysCtlDelay(120000);//1mSec for(i=0;i<NUM_OF_MOTORS;i++) { diff --git a/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c b/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c index 57f96fbbf..df05156e4 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c +++ b/Software/Embedded_SW/Embedded/Drivers/Heater/Heater.c @@ -114,6 +114,9 @@ uint32_t ActivateHeater (int HeaterId) { F2_CTRL_Reg.ushort |= portMap[HeaterId].m_pin; F2_CTRL = F2_CTRL_Reg.ushort; + portMap[HeaterId].Active = true; + //--------------------------------------------------------------------------------------- + HeaterActive |= 1 << HeaterId; } else { //F2_CTRL |= portMap[HeaterId].m_pin; @@ -177,6 +180,8 @@ uint32_t DeActivateHeater (int HeaterId) //F2_CTRL &= ~portMap[HeaterId].m_pin; F2_CTRL_Reg.ushort &= ~portMap[HeaterId].m_pin; F2_CTRL = F2_CTRL_Reg.ushort; + portMap[HeaterId].Active = false; + HeaterActive &= ~(1 << HeaterId); } else { diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/EEPROM/Head_EEPROM.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/EEPROM/Head_EEPROM.c index a2f003840..9b17ae0dd 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/EEPROM/Head_EEPROM.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/EEPROM/Head_EEPROM.c @@ -127,14 +127,5 @@ uint32_t Check_Head_Type_Via_EEPROM() Head_Type = Head_struct.Read_Head_EEPROM.bytes.HeadType; } - //temporary - #ifdef Use_Head_Card - Head_Type = HEAD_TYPE_SYLKO; - #else - Head_Type = HEAD_TYPE_SYLKO_WITHOUT_CARD; - #endif - - //TODO to test and replace #ifdef Use_Head_Card with if(Head_Type != HEAD_TYPE_SYLKO_WITHOUT_CARD) - return status; } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/Fan/fan_click.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/Fan/fan_click.c index 87616e52a..6a37a2003 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/Fan/fan_click.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/Fan/fan_click.c @@ -279,11 +279,7 @@ void Test_Head_fan_Click() static uint8_t once = 1; if (once) { - #ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 - Select_Main_Head_Mux_Channel_test(); - #else - Select_Main_Head_Mux_Channel(); - #endif + Select_Main_Head_Mux_Channel(); //once = 0; } @@ -299,11 +295,7 @@ uint8_t Head_Fan_PWM_Control(uint8_t Fan_ID, uint8_t PWM) { uint8_t status = OK; - #ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 - Select_Main_Head_Mux_Channel_test(); - #else - Select_Main_Head_Mux_Channel(); - #endif + Select_Main_Head_Mux_Channel(); if(Fan_ID < 0x02) { diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.h index 24eb5bfe7..4709f5d92 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.h @@ -18,11 +18,7 @@ The I2C addresses on the board: //#include "Drivers/I2C_Communication/PT100/PT100_ADC.h" //I2C MAIM OUTPUT 12v: -#ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 - #define I2C_ID_HEAD_CARD 0x04 // 4 for testing via dispenser card 0x03 -#else - #define I2C_ID_HEAD_CARD 0x03 // -#endif +#define I2C_ID_HEAD_CARD 0x03 // #define I2C3_MAIN_MUX_TCA9548A_0xE2 0xE2 //SD4 - MCU_SPARE1_SDA , SC4 - MCU_SPARE1_SCL //---------------------------------------------------------- diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.c index 47bbb7b60..8ed492ccc 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.c @@ -238,66 +238,60 @@ uint32_t HeadADCPT100_WriteReg(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint8_t reg, return Status; } - - -#ifdef Use_Head_Card - uint8_t HeadADCPT100_InitConfigReg() { uint8_t i; - - for(i=HEAD_PT100_ZONE_1_0X80_0;i < MAX_HEAD_CARD_TEMP_SENS_ID;i++) // for now we are using the same configuration to all of them + if (Head_Type >= HEAD_TYPE_SYLKO)//adjust the limit switches { - // - - - - - - - - - - Reg0 - - - - - - - - - - - HeadTempSensConfig[i].Reg0.bits.PGA_BYPASS = ADS122X_USE_PGA ;//Bit 0 - HeadTempSensConfig[i].Reg0.bits.GAIN = ADS122X_GAIN_8 ;//Bits 1-3 - //HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 + for(i=HEAD_PT100_ZONE_1_0X80_0;i < MAX_HEAD_CARD_TEMP_SENS_ID;i++) // for now we are using the same configuration to all of them + { + // - - - - - - - - - - Reg0 - - - - - - - - - - + HeadTempSensConfig[i].Reg0.bits.PGA_BYPASS = ADS122X_USE_PGA ;//Bit 0 + HeadTempSensConfig[i].Reg0.bits.GAIN = ADS122X_GAIN_8 ;//Bits 1-3 + //HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 - // - - - - - - - - - - Reg1 - - - - - - - - - - + // - - - - - - - - - - Reg1 - - - - - - - - - - - HeadTempSensConfig[i].Reg1.bits.TS = ADS122X_TEMP_SENSOR_OFF ;//Bit 0 - HeadTempSensConfig[i].Reg1.bits.VREF = ADS122X_VREF_EXT_REF0_PINS ;//Bits 1-2 - HeadTempSensConfig[i].Reg1.bits.CM = ADS122X_CONVERSION_CONTINUOUS ;//Bit 3 - HeadTempSensConfig[i].Reg1.bits.MODE = ADS122X_OP_MODE_NORMAL ;//Bit 4 - HeadTempSensConfig[i].Reg1.bits.DR = ADS122X_DATA_RATE_20SPS ;//Bits 5-7 + HeadTempSensConfig[i].Reg1.bits.TS = ADS122X_TEMP_SENSOR_OFF ;//Bit 0 + HeadTempSensConfig[i].Reg1.bits.VREF = ADS122X_VREF_EXT_REF0_PINS ;//Bits 1-2 + HeadTempSensConfig[i].Reg1.bits.CM = ADS122X_CONVERSION_CONTINUOUS ;//Bit 3 + HeadTempSensConfig[i].Reg1.bits.MODE = ADS122X_OP_MODE_NORMAL ;//Bit 4 + HeadTempSensConfig[i].Reg1.bits.DR = ADS122X_DATA_RATE_20SPS ;//Bits 5-7 - // - - - - - - - - - - Reg2 - - - - - - - - - - + // - - - - - - - - - - Reg2 - - - - - - - - - - - HeadTempSensConfig[i].Reg2.bits.IDAC = ADS122X_IDAC_CURRENT_1000_UA ;//Bits 0-2 - HeadTempSensConfig[i].Reg2.bits.BCS = ADS122X_BCS_CURRENT_SOURCES_OFF ;//Bit 3 - HeadTempSensConfig[i].Reg2.bits.CRC = ADS122X_CRC_DISABLED ;//BitS 4-5 - HeadTempSensConfig[i].Reg2.bits.DCNT = ADS122X_DCNT_CONVERSION_COUNTER_DISABLED ;//Bit 6 - HeadTempSensConfig[i].Reg2.bits.DRDY = ADS122X_DRDY_NO_NEW_CONVERSION ;//Bit 7 + HeadTempSensConfig[i].Reg2.bits.IDAC = ADS122X_IDAC_CURRENT_1000_UA ;//Bits 0-2 + HeadTempSensConfig[i].Reg2.bits.BCS = ADS122X_BCS_CURRENT_SOURCES_OFF ;//Bit 3 + HeadTempSensConfig[i].Reg2.bits.CRC = ADS122X_CRC_DISABLED ;//BitS 4-5 + HeadTempSensConfig[i].Reg2.bits.DCNT = ADS122X_DCNT_CONVERSION_COUNTER_DISABLED ;//Bit 6 + HeadTempSensConfig[i].Reg2.bits.DRDY = ADS122X_DRDY_NO_NEW_CONVERSION ;//Bit 7 - // - - - - - - - - - - Reg3 - - - - - - - - - - - HeadTempSensConfig[i].Reg3.bits.Always_write_0 = ADS122X_RESERVED_WRITE_0 ;//BitS 0-1 Always write 0 - HeadTempSensConfig[i].Reg3.bits.I2MUX = ADS122X_IDAC2_AIN3 ;//Bits 2-4 - HeadTempSensConfig[i].Reg3.bits.I1MUX = ADS122X_IDAC1_AIN0 ;//Bits 5-7 + // - - - - - - - - - - Reg3 - - - - - - - - - - + HeadTempSensConfig[i].Reg3.bits.Always_write_0 = ADS122X_RESERVED_WRITE_0 ;//BitS 0-1 Always write 0 + HeadTempSensConfig[i].Reg3.bits.I2MUX = ADS122X_IDAC2_AIN3 ;//Bits 2-4 + HeadTempSensConfig[i].Reg3.bits.I1MUX = ADS122X_IDAC1_AIN0 ;//Bits 5-7 - } + } - for(i=HEAD_PT100_ZONE_1_0X80_0;i < HEAD_PT100_ZONE_2_0X80_1;i++) - { - HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 - HeadTempSensConfig[i].SEL = HEAD_CONFIG_ODD_PT100_PT_SEL; - } + for(i=HEAD_PT100_ZONE_1_0X80_0;i < HEAD_PT100_ZONE_2_0X80_1;i++) + { + HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 + HeadTempSensConfig[i].SEL = HEAD_CONFIG_ODD_PT100_PT_SEL; + } - for(i=HEAD_PT100_ZONE_2_0X80_1;i < HEAD_PT100_RESERVE_0X8E_1;i++) - { - HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_EVEN_PT100_MUX ;//Bits 4-7 - HeadTempSensConfig[i].SEL = HEAD_CONFIG_EVEN_PT100_PT_SEL; - } + for(i=HEAD_PT100_ZONE_2_0X80_1;i < HEAD_PT100_RESERVE_0X8E_1;i++) + { + HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_EVEN_PT100_MUX ;//Bits 4-7 + HeadTempSensConfig[i].SEL = HEAD_CONFIG_EVEN_PT100_PT_SEL; + } - HeadTempSensConfig[i].Config = 0; + HeadTempSensConfig[i].Config = 0; - HeadTempSensConfig[i].MUX_Status = UNKNOWN; + HeadTempSensConfig[i].MUX_Status = UNKNOWN; - return OK; -} -#else - uint8_t HeadADCPT100_InitConfigReg() + } + else { - uint8_t i; for(i=HEAD_PT100_ZONE_1_0X80_0;i<MAX_HEAD_CARD_TEMP_SENS_ID; i++) { @@ -328,10 +322,10 @@ uint8_t HeadADCPT100_InitConfigReg() HeadTempSensConfig[i].Reg3.bits.I1MUX = ADS122X_IDAC1_AIN3 ;//Bits 5-7 } - - return OK; } -#endif + + return OK; +} uint32_t HeadADCPT100_Config_callback(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint32_t Stage) { @@ -606,11 +600,7 @@ uint32_t Test_HeadCard_PT100(TEMPERATURE_SENSOR_ID_ENUM SensorId) uint32_t Status = OK; //uint8_t i = 0; - #ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 - Select_Main_Head_Mux_Channel_test(); - #else - Select_Main_Head_Mux_Channel(); - #endif + Select_Main_Head_Mux_Channel(); //HeadADCPT100_Reset(); //HeadADCPT100_InitConfigReg(); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c index 27ae72084..c6b8dbf39 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c @@ -82,12 +82,9 @@ void Trigger_Heater_Current_Read(void) I2C_ReadingMessage.parameter = NUM_OF_CURRENT_HEATERS; if (I2C_ReadingMsgQ != NULL) Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); - I2C_ReadingMessage.parameter = HEATER_DRYER_CURRENT_1; - if (I2C_ReadingMsgQ != NULL) - Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); - I2C_ReadingMessage.parameter = HEATER_DRYER_CURRENT_2; - if (I2C_ReadingMsgQ != NULL) - Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); + + Read_Heaters_Current(HEATER_DRYER_CURRENT_1); + Read_Heaters_Current(HEATER_DRYER_CURRENT_2); return; @@ -302,17 +299,17 @@ void Trigger_SetWHSBlowerVoltage (uint16_t voltage) return; } -void Trigger_WHS_Set_Blower_Control_Closed_Loop (uint32_t setpoint_Q) -{ - I2C_ReadingMessageStruc I2C_ReadingMessage; - - I2C_ReadingMessage.messageId = WHS_SETPOINT_Q_BLOWER; - I2C_ReadingMessage.parameter = setpoint_Q; - - if (I2C_ReadingMsgQ != NULL) - Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); - return; -} +//void Trigger_WHS_Set_Blower_Control_Closed_Loop (uint32_t setpoint_Q) +//{ +// I2C_ReadingMessageStruc I2C_ReadingMessage; +// +// I2C_ReadingMessage.messageId = WHS_SETPOINT_Q_BLOWER; +// I2C_ReadingMessage.parameter = setpoint_Q; +// +// if (I2C_ReadingMsgQ != NULL) +// Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); +// return; +//} //void Trigger_WHS_Set_Valve(uint8_t valve_number, bool status) @@ -440,8 +437,8 @@ void I2C_ReadingTask(UArg arg0, UArg arg1) //Report("Read_Heaters_Current",__FILE__,__LINE__,255,RpWarning,0,0); if((Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)&&(I2C_ReadingMessage.parameter>=HEATER_DRYER_CURRENT_3)) Read_Head_ADC(I2C_ReadingMessage.parameter); - else - Read_Heaters_Current(I2C_ReadingMessage.parameter); +// else +// Read_Heaters_Current(I2C_ReadingMessage.parameter); break; case PT100_Reading: Set_HeadCard_PT100(); @@ -514,11 +511,10 @@ void I2C_ReadingTask(UArg arg0, UArg arg1) WHS_Set_Volt_Blower_Control(I2C_ReadingMessage.parameter); //(fan_number, 0x20) break; - case WHS_SETPOINT_Q_BLOWER: - - dbl_setpoint_Q = (double)(I2C_ReadingMessage.parameter / 100) ; - WHS_Set_Blower_Control_Closed_Loop(dbl_setpoint_Q); - break; +// case WHS_SETPOINT_Q_BLOWER: +// dbl_setpoint_Q = (double)(I2C_ReadingMessage.parameter / 100) ; +// WHS_Set_Blower_Control_Closed_Loop(dbl_setpoint_Q); +// break; case WHS_SET_VAlVE_CARTRIDGE: // Set_WHS_valve(VALVE_0, I2C_ReadingMessage.parameter, 0); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h index b16e87766..c34191c0a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h @@ -27,7 +27,7 @@ void Trigger_WHS_PT100_Read_All(void); void Trigger_ReadWHSPT100(uint8_t PT100_Id); //void Trigger_WHS_Set_Volt_Blower_Control(uint16_t volt); void Trigger_SetWHSBlowerVoltage (uint16_t voltage); -void Trigger_WHS_Set_Blower_Control_Closed_Loop (uint32_t setpoint_Q); +//void Trigger_WHS_Set_Blower_Control_Closed_Loop (uint32_t setpoint_Q); //void Trigger_WHS_Set_Valve(uint8_t valve_number, bool status); void Trigger_SetWHSValveWatseCartridge(uint8_t Cart_Id); //void Trigger_WHS_Set_Pump(bool status); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/ADS122X04_Driver.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/ADS122X04_Driver.c index 2316b3387..97b572697 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/ADS122X04_Driver.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/ADS122X04_Driver.c @@ -481,11 +481,7 @@ bool D_ADS122_InitConfigReg() // uint32_t Status = OK; // uint8_t i = 0; // -// #ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 -// Select_Main_Head_Mux_Channel_test(); -// #else -// Select_Main_Head_Mux_Channel(); -// #endif +// Select_Main_Head_Mux_Channel(); // // //HeadADCPT100_Reset(); // HeadADCPT100_InitConfigReg(); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/WHS_PT100_ADC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/WHS_PT100_ADC.c index d34787671..6cfdee163 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/WHS_PT100_ADC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/WHS_PT100_ADC.c @@ -293,652 +293,6 @@ bool Test_WHS_PT100_ADC() status |= WHS_PT100_Read(/*TEMPERATURE_SENSOR_ID_ENUM*/ WHS_PT100_2_0X80_1); status |= WHS_PT100_Read(/*TEMPERATURE_SENSOR_ID_ENUM*/ WHS_PT100_4_0X82_1); - - - /* - * WHS_PT100_1_0X80_0, -WHS_PT100_2_0X80_1, -WHS_PT100_3_0X82_0, -WHS_PT100_4_0X82_1, - * */ - - return status; -} - - -//D_ADS122C04_TempSensConfigStruc HeadTempSensConfig[MAX_HEAD_CARD_TEMP_SENS_ID];//using only from HEAD_PT100_ZONE_1_0X80_0 -// -//uint32_t was_I2C_ADC_ADS122C04_SLAVE_ADD = 0x80; //A0-GND A1-GND 4-Bit, 4-Channel, 2-kSPS, ADC ------ PT100 ADC – 0x80 … 0x87. -// -//uint8_t was_Save_Sel_Status = UNKNOWN; - -//uint32_t SensorId_To_SlaveAdd(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// switch(SensorId) -// { -// case HEAD_PT100_ZONE_1_0X80_0: -// case HEAD_PT100_ZONE_2_0X80_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x80; -// break; -// case HEAD_PT100_ZONE_3_0X82_0: -// case HEAD_PT100_ZONE_4_0X82_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x82; -// break; -// case HEAD_PT100_ZONE_5_0X84_0: -// case HEAD_PT100_ZONE_6_0X84_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x84; -// break; -// case HEAD_PT100_ZONE_7_0X86_0: -// case HEAD_PT100_ZONE_8_0X86_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x86; -// break; -// case HEAD_PT100_ZONE_9_0X88_0: -// case HEAD_PT100_ZONE_10_0X88_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x88; -// break; -// case HEAD_PT100_ZONE_11_0X8A_0: -// case HEAD_PT100_ZONE_12_0X8A_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x8A; -// break; -// case HEAD_PT100_AIR_HEATER_1_0X8C_0: -// case HEAD_PT100_AIR_HEATER_2_0X8C_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x8C; -// break; -// case HEAD_PT100_MIXER_0X8E_0: -// case HEAD_PT100_RESERVE_0X8E_1: -// I2C_ADC_ADS122C04_SLAVE_ADD = 0x8E; -// break; -// default: -// break; -// } -// -// return I2C_ADC_ADS122C04_SLAVE_ADD; -//} - -//uint32_t I2C_Write_SensorId(uint32_t I2C_ID, TEMPERATURE_SENSOR_ID_ENUM SensorId, uint32_t *I2C_Write_buf, uint32_t No_BytesToWrite ) -//{ -// uint32_t status = OK; -// -// I2C_ADC_ADS122C04_SLAVE_ADD = SensorId_To_SlaveAdd(SensorId); -// status |= I2C_Write(I2C_ID, I2C_ADC_ADS122C04_SLAVE_ADD, I2C_Write_buf, No_BytesToWrite); -// -// return status; -//} - -//uint32_t HeadADCPT100_ControlMux_Brfore_Reading(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Status = OK; -// -// uint8_t Write_Buf[2]; -// -// if(SensorId % 2) -// HeadTempSensConfig[SensorId].Reg0.bits.MUX = 0x03; // TBD -// else -// HeadTempSensConfig[SensorId].Reg0.bits.MUX = 0x04; // TBD -// -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_0_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg0.Byte; -// -// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 1); -// -// return Status; -//} - - -//uint32_t was_I2C_Read_SensorId(uint32_t I2C_ID, TEMPERATURE_SENSOR_ID_ENUM SensorId, uint32_t *I2C_Read_buf, uint32_t No_BytesToRead ) -//{ -// uint32_t status = OK; -// -// //HeadADCPT100_ControlMux_Brfore_Reading(SensorId); -// //TODO Choose TEMP1 sensor by I/O -// was_I2C_ADC_ADS122C04_SLAVE_ADD = SensorId_To_SlaveAdd(SensorId); -// status |= I2C_Read(I2C_ID, was_I2C_ADC_ADS122C04_SLAVE_ADD + 1, I2C_Read_buf, No_BytesToRead); -// -// return status; -//} - -//uint32_t was_HeadADCPT100_Reset(void) -//{ -// uint32_t status = OK; -// #ifndef EVALUATION_BOARD -// uint8_t i; -// uint8_t Write_Buf[1]; -// -// for(i=HEAD_PT100_ZONE_1_0X80_0;i<MAX_HEAD_CARD_TEMP_SENS_ID; i++) -// { -// //Reset the device -// Write_Buf[0] = ADS122X_RESET_CMD; -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -//// status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, i, Write_Buf, 1); -// //status |= I2C_Write(I2C_ID_HEAD_CARD, I2C_ADC_ADS122C04_SLAVE_ADD, Write_Buf, 1); -// //Wait at least (50 us + 32 · t(CLK)) after the RESET command is sent before sending any other command. -// -// } -// #endif -// SysCtlDelay(100); // Must delay after hard reset -// -// return status; -//} - - -//uint32_t was_HeadADCPT100_StartSync(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Status = OK; -// uint8_t Write_Buf[1]; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// Status = ERROR; -// -// Write_Buf[0] = ADS122X_START_CMD; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -// -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 1); -// //Status |= I2C_Write(I2C_ID_HEAD_CARD, I2C_ADC_ADS122C04_SLAVE_ADD, Write_Buf, 1); -// -// return Status; -//} - -//uint32_t was_HeadADCPT100_PowerDown(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Status = OK; -// uint8_t Write_Buf[1]; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// Status = ERROR; -// -// Write_Buf[0] = ADS122X_POWERDOWN_CMD; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 1); -// //Status |= I2C_Write(I2C_ID_HEAD_CARD, I2C_ADC_ADS122C04_SLAVE_ADD, Write_Buf, 1); -// -// return Status; -//} - -//uint32_t was_Data_ADC_Head = 0; -//uint32_t was_HeadADCPT100_SendReadDataCommand(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Status = OK; -// uint8_t Write_Buf[1]; -// -// uint32_t temp; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// Status = ERROR; -// -// //Write_Buf[0] = ADS122X_RDATA_CMD; -// Write_Buf[0] = ADS122X_RDATA_CMD; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 1); -// //Status |= I2C_Write(I2C_ID_HEAD_CARD, I2C_ADC_ADS122C04_SLAVE_ADD, Write_Buf, 1); -// -//// Status |= I2C_Read_SensorId(I2C_ID_HEAD_CARD, SensorId, &temp, 3); -// was_Data_ADC_Head = (temp & 0xFF0000) >> 16 | (temp & 0xFF00) | (temp & 0x0000FF) << 16;//First send the MSB so we need to reorder the bytes -// -// CalculateTemperatures(SensorId, was_Data_ADC_Head); -// -// -// return Status; -//} - -//uint32_t was_HeadADCPT100_WriteReg(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint8_t reg, uint8_t writeValue) -//{ -// uint32_t Status = OK; -// uint8_t Write_Buf[2]; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// Status = ERROR; -// -// Write_Buf[0] = ADS122X_WRITE_CMD(reg); -// Write_Buf[1] = writeValue; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 2); -// //Status |= I2C_Write(I2C_ID_HEAD_CARD, I2C_ADC_ADS122C04_SLAVE_ADD, Write_Buf, 2); -// -// return Status; -//} - - - -//#ifdef Use_Head_Card -// -//uint8_t was_HeadADCPT100_InitConfigReg() -//{ -// uint8_t i; -// -// for(i=HEAD_PT100_ZONE_1_0X80_0;i < MAX_HEAD_CARD_TEMP_SENS_ID;i++) // for now we are using the same configuration to all of them -// { -// // - - - - - - - - - - Reg0 - - - - - - - - - - -// HeadTempSensConfig[i].Reg0.bits.PGA_BYPASS = ADS122X_USE_PGA ;//Bit 0 -// HeadTempSensConfig[i].Reg0.bits.GAIN = ADS122X_GAIN_8 ;//Bits 1-3 -// //HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 -// -// // - - - - - - - - - - Reg1 - - - - - - - - - - -// -// HeadTempSensConfig[i].Reg1.bits.TS = ADS122X_TEMP_SENSOR_OFF ;//Bit 0 -// HeadTempSensConfig[i].Reg1.bits.VREF = ADS122X_VREF_INTERNAL ;//Bits 1-2 -// HeadTempSensConfig[i].Reg1.bits.CM = ADS122X_CONVERSION_CONTINUOUS ;//Bit 3 -// HeadTempSensConfig[i].Reg1.bits.MODE = ADS122X_OP_MODE_NORMAL ;//Bit 4 -// HeadTempSensConfig[i].Reg1.bits.DR = ADS122X_DATA_RATE_20SPS ;//Bits 5-7 -// -// // - - - - - - - - - - Reg2 - - - - - - - - - - -// -// HeadTempSensConfig[i].Reg2.bits.IDAC = ADS122X_IDAC_CURRENT_1000_UA ;//Bits 0-2 -// HeadTempSensConfig[i].Reg2.bits.BCS = ADS122X_BCS_CURRENT_SOURCES_OFF ;//Bit 3 -// HeadTempSensConfig[i].Reg2.bits.CRC = ADS122X_CRC_DISABLED ;//BitS 4-5 -// HeadTempSensConfig[i].Reg2.bits.DCNT = ADS122X_DCNT_CONVERSION_COUNTER_DISABLED ;//Bit 6 -// HeadTempSensConfig[i].Reg2.bits.DRDY = ADS122X_DRDY_NO_NEW_CONVERSION ;//Bit 7 -// -// // - - - - - - - - - - Reg3 - - - - - - - - - - -// HeadTempSensConfig[i].Reg3.bits.Always_write_0 = ADS122X_RESERVED_WRITE_0 ;//BitS 0-1 Always write 0 -// HeadTempSensConfig[i].Reg3.bits.I2MUX = ADS122X_IDAC2_AIN3 ;//Bits 2-4 -// HeadTempSensConfig[i].Reg3.bits.I1MUX = ADS122X_IDAC1_AIN0 ;//Bits 5-7 -// -// } -// -// for(i=HEAD_PT100_ZONE_1_0X80_0;i < MAX_HEAD_CARD_TEMP_SENS_ID_0;i++) -// { -// HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX ;//Bits 4-7 -// HeadTempSensConfig[i].SEL = ODD; -// } -// -// for(i=HEAD_PT100_ZONE_2_0X80_1;i < MAX_HEAD_CARD_TEMP_SENS_ID_1;i++) -// { -// HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_EVEN_PT100_MUX ;//Bits 4-7 -// HeadTempSensConfig[i].SEL = EVEN; -// } -// -// HeadTempSensConfig[i].Config = 0; -// -// HeadTempSensConfig[i].MUX_Status = UNKNOWN; -// -// return OK; -//} -//#else -// uint8_t was_HeadADCPT100_InitConfigReg() -// { -// uint8_t i; -// -// for(i=HEAD_PT100_ZONE_1_0X80_0;i<MAX_HEAD_CARD_TEMP_SENS_ID; i++) -// { -// // - - - - - - - - - - Reg0 - - - - - - - - - - -// HeadTempSensConfig[i].Reg0.bits.PGA_BYPASS = ADS122X_PGA_ENABLE ;//Bit 0 -// HeadTempSensConfig[i].Reg0.bits.GAIN = ADS122X_GAIN_8 ;//Bits 1-3 -// HeadTempSensConfig[i].Reg0.bits.MUX = ADS122X_MUX_AIN1_AIN0 ;//Bits 4-7 -// -// // - - - - - - - - - - Reg1 - - - - - - - - - - -// -// HeadTempSensConfig[i].Reg1.bits.TS = ADS122X_TEMP_SENSOR_OFF ;//Bit 0 -// HeadTempSensConfig[i].Reg1.bits.VREF = ADS122X_VREF_INTERNAL ;//Bits 1-2 -// HeadTempSensConfig[i].Reg1.bits.CM = ADS122X_CONVERSION_CONTINUOUS ;//Bit 3 -// HeadTempSensConfig[i].Reg1.bits.MODE = ADS122X_OP_MODE_NORMAL ;//Bit 4 -// HeadTempSensConfig[i].Reg1.bits.DR = ADS122X_DATA_RATE_20SPS ;//Bits 5-7 -// -// // - - - - - - - - - - Reg2 - - - - - - - - - - -// -// HeadTempSensConfig[i].Reg2.bits.IDAC = ADS122X_IDAC_CURRENT_500_UA ;//Bits 0-2 -// HeadTempSensConfig[i].Reg2.bits.BCS = ADS122X_BCS_CURRENT_SOURCES_OFF ;//Bit 3 -// HeadTempSensConfig[i].Reg2.bits.CRC = ADS122X_CRC_DISABLED ;//BitS 4-5 -// HeadTempSensConfig[i].Reg2.bits.DCNT = ADS122X_DCNT_CONVERSION_COUNTER_DISABLED ;//Bit 6 -// HeadTempSensConfig[i].Reg2.bits.DRDY = ADS122X_DRDY_NO_NEW_CONVERSION ;//Bit 7 -// -// // - - - - - - - - - - Reg3 - - - - - - - - - - -// HeadTempSensConfig[i].Reg3.bits.Always_write_0 = ADS122X_RESERVED_WRITE_0 ;//BitS 0-1 Always write 0 -// HeadTempSensConfig[i].Reg3.bits.I2MUX = ADS122X_IDAC2_DISABLED ;//Bits 2-4 -// HeadTempSensConfig[i].Reg3.bits.I1MUX = ADS122X_IDAC1_AIN3 ;//Bits 5-7 -// -// } -// -// return OK; -// } -//#endif - -//uint32_t was_HeadADCPT100_Config_callback(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint32_t Stage) -//{ -// uint32_t Status = OK; -// -// #ifndef EVALUATION_BOARD -// -// uint8_t Write_Buf[2]; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// return ERROR; -// -// if(HeadTempSensConfig[SensorId].Config == DONE) -// return Status; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -// -// switch(Stage) -// { -// case SENSOR_CONFIG_REG0: -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_0_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg0.Byte; -// break; -// case SENSOR_CONFIG_REG1: -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_1_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg1.Byte; -// break; -// case SENSOR_CONFIG_REG2: -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_2_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg2.Byte; -// break; -// case SENSOR_CONFIG_REG3: -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_3_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg3.Byte; -// break; -// default: -// Status = ERROR; -// } -// -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 2); -// -// switch(SensorId) -// { -// case HEAD_PT100_ZONE_1_0X80_0: -// case HEAD_PT100_ZONE_2_0X80_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_1_0X80_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_2_0X80_1].Config = DONE; -// break; -// case HEAD_PT100_ZONE_3_0X82_0: -// case HEAD_PT100_ZONE_4_0X82_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_3_0X82_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_4_0X82_1].Config = DONE; -// break; -// case HEAD_PT100_ZONE_5_0X84_0: -// case HEAD_PT100_ZONE_6_0X84_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_5_0X84_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_6_0X84_1].Config = DONE; -// break; -// case HEAD_PT100_ZONE_7_0X86_0: -// case HEAD_PT100_ZONE_8_0X86_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_7_0X86_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_8_0X86_1].Config = DONE; -// break; -// case HEAD_PT100_ZONE_9_0X88_0: -// case HEAD_PT100_ZONE_10_0X88_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_9_0X88_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_10_0X88_1].Config = DONE; -// break; -// case HEAD_PT100_ZONE_11_0X8A_0: -// case HEAD_PT100_ZONE_12_0X8A_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_11_0X8A_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_ZONE_12_0X8A_1].Config = DONE; -// break; -// case HEAD_PT100_AIR_HEATER_1_0X8C_0: -// case HEAD_PT100_AIR_HEATER_2_0X8C_1: -// HeadTempSensConfig[HEAD_PT100_AIR_HEATER_1_0X8C_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_AIR_HEATER_2_0X8C_1].Config = DONE; -// break; -// case HEAD_PT100_MIXER_0X8E_0: -// case HEAD_PT100_RESERVE_0X8E_1: -// HeadTempSensConfig[HEAD_PT100_MIXER_0X8E_0].Config = DONE; -// HeadTempSensConfig[HEAD_PT100_RESERVE_0X8E_1].Config = DONE; -// break; -// default: -// break; -// } -// -// #endif -// -// return Status; -//} - -//void was_HeadADCPT100_SensorInitConfig() -//{ -// int Sensor=0,Register = 0; -// -// HeadADCPT100_InitConfigReg(); // Initial the configuration registers -// -// for(Register=0;Register<=SENSOR_CONFIG_REG3;Register++) -// { -// for(Sensor=HEAD_PT100_ZONE_1_0X80_0;Sensor<MAX_HEAD_CARD_TEMP_SENS_ID; Sensor++) -// { -// HeadADCPT100_Config_callback( (TEMPERATURE_SENSOR_ID_ENUM)(Sensor), Register); -// } -// SysCtlDelay(1000); -// } -//} -/* -uint32_t was_HeadCard_Toggle_PT100(bool Odd_OR_Even)//ODD/EVEN -{ - uint32_t status = OK; - uint8_t i=0; - uint8_t Write_Buf[2]; - - was_HeadCard_Toggle_PT100_SEL(Odd_OR_Even); - - if(Odd_OR_Even == EVEN) - { - for(i=HEAD_PT100_ZONE_2_0X80_1;i < MAX_HEAD_CARD_TEMP_SENS_ID;i=i+2) - { - HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_EVEN_PT100_MUX;//Reg0 Bits 4-7 - - Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_0_REG<<2); - Write_Buf[1] = HeadTempSensConfig[i].Reg0.Byte; - - status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, i, Write_Buf, 2); - } - } - else - { - for(i=HEAD_PT100_ZONE_1_0X80_0;i < MAX_HEAD_CARD_TEMP_SENS_ID;i=i+2) - { - HeadTempSensConfig[i].Reg0.bits.MUX = HEAD_CONFIG_ODD_PT100_MUX;//Reg0 Bits 4-7 - - Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_0_REG<<2); - Write_Buf[1] = HeadTempSensConfig[i].Reg0.Byte; - - status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, i, Write_Buf, 2); - } - } - return status; } -*/ - -//uint32_t was_HeadCard_Toggle_PT100(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t status = OK; -// uint8_t Write_Buf[2]; -// -// if((SensorId < HEAD_PT100_ZONE_1_0X80_0) || (SensorId > MAX_HEAD_CARD_TEMP_SENS_ID)) -// return ERROR; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -// -//// if(was_Save_Sel_Status != HeadTempSensConfig[SensorId].SEL) -//// { -//// was_HeadCard_Toggle_PT100_SEL(HeadTempSensConfig[SensorId].SEL); -//// was_Save_Sel_Status = HeadTempSensConfig[SensorId].SEL; -//// } -// -// if(HeadTempSensConfig[SensorId].MUX_Status != HeadTempSensConfig[SensorId].Reg0.bits.MUX) -// { -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_0_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg0.Byte; -// -//// status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 2); -// -// switch(SensorId) -// { -// case HEAD_PT100_ZONE_1_0X80_0: -// case HEAD_PT100_ZONE_2_0X80_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_1_0X80_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_2_0X80_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_ZONE_3_0X82_0: -// case HEAD_PT100_ZONE_4_0X82_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_3_0X82_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_4_0X82_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_ZONE_5_0X84_0: -// case HEAD_PT100_ZONE_6_0X84_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_5_0X84_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_6_0X84_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_ZONE_7_0X86_0: -// case HEAD_PT100_ZONE_8_0X86_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_7_0X86_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_8_0X86_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_ZONE_9_0X88_0: -// case HEAD_PT100_ZONE_10_0X88_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_9_0X88_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_10_0X88_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_ZONE_11_0X8A_0: -// case HEAD_PT100_ZONE_12_0X8A_1: -// HeadTempSensConfig[HEAD_PT100_ZONE_11_0X8A_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_ZONE_12_0X8A_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_AIR_HEATER_1_0X8C_0: -// case HEAD_PT100_AIR_HEATER_2_0X8C_1: -// HeadTempSensConfig[HEAD_PT100_AIR_HEATER_1_0X8C_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_AIR_HEATER_2_0X8C_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// case HEAD_PT100_MIXER_0X8E_0: -// case HEAD_PT100_RESERVE_0X8E_1: -// HeadTempSensConfig[HEAD_PT100_MIXER_0X8E_0].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// HeadTempSensConfig[HEAD_PT100_RESERVE_0X8E_1].MUX_Status = TempSensConfig[SensorId].Reg0.bits.MUX; -// break; -// default: -// break; -// } -// } -// return status; -//} - - -//uint32_t was_HeadADCPT100_ReadReg(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint8_t reg, uint8_t *readValue) -//{ -// uint32_t Status = OK; -// -// uint8_t Write_Buf[1]; -// -// #ifdef Use_Head_Card -// Select_Main_Head_Mux_Channel(); -// #endif -// -// Write_Buf[0] = ADS122X_READ_CMD(reg); -// -//// Status |= I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 1); -// delayUs(1); // delayUs(50); -//// Status |= I2C_Read_SensorId(I2C_ID_HEAD_CARD, SensorId, readValue, 1); -// -// return Status; -//} - -//uint8_t was_Test_Read_Buf[4] = {0,0,0,0}; - -//uint32_t was_Test_HeadCard_PT100(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Status = OK; -// uint8_t i = 0; -// -// #ifdef Test_headCard_With_DispCard_I2C4_Add0xE2_DispID_0 -// Select_Main_Head_Mux_Channel_test(); -// #else -// Select_Main_Head_Mux_Channel(); -// #endif -// -// //HeadADCPT100_Reset(); -// HeadADCPT100_InitConfigReg(); -// -// -// was_HeadADCPT100_Config_callback(SensorId, SENSOR_CONFIG_REG0); -// was_HeadADCPT100_Config_callback(SensorId, SENSOR_CONFIG_REG1); -// was_HeadADCPT100_Config_callback(SensorId, SENSOR_CONFIG_REG2); -// was_HeadADCPT100_Config_callback(SensorId, SENSOR_CONFIG_REG3); -// -// was_HeadADCPT100_StartSync(SensorId); -// -// -// -// uint8_t Write_Buf[4] = {SENSOR_CONFIG_REG0,SENSOR_CONFIG_REG1,SENSOR_CONFIG_REG2,SENSOR_CONFIG_REG3}; -// -// for(i=0; i<4; i++) -// { -// was_HeadADCPT100_ReadReg(SensorId, Write_Buf[i], &was_Test_Read_Buf[i]); -// -// } -// -// was_HeadADCPT100_SendReadDataCommand(SensorId); -// -// -// return Status; -//} - -//uint32_t was_HeadADCPT100_Calc_Resistance(TEMPERATURE_SENSOR_ID_ENUM SensorId, unsigned int Current_Measurement) -//{ -// -// #define Rref 1650 //ohm -// -// uint32_t HeadADCPT100_Resistance_100; -// -// unsigned int Factor_2Rref_E_H; -// unsigned int Factor_2Rref_E_L; -// -// //Resistance = Measurement / (2^23) *4 * Rref / Gain //---------------------- is it *4 ???? -// -// Factor_2Rref_E_H = 400 * Rref; // 200 to calculate Resistance*100 -// -// Factor_2Rref_E_L = 8388608 * (2<<(TempSensConfig[SensorId].Reg0.bits.GAIN -1));//2^23*Gain -// -// HeadADCPT100_Resistance_100 = (float)Current_Measurement / (float)Factor_2Rref_E_L * (float)Factor_2Rref_E_H; -// -// return HeadADCPT100_Resistance_100; -//} -//uint32_t was_Test_ADS122X_Internal_Temperature_Sensor(TEMPERATURE_SENSOR_ID_ENUM SensorId) -//{ -// uint32_t Data = 0; -// -// uint8_t Write_Buf[2]; -// -// Select_Main_Head_Mux_Channel(); -// -// SysCtlDelay(5000); -// HeadTempSensConfig[SensorId].Reg1.bits.TS = ADS122X_TEMP_SENSOR_ON;//Bit 1 Enables the Internal temperature sensor -// -// Write_Buf[0] = ADS122X_WREG_CMD | (ADS122X_CONFIG_1_REG<<2); -// Write_Buf[1] = HeadTempSensConfig[SensorId].Reg1.Byte; -//// I2C_Write_SensorId(I2C_ID_HEAD_CARD, SensorId, Write_Buf, 2); -// -// was_HeadCard_Toggle_PT100(SensorId); -// -// SysCtlDelay(5000); -// -// was_HeadADCPT100_StartSync(SensorId); -// SysCtlDelay(3000); -// -// was_HeadADCPT100_SendReadDataCommand(SensorId); -// -// Data = was_Data_ADC_Head; -// -// Data = Data & 0xFFFFFF;//24bit -// -// Data = Data >> 10;//need the 14 left bits // According to ADS1220 data sheet page 31 8.3.13 -// -// Data*=0.03125;// According to ADS1220 data sheet page 31 8.3.13 -// -// return Data;//Temperature_C -// -//} diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.c index ab7ea8303..b3d967ad3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.c @@ -72,7 +72,7 @@ bool Select_WHS_Fan_Mux_Channel(WHS_fan_num fan_number) // { // return status; // } - ReportWithPackageFilter(WasteFilter,"------------ select fan MUX (fan_number)-----------------", __FILE__,__LINE__,fan_number, RpMessage, 0, 0); + //ReportWithPackageFilter(WasteFilter,"------------ select fan MUX (fan_number)-----------------", __FILE__,__LINE__,fan_number, RpMessage, 0, 0); switch (fan_number) { case FAN1: @@ -122,7 +122,7 @@ bool WHS_Read_fan_tach(WHS_fan_num fan_number) bool status = OK; uint8_t fan_driver = 0; - fan_driver = Select_Fan_Driver(fan_number); + fan_driver = Select_Fan_Driver(fan_number); status = Select_Main_WHS_Mux_Channel(); Select_WHS_Fan_Mux_Channel(fan_number); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c index 58f2878ef..aa2be496e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c @@ -17,6 +17,7 @@ #include <Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.h> #include <Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.h> #include <Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h> +#include <Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.h> MAX11614 U20_MAX11614 ; @@ -181,16 +182,17 @@ bool Test_WHS_max11614() #define Aorf_ofset 0.0425 //#define Corf_flow 0.2485 #define Corf_flow 0.239 //email from Sergey 3.2.2020 +#define V0 1000 double get_Q(int16_t num) { double Sqrt = 0; double calc = 0; - int16_t tmp = num; + int16_t tmp = num-V0; if (tmp<0) tmp = 0; Sqrt = sqrt((double)tmp); - calc = Aorf_ofset + Corf_flow*Sqrt; + calc = Corf_flow*Sqrt; ReportWithPackageFilter(WasteFilter,"------------ calc Q value (calc)-----------------", __FILE__,__LINE__, calc, RpMessage, num, 0); return calc; } @@ -273,16 +275,19 @@ uint16_t Orf_zero_value[HEAD_FLOW_METER+1] = {1112,0,1040}; double GetWHSAirFlow(uint8_t OR_Id) { uint16_t value = 0; + double Q_value = 0 ; switch (OR_Id) { case DRIER_FLOW_METER: - get_orf_1(&value); + //get_orf_1(&value); + Q_value = get_average_ORF1_Q(); break; case NU_FLOW_METER: get_orf_2(&value); break; case HEAD_FLOW_METER: - get_orf_3(&value); + //get_orf_3(&value); + Q_value = get_average_ORF3_Q(); break; default: break; @@ -290,7 +295,7 @@ double GetWHSAirFlow(uint8_t OR_Id) ReportWithPackageFilter(WasteFilter,"------------ GetWHSAirFlow -----------------",__FILE__, OR_Id, (int)value, RpWarning, (int) Orf_zero_value[OR_Id], 0); - return get_Q((int16_t)value-Orf_zero_value[OR_Id]); + return Q_value ;//get_Q((int16_t)value-Orf_zero_value[OR_Id]); } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c index 28b4f8598..384e3cd59 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c @@ -26,6 +26,8 @@ double average_orf3_Q_buff[ORF_BUFF_SIZE] = {0}; double average_Q_orifice1; double average_Q_orifice3; +bool ORF1_flageNewBlowerValue; +bool ORF3_flageNewBlowerValue; int32_t i2c_smbus_write_word_data(int i2cFileDescriptor, uint8_t command_regAddress, uint16_t regValue) { @@ -115,6 +117,8 @@ bool WHS_Set_Volt_Blower_Control(uint16_t volt) } else { + ORF1_flageNewBlowerValue = 1; + ORF3_flageNewBlowerValue = 1; MAX5805_CODE_LOAD( volt); ReportWithPackageFilter(WasteFilter,"------------ WHS_Set_Volt_Blower_Control (volt)-----------------", __FILE__,__LINE__, volt, RpMessage, 0, 0); } @@ -190,21 +194,38 @@ double WHS_Blower_Avarege_ORF1() static uint8_t i = 0 ; static double sum_orifice_Q = 0; uint16_t orifice_hex_value = 0; + double Q_temp = 0 ; - if (i == ORF_BUFF_SIZE) + get_orf_1( &orifice_hex_value ); + if (ORF1_flageNewBlowerValue) { - i = 0; + ORF1_flageNewBlowerValue = 0; + Q_temp = get_Q(orifice_hex_value); + sum_orifice_Q = Q_temp*ORF_BUFF_SIZE; + average_Q_orifice1 = Q_temp; + for (i = 0; i < ORF_BUFF_SIZE; i+=1) + { + average_orf1_Q_buff[i] = Q_temp; + } + ReportWithPackageFilter(WasteFilter,"------------ average_Q_orifice1 hex drier new value-----------------", __FILE__,__LINE__,(int)orifice_hex_value, RpMessage, (average_Q_orifice1*1000), 0); } else { - i += 1; + if (i == ORF_BUFF_SIZE) + { + i = 0; + } + else + { + i += 1; + } + sum_orifice_Q -= average_orf1_Q_buff[i]; + get_orf_1(&orifice_hex_value ); + average_orf1_Q_buff[i] = get_Q(orifice_hex_value); + sum_orifice_Q += average_orf1_Q_buff[i]; + average_Q_orifice1 = sum_orifice_Q / ORF_BUFF_SIZE; + ReportWithPackageFilter(WasteFilter,"------------ average_Q_orifice3 hex head -----------------", __FILE__,__LINE__,(int)orifice_hex_value, RpMessage, (average_Q_orifice3*1000), 0); } - sum_orifice_Q -= average_orf1_Q_buff[i]; - get_orf_1(&orifice_hex_value ); - average_orf1_Q_buff[i] = get_Q(orifice_hex_value); - sum_orifice_Q += average_orf1_Q_buff[i]; - - average_Q_orifice1 = sum_orifice_Q /ORF_BUFF_SIZE; return average_Q_orifice1; } @@ -213,23 +234,39 @@ double WHS_Blower_Avarege_ORF3() static uint8_t i = 0 ; static double sum_orifice_Q = 0; uint16_t orifice_hex_value = 0; + double Q_temp = 0 ; - if (i == ORF_BUFF_SIZE) + get_orf_3( &orifice_hex_value ); + if (ORF3_flageNewBlowerValue) { - i = 0; + ORF3_flageNewBlowerValue = 0; + Q_temp = get_Q(orifice_hex_value); + sum_orifice_Q = Q_temp*60; + average_Q_orifice3= Q_temp; + for (i = 0; i < ORF_BUFF_SIZE; i+=1) + { + average_orf3_Q_buff[i] = Q_temp; + } + ReportWithPackageFilter(WasteFilter,"------------ average_Q_orifice3 hex head new value-----------------", __FILE__,__LINE__,(int)orifice_hex_value, RpMessage, (average_Q_orifice3*1000), 0); + } else { - i += 1; + if (i == ORF_BUFF_SIZE) + { + i = 0; + } + else + { + i += 1; + } + sum_orifice_Q -= average_orf3_Q_buff[i]; + average_orf3_Q_buff[i] = get_Q(orifice_hex_value); + sum_orifice_Q += average_orf3_Q_buff[i]; + average_Q_orifice3 = sum_orifice_Q /ORF_BUFF_SIZE; } - sum_orifice_Q -= average_orf3_Q_buff[i]; - get_orf_3( &orifice_hex_value ); //average_orf1_buff[i] = - average_orf3_Q_buff[i] = get_Q(orifice_hex_value); - sum_orifice_Q += average_orf3_Q_buff[i]; - - average_Q_orifice3 = sum_orifice_Q /ORF_BUFF_SIZE; ReportWithPackageFilter(WasteFilter,"------------ average_Q_orifice3 hex head -----------------", __FILE__,__LINE__,(int)orifice_hex_value, RpMessage, (average_Q_orifice3*1000), 0); - return OK; + return average_Q_orifice3; } double get_average_ORF1_Q() @@ -274,7 +311,7 @@ bool WHS_Set_Blower_Control_Closed_Loop(double SetPoint_Q) current_dying_head_flow_Q = get_average_ORF3_Q(); ReportWithPackageFilter(WasteFilter,"------------ current_dying_head_flow_Q =-----------------", __FILE__,__LINE__, current_dying_head_flow_Q, RpMessage, 0, 0); ReportWithPackageFilter(WasteFilter,"------------ SET_DYEING_HEAD_ORRIFFICE_SENSOR =-----------------", __FILE__,__LINE__, SET_DYEING_HEAD_ORRIFFICE_SENSOR, RpMessage, current_dying_head_flow_Q, 0); - if (abs(current_dying_head_flow_Q - SetPoint_Q) > 0.2) + while (abs(current_dying_head_flow_Q - SetPoint_Q) > 0.2) { volt = getBlowerState(); if (current_dying_head_flow_Q < SetPoint_Q) @@ -283,13 +320,15 @@ bool WHS_Set_Blower_Control_Closed_Loop(double SetPoint_Q) { /* increase blower voltage by large step: */ ReportWithPackageFilter(WasteFilter,"------------ increase blower voltage by large step:-----------------", __FILE__,__LINE__, volt, RpMessage, LARGE_STEP, 0); - WHS_Set_Volt_Blower_Control( volt + LARGE_STEP ); + //WHS_Set_Volt_Blower_Control( volt + LARGE_STEP );//call func :Control_Voltage_To_Blower + Control_Voltage_To_Blower(volt + LARGE_STEP); } else { /* increase blower voltage by small step: */ ReportWithPackageFilter(WasteFilter,"------------ increase blower voltage by large step:-----------------", __FILE__,__LINE__, volt, RpMessage, SMALL_STEP, 0); - WHS_Set_Volt_Blower_Control( volt + SMALL_STEP ); + //WHS_Set_Volt_Blower_Control( volt + SMALL_STEP ); + Control_Voltage_To_Blower(volt + SMALL_STEP); } } else @@ -298,13 +337,15 @@ bool WHS_Set_Blower_Control_Closed_Loop(double SetPoint_Q) { /* decrease blower voltage by large step: */ ReportWithPackageFilter(WasteFilter,"------------ decrease blower voltage by large step:-----------------", __FILE__,__LINE__, volt, RpMessage, LARGE_STEP, 0); - WHS_Set_Volt_Blower_Control(volt - LARGE_STEP); + //WHS_Set_Volt_Blower_Control(volt - LARGE_STEP); + Control_Voltage_To_Blower(volt - LARGE_STEP); } else { /* decrease blower voltage by small step: */ ReportWithPackageFilter(WasteFilter,"------------ decrease blower voltage by small step:-----------------", __FILE__,__LINE__, volt, RpMessage, SMALL_STEP, 0); - WHS_Set_Volt_Blower_Control( volt + SMALL_STEP ); + //WHS_Set_Volt_Blower_Control( volt - SMALL_STEP ); + Control_Voltage_To_Blower(volt - SMALL_STEP); } } } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c index a472fb9eb..f7fe99aed 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c @@ -37,7 +37,7 @@ bool D_TCA9546_Select_Channel(uint8_t TCA9546A_I2C_bus_number, uint8_t TCA9546A_ } Write_Buf[0]=chnl_number; status |= I2C_Write(TCA9546A_I2C_bus_number, TCA9546A_I2C_addr, Write_Buf, 1); - ReportWithPackageFilter(WasteFilter,"------------ Select I2C Channel (chnl_number)-----------------", __FILE__,__LINE__, chnl_number, RpMessage, status, 0); + // ReportWithPackageFilter(WasteFilter,"------------ Select I2C Channel (chnl_number)-----------------", __FILE__,__LINE__, chnl_number, RpMessage, status, 0); return status; } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c index 117a20913..dfd49a71b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c @@ -101,9 +101,6 @@ uint32_t Check_WHS_Type_Via_EEPROM() WHS_Type = WHS_TYPE_NEW; } - - //TODO to test and replace #ifdef Use_Head_Card with if(Head_Type != HEAD_TYPE_SYLKO_WITHOUT_CARD) - return status; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index dc92b6683..3ea703b93 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -430,8 +430,8 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb Valve3WayControlId[_ValveId] = AddControlCallback("Valve3WayControlId", Valve3WayCallBackFunction, eOneSecond/*eHundredMillisecond*/, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); if (Valve3WayControlId[_ValveId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_ValveId],0); - else - Report("Add control callback",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_ValveId],0); +// else +// Report("Add control callback",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_ValveId],0); /*busy = */FPGA_GetDispenserValveBusyOCD(_ValveId,0); //Report("Set valve id, dir, busy",__FILE__,_ValveId,(int)direction,RpWarning,(int)busy,0); diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 6b5424d74..803a22cc4 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -298,6 +298,7 @@ int main(void) //Turn_the_Blower_On();//Turn on with the Default_Voltage ActivateChiller();//WHS Cooler SSR9 //ActivateHeadMagnet(); + Set_Speed_Sensor_TypeII_Registers(10,5);//set default values #endif I2C_ReadingTask_Init(); //EMAC_initEMAC(); @@ -337,11 +338,6 @@ int main(void) // //test_avi(); //example for shai - - -#ifndef EVALUATION_BOARD - //Set_Speed_Sensor_TypeII_Registers(2,2);//set default values -#endif //Read_Speed_Sensor_TypeII();//must be delay between Set_Speed_Sensor_TypeII_Registers to Read_Speed_Sensor_TypeII //Test_ADS120_Internal_Temperature_Sensor(0); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index e5064ef70..2c7512129 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -606,7 +606,7 @@ uint32_t MillisecLowLoop(uint32_t tick) StartPT100 = TEMP_SENSE_ANALOG_DRYER_TEMP1; if (Ten_msTick) { - //Speed_Data = Calculate_Speed_Sensor_Velocity(); + Speed_Data = Read_Speed_Sensor_TypeII(); //MillisecReadFromTempSensor(Sensor_Read, NULL); //if (Sensor_Read++ >= MAX_MAIN_CARD_TEMPERATURE_SENSOR_ID) Sensor_Read = 0; if(Machine_Idle_Mode == true) @@ -720,7 +720,7 @@ uint32_t MillisecLowLoop(uint32_t tick) } Trigger_WHS_PT100_Read_All(); Trigger_WHS_MAX11614_Read_allADC(); -// WHS_Blower_Avarege_ORF1(); //drier + WHS_Blower_Avarege_ORF1(); //drier WHS_Blower_Avarege_ORF3(); //head Trigger_WHSReadAllFanTacho (); } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 36d4505d0..63fe510c4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -314,12 +314,14 @@ uint32_t DiagnosticsLoadDigitalValues(void) DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE_SSR13_CTRL; DigitalOutputState[index++].value = ReadHeadMagnetBit(); - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_LED3; - //DigitalOutputState[index++].value = HeadCard_Actuators_Status(ACTIN); + /*if (Head_Type == HEAD_TYPE_SYLKO) //rapid/pp machines + { + DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_LED3; + DigitalOutputState[index++].value = HeadCard_Actuators_Status(ACTIN); - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_LED4; - // indication of movement cause the switch in the tech board to change, also doesn't go through the task - //DigitalOutputState[index++].value = HeadCard_Actuators_Status(ACTOT); + DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_LED4; + DigitalOutputState[index++].value = HeadCard_Actuators_Status(ACTOT); + }*/ DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPI_WCONTAINER_FULL; DigitalOutputState[index++].value = WHS_IsContainerFull(); @@ -408,7 +410,7 @@ void DiagnosticTenMsecCollection(void) DiagnosticLoadDancerError(POOLER_DANCER,ThreadGetMotorCalculatedError(POOLER_DANCER)); DiagnosticLoadDancerError(FEEDER_DANCER,ThreadGetMotorCalculatedError(FEEDER_DANCER)); - //DiagnosticLoadSpeedSensor(getSensorSpeedData()); + DiagnosticLoadSpeedSensor(getSensorSpeedData()); } void DiagnosticOneMinuteCollection(void) { @@ -444,7 +446,7 @@ void DiagnosticOneMinuteCollection(void) } DiagnosticsMonitor.n_overalltemperature = 1; OverallTemperature = max(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1),MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)); - OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1))*1000 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2))); + OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1))*10 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); DiagnosticsMonitor.overalltemperature = &OverallTemperature; DiagnosticsMonitor.n_midtank1level = 1; @@ -794,7 +796,9 @@ void Diagnostic100msecCollection(void) } } + DiagnosticsMonitor.n_drierzone1heatercurrent = 1; HeatersCurrent[HEATER_DRYER_CURRENT_1][0] = Get_Heaters_Current(HEATER_DRYER_CURRENT_1); + DiagnosticsMonitor.n_drierzone2heatercurrent = 1; HeatersCurrent[HEATER_DRYER_CURRENT_2][0] = Get_Heaters_Current(HEATER_DRYER_CURRENT_2); /*dispenser1motorfrequency[DiagnosticsIndex] = MotorGetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index f43cf8c56..6e4eed580 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -27,9 +27,9 @@ uint32_t CloseValveTimeout = 10; uint32_t OpenValveTimeout = 10; -#define DISPENSER_BUILD_PRESSURE_SPEED 900 -#define DISPENSER_BUILD_PRESSURE_LIMIT 1.5 -#define DISPENSER_BUILD_PRESSURE_TIMEOUT 60000 +#define DISPENSER_BUILD_PRESSURE_SPEED 940 +#define DISPENSER_BUILD_PRESSURE_LIMIT 1.0 +#define DISPENSER_BUILD_PRESSURE_TIMEOUT 120000 #define DISPENSER_BUILD_PRESSURE_LAG 50 #define DEFAULT_NANOLITER_PER_PULSE 2.34 uint32_t DispenserPrepareSpeed = DISPENSER_BUILD_PRESSURE_SPEED; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 14718ab0e..0c28ee564 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -519,12 +519,12 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { HW_Motor_Id = DispenserIdToMotorId[i]; - if (GetDispenserPressure(i) > DispenserPreparePressure*1.02) + if (GetDispenserPressure(i) > DispenserPreparePressure*1.05) { NumofReadyDispensers++; - CurrentDispenserSpeed[i] = 0; #ifdef SPECIAL_DISPENSERS MotorStop(HW_Motor_Id, Hard_Hiz); + CurrentDispenserSpeed[i] = 0; //Report("IDS stopped ready",__FILE__,i,(int)(DispenserPreparePressure*100),RpWarning,(int)NumofReadyDispensers,0); #else tempSpeed = CurrentDispenserSpeed[i]; @@ -569,7 +569,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) Report("pressureReady = true or timeout;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); } } -#ifndef SPECIAL_DISPENSERS +//#ifndef SPECIAL_DISPENSERS else if (endOfPrepareWCF == false) { if ((DispenserBuildTimeCounter == PRESSURE_READ_TIME_GAP)&&(FirstBrushStop)) @@ -614,8 +614,11 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) segmentfirst_speed /= 100; DispenserSegmentReady[DispenserId] = false; //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer - //IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); +#ifdef SPECIAL_DISPENSERS + IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); +#else MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); +#endif CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; usnprintf(IdMessage, 80, @@ -657,13 +660,13 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) } } -#endif +/*#endif #ifdef SPECIAL_DISPENSERS if (pressureReady == true) -#else +#else*/ //start new stage if (endOfPrepareWCF == true) -#endif +//#endif { SafeRemoveControlCallback(DispenserPrepareControlId, IDS_Prepare_Callback ); DispenserPrepareControlId = 0xFF; @@ -785,6 +788,9 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) for (i = 0; i < MAX_DYE_DISPENSERS; i++) { dispenserspeed = DispenserPrepareSpeed; +#ifdef SPECIAL_DISPENSERS + dispenserspeed = 300; +#endif TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[i]; if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers @@ -1060,7 +1066,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); //cleaning return OK; } -#ifndef SPECIAL_DISPENSERS +//#ifndef SPECIAL_DISPENSERS if ((InterSegmentStartWFCFDispensers > 12000)&&(InterSegmentStartWFCFDispensers == (InterSegmentStepsCount+12000))) { //start prepare 4 seconds before wcf @@ -1141,7 +1147,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); //close waste valve one second before segment - trial Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); } -#endif +//#endif return OK; } uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 51fe807d8..d3a97bf3a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -107,64 +107,65 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) } } else - if((request->amount == 0x3E8) && (request->delay <= 0x0fff))// set WHS Blower speed 0x00-0xfff - { - if (WHS_Type == WHS_TYPE_NEW) + if((request->amount == 0x3E8) && (request->delay <= 0x0fff))// set WHS Blower speed 0x00-0xfff { - Trigger_SetWHSBlowerVoltage (request->delay); - response.progress = 0; - response.has_progress = true; - } //Trigger_WHS_Set_Volt_Blower_Control(request->delay); - } + if (WHS_Type == WHS_TYPE_NEW) + { + Trigger_SetWHSBlowerVoltage (request->delay); + response.progress = 0; + response.has_progress = false; + } + } else if (request->amount == 0x3E7) // set WHS Blower speed by Q value { if (WHS_Type == WHS_TYPE_NEW) { - Trigger_WHS_Set_Blower_Control_Closed_Loop (request->delay); + WHS_Set_Blower_Control_Closed_Loop (request->delay); response.progress = 0; - response.has_progress = true; - } //Trigger_WHS_Set_Volt_Blower_Control(request->delay); + response.has_progress = false; + } } - else if(request->amount == 0x3EA) - { - uint16_t tempu16 = 0; - if (WHS_Type == WHS_TYPE_NEW) - { - switch(request->delay )// set WHS Blower speed 0x00-0xfff - { - case 0: - get_orf_1(&tempu16); - break; - case 1: - get_orf_2(&tempu16); - break; - case 2: - get_orf_3(&tempu16); - break; - case 3: - get_vlev1(&tempu16); - break; - case 4: - get_vlev2(&tempu16); - break; - case 5: - get_gas_out(&tempu16); - break; - case 6: - get_cur_fan(&tempu16); - break; - case 7: - get_cur_vlv1(&tempu16); - break; - case 8: - tempu16 = 0; //get_cur_vlv2(&tempu16); - break; - default : - tempu16 = 0x500; //get_cur_vlv2(&tempu16); - break; + else + if(request->amount == 0x3EA) + { + uint16_t tempu16 = 0; + if (WHS_Type == WHS_TYPE_NEW) + { + switch(request->delay )// set WHS Blower speed 0x00-0xfff + { + case 0: + get_orf_1(&tempu16); + break; + case 1: + get_orf_2(&tempu16); + break; + case 2: + get_orf_3(&tempu16); + break; + case 3: + get_vlev1(&tempu16); + break; + case 4: + get_vlev2(&tempu16); + break; + case 5: + get_gas_out(&tempu16); + break; + case 6: + get_cur_fan(&tempu16); + break; + case 7: + get_cur_vlv1(&tempu16); + break; + case 8: + tempu16 = 0; //get_cur_vlv2(&tempu16); + break; + default : + tempu16 = 0x500; //get_cur_vlv2(&tempu16); + break; + } } - } response.progress = (double)tempu16; response.has_progress = true; } @@ -511,7 +512,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if((request->amount == 0x0CE) && (request->delay == 0x0CE)) //Get Gas Sensor { LOG_ERROR(request->delay,"FlashInitAndLoad"); - FlashInitAndLoad(); + FlashInit(); response.progress = (double)OK; response.has_progress = true; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index fd48e799a..1dd101f82 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -28,6 +28,7 @@ #include "drivers/Heater/Heater.h" #include "drivers/Motors/Motor.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include "drivers/FPGA/FPGA_SPI_Comm.h" #include "modules/heaters/heaters.h" #include "modules/General/process.h" #include "modules/ids/ids_ex.h" @@ -117,8 +118,8 @@ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Rea if (Current_Read < Previous_Read) { - ReportWithPackageFilter(ThreadFilter,"Length rollover",__FILE__,__LINE__,(int)Current_Read,RpWarning,(int)Previous_Read,0); Time_Pass = (MAX_COUNTER - Previous_Read) + Current_Read + 1; + ReportWithPackageFilter(ThreadFilter,"Length rollover",__FILE__,Time_Pass,(int)Current_Read,RpWarning,(int)Previous_Read,0); } else Time_Pass = Current_Read - Previous_Read; @@ -178,7 +179,10 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) initialpos = 0; } prevprev = PreviousPosition; - positionDiff = Control_Delta_Position_Pass(CurrentPosition,PreviousPosition); + if (Extended_Motor_Param[ThreadMotorIdToMotorId[index]] == true) //powerstep driver reverses the direction + positionDiff = Control_Delta_Position_Pass(PoolerPreviousPosition,PoolerCurrentPosition); + else + positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition); //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; PreviousPosition = CurrentPosition; @@ -268,7 +272,10 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) Poolerinitialpos = 0; } prevprev = PoolerPreviousPosition; - positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition); + if (Extended_Motor_Param[ThreadMotorIdToMotorId[index]] == true) //powerstep driver reverses the direction + positionDiff = Control_Delta_Position_Pass(PoolerPreviousPosition,PoolerCurrentPosition); + else + positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition); //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; PoolerPreviousPosition = PoolerCurrentPosition; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index d1f667405..92ab2b43c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -28,6 +28,7 @@ #include "drivers/I2C_Communication/DAC/Blower.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" +#include "drivers/adc_sampling/adc.h" #include "drivers/Valves/Valve.h" #include "heaters/heaters_ex.h" @@ -39,6 +40,7 @@ INIT_SEQUENCE_BUILT_IN_TEST, INIT_SEQUENCE_INITIAL_BLOWER_ACTIVATION, //INIT_SEQUENCE_DISPENSER_PRESSURE_BUILDUP_TEST, + INIT_SEQUENCE_POWER_MANAGEMENT_INIT, INIT_SEQUENCE_WAIT_FOR_COOLER, INIT_SEQUENCE_THREAD_DETECTION, INIT_SEQUENCE_START_HEATING, @@ -208,6 +210,140 @@ uint32_t InitSequenceBlowerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //InitSequenceStateMachine(InitStages); return OK; } +/////////////////////////////////////////////////////////////////////////////////////////////////////// +#define MAX_CURRENT_READING 5 +#define CURRENT_READING_ERROR_UNSTABLE 100 +int Heater_Current[MAX_CURRENT_READING] ; +bool initial_wait = false; +int count_Heater_Current = 0; +int Maxcount_Heater_Current = 0; +bool MainHeaterStable = false,SecondaryHeaterStable = false; +double MainCurrent,SecondaryCurrent,StableCurrent; +double InitDrierAcVoltage = 0.0; +int InitDrierAcVoltageCount = 0; +double Zone2Resistance = 0.0; +void InitCurrentReadingStable(void) +{ + memset(Heater_Current,0,sizeof(Heater_Current)); + initial_wait = false; + count_Heater_Current = 0; + Maxcount_Heater_Current = 0; + StableCurrent = 0.0; +} + +bool DetectIfCurrentReadingStable(double HeaterCurrent) +{ + bool ret = false; + int i=0; + int sum = 0; + int average = 0; + + Maxcount_Heater_Current++; + Heater_Current[count_Heater_Current++] = HeaterCurrent; + if ( count_Heater_Current >= MAX_CURRENT_READING) + { + count_Heater_Current = 0; + initial_wait = true; + } + if (initial_wait == false) + return false; + for (i=0;i<MAX_CURRENT_READING;i++) + sum += Heater_Current[i]; + average = sum/MAX_CURRENT_READING; + if (fabs(average - HeaterCurrent)<0.2) + { + ret = true; + StableCurrent = average; + } + return ret; +} +double GetZone2RMSCurrent(double VAC) +{ + return (VAC/Zone2Resistance); +} +uint32_t PowerManagementCallBack(uint32_t IfIndex, uint32_t BusyFlag) +{ + ReportWithPackageFilter(InitFilter,"PowerManagementCallBack", __FILE__,MainHeaterStable,(int)(SecondaryHeaterStable), RpMessage, Maxcount_Heater_Current, 0); + ReportWithPackageFilter(InitFilter,"PowerManagementCallBack", __FILE__,GetHeaterState(HEATER_TYPE__DryerMainHeater),(int)(GetHeaterState(HEATER_TYPE__DryerSecondaryHeater)), RpMessage, Maxcount_Heater_Current, 0); + + if ((MainHeaterStable == false)&&(Maxcount_Heater_Current<CURRENT_READING_ERROR_UNSTABLE)) + { + InitDrierAcVoltage += ReadVAC(); + InitDrierAcVoltageCount++; + ReportWithPackageFilter(InitFilter,"main heater current not stable", __FILE__,GetHeaterState(HEATER_TYPE__DryerMainHeater),(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + MainHeaterStable = DetectIfCurrentReadingStable(Get_Heaters_Current(HEATER_DRYER_CURRENT_1)); + Read_Heaters_Current(HEATER_DRYER_CURRENT_1); + if (MainHeaterStable == true) + { + ReportWithPackageFilter(InitFilter,"main heater current stable", __FILE__,GetHeaterState(HEATER_TYPE__DryerMainHeater),(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + InitDrierAcVoltage /= InitDrierAcVoltageCount; + MainCurrent = StableCurrent; + InitCurrentReadingStable(); + DeActivateHeater(HEATER_TYPE__DryerMainHeater); + ActivateHeater(HEATER_TYPE__DryerSecondaryHeater); + ReportWithPackageFilter(InitFilter,"starting secondary heater ", __FILE__,__LINE__,(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + } + } + else + { + DeActivateHeater(HEATER_TYPE__DryerMainHeater); + if (Maxcount_Heater_Current>=CURRENT_READING_ERROR_UNSTABLE) + { + ReportWithPackageFilter(InitFilter,"drier heaters current not stable", __FILE__,GetHeaterState(HEATER_TYPE__DryerSecondaryHeater),(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + if (SafeRemoveControlCallback(HWControlId, PowerManagementCallBack )==OK) + HWControlId = 0xFF; + else + Report("Remove control callback failed",__FILE__,__LINE__,(int)HWControlId,RpWarning,(int)PowerManagementCallBack,0); + AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_HEATERS_ZONE_1_CURRENT_OUT_OF_RANGE,ON); + DeActivateHeater(HEATER_TYPE__DryerSecondaryHeater); + DeActivateHeater(HEATER_TYPE__DryerMainHeater); + InitStages++; + } + else //go to secondary + { + if ((SecondaryHeaterStable == false)&&(Maxcount_Heater_Current<CURRENT_READING_ERROR_UNSTABLE)) + { + SecondaryHeaterStable = DetectIfCurrentReadingStable(Get_Heaters_Current(HEATER_DRYER_CURRENT_2)); + Read_Heaters_Current(HEATER_DRYER_CURRENT_2); + if (SecondaryHeaterStable == true) + { + ReportWithPackageFilter(InitFilter,"main heater current stable", __FILE__,__LINE__,(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + SecondaryCurrent = StableCurrent; + InitCurrentReadingStable(); + DeActivateHeater(HEATER_TYPE__DryerSecondaryHeater); + //do stuff for RMS 2 + Zone2Resistance = InitDrierAcVoltage/SecondaryCurrent; + } + } + else + { + if (SafeRemoveControlCallback(HWControlId, PowerManagementCallBack )==OK) + HWControlId = 0xFF; + else + Report("Remove control callback failed",__FILE__,__LINE__,(int)HWControlId,RpWarning,(int)PowerManagementCallBack,0); + DeActivateHeater(HEATER_TYPE__DryerSecondaryHeater); + DeActivateHeater(HEATER_TYPE__DryerMainHeater); + if (Maxcount_Heater_Current>=CURRENT_READING_ERROR_UNSTABLE) + AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_HEATERS_ZONE_2_CURRENT_OUT_OF_RANGE,ON); + InitStages++; + } + } + } +return OK; +} +uint32_t InitSequencePowerManagementInit(void) +{ + if ((Head_Type >= HEAD_TYPE_SYLKO)&&(WHS_Type == WHS_TYPE_NEW)) + { + InitCurrentReadingStable(); + ActivateHeater(HEATER_TYPE__DryerMainHeater); + HWControlId = AddControlCallback("Init Power", PowerManagementCallBack, eHundredMillisecond, TemplateDataReadCBFunction,0,0, 0 ); + ReportWithPackageFilter(InitFilter,"starting main heater ", __FILE__,__LINE__,(int)(StableCurrent*100), RpMessage, Maxcount_Heater_Current, 0); + } + else + InitStages++; + return OK; +} uint32_t InitSequenceInitialBlowerActivation(void) { MachineStateDetail = MACHINE_STATE_INITIAL_BLOWER_ACTIVATION; @@ -260,13 +396,13 @@ uint32_t InitSequenceDispenserPressureBuildUpTest(void) } uint32_t InitSequenceWaitForCoolerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { - InitStages++; MachineStateDetail = INIT_SEQUENCE_WAIT_FOR_COOLER; if (SafeRemoveControlCallback(HWControlId, InitSequenceWaitForCoolerCallBackFunction )==OK) HWControlId = 0xFF; else Report("Remove control callback failed",__FILE__,__LINE__,(int)HWControlId,RpWarning,(int)InitSequenceWaitForCoolerCallBackFunction,0); + InitStages++; return OK; } uint32_t InitSequenceWaitForCooler(void) @@ -286,7 +422,8 @@ uint32_t InitSequenceWaitForCooler(void) else { //cold reset, wait 2 minutes for cooler start - HWControlId = AddControlCallback("Init Cooler", InitSequenceWaitForCoolerCallBackFunction, 2*eOneMinute, TemplateDataReadCBFunction,0,0, 0 ); +// HWControlId = AddControlCallback("Init Cooler", InitSequenceWaitForCoolerCallBackFunction, 2*eOneMinute, TemplateDataReadCBFunction,0,0, 0 ); + HWControlId = AddControlCallback("Init Cooler", InitSequenceWaitForCoolerCallBackFunction, 2*eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } //InitSequenceStateMachine(InitStages); return OK; @@ -385,6 +522,9 @@ uint32_t InitSequenceStateMachine( INIT_SEQUENCE_STAGES_ENUM ReadValue) case INIT_SEQUENCE_INITIAL_BLOWER_ACTIVATION: InitSequenceInitialBlowerActivation(); break; + case INIT_SEQUENCE_POWER_MANAGEMENT_INIT: + InitSequencePowerManagementInit(); + break; /*case INIT_SEQUENCE_DISPENSER_PRESSURE_BUILDUP_TEST: InitSequenceDispenserPressureBuildUpTest(); break;*/ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h index 105537721..f65329c4b 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h @@ -33,6 +33,7 @@ void StopInitSequence(void); MACHINE_STATE_STAGES_ENUM GetMachineState(void); void SetMachineState(MACHINE_STATE_STAGES_ENUM); void InitSequenceSetStartHeating(bool StartHeating); +double GetZone2RMSCurrent(double VAC); #endif /* STATEMACHINES_INITIALIZATION_INITSEQUENCE_H_ */ |
