From 55387f5654403fff0ca3173f5bfcd69a12825ed8 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 17 Jun 2019 13:53:39 +0300 Subject: preparation for sample winding, preparation for work with FLASH instead of FFS --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 9d773c1af..81fa33ef2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -42,7 +42,7 @@ uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); uint32_t Winder_Init(void); -uint32_t Winder_Prepare(void); +uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); uint32_t WinderDistanceToSpoolState(void ); uint32_t Winder_End(void); -- cgit v1.3.1 From fa3f933179443f7f50b321e1730f363ae60a6c14 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 27 Jun 2019 19:02:38 +0300 Subject: Embedded SW Release note - Version 1.4.1.0 ============================================================= Move to length calculation FROM PULLER fix intersegment handling FLASH - rebuilt. using data from flash instead of FFS DFU fixed. Heaters handling fixed. job starts only in proximity to requested temperature --- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded_SW/Embedded/Common/Utilities/Update.c | 7 + .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 4 +- .../Drivers/I2C_Communication/DAC/Blower.c | 2 +- .../Embedded_SW/Embedded/Drivers/Motors/Motor.h | 7 +- .../Embedded/Drivers/Motors/MotorActions.c | 1 + .../Embedded/Drivers/USB_Communication/USBCDCD.c | 5 +- .../Embedded/Drivers/USB_Communication/USBCDCD.h | 2 + .../Embedded/Drivers/flash_ram/FlashProgram.c | 1 - .../Embedded/Drivers/flash_ram/FlashProgram.h | 7 +- Software/Embedded_SW/Embedded/Embedded.cfg | 2 +- Software/Embedded_SW/Embedded/Main.c | 10 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 37 +++- .../Embedded/Modules/AlarmHandling/AlarmHandling.h | 3 + .../Embedded/Modules/General/GeneralHardware.c | 206 ++++++++++++++++----- .../Embedded/Modules/General/GeneralHardware.h | 1 + .../Embedded_SW/Embedded/Modules/General/process.c | 31 +++- .../Embedded/Modules/Heaters/Heaters_print.c | 41 +++- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 52 +++++- .../Embedded/Modules/Stubs_Handler/Progress.c | 8 + .../Embedded/Modules/Thread/Thread_Winder.c | 4 +- .../Embedded/Modules/Thread/Thread_ex.h | 1 + .../Embedded/Modules/Thread/Thread_print.c | 88 +++++++-- .../Embedded/Software Release Notes.txt | 8 + .../Embedded/StateMachines/Printing/JobSTM.c | 10 + 25 files changed, 428 insertions(+), 112 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h') diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index f0ee0af19..7fbc9acc8 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,4,0,9}; +TangoVersion_t _gTangoVersion = {1,4,1,0}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Update.c b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c index 422c1632b..c2aad92f1 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Update.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c @@ -31,6 +31,13 @@ void UpdateUsb(void) // Disable all interrupts. // ROM_IntMasterDisable(); +#ifdef WATCHDOG + //ROM_WatchdogResetDisable(WATCHDOG0_BASE); + //ROM_WatchdogReloadSet(WATCHDOG0_BASE, 120000000*35); +#endif + ControlStop(); + MillisecStop(); + HeatersEnd(); // // Disable SysTick and its interrupt. diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c index fcf055b53..5aea18994 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -31,7 +31,7 @@ uint32_t MidTank_Pressure_Bits[8];//just for debug static uint8_t Config_Buf[3]; -static double MidThankReadingOffset = 0; +//static double MidThankReadingOffset = 0; uint32_t I2C_ADC_Config(uint32_t I2C_Slave_Add,uint32_t channel ) { @@ -125,7 +125,7 @@ double Calculate_Pressure(uint32_t VsampleInBits ) void MidTankPressureCorrection(double Offset) { - MidThankReadingOffset = Offset; + //MidThankReadingOffset = Offset; } double Calculate_Pressure(uint32_t VsampleInBits )//MidTank diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c index 6ee02783d..1cbd88f3b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -23,6 +23,7 @@ #include "drivers/I2C_Communication/I2C.h" #include "Blower.h" #include "modules/control/control.h" +#include "drivers/FPGA/FPGA.h" DAC_Union DAC; @@ -237,7 +238,6 @@ uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) ////////////////////////////////////////////////////////////////////////////////////////// -#include "drivers/FPGA/FPGA.h"; extern SCREW_ENC Screw_RotEnc; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index 2802d2e95..c9a3a4f38 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h @@ -20,8 +20,8 @@ #define TimerMotors_t HardwareMotorType -#define NUM_OF_MOTORS (HARDWARE_MOTOR_TYPE__MOTO_SPARE3_1 + 1) // TODO After the integration with mulbery change to: -//#define NUM_OF_MOTORS HARDWARE_MOTOR_TYPE__MOTO_SPARE1_1 +//#define NUM_OF_MOTORS (HARDWARE_MOTOR_TYPE__MOTO_RLOADING + 1) // TODO After the integration with mulbery change to: +#define NUM_OF_MOTORS HARDWARE_MOTOR_TYPE__MOTO_SPARE3_1+1 #define MINIMAL_MOTOR_SPEED 0.2 //typedef enum @@ -184,6 +184,9 @@ uint32_t MotorMove(TimerMotors_t _motorId,bool direction, uint32_t Steps); uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout); uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t LimitSwitchId,callback_fptr callback,uint32_t timeout); //TODO +uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout); //TODO + +uint32_t MotorGoToDir(TimerMotors_t _motorId,bool direction, uint32_t Steps); bool MotorControlGetnBusyState(uint32_t _motorId, uint32_t parameter); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index b394a4391..a190730cb 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -431,6 +431,7 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit } else { + REPORT_MSG(MotorId,"Motor at limit"); MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction } diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 56e695ca4..b7a6fb67e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -455,12 +455,9 @@ DFUDetachCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData, // // Release updateSem // - ControlStop(); - MillisecStop(); + UpdateFlag = true; Semaphore_post(updateSem); - ROM_WatchdogResetDisable(WATCHDOG0_BASE); - //ROM_WatchdogReloadSet(WATCHDOG0_BASE, 120000000*90); } diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h index 93719ab3e..95ce37568 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h @@ -77,6 +77,8 @@ void USBCDCD_Reinit(void); void USBCDCD_hwiHandler(UArg arg0); +extern bool UpdateFlag; + //bool SendChars(char* buffer,size_t length); #ifdef __cplusplus } diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c index ac1cff75e..f2f5aefb6 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c @@ -108,7 +108,6 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b // return(1); } -#warning flash erase is now done only in init. should consider adding before config changes uint32_t EraseFlashSection(uint32_t ui32FlashStart,uint32_t ui32FileSize) { volatile uint32_t ui32Idx; diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h index b5c0e7373..68b6dc2c5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h @@ -10,10 +10,11 @@ #define FLASH_RAM_BASE 0x000D0000 -#define MOTOR_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 ) +#define EMBEDDED_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 ) +#define PROCESS_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0400 ) +#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0500) +#define DISPENSERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X1000) #define ALARM_MAP_IN_FLASH (FLASH_RAM_BASE + 0X2000 ) -#define JOB_MAP_IN_FLASH (FLASH_RAM_BASE + 0X4000 ) -#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0XA000) #define GENHWCFG_MAP_IN_FLASH (FLASH_RAM_BASE + 0X10000) #define OTHER_MAP_IN_FLASH (FLASH_RAM_BASE + 0X12000) diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index c50a0057a..a0b853ec8 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -86,7 +86,7 @@ Program.global.ReconnectSem = Semaphore.create(null, semaphore7Params); var MillisecTaskParams = new Task.Params(); MillisecTaskParams.instance.name = "MilliSecond"; -MillisecTaskParams.stackSize = 2048; +MillisecTaskParams.stackSize = 4096; MillisecTaskParams.priority = 12; Program.global.millisec = Task.create("&MillisecTask", MillisecTaskParams); diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index a4cee031d..ba4b3ebf0 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -108,14 +108,14 @@ F3_GPO_01_REG F3_GPO_01_Reg; Types_Site *site; Error_Id eid; int eCode; - +char ErrorPath[50] = "0://ErrFile.txt"; +bool UpdateFlag = false; /* ======== errHook ======== */ Void errHook(Error_Block *eb) { FRESULT Fresult = FR_OK; FIL *FileHandle = 0; //the system supports a single active file uint32_t Bytes = 0; - char ErrorPath[50] = "0://ErrFile.txt"; char File[50] = ""; char message[300]; int len; @@ -128,6 +128,8 @@ Void errHook(Error_Block *eb) ACTIVITY_RED_LED_ON; COMM_RED_LED_ON; + if (UpdateFlag == true) + return; site = Error_getSite(eb); eid = Error_getId(eb); eCode = Error_getCode(eb); @@ -250,6 +252,7 @@ int main(void) InitWatchdog(ui32SysClock*10); #endif + //FlashInitAndLoad(); CommunicationTaskInit(); utilsInit(ui32SysClock); @@ -276,9 +279,6 @@ int main(void) //IDS_ModuleInit(); Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); -#ifndef FPGA_WATCHDOG - Control_WD(DISABLE,0); -#endif //////////////////////////// diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index b651f2448..d81b75529 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -24,9 +24,9 @@ #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "drivers/FPGA/FPGA.h" -#include "PMR/Hardware/HardwareDancerType.pb-c.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h" +#include "Common/SWUpdate/FileSystem.h" #include "modules/thread/thread_ex.h" #include "modules/heaters/heaters_ex.h" @@ -38,6 +38,8 @@ #include #include +#include + #include #include #include @@ -347,7 +349,7 @@ const AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ }; -char AlarmStorePath[25] ="0://SysInfo//AlarmPrm.cfg"; +char AlarmStorePath[30] ="0://SysInfo//AlarmPrm.cfg"; //bool DispenserInUse[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; bool EventsNotificationRequestAccepted = false; @@ -361,6 +363,30 @@ bool EventsNotificationRequestAccepted = false; //valve OCD //Motor Status //machine cover open +uint32_t AlarmHandlingFlashLoad(void) +{ + +// EraseFlashSection(ALARM_MAP_IN_FLASH,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); + ReadAppAndProgram(AlarmItem, sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS, HardCodedAlarmItem); +// LOG_ERROR(AlarmItem[2].EventName,"Flash Test"); + + return sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS; +} +uint32_t AlarmHandlingLoadFile(void) +{ + FRESULT Fresult = FR_OK; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + Fresult = FileRead(AlarmStorePath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + ReadAppAndProgram(AlarmItem, Bytes,buffer); + free (buffer); + } + return Bytes; +} + void AlarmHandlingInit(void) { Error_Block eb; @@ -378,9 +404,8 @@ void AlarmHandlingInit(void) } AlarmItem = (AlarmHandlingItemStruc *)ALARM_MAP_IN_FLASH; -// EraseFlashSection(ALARM_MAP_IN_FLASH,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); - ReadAppAndProgram(AlarmItem, sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS, HardCodedAlarmItem); -// LOG_ERROR(AlarmItem[2].EventName,"Flash Test"); + + //AlarmHandlingFlashLoad(); return; } @@ -758,6 +783,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) for (Alarm_i = 0;Alarm_i < MAX_SYSTEM_ALARMS;Alarm_i++) { Status = false; + if (AlarmItem[Alarm_i].AlarmSource > ALARM_SOURCE_TYPE__FluidLevelAlarm) + continue; if (tick%AlarmItem[Alarm_i].Frequency == 0) { switch (AlarmItem[Alarm_i].AlarmSource) diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h index 09dfa3f3d..392b31afc 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h @@ -9,6 +9,9 @@ #define MODULES_ALARMHANDLING_ALARMHANDLING_H_ #include "StateMachines/Printing/PrintingSTM.h" +uint32_t AlarmHandlingFlashLoad(void); +uint32_t AlarmHandlingLoadFile(void); + uint32_t AlarmHandling_ControlTrigger(uint32_t IfIndex, uint32_t ReadValue); //uint32_t AlarmHandling_CalculateTemperatures(uint32_t SensorId, uint32_t Data); diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 2d64c8515..23009d7fb 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -34,6 +34,10 @@ #include "PMR/Hardware/SystemResetRequest.pb-c.h" #include "PMR/Hardware/SystemResetResponse.pb-c.h" +#include "PMR/Printing/ProcessParameters.pb-c.h" +#include "PMR/Printing/UploadProcessParametersRequest.pb-c.h" +#include "PMR/Printing/UploadProcessParametersResponse.pb-c.h" + #include "drivers/I2C_Communication/DAC/Blower.h" #include "drivers/Valves/Valve.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" @@ -55,30 +59,14 @@ HardwareBlower BlowerCfg; char *SW_INFO_DIR = "0://SysInfo"; char HwConfigPath[50] = "0://SysInfo//GenHwCfg.cfg"; -uint32_t HWConfigurationInit(void) +void *HWConfigurationLoadFromFile( uint32_t *NumOfBytes) { FRESULT Fresult = FR_OK; FIL *FileHandle = 0; //the system supports a single active file uint8_t* buffer = NULL; - void* buffer1 = NULL; uint32_t Bytes = 0,i,j,k=0; - uint32_t status = OK; - UploadHardwareConfigurationRequest* UploadRequest=0; - GeneralHwReady = false; - Control_WD(ENABLE,250); - - memcpy(&Bytes,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(Bytes)); - - if ((Bytes)&&(Bytes < 4000)) - { - buffer1 = my_malloc (Bytes); - if (buffer1) - { - memcpy(buffer1, (void *)(GENHWCFG_MAP_IN_FLASH+4),Bytes); - UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer1); - } - } + *NumOfBytes = 0; Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { @@ -96,32 +84,68 @@ uint32_t HWConfigurationInit(void) k+=j; } if (k!=Bytes) + { LOG_ERROR(k,"File read error"); + free (buffer); + buffer = NULL; + } + else + *NumOfBytes = Bytes; } - Fresult= memcmp(buffer,buffer1,Bytes); - UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); - status = HWConfiguration(UploadRequest); - if (status ==OK) - { - upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL); - //EraseFlashSection(GENHWCFG_MAP_IN_FLASH,Bytes+4); - //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,Bytes); - //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); - } - else - { - SetMachineState(MACHINE_STATE_HW_CONFIG_FAILED); - } - free (buffer); } f_close(FileHandle); + free (FileHandle); + } + + return buffer; +} + +uint32_t HWConfigurationInit(void) +{ + void* buffer1 = NULL; + uint32_t status = OK; + UploadHardwareConfigurationRequest* UploadRequest=0; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + GeneralHwReady = false; + Control_WD(ENABLE,250); + + memcpy(&Bytes,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(Bytes)); + + if ((Bytes)&&(Bytes < 4000)) + { + buffer1 = my_malloc (Bytes); + if (buffer1) + { + memcpy(buffer1, (void *)(GENHWCFG_MAP_IN_FLASH+4),Bytes); + UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer1); + } + } + //buffer = HWConfigurationLoadFromFile(&Bytes); + //status= memcmp(buffer,buffer1,Bytes); + //UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); + status = HWConfiguration(UploadRequest); + if (status ==OK) + { + upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL); + //EraseFlashSection(GENHWCFG_MAP_IN_FLASH,Bytes+4); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,Bytes); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); + } + else + { + SetMachineState(MACHINE_STATE_HW_CONFIG_FAILED); } + if (buffer) + free (buffer); + //EmbeddedParametersInit(); IDS_Dispenser_Content_Init(); //ProcessParamsInit(); GeneralHwReady = true; STATUS_RED_LED_OFF; - return Fresult; + return status; } char EmbeddedParametersPath[50] = "0://SysInfo//EmbParam.cfg"; @@ -153,7 +177,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters.has_dispenserbuildpressurespeed = true; EmbeddedParameters.dispenserbuildpressurespeed=500; EmbeddedParameters.has_dispenserbuildpressurelimit = true; - EmbeddedParameters.dispenserbuildpressurelimit=1.5 ; + EmbeddedParameters.dispenserbuildpressurelimit=0.8 ; EmbeddedParameters.has_dispenserbuildpressuretimeout = true; EmbeddedParameters.dispenserbuildpressuretimeout=60000; EmbeddedParameters.has_dispenserbuildpressurelag = true; @@ -174,6 +198,16 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters.startheatingoninitsequence = true; //set to true shlomo 14/5/2019 //size_t n_generalparameters; // EmbeddedParameters.*generalparameters; + EmbeddedParameters.generalparameters = malloc (sizeof(double)*10); + if (EmbeddedParameters.generalparameters) + { + EmbeddedParameters.generalparameters[0] = 1.0; //CheckHardLimitAlarms + EmbeddedParameters.generalparameters[1] = 0.0; //CheckCurrentAlarms + EmbeddedParameters.generalparameters[2] = 0.0; //CheckTamperAlarms + EmbeddedParameters.generalparameters[3] = 800.0; //Winder homing time at end of job + //EmbeddedParameters.generalparameters[4] = 1.0; //Dispenser initial pressure limit + //EmbeddedParameters.generalparameters[5] = 1.0; //Dispenser initial pressure speed + } EmbeddedParameters.has_currentalarmlowlimit = true; EmbeddedParameters.currentalarmlowlimit = 0.80; EmbeddedParameters.has_currentalarmhighlimit = true; @@ -213,29 +247,34 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) FileWrite(response_buffer,response_size,EmbeddedParametersPath); my_free(response_buffer); } - else memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); + else + { + memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); + } + uint32_t Bytes = sizeof(EmbeddedParameters); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, &EmbeddedParameters); } uint32_t EmbeddedParametersInit(void) { FRESULT Fresult = FR_OK; - void* buffer = NULL; + //void* buffer = NULL; uint32_t Bytes = 0; - //ConfigurationParameters *Params; + ConfigurationParameters *Params; - Fresult = FileRead(EmbeddedParametersPath, &Bytes, &buffer); - /*if (Fresult == FR_OK) + memcpy(&Bytes,(void *)EMBEDDED_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + + if ((Bytes)&&(Bytes < 1000)) { - Params = configuration_parameters__unpack(NULL, Bytes, buffer); - LoadConfigurationParameters(Params); - DataUpdated=true; - free (buffer); - configuration_parameters__free_unpacked(Params,NULL); + Params = (ConfigurationParameters *)(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4); + memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); } - else*/ + else { LoadConfigurationParameters(0); } + IDS_Dispenser_SetTimeOutValues(EmbeddedParameters.closevalvetimeout, EmbeddedParameters.openvalvetimeout); IDS_Dispenser_SetBackLashValues(EmbeddedParameters.initialdispenserpressure, EmbeddedParameters.initialdispensertimeout, EmbeddedParameters.initialdispensertimelag); IDS_Dispenser_SetPrepareValues(EmbeddedParameters.dispenserbuildpressurespeed, EmbeddedParameters.dispenserbuildpressurelimit, EmbeddedParameters.dispenserbuildpressuretimeout, EmbeddedParameters.dispenserbuildpressurelag); @@ -481,3 +520,78 @@ void HWSystemResetRequest(MessageContainer* requestContainer) HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ; } +uint32_t FlashInitResults[5] = {0,0,0,0,0}; +void FlashInitAndLoad(void) +{ + FRESULT Fresult = FR_OK; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + ConfigurationParameters *Params = NULL; + ProcessParameters* ProcessParams = NULL; + UploadProcessParametersRequest* request = NULL; + + char ProcessParamsPath[50] = "0://SysInfo//ProcessP.cfg"; + + FlashInit(); //initialize flash + Report("Flash Initialized", __FILE__,__LINE__,FLASH_SIZE, RpMessage, FLASH_RAM_BASE, 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); + + StoreDancerConfigMessage(); + Report("Dancer Initialized", __FILE__,DancersCfg[0].zeropoint,DancersCfg[1].zeropoint, RpMessage, DancersCfg[2].zeropoint, 0); + Bytes = AlarmHandlingLoadFile(); + if (Bytes>0) + { + Report("Alarm Initialized from file", __FILE__,__LINE__,Bytes, RpMessage, ALARM_MAP_IN_FLASH, 0); + } + else + { + Bytes = AlarmHandlingFlashLoad(); + Report("Alarm Initialized hard coded", __FILE__,__LINE__,Bytes, RpMessage, ALARM_MAP_IN_FLASH, 0); + } + + Fresult = FileRead(EmbeddedParametersPath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + Params = configuration_parameters__unpack(NULL, Bytes, buffer); + LoadConfigurationParameters(Params); + free (buffer); + configuration_parameters__free_unpacked(Params,NULL); + FlashInitResults[1] = true; + Report("Parameters Initialized from file", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0); + } + else + { + LoadConfigurationParameters(0); + FlashInitResults[1] = 2; + Report("Parameters Initialized from default", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0); + } + Bytes = sizeof(EmbeddedParameters); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, &EmbeddedParameters); + + Fresult = FileRead(ProcessParamsPath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + request = upload_process_parameters_request__unpack(NULL, Bytes, buffer); + ProcessParams = request->processparameters; + Bytes = sizeof(ProcessParams); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, &ProcessParams); + upload_process_parameters_request__free_unpacked(request,NULL); + FlashInitResults[2] = true; + Report("Process Initialized", __FILE__,__LINE__,Bytes, RpMessage, (int)ProcessParams->dryerzone1temp, 0); + } + else + Report("Process not Initialized", __FILE__,__LINE__,0, RpMessage, 0, 0); + +} diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h index 8fdbad42e..86f164977 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h @@ -12,6 +12,7 @@ extern ConfigurationParameters EmbeddedParameters; extern uint32_t HWConfigurationFunc(MessageContainer* requestContainer); extern void HWSystemResetRequest(MessageContainer* requestContainer); uint32_t HWConfigurationInit(void); +void FlashInitAndLoad(void); extern HardwareBlower BlowerCfg; diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index b0351b4ff..aafc1c5a9 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -15,13 +15,16 @@ #include "PMR/Printing/UploadProcessParametersResponse.pb-c.h" #include "PMR/Hardware/HardwarePidControlType.pb-c.h" #include "PMR/common/MessageContainer.pb-c.h" + #include "drivers/Valves/Valve.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" + #include "modules/ids/ids_ex.h" #include "third_party/fatfs/src/ffconf.h" #include "Common/SWUpdate/FileSystem.h" #include "StateMachines/Initialization/PowerIdle.h" +#include "drivers/Flash_ram/FlashProgram.h" double dyeingspeed = 0; @@ -182,11 +185,19 @@ void ProcessRequestFunc(MessageContainer* requestContainer) MessageContainer responseContainer; uint8_t* container_buffer; uint32_t status = 0; + uint32_t Bytes = 0; UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ProcessParameters* ProcessParams = request->processparameters; if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters + { FileWrite(requestContainer->data.data, requestContainer->data.len,ProcessParamsConfigPath); + Bytes = sizeof(ProcessParameters); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); + REPORT_MSG(Bytes,"Bytes wrtie to flash"); + + } //////////////////////////////////////////////////////////////////////// /*UploadProcessParametersRequest* requesttest; uint8_t* buffer = NULL; @@ -229,11 +240,11 @@ void ProcessRequestFunc(MessageContainer* requestContainer) uint32_t ProcessParamsInit(void) { FRESULT Fresult = FR_OK; - FIL *FileHandle = 0; //the system supports a single active file - uint8_t* buffer = NULL; - uint32_t Bytes = 0,i,j,k=0; - UploadProcessParametersRequest* request; - + //FIL *FileHandle = 0; //the system supports a single active file + //uint8_t* buffer = NULL; + uint32_t Bytes;// = 0,i,j,k=0; + //UploadProcessParametersRequest* request; +/* FileHandle = my_malloc(sizeof(FIL)); if (FileHandle) { @@ -270,6 +281,16 @@ uint32_t ProcessParamsInit(void) } my_free (FileHandle); } +*/ + + memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + REPORT_MSG(Bytes,"Bytes read from flash"); + + if ((Bytes)&&(Bytes < 1000)) + { + ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); + Fresult = HandleProcessParameters(ProcessParams); + } return Fresult; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 3ebf56c7f..fe9671657 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -112,6 +112,7 @@ Mailbox_Handle HeatersControlMsgQ = NULL; //bool InitialHeating = true; //bool DCInitialHeating[MAX_HEATERS_NUM] = {true}; bool HeaterReady[MAX_HEATERS_NUM] = {true}; +bool HeaterAtTemp[MAX_HEATERS_NUM] = {true}; uint32_t HeaterPreviousRead[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0}; //A/C Heaters Cycle time in milliseconds - one for all heaters EventType HeaterEventType[MAX_HEATERS_NUM] = {EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_2_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_2_OVERTEMPERATURE, EVENT_TYPE__DYEING_HEAD_ZONE_3_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_4_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_5_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_6_OVERTEMPERATURE, @@ -158,6 +159,7 @@ void HeatersControlInit(void) { //DCInitialHeating[i] = true; HeaterReady[i] = true; + HeaterAtTemp[i] = true; HeaterCmd[i].targettemperatue = 0; HeaterCmd[i].command = HEATER_OFF; HeaterCmd[i].heaterid = i; @@ -225,7 +227,7 @@ void LoadHeaterState(HeaterType HeaterType,HeaterState *HeaterState) HeaterState->has_isactive = true; HeaterState->isactive = GetHeaterState(HeaterId); HeaterState->has_isrampingup = true; - HeaterState->isrampingup = 1-HeaterReady[HeaterId]; + HeaterState->isrampingup = 1-HeaterAtTemp[HeaterId]; HeaterState->has_isinsetpoint = true; HeaterState->isinsetpoint = HeaterReady[HeaterId]; if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) @@ -260,6 +262,7 @@ uint32_t HeatersSingleHeaterEnd(HardwarePidControlType HeaterId) DeActivateHeater(HeaterId); HeaterPIDConfig[HeaterId].m_SetParam = 0; HeaterReady[HeaterId] = true; + HeaterAtTemp[HeaterId] = true; } else if (HeaterId < MAX_AC_HEATERS) //AC Heaters { @@ -289,6 +292,7 @@ uint32_t HeatersSingleHeaterEnd(HardwarePidControlType HeaterId) DeActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary); HeaterPIDConfig[HeaterId].m_SetParam = 0; HeaterReady[HeaterId] = true; + HeaterAtTemp[HeaterId] = true; } AlarmHandlingSetAlarm(HeaterUnderEventType[HeaterId], false); @@ -474,6 +478,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); //InitialHeating = true; HeaterReady[HeaterId] = false; + HeaterAtTemp[HeaterId] = false; if (BlowerCfg.enabled == true) { Turn_the_Blower_On();//Turn on with the Default_Voltage @@ -503,6 +508,7 @@ int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) //HeaterPIDConfig[HeaterId].m_params.dt *=10; //DCInitialHeating[HeaterId] = true; HeaterReady[HeaterId] = false; + HeaterAtTemp[HeaterId] = false; HeaterRecalculateHeaterParams(HeaterId, 0); //turn all alarms off @@ -593,7 +599,7 @@ bool HeaterCheckReady(void) int i; for (i=0;i (HeaterCmd[index].targettemperatue * AcHeatersLoweroperationLimit/1000))&&(readValue < (HeaterCmd[index].targettemperatue * AcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target + { + //InitialHeating = false; + Report("AC Ready",__FILE__,__LINE__,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = true; + HeaterPrepareReady(); + } + } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { HeaterPIDConfig[index].m_mesuredParam = readValue; @@ -1057,13 +1070,21 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) Report("DC PID Activating",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); //DCInitialHeating[index] = false; HeatersControlStart(); - HeaterReady[index] = true; AlarmHandlingSetAlarm(HeaterUnderEventType[index], false); Disable_Reading_Heaters_Current(HeaterId2CurrentId[index]); - HeaterPrepareReady(); + HeaterReady[index] = true; } return OK; } + if (HeaterAtTemp[index] == false) + { + if ((readValue > (HeaterCmd[index].targettemperatue * DcHeatersLoweroperationLimit/1000))&&(readValue < (HeaterCmd[index].targettemperatue * DcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target + { + Report("DC Ready",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = true; + HeaterPrepareReady(); + } + } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 4cc6eac30..c8836a2b4 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -107,8 +107,8 @@ int lInterSegmentLength = 0; uint32_t IDS_DispenserControlInit() { - DispensersControl = (void *)(DANCERS_MAP_IN_FLASH + 1024); - EraseFlashSection(DispensersControl,sizeof(HardwarePidControl)*MAX_SYSTEM_DISPENSERS); + DispensersControl = (void *)(DISPENSERS_MAP_IN_FLASH); + //EraseFlashSection(DispensersControl,sizeof(HardwarePidControl)*MAX_SYSTEM_DISPENSERS); return OK; } @@ -595,7 +595,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { - if (GetDispenserPressure(i) > 0.80) + if (GetDispenserPressure(i) > DispenserPreparePressure) NumofReadyDispensers++; } } @@ -691,8 +691,8 @@ c. Go to step 2.a x Segment.BrushStopsCount. REPORT_MSG((int)NumOfActiveDispensers, "Num Of Active Dispensers"); for (i = 0; i < MAX_DYE_DISPENSERS; i++) { - dispenserspeed = PrepeareSpeed/MotorsCfg[DispenserIdToMotorId[i]].microstep; - dispenserspeed = 480; + //dispenserspeed = PrepeareSpeed/MotorsCfg[DispenserIdToMotorId[i]].microstep; + dispenserspeed = DispenserPrepareSpeed; //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { @@ -851,9 +851,10 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); 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); + //IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); + MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); + CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; + usnprintf(IdsMessage, 80, "WFCF Dispenser %d nl/sec %d nl/pulse %d speed %d", DispenserId, @@ -952,6 +953,37 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; } } + /*if (SegmentId == 0)//first segment - running the DTS out of the drier + { + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away + for (Dispenser_i = 0; Dispenser_i < MAX_SYSTEM_DISPENSERS; Dispenser_i++) + { + HW_Motor_Id = DispenserIdToMotorId[Dispenser_i]; + //MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves + if (DispenserUsedInJob[Dispenser_i]==true)//unconfigured dispenser + { + MotorStop(HW_Motor_Id, Soft_Hiz); + CurrentDispenserSpeed[Dispenser_i] = 0; + } + } + lInterSegmentLength = ((dryerbufferlength*100)*1000/dyeingspeed); + lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication + InterSegmentStepsCount = 0; + DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); + if (DispenserPreSegmentControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); + return ERROR; + } + Report("Add control callback ",__FILE__,__LINE__,(int)100,RpWarning,(int)dryerbufferlength,0); + if (EnableCleaning == true) + { + InterSegmentStartSprayCleaner = 500; + InterSegmentStartRocking = 1000; + InterSegmentCenterRockers = 3000; + } + InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; + }*/ if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) { @@ -1017,8 +1049,10 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) } if ((EnableIntersegment == true)&&(IntersegmentLength>0)) { - MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves + MotorStop(HW_Motor_Id,Soft_Hiz); //26/03/19 test without valves CurrentDispenserSpeed[DispenserId] = 0; + //MotorSetSpeed(HW_Motor_Id, 5); + //CurrentDispenserSpeed[Dispenser_i] = 5; DispenserPreSegmentReady[DispenserId] = true; //27/03/19 check if job should be stopped REPORT_MSG(DispenserId,"Dispenser stopped pre Segment"); } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 5d50a21c7..1420f7b97 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -51,6 +51,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = (double)Calculate_Gas_Power_Consumption(); response.has_progress = true; + } + else + if((request->amount == 0x0CE) && (request->delay == 0x0CE)) //Get Gas Sensor + { + FlashInitAndLoad(); + response.progress = (double)OK; + response.has_progress = true; + } else if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 4f6585f2a..8943e5d30 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -36,6 +36,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); void ScrewTimerInterruptInit(void); void ScrewsStopControlTimer (void); void ScrewsStartControlTimer (void); +void ScrewTimerInterrupt(int); bool Winder_ScrewHoming = false; bool ScrewCurrentDirection = false; //holds current screw direction @@ -361,6 +362,7 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue) uint32_t WinderSamplesSegmentCallback(uint32_t SegmentDetails, uint32_t SegmentId) { ScrewTimerInterrupt(0); + return OK; } uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) @@ -381,7 +383,7 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) { InternalWinderCfg.segmentoffsetpulses = 120; MotorGotoWithBusyCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW,true, (InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1)), WinderSamplesSegmentCallback,2000); //TODO - Report("ScrewsMotorGoTo direction,speed ", __FILE__,__LINE__,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep, RpMessage, ScrewSpeed, 0); + Report("ScrewsMotorGoTo direction,speed ", __FILE__,__LINE__,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1), RpMessage, ScrewSpeed, 0); InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 81fa33ef2..167616afe 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -22,6 +22,7 @@ typedef enum threadMotorsEnum }threadMotorsEnum; extern double TotalProcessedLength; +extern double PoolerTotalProcessedLength; void ThreadSetBreakSensorLimit(int limit); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index d0124fcc0..5efc3798e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -67,6 +67,7 @@ double PoolerLengthCalculationMultiplier; double TempPoolerTotalProcessedLength = 0.0; double TempTotalProcessedLength = 0.0; +bool InitialProcess = false; bool PrepareState = false; // job parameters bool EnableLubrication = false; @@ -148,10 +149,12 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) double length = 0.0; int index = MAX_THREAD_MOTORS_NUM; - // if (ThreadControlActive == false) - // return OK; - // if (PrepareState == true) - // return OK; +#ifndef FEEDER_LENGTH_CALCULATION + if (ThreadControlActive == false) + return OK; + if (PrepareState == true) + return OK; +#endif if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -194,13 +197,14 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) } } + TotalProcessedLength += (length/100); + TempTotalProcessedLength = TotalProcessedLength; +#ifdef FEEDER_LENGTH_CALCULATION CurrentProcessedLength+=length; - static int pooler_counter = 0; - pooler_counter++; - TotalProcessedLength+= (length/100); - TempTotalProcessedLength = TotalProcessedLength; - if (pooler_counter%10 == 0) + static int feeder_counter = 0; + feeder_counter++; + if (feeder_counter%10 == 0) { if (PrepareState == true) { @@ -225,18 +229,22 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) ProcessedLengthFuncPtr(); } -return OK; +#endif + + return OK; } uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { - uint32_t positionDiff = 0; + uint32_t positionDiff = 0,prevprev; double length = 0.0; int index = MAX_THREAD_MOTORS_NUM; +#ifdef FEEDER_LENGTH_CALCULATION if (ThreadControlActive == false) return OK; if (PrepareState == true) return OK; +#endif if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -258,13 +266,56 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) PoolerPreviousPosition = PoolerCurrentPosition; Poolerinitialpos = 0; } + prevprev = PreviousPosition; positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition); //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; PoolerPreviousPosition = PoolerCurrentPosition; length = (double)(positionDiff)*PoolerLengthCalculationMultiplier; - PoolerTotalProcessedLength+= (length/100); - TempPoolerTotalProcessedLength = PoolerTotalProcessedLength; + //if (InitialProcess == false) + { + PoolerTotalProcessedLength+= (length/100); + TempPoolerTotalProcessedLength = PoolerTotalProcessedLength; + } + if (length > 1000) + { + usnprintf(Lenstr, 100, "pooler length huge: length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,PreviousPosition,prevprev); + SendJobProgress(0.0,0,false, Lenstr); + Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); + length = 0; + + } +#ifndef FEEDER_LENGTH_CALCULATION + CurrentProcessedLength+=length; + + static int puller_counter = 0; + puller_counter++; + if (puller_counter%10 == 0) + { + if (PrepareState == true) + { + //later - add temperatures + TemperatureListString(Lenstr); + + SendJobProgress(0.0,0,false, Lenstr); + } + else + { + SendJobProgress(PoolerTotalProcessedLength,0,false, NULL); + } + + } + if ((CurrentProcessedLength>=CurrentRequestedLength )&&(CurrentRequestedLength > 0.0)) + { + usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength); + SendJobProgress(0.0,0,false, Lenstr); + Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); + // segment/intersegment/distance to spool finished + if (ProcessedLengthFuncPtr) + ProcessedLengthFuncPtr(); + + } +#endif return OK; } @@ -632,7 +683,6 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) ThreadPreSegmentState(request,0); return OK; } -bool InitialProcess = false; //******************************************************************************************************************** uint32_t ThreadPrepareState(void *JobDetails) @@ -782,6 +832,7 @@ void SetOriginMotorSpeed(float process_speed) } void ThreadPreSegmentEnded(void) { + InitialProcess = false; REPORT_MSG (0,"First ThreadPreSegmentEnded"); PreSegmentReady(Module_Thread,ModuleDone); } @@ -839,14 +890,14 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) PreSegmentState = true; DTSState = false; } - else if ((InitialProcess==true) && (SampleWinding == true)) + /*else if (InitialProcess==true) { ThreadUpdateProcessLength (dryerbufferlength,(void *)ThreadPreSegmentEnded); REPORT_MSG (dryerbufferlength," ThreadPreSegmentState DTS length (sample)"); SegmentState = false; PreSegmentState = true; DTSState = false; - } + }*/ else { ThreadUpdateProcessLength (0,(void *)NULL); @@ -906,7 +957,12 @@ uint32_t ThreadDistanceToSpoolState(void ) { seglength = dryerbufferlength; REPORT_MSG (seglength,"ThreadDistanceToSpoolState"); +//#ifdef FEEDER_LENGTH_CALCULATION ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); +/*#else + ThreadUpdateProcessLength (0,(void *)NULL); //move DTS to job start + DistanceToSpoolReady(Module_Thread,ModuleDone); +#endif*/ SegmentState = false; PreSegmentState = false; DTSState = true; diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index ac5fb1b21..a03ab04b0 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,11 @@ +Embedded SW Release note - Version 1.4.1.0 +============================================================= +Move to length calculation FROM PULLER +fix intersegment handling +FLASH - rebuilt. using data from flash instead of FFS +DFU fixed. +Heaters handling fixed. job starts only in proximity to requested temperature + Embedded SW Release note - Version 1.4.0.9 ============================================================= Drivers: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index f552636cd..b33bf09c1 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -763,6 +763,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes } //previousJobLength = ProcessedLength; jobStatus.has_progress = true; +#ifdef FEEDER_LENGTH_CALCULATION totlength = TotalProcessedLength; if (TotalProcessedLength > job_length) { @@ -770,6 +771,15 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes //TotalProcessedLength = job_length; totlength = job_length; } +#else + totlength = PoolerTotalProcessedLength; + if (PoolerTotalProcessedLength > job_length) + { + Report("job length bigger than assigned",__FILE__,__LINE__,PoolerTotalProcessedLength,RpWarning,job_length, done); + //TotalProcessedLength = job_length; + totlength = job_length; + } +#endif jobStatus.progress = totlength; jobStatus.has_currentsegmentindex = true; jobStatus.currentsegmentindex = SegmentId; -- cgit v1.3.1