From bee3522e23c95021a9637669a8091069af98e0c4 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 4 Feb 2020 18:51:57 +0200 Subject: Version 1.4.6.8: remove most of head/whs ifdefs, checked to be working. fix control for missed milliseconds calls and more --- Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 8aabafd2e..873c89b7e 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -715,8 +715,10 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path, uint32_t timeout) Fresult = f_write(FileHandle,buffer,size,&Bytes ); if(Fresult != FR_OK) { - LOG_ERROR (Fresult,"fread error"); + LOG_ERROR (Fresult,"fwrite error"); } + //LOG_ERROR (Bytes,"f_write ok no of bytes"); + Report("f_write ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)size, 0); f_close(FileHandle); } else @@ -762,6 +764,7 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer) { *Buffer = buffer; *Size = (uint32_t)fno->fsize; + Report("f_read ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)fno->fsize, 0); } else { -- cgit v1.3.1 From b14dc1bc35994c4da27bd64e7de65ff66ae7ee0d Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 18 Feb 2020 10:19:36 +0200 Subject: preparing rapid release --- .../Embedded/Common/SWUpdate/FileSystem.c | 28 +++-- Software/Embedded_SW/Embedded/DataDef.h | 4 +- .../Head_Card/EEPROM/Head_EEPROM.c | 4 +- .../Head_Card/PT100/Head_PT100_ADC.c | 88 +++++++------- Software/Embedded_SW/Embedded/Main.c | 6 +- .../Embedded/Modules/Control/MillisecTask.c | 2 +- .../Embedded/Modules/IDS/IDS_dispenser.c | 6 +- .../StateMachines/Initialization/InitSequence.c | 131 +++++++++++++++++++++ .../StateMachines/Initialization/InitSequence.h | 1 + 9 files changed, 200 insertions(+), 70 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') 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..4f7a5d2dc 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -26,8 +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 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 I2C_2_Data_Transfer_Rate_400kbps 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..25c264755 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 @@ -128,12 +128,12 @@ uint32_t Check_Head_Type_Via_EEPROM() } //temporary - #ifdef Use_Head_Card +/* #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/PT100/Head_PT100_ADC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.c index 47bbb7b60..4d8965de8 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_MAIN_CARD_TEMPERATURE_SENSOR_ID) Sensor_Read = 0; if(Machine_Idle_Mode == true) 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/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index d1f667405..ba3a3e1a7 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,132 @@ 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 >= 5) + { + count_Heater_Current = 0; + initial_wait = true; + } + if (initial_wait == false) + return false; + for (i=0;i=CURRENT_READING_ERROR_UNSTABLE) + { + ReportWithPackageFilter(InitFilter,"drier heaters current not stable", __FILE__,__LINE__,(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) + AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_HEATERS_ZONE_2_CURRENT_OUT_OF_RANGE,ON); + InitStages++; + } + } + } +return OK; +} +uint32_t InitSequencePowerManagementInit(void) +{ + 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); + return OK; +} uint32_t InitSequenceInitialBlowerActivation(void) { MachineStateDetail = MACHINE_STATE_INITIAL_BLOWER_ACTIVATION; @@ -385,6 +513,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_ */ -- cgit v1.3.1 From 096bd938ce5a1c3643695bc8f6818e8e1fd3c064 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 19 Feb 2020 11:30:46 +0200 Subject: bug fixes before version 1.4.6.12 --- .../Embedded/Common/SWUpdate/FileSystem.c | 4 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 2 + .../Embedded/Drivers/I2C_Communication/I2C_Task.c | 8 +++ Software/Embedded_SW/Embedded/Embedded.cfg | 4 +- Software/Embedded_SW/Embedded/Main.c | 3 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 29 ++++++++-- .../Embedded/Modules/Control/MillisecTask.c | 6 ++- .../Embedded/Modules/Diagnostics/Diagnostics.c | 2 +- .../Embedded/Modules/General/GeneralHardware.c | 15 ++++++ .../Embedded/Modules/General/GeneralHardware.h | 2 + .../Embedded/Modules/Stubs_Handler/Progress.c | 63 ++++++++++++++++++++-- 11 files changed, 121 insertions(+), 17 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index e8d7f6f58..15e845527 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -49,7 +49,7 @@ FIL *UploadFileHandle = 0; //the system supports a single active file FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; -#define MAX_CHUNK_LENGTH 5500 +#define MAX_CHUNK_LENGTH 4000 int32_t FileLength = 0; int32_t FileReceivedLength = 0; int32_t FileSentLength = 0; @@ -100,7 +100,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) { CommRxTaskHandle = Task_self(); - Task_setPri(CommRxTaskHandle, 3); + Task_setPri(CommRxTaskHandle, 2); // Report("Task_setPri", __FILE__, __LINE__, 4, RpWarning, (int)CommRxTaskHandle, 0); //Report("FileUploadRequestFunc 2", __FILE__, __LINE__, msec_millisecondCounter, RpWarning, (int)0, 0); Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS); diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 24f02f60c..4bbe44aea 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -165,6 +165,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); Fresult = f_unlink("//SYSINFO//PROCESSP.CFG"); Fresult |= f_rename (FullPath, "//SYSINFO//PROCESSP.CFG"); + LoadProcessParamsFromFile(); CurrentRunningFile++; break; case VERSION_FILE_DESTINATION__AlarmParams: @@ -180,6 +181,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); Fresult = f_unlink("//SYSINFO//GENHWCFG.CFG"); Fresult |= f_rename (FullPath, "//SYSINFO//GENHWCFG.CFG"); + HWConfigurationLoadFile(); CurrentRunningFile++; break; default: 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 c6b8dbf39..40f6fce5e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c @@ -396,9 +396,17 @@ void Trigger_WHS_I2C_EEprom_Read(uint32_t address, uint16_t size, uint8_t *p_dat Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); return; } +void I2C_ReadingTask(UArg arg0, UArg arg1); void I2C_ReadingTask_Init(void) { + Task_Params taskParams; + I2C_ReadingMsgQ = Mailbox_create(sizeof(I2C_ReadingMessageStruc), 40, NULL,NULL); + Task_Params_init(&taskParams); + taskParams.instance->name = "I2C_Reading"; + taskParams.priority = 8; + taskParams.stackSize = 2048; + I2C_Task_Handle = Task_create((Task_FuncPtr)I2C_ReadingTask, &taskParams, NULL); } void I2C_ReadingTask(UArg arg0, UArg arg1) diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 734902ce7..a9a958a55 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -132,12 +132,12 @@ ProcessTaskParams.stackSize = 4096; ProcessTaskParams.priority = 9; Program.global.process = Task.create("&jobTask", ProcessTaskParams); -var I2C_Reading = new Task.Params(); +/*var I2C_Reading = new Task.Params(); I2C_Reading.instance.name = "I2C_Reading"; I2C_Reading.stackSize = 2048; I2C_Reading.priority = 8; Program.global.I2C_Reading = Task.create("&I2C_ReadingTask", I2C_Reading); - +*/ var HeaterControlTaskParams = new Task.Params(); HeaterControlTaskParams.instance.name = "HeatersControl"; HeaterControlTaskParams.priority = 7; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 803a22cc4..604fc73fb 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -300,7 +300,8 @@ int main(void) //ActivateHeadMagnet(); Set_Speed_Sensor_TypeII_Registers(10,5);//set default values #endif - I2C_ReadingTask_Init(); + if ((Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)||(WHS_Type == WHS_TYPE_NEW)) + I2C_ReadingTask_Init(); //EMAC_initEMAC(); ControlInit(); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index e06e908bd..22cc33822 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -1566,7 +1566,7 @@ void SendEventNotifications(void) } EventsResponse.n_events = 0; - UInt Key = Task_disable(); + //UInt Key = Task_disable(); for (i = 0;i EventsResponse.n_events) + { + ReportWithPackageFilter(AlarmFilter,"Error in alarm numbers - large ", __FILE__,__LINE__,EventsResponse.n_events, RpFatalError, e, 0); + break; + } } } } + if (e!=EventsResponse.n_events) + { + ReportWithPackageFilter(AlarmFilter,"Error in alarm numbers - small ", __FILE__,__LINE__,EventsResponse.n_events, RpFatalError, e, 0); + EventsResponse.n_events = e; + } } else { LOG_ERROR(EventsResponse.n_events,"events malloc error"); - Task_restore(Key); + //Task_restore(Key); return; } } @@ -1609,7 +1619,7 @@ void SendEventNotifications(void) { EventsResponse.events = NULL; } - Task_restore(Key); + //Task_restore(Key); responseContainer = createAllocatedContainer(MESSAGE_TYPE__StartEventsNotificationResponse, AlarmHandlingToken, false, &EventsResponse, &start_events_notification_response__pack, &start_events_notification_response__get_packed_size,&alarm_response_buffer); responseContainer.has_continuous = true; responseContainer.continuous = true; @@ -1670,11 +1680,22 @@ uint32_t StartEventsNotificationRequestFunc(MessageContainer* requestContainer) // ReportInitParams InitParams; //ControlStart(); EventsNotificationRequestAccepted = true; - //AlarmHandlingStart(); + AlarmHandlingStart(); + MessageContainer responseContainer; + + StartEventsNotificationResponse response = START_EVENTS_NOTIFICATION_RESPONSE__INIT; StartEventsNotificationRequest* request = start_events_notification_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (AlarmHandlingToken, requestContainer->token,36); start_events_notification_request__free_unpacked(request,NULL); + + responseContainer = createContainer(MESSAGE_TYPE__StartEventsNotificationResponse, AlarmHandlingToken, false, &response, &start_events_notification_response__pack, &start_events_notification_response__get_packed_size); + responseContainer.has_continuous = true; + responseContainer.continuous = true; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + SendChars(container_buffer, container_size); return status; } uint32_t StopEventsNotificationRequestFunc(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 2c7512129..dec526668 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -569,6 +569,7 @@ void setRapidPressureRead(bool value) } uint16_t PumpCounter = 0; +uint16_t realtimetest[101]; uint32_t MillisecLowLoop(uint32_t tick) { uint8_t Motor_i,Disp_i,temp; @@ -598,6 +599,7 @@ uint32_t MillisecLowLoop(uint32_t tick) Onesecond_Tick = (tick%eOneSecond == 0) ?true:false; OneMinute_Tick = (tick%eOneMinute == 0) ?true:false; OneHourTick = (tick%eOneHour == 0) ?true:false; + realtimetest[(tick%1000)/10]++; //gather Motor data from FPGA //ROM_IntMasterDisable(); int StartPT100 = 0; @@ -720,8 +722,8 @@ uint32_t MillisecLowLoop(uint32_t tick) } Trigger_WHS_PT100_Read_All(); Trigger_WHS_MAX11614_Read_allADC(); - WHS_Blower_Avarege_ORF1(); //drier - WHS_Blower_Avarege_ORF3(); //head + //WHS_Blower_Avarege_ORF1(); //drier + //WHS_Blower_Avarege_ORF3(); //head Trigger_WHSReadAllFanTacho (); } if (OneMinute_Tick) diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 63fe510c4..0764b2028 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -446,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))*10 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); + OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1)/100)*1000 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); DiagnosticsMonitor.overalltemperature = &OverallTemperature; DiagnosticsMonitor.n_midtank1level = 1; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 4f6a40c90..e4667a95f 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -717,6 +717,21 @@ uint32_t LoadConfigurationParamsFromFile(bool Initialize) } return Fresult; } +void HWConfigurationLoadFile(void) +{ + FRESULT Fresult = FR_OK; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config + if (buffer) + { + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); + free (buffer); + FlashInitResults[0] = true; + } + Report("Hardware Initialized", __FILE__,__LINE__,Bytes, RpMessage, GENHWCFG_MAP_IN_FLASH, 0); +} void FlashInitAndLoad(void) { FRESULT Fresult = FR_OK; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h index 76e4d4414..55490a140 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h @@ -17,6 +17,8 @@ extern void HWSystemResetRequest(MessageContainer* requestContainer); uint32_t HWConfigurationInit(void); void FlashInitAndLoad(void); uint32_t LoadConfigurationParamsFromFile(bool); +void HWConfigurationLoadFile(void); + extern HardwareBlower BlowerCfg; extern bool DataUpdated; diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index d3a97bf3a..98fb74ea7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -126,13 +126,25 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.has_progress = false; } } + else + if (request->amount == 0x3E6) // get WHS Blower speed by Q value + { + if (WHS_Type == WHS_TYPE_NEW) + { + response.progress = WHS_Get_Volt_Blower_Control(); + //response.progress = 0; + response.has_progress = true; + } + } + // WHS_Get_Volt_Blower_Control else if(request->amount == 0x3EA) { uint16_t tempu16 = 0; + double temp_double = 0.0; if (WHS_Type == WHS_TYPE_NEW) { - switch(request->delay )// set WHS Blower speed 0x00-0xfff + switch(request->delay )// get A2D { case 0: get_orf_1(&tempu16); @@ -161,12 +173,53 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) case 8: tempu16 = 0; //get_cur_vlv2(&tempu16); break; + case 10: + temp_double = get_ORF1_Q(); + break; + case 12: + temp_double = get_ORF3_Q(); + break; + case 20: + temp_double = get_average_ORF1_Q(); + break; + case 22: + temp_double = get_average_ORF3_Q(); + break; + + case 11: + //get_orf_2(&tempu16); + break; + case 13: + //get_vlev1(&tempu16); + break; + case 14: + //get_vlev2(&tempu16); + break; + case 15: + //get_gas_out(&tempu16); + break; + case 16: + //get_cur_fan(&tempu16); + break; + case 17: + //get_cur_vlv1(&tempu16); + break; + case 18: + //tempu16 = 0; //get_cur_vlv2(&tempu16); + break; default : tempu16 = 0x500; //get_cur_vlv2(&tempu16); break; } } - response.progress = (double)tempu16; + if ((request->delay)<10) + { + response.progress = (double)tempu16; + } + else + { + response.progress = temp_double; + } response.has_progress = true; } else // @@ -392,8 +445,8 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if((request -> delay & 0xFFF000) == 0xCAF000)//Actuator { - HeadCard_Actuators_Control((ACTUATORS)(((request -> delay) & 0x100)>>8), /*(bool)((request -> delay & 0x10)>>4), */(bool)((request -> delay & 0x01)));//Actuators: ID, power, Direction - //Trigger_Head_Actuators_Control((ACTUATORS)(((request -> delay) & 0x100)>>8), (bool)((request -> delay & 0x10)>>4), (bool)((request -> delay & 0x01)));//Actuators: ID, power, Direction + //HeadCard_Actuators_Control((ACTUATORS)(((request -> delay) & 0x100)>>8), /*(bool)((request -> delay & 0x10)>>4), */(bool)((request -> delay & 0x01)));//Actuators: ID, power, Direction + Trigger_Head_Actuators_Control((ACTUATORS)(((request -> delay) & 0x100)>>8), (bool)((request -> delay & 0x10)>>4), (bool)((request -> delay & 0x01)));//Actuators: ID, power, Direction //response.progress = HeadCard_Actuators_Status((ACTUATORS)((request -> delay) & 0x100)>>8); response.has_progress = true; } @@ -511,7 +564,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if((request->amount == 0x0CE) && (request->delay == 0x0CE)) //Get Gas Sensor { - LOG_ERROR(request->delay,"FlashInitAndLoad"); + LOG_ERROR(request->delay,"FlashInit"); FlashInit(); response.progress = (double)OK; response.has_progress = true; -- cgit v1.3.1 From 91fbd106c73ab40c76ad0e9d58b32e42c5325060 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 19 Feb 2020 12:35:02 +0200 Subject: voltage control handling, feature #1316, #1565 resolved --- .../Embedded/Common/SWUpdate/FileSystem.c | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 64 ++++++++++++++++++++-- 2 files changed, 61 insertions(+), 5 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 15e845527..1ba656657 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -49,7 +49,7 @@ FIL *UploadFileHandle = 0; //the system supports a single active file FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; -#define MAX_CHUNK_LENGTH 4000 +#define MAX_CHUNK_LENGTH 5500 int32_t FileLength = 0; int32_t FileReceivedLength = 0; int32_t FileSentLength = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 290e65fa9..d8cc94273 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -1485,19 +1485,75 @@ uint32_t HeatersDisasterControl(uint32_t x,uint32_t y) return OK; } bool UseSecondaryDrierHeater = true; -uint32_t DrierHeaterVlotageSetup(double voltage) +double TotalCurrentLimit(double VAC) +{ + if (VAC<=210) + { + return 5.8; + } + else if (VAC>222) + { + return 5.15; + } + else + { + return 5.5; + } + +} +uint32_t DrierHeaterVoltageSetup(double voltage) { - uint32_t status = OK; double DrierAcVoltage = 0.0; + char str[100]; + bool tempDrier2 = UseSecondaryDrierHeater; + if (Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD) //rapid/pp machines { DrierAcVoltage = ReadVAC(); - + if (DrierAcVoltage<=180) + { + AlarmHandlingSetAlarm(EVENT_TYPE__POWER_UP_BIT_FAILURE, true); + ReportWithPackageFilter(HeatersFilter,"Power too low!!!!!", __FILE__,__LINE__,DrierAcVoltage, RpMessage, 0, 0); + } + else if (DrierAcVoltage>264) + { + AlarmHandlingSetAlarm(EVENT_TYPE__POWER_UP_BIT_FAILURE, true); + ReportWithPackageFilter(HeatersFilter,"Power too high!!!!!", __FILE__,__LINE__,DrierAcVoltage, RpMessage, 0, 0); + ReportWithPackageFilter(HeatersFilter,"Power too high!!!!!", __FILE__,__LINE__,DrierAcVoltage, RpMessage, 0, 0); + ReportWithPackageFilter(HeatersFilter,"Power too high!!!!!", __FILE__,__LINE__,DrierAcVoltage, RpMessage, 0, 0); + HeatersEnd(); + //PowerOffPowerOff(); + } + else if (DrierAcVoltage<205) + { + UseSecondaryDrierHeater = true; + } + else if (DrierAcVoltage>224) + { + UseSecondaryDrierHeater = false; + } + else + { + if ((GetZone2RMSCurrent(DrierAcVoltage)+Get_Heaters_Current(HEATER_DRYER_CURRENT_1))>TotalCurrentLimit(DrierAcVoltage)) + { + UseSecondaryDrierHeater = false; + } + else + { + UseSecondaryDrierHeater = true; + } + } } else { UseSecondaryDrierHeater = true; } + if (tempDrier2 != UseSecondaryDrierHeater) + { + usnprintf(str, 100, "\r\n Changing Drier 2 setting VAC %d D1 Current %d D2 assumed current %d limit %d" + ,DrierAcVoltage,(int)(GetZone2RMSCurrent(DrierAcVoltage)*100),(int)(Get_Heaters_Current(HEATER_DRYER_CURRENT_1)*100),(int)(TotalCurrentLimit(DrierAcVoltage)*100)); + ReportWithPackageFilter(HeatersFilter,str, __FILE__,__LINE__,DrierAcVoltage, RpMessage, UseSecondaryDrierHeater, 0); + } return OK; } uint32_t HeatersControlLoop(uint32_t tick) @@ -1541,7 +1597,7 @@ uint32_t HeatersControlLoop(uint32_t tick) } if ((HeaterMaxTempFlag[HEATER_TYPE__DryerSecondaryHeater] == false)&&(UseSecondaryDrierHeater == true)) { -#warning trial use both heaters in drier +//#warning trial use both heaters in drier ActivateHeater (HEATER_TYPE__DryerSecondaryHeater); //DeActivate HEATER_TYPE__DryerSecondaryHeater //DeActivateHeater (HEATER_TYPE__DryerSecondaryHeater); -- cgit v1.3.1