From 15f9a26d5a4f0a90b628805bb551086d4b81c7ee Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 16 Jul 2019 08:54:56 +0300 Subject: cosmetics --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c | 1 - 1 file changed, 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 78203b236..cab3b592e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -44,7 +44,6 @@ uint32_t MotorsConfigMessage(HardwareConfiguration * HWrequest) { uint32_t status = PASSED; TimerMotors_t Motor_i,MotorId; - MOTDRIVER_TYPE DriverType; HardwareMotor *request; if (HWrequest == NULL) return ERROR; -- cgit v1.3.1 From 0f9ed0892d136072c1e5b82c14aa401e84a5ce4f Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 23 Jul 2019 18:30:48 +0300 Subject: Version 1.4.2.5 store data in EEPROM, thread loading, IDS datat store, IDS prepare with reduced ink usage --- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 16 +++-- .../Embedded/Common/SWUpdate/FirmwareUpgrade.h | 1 + .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Common/Sys_PinOut_Config/MCU_MAIN_pinout.c | 1 + .../Embedded_SW/Embedded/Common/report/report.h | 2 +- .../Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c | 25 +++++-- .../Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c | 1 + .../Embedded/Drivers/Motors/MotorActions.c | 48 ++++++++----- .../Embedded/Drivers/flash_ram/MCU_E2Prom.c | 40 +++++++++++ .../Embedded/Drivers/flash_ram/MCU_E2Prom.h | 27 ++++++++ Software/Embedded_SW/Embedded/Main.c | 7 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 6 +- .../Embedded/Modules/Control/MillisecTask.c | 2 + .../Embedded/Modules/Diagnostics/Diagnostics.c | 37 ++-------- .../Modules/Diagnostics/DiagnosticsJogging.c | 2 + .../Embedded/Modules/General/GeneralHardware.c | 15 ++-- .../Embedded_SW/Embedded/Modules/General/process.c | 2 + .../Embedded/Modules/Heaters/Heaters_print.c | 80 ++++++++++++++++++++++ .../Embedded/Modules/IDS/IDS_dispenser.c | 17 ++++- Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 5 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 11 +-- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 45 +++++++++++- .../Embedded/Modules/Stubs_Handler/Stub_Dancer.c | 3 +- .../Embedded/Modules/Thread/ThreadLoad.c | 64 ++++++++++++----- .../Embedded/Modules/Thread/Thread_Winder.c | 2 +- .../Embedded/Modules/Thread/Thread_init.c | 22 ++++-- .../Embedded/Modules/Thread/Thread_print.c | 19 +++++ .../StateMachines/Initialization/PowerIdle.c | 7 ++ 28 files changed, 401 insertions(+), 108 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c create mode 100644 Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 77056213f..dabd5ff44 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -28,6 +28,7 @@ #include "Common/SWUpdate/FileSystem.h" #include "Modules/Control/Control.h" +#include "Modules/AlarmHandling/AlarmHandling.h" int NumberOfFiles = 0,CurrentRunningFile; int CurrentFileSize = 0; @@ -48,8 +49,8 @@ bool SwUpgradeActive(void) } uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { - //ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; - //MessageContainer responseContainer; + ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; + MessageContainer responseContainer; usnprintf(activateString, 1000, "file %d of %d bytes %d of %d",CurrentRunningFile,NumberOfFiles,vme_index,CurrentFileSize); @@ -61,9 +62,6 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) ActivateVersionControlId = 0xFF; else LOG_ERROR(255,"ActivateVersionCallBackFunction"); - return OK; - - /* responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, ActivateToken, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); responseContainer.continuous = true; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); @@ -73,9 +71,13 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) if (Reboot == true) { + Task_sleep (120000000*5); Power_Reset(); } -*/ + return OK; + + + } int File_i = 0; @@ -121,7 +123,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) for (File_i = 0;File_in_filedescriptors;File_i++) { CurrentFileSize = -1; - vme_index = 0; + //vme_index = 0; switch(VersionPackage->filedescriptors[File_i]->destination) { case VERSION_FILE_DESTINATION__MCU: diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h index 6f817fe90..1d11a84b6 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h @@ -8,6 +8,7 @@ #ifndef COMMON_SWUPDATE_FIRMWAREUPGRADE_H_ #define COMMON_SWUPDATE_FIRMWAREUPGRADE_H_ +extern int CurrentFileSize; uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer); uint32_t ValidateVersionRequestFunc(MessageContainer* requestContainer); 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 5112fd730..9c02e609e 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,2,2}; +TangoVersion_t _gTangoVersion = {1,4,2,5}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Common/Sys_PinOut_Config/MCU_MAIN_pinout.c b/Software/Embedded_SW/Embedded/Common/Sys_PinOut_Config/MCU_MAIN_pinout.c index bd9336db3..93ce6cf51 100644 --- a/Software/Embedded_SW/Embedded/Common/Sys_PinOut_Config/MCU_MAIN_pinout.c +++ b/Software/Embedded_SW/Embedded/Common/Sys_PinOut_Config/MCU_MAIN_pinout.c @@ -123,6 +123,7 @@ PinoutSet(void) MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOT); + MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0); // // Configure the GPIO Pin Mux for PD1 diff --git a/Software/Embedded_SW/Embedded/Common/report/report.h b/Software/Embedded_SW/Embedded/Common/report/report.h index 349bdb733..093481081 100644 --- a/Software/Embedded_SW/Embedded/Common/report/report.h +++ b/Software/Embedded_SW/Embedded/Common/report/report.h @@ -228,7 +228,7 @@ extern STATUS ReportMessage2Dist(DistributorHandle distributor, const char *mess * Return value: OK; or Report's return code **************************************************************************/ #define REPORT_IF_ERROR(condition, msg, error, severity, par1, par2) \ - ((condition) ? Report(REPORT_LINE(msg), error, severity, par1, par2) : OK) + ((condition) ? Report(msg, __FILE__,__LINE__, error, severity, par1, par2) : OK) /*----------------------------------------------------------------------------*/ /*---------------------- Report Tracing and Exceptions -----------------------*/ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c index cb4b413e5..931044f82 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c @@ -16,6 +16,7 @@ #include "Modules/Control/Control.h" #include "Modules/Control/MillisecTask.h" +#include "Common/SWUpdate/FirmwareUpgrade.h" extern short int main_vme(); @@ -73,13 +74,29 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot //break; } + FILINFO* fno; + fno = my_malloc(sizeof(FILINFO)); + if (fno == 0) + fresult = FR_DENIED; + else + { + memset (fno,0,sizeof(FILINFO)); + fresult = f_stat(FullPath,fno); + CurrentFileSize = fno->fsize; + free (fno); + } FileHandlevme = malloc(sizeof(FIL)); - fresult |= f_open(FileHandlevme, FullPath, FA_READ); - if(fresult != FR_OK) + if (FileHandlevme) { - return(fresult); + fresult |= f_open(FileHandlevme, FullPath, FA_READ); + if(fresult != FR_OK) + { + return(fresult); + } + Report(FullPath,__FILE__,__LINE__,CurrentFileSize,RpWarning,0,0); + + fresult = main_vme(); } - fresult = main_vme(); diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c index 0286d53a7..1d114f8ce 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c @@ -683,6 +683,7 @@ short int main_vme() *************************************************************/ short int siRetCode = 0; + vme_index = 0; /************************************************************* * * * Pass in the command line arguments to the entry point. * diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index a190730cb..911b31eed 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -133,7 +133,7 @@ MotorHomingDirectionEnum Motor_Id_to_LS_Direction[NUM_OF_MOTORS] = { }; uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t LimitSwitchId,callback_fptr callback,uint32_t timeout) //TODO { - assert (callback); + //assert (callback); //assert (isValid(deviceId)); //call driver action to device id with the parameter @@ -151,7 +151,7 @@ uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t } uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout) //TODO { - assert (callback); + //assert (callback); //assert (isValid(deviceId)); //call driver action to device id with the parameter @@ -168,7 +168,7 @@ uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32 uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout) //TODO { - assert (callback); + //assert (callback); //assert (isValid(deviceId)); //call driver action to device id with the parameter @@ -185,7 +185,7 @@ uint32_t DryerBackLash = 0; uint32_t DrierZeroPosition = 0; bool DrierBackLashDirection = false; int CallbackCalls=0; -bool FirstCall = false; +int FirstCall = 0; uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) //TODO { uint32_t MotorId; @@ -197,20 +197,20 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / } MotorId = IfIndex&0xFF; MotorPosition = ArmPosition; - if (FirstCall) - { - FirstCall = false; - return OK; - } CallbackCalls++; if (CallbackCalls%20 == 0) { - REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction"); +// REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction"); + Report("Move_To_Stopper_Callback",__FILE__,__LINE__,MotorPosition,RpMessage,StoredMotorPosition[MotorId],0); //CallbackCalls = 0; } - Report("Move_To_Stopper_Callback",__FILE__,__LINE__,MotorPosition,RpMessage,StoredMotorPosition[MotorId],0); Read_Dryer_ENC_Position(); //trigger the next call + if (FirstCall<5) + { + FirstCall++; + return OK; + } //if (((abs(MotorPosition - StoredMotorPosition[MotorId])<=60)||(MotorGetDirection(MotorId)!=(1-DrierBackLashDirection)))&&(CallbackCalls>=10)) /*Motor did not move in the last time lag*/ if (abs(MotorPosition - StoredMotorPosition[MotorId])<=10) @@ -224,8 +224,10 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / Task_sleep(5); MotorMove(MotorId,DrierBackLashDirection,DryerBackLash ); Task_sleep(5); + if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) + MotorStop(MotorId,Hard_Stop ); DrierZeroPosition = Read_Dryer_ENC_Position(); //trigger the next call - Report("MotorVerifiedCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,0,0); + Report("MotorVerifiedCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,DryerBackLash,0); //call the module callback if (MotorCallback[MotorId]) @@ -238,7 +240,7 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / } uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Speed, callback_fptr callback,uint32_t backlash,uint32_t timeout) //TODO { - assert (callback); + //assert (callback); //assert (isValid(deviceId)); //call driver action to device id with the parameter @@ -251,9 +253,11 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee MotorSetDirection( MotorId, direction); CallbackCalls = 0; - FirstCall = true; + FirstCall = 0; MotorGetPositionFromFPGA(MotorId); Task_sleep(5); + Read_Dryer_ENC_Position(); //trigger the next call + StoredMotorPosition[MotorId] = MotorGetPosition(MotorId); REPORT_MSG(StoredMotorPosition[MotorId],"MotorMoveToStopper initial position"); MotorSetSpeed (MotorId, Speed); @@ -273,7 +277,13 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea if (MotorControlId[MotorId] == 0xFF) return ERROR; - Report("MotorMoveToDrierPositionCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); + CallbackCalls++; + if (CallbackCalls%20 == 0) + { +// REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction"); + Report("MotorMoveToDrierPositionCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); + //CallbackCalls = 0; + } if (DrierZeroPosition == ReadValue) //thread running identified { @@ -282,6 +292,8 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction + if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) + MotorStop(MotorId,Hard_Stop ); //possibly: start regular control (speed etc) //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); @@ -294,7 +306,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea } uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callback,uint32_t timeout) { - assert (callback); + //assert (callback); uint32_t currentposition = 0; bool direction; //assert (isValid(deviceId)); @@ -332,7 +344,7 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb MotorSetDirection( MotorId, direction); MotorSetSpeed (MotorId, 5); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToDrierPositionCallBackFunction, eOneMillisecond,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback( MotorMoveToDrierPositionCallBackFunction, eTenMillisecond,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveToDrierPositionCallBackFunction; return MotorControlId[MotorId]; @@ -340,7 +352,7 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb uint32_t MotorSetSpeedWithCallback (TimerMotors_t MotorId, uint32_t _freq, callback_fptr callback) //TODO { - assert (callback); + //assert (callback); MotorCallback[MotorId] = callback; MotorControlId[MotorId] = AddControlCallback( MotorSetSpeedCallBackFunction, eTenMillisecond, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c new file mode 100644 index 000000000..f3ca9615a --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c @@ -0,0 +1,40 @@ +/* + * MCU_E2Prom.c + * + * Created on: July 22, 2019 + * Author: shlomo + */ + +#include "include.h" +#include +#include "MCU_E2Prom.h" +#include "driverlib/eeprom.h" + +uint32_t E2Prom_Data[MAX_EEPROM_STORAGE] = {0,0,0,0,0,0}; +uint32_t MCU_E2PromProgram(int Address,uint32_t Data) +{ + uint32_t Buffer = Data; + if (Address>=MAX_EEPROM_STORAGE) + return ERROR; + Report("MCU_E2PromProgram",__FILE__,__LINE__,Address,RpWarning,Data,0); + + return (EEPROMProgram((uint32_t *)&Buffer, Address*4, 4)); +} +uint32_t MCU_E2PromRead(int Address,uint32_t *Data) +{ + if (Address>=MAX_EEPROM_STORAGE) + return ERROR; + EEPROMRead((uint32_t *)Data,Address*4, 4); + Report("MCU_E2PromRead",__FILE__,__LINE__,Address,RpWarning,*Data,0); + + return OK; + +} +//Each word may not be subject to more than a specific number of programming cycles before an +//erase cycle is required. In other words, for any given word, FlashProgram can only be called +//twice before FlashErase is called. +void MCU_E2PromInit(void) +{ + EEPROMInit(); +} + diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h new file mode 100644 index 000000000..5beb6c62b --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h @@ -0,0 +1,27 @@ +/* + * MCU_E2Prom.h + * + * Created on: Jul 21, 2019 + * Author: shlomo + */ + +#ifndef DRIVERS_FLASH_RAM_MCU_E2PROM_H_ +#define DRIVERS_FLASH_RAM_MCU_E2PROM_H_ + +typedef enum { + EEPROM_STORAGE_DATA_SIZE, + EEPROM_STORAGE_DANCER_0, + EEPROM_STORAGE_DANCER_1, + EEPROM_STORAGE_DANCER_2, + EEPROM_STORAGE_DRYER_CENTER, + EEPROM_STORAGE_DRYER_CYCLES, + MAX_EEPROM_STORAGE +}EEPROM_STORAGE_USAGE_ENUM; +uint32_t MCU_E2PromProgram(int Address,uint32_t Data); +uint32_t MCU_E2PromRead(int Address,uint32_t *Data); +void MCU_E2PromInit(void); + + + + +#endif /* DRIVERS_FLASH_RAM_MCU_E2PROM_H_ */ diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 5667d4f48..e04ce0d36 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -12,6 +12,7 @@ #include */ #include + #include "Drivers/USB_Communication/USBCDCD.h" #include "Drivers/I2C_Communication/I2C.h" #include "PMR/common/MessageContainer.pb-c.h" @@ -34,6 +35,7 @@ #include #include "drivers/Flash_ram/FlashProgram.h" +#include "drivers/Flash_ram/MCU_E2Prom.h" #include #include "Sys_PinOut_Config/MCU_MAIN_pinout.h" @@ -126,11 +128,11 @@ 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); + if (UpdateFlag == true) + return; FileHandle = my_malloc(sizeof(FIL)); if (FileHandle == 0) Fresult = FR_DENIED; @@ -230,6 +232,7 @@ int main(void) Init_All_I2C(); + MCU_E2PromInit(); #ifndef EVALUATION_BOARD STATUS_RED_LED_ON; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index fc722a234..5bb5398d7 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -246,6 +246,9 @@ const AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ {eHundredMillisecond,ALARM_SOURCE_TYPE__TemperatureAlarm,HEAD6_PT100, HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6 ,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,EVENT_TYPE__DYEING_HEAD_ZONE_6_OVERTEMPERATURE }, {eHundredMillisecond,ALARM_SOURCE_TYPE__TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP1, HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE }, + {eOneSecond,ALARM_SOURCE_TYPE__TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP1, 0,40,true,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE }, + {eOneSecond,ALARM_SOURCE_TYPE__TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP2, 1,40,true,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE }, + {eHundredMillisecond,ALARM_SOURCE_TYPE__CoversAlarm,FrontDoor1 ,1,false,true,DEBUG_LOG_CATEGORY__Error, 0xFF,5,EVENT_TYPE__FRONT_COVER_1_OPEN}, {eHundredMillisecond,ALARM_SOURCE_TYPE__CoversAlarm,FrontDoor2 ,1,false,true,DEBUG_LOG_CATEGORY__Error, 0xFF,5,EVENT_TYPE__FRONT_COVER_2_OPEN}, {eHundredMillisecond,ALARM_SOURCE_TYPE__CoversAlarm,FrontDoor3 ,1,false,true,DEBUG_LOG_CATEGORY__Error, 0xFF,5,EVENT_TYPE__FRONT_COVER_3_OPEN}, @@ -365,7 +368,7 @@ bool EventsNotificationRequestAccepted = false; uint32_t AlarmHandlingFlashLoad(void) { -// EraseFlashSection(ALARM_MAP_IN_FLASH,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); + EraseFlashSection(AlarmItem,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); ReadAppAndProgram(AlarmItem, sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS, HardCodedAlarmItem); // LOG_ERROR(AlarmItem[2].EventName,"Flash Test"); @@ -380,6 +383,7 @@ uint32_t AlarmHandlingLoadFile(void) Fresult = FileRead(AlarmStorePath, &Bytes, &buffer); if (Fresult == FR_OK) { + EraseFlashSection(AlarmItem,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); ReadAppAndProgram(AlarmItem, Bytes,buffer); free (buffer); ReportWithPackageFilter(AlarmFilter,"AlarmHandlingLoadFile", __FILE__,__LINE__,Bytes, RpMessage, Fresult, 0); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 7c15c6ae7..84e3bf56e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -544,6 +544,8 @@ uint32_t MillisecLowLoop(uint32_t tick) } ADC_TriggerCollection(); } + DispensersCollectionCall(); + } if ((O900Millisecond_Tick)&&(RapidPressureRead == false)) diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 8427ebd4a..a22bfc815 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -137,7 +137,6 @@ typedef enum { DiagnosticsTrigger, DiagnosticsTenMiliTrigger, - DispensersCollectionTrigger, }DiagnosticsMessages; typedef struct DiagnosticsMessage{ @@ -386,8 +385,12 @@ void Diagnostic100msecCollection(void) for (i=0;imotortype; MotorStop(MotorId,Hard_Hiz); + if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) + MotorStop(MotorId,Hard_Stop ); responseContainer = createContainer(MESSAGE_TYPE__MotorAbortJoggingResponse, requestContainer->token, false, &response, &motor_abort_jogging_response__pack, &motor_abort_jogging_response__get_packed_size); responseContainer.continuous = false; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 914d4f51c..52f4a3447 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -62,12 +62,14 @@ char HwConfigPath[50] = "0://SysInfo//GenHwCfg.cfg"; void *HWConfigurationLoadFromFile( uint32_t *NumOfBytes) { 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; *NumOfBytes = 0; - Fresult = FileRead(HwConfigPath, &Bytes, &buffer); + Fresult = FileRead(HwConfigPath, NumOfBytes, &buffer); + REPORT_IF_ERROR(Fresult, "HW Config File Read error", Fresult, RpError, buffer, 0); +// if (Fresult) +// Report("HW Config File Read error", __FILE__,__LINE__, Fresult, RpError, buffer, 0); + return buffer; } @@ -98,6 +100,7 @@ uint32_t HWConfigurationInit(void) buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config if (buffer) { + EraseFlashSection(GENHWCFG_MAP_IN_FLASH,Bytes+4); ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes); ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); @@ -187,7 +190,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->generalparameters[2] = 0.0; //CheckTamperAlarms EmbeddedParameters->generalparameters[3] = 0.0; //CheckMotorAlarms EmbeddedParameters->generalparameters[4] = 800.0; //Winder homing time at end of job - //EmbeddedParameters->generalparameters[5] = 1.0; //Dispenser initial pressure speed + EmbeddedParameters->generalparameters[5] = 1000.0; //Dispenser initial pressure speed } EmbeddedParameters->has_currentalarmlowlimit = true; EmbeddedParameters->currentalarmlowlimit = 0.80; @@ -225,6 +228,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) { response_size = configuration_parameters__pack(EmbeddedParameters, response_buffer); //FileWrite(response_buffer,response_size,EmbeddedParametersPath); + EraseFlashSection(EMBEDDED_PARAMETERS_MAP_IN_FLASH,response_size+4); ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&response_size); ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, response_size, response_buffer); my_free(response_buffer); @@ -264,7 +268,7 @@ uint32_t EmbeddedParametersInit(void) } IDS_Dispenser_SetTimeOutValues(EmbeddedParameters->closevalvetimeout, EmbeddedParameters->openvalvetimeout); - IDS_Dispenser_SetBackLashValues(EmbeddedParameters->initialdispenserpressure, EmbeddedParameters->initialdispensertimeout, EmbeddedParameters->initialdispensertimelag); + IDS_Dispenser_SetBackLashValues(EmbeddedParameters->initialdispenserpressure, EmbeddedParameters->initialdispensertimeout, EmbeddedParameters->initialdispensertimelag,EmbeddedParameters->generalparameters[5]); IDS_Dispenser_SetPrepareValues(EmbeddedParameters->dispenserbuildpressurespeed, EmbeddedParameters->dispenserbuildpressurelimit, EmbeddedParameters->dispenserbuildpressuretimeout, EmbeddedParameters->dispenserbuildpressurelag); IDS_Dispenser_SetPreSegmentWFCFValues(EmbeddedParameters->dispenserpresegmentwfcf, EmbeddedParameters->ids_presegment_wfcf_timebeforesegment); IDS_Dispenser_SetPreSegmentCleaningValues(EmbeddedParameters->ids_cleaningspeed,EmbeddedParameters->ids_cleaningstartspraypresegmenttime ,EmbeddedParameters->ids_cleaningstopbeforesegmenttime,EmbeddedParameters->ids_leftcleaningmotorspeed,EmbeddedParameters->ids_rightcleaningmotorspeed); @@ -527,6 +531,7 @@ uint32_t LoadConfigurationParamsFromFile(void) //configuration_parameters__free_unpacked(Params,NULL); FlashInitResults[1] = true; Report("Parameters Initialized from file", __FILE__,__LINE__,Bytes, RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0); + EraseFlashSection(EMBEDDED_PARAMETERS_MAP_IN_FLASH,Bytes+4); ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, buffer); } diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 6ee11105f..b968381c6 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -193,6 +193,7 @@ void ProcessRequestFunc(MessageContainer* requestContainer) { FileWrite(requestContainer->data.data, requestContainer->data.len,ProcessParamsConfigPath); Bytes = sizeof(ProcessParameters); + EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); REPORT_MSG(Bytes,"Bytes write to flash"); @@ -252,6 +253,7 @@ uint32_t LoadProcessParamsFromFile(void) if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters { Bytes = sizeof(ProcessParameters); + EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); REPORT_MSG(Bytes,"ProcessParameters Bytes write to flash"); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 179ac30d7..d60d5b840 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -192,15 +192,95 @@ void HeatersControlStop(void) HeatersRestart = false; } } + +//{eOneSecond,ALARM_SOURCE_TYPE__TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP1, 0,40,true,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE }, +//{eOneSecond,ALARM_SOURCE_TYPE__TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP2, 1,40,true,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE }, +typedef enum{ + ENCLOSURE_INTERNAL_TEMP, + CABINET_INTERNAL_TEMP, + MAIN_CARD_INTERNAL_TEMP, + MAX_INTERNAL_ALARMS +}; +int InternalAlarmCounter[MAX_INTERNAL_ALARMS] = {0,0,0}; +uint32_t InternalId2PT100Id[MAX_INTERNAL_ALARMS] = {TEMP_SENSE_AN_ENCLOSURETEMP1,TEMP_SENSE_AN_ENCLOSURETEMP1,0xFF}; +int32_t InternalOverHeatCounter [MAX_INTERNAL_ALARMS] = {0,0,0}; +bool InternalAlarmActive[MAX_INTERNAL_ALARMS] = {false,false,false}; +uint32_t ControlIdtoInternalId[MAX_INTERNAL_ALARMS] = {0xFF,0xFF,0xFF}; +uint32_t HeatersTestInternalAlarmsCBFunction(uint32_t IfIndex, uint32_t readValue) +{ + int index=MAX_HEATERS_NUM; + + if (IfIndex>>8 != IfTypeHeaters) + { + ReportWithPackageFilter(HeatersFilter, "Wrong Interface type",__FILE__,__LINE__,IfIndex,RpError, 0,0); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; + if (index >= MAX_INTERNAL_ALARMS) //Enclosure pt100 + { + ReportWithPackageFilter(HeatersFilter, "Wrong Interface ",__FILE__,__LINE__,IfIndex,RpError, 0,0); + return 0xFFFFFFFF; + } + + readValue = MillisecGetTemperatures(InternalId2PT100Id[index]); + if((MINIMUM_HEATER_READ>=readValue)||(MAXIMUM_HEATER_READ < readValue)) + { + //ReportWithPackageFilter(HeatersFilter,"PT100 not working properly",__FILE__,__LINE__,HeaterId,RpError, 0,0); + return ERROR; + } + + // no test for spikes yet! + if (readValue >= 40.0) + { + if (InternalAlarmActive[index] == false) + { + if(InternalOverHeatCounter[index]++ >=Overheat_Count_Limit) + { + InternalOverHeatCounter[index] = Overheat_Count_Limit; + + InternalAlarmActive[index] = true; + ReportWithPackageFilter(HeatersFilter,"Internal Over the max temperature, turned off",__FILE__,index,readValue,RpWarning, 0,0); + AlarmHandlingSetAlarm(EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE, true); + } + } + } + else + { + if (InternalAlarmActive[index] == true) + { + if(InternalOverHeatCounter[index]-- <= 0) + { + InternalOverHeatCounter[index] = 0; + + InternalAlarmActive[index] = true; + ReportWithPackageFilter(HeatersFilter,"Internal Over the max temperature, turned off",__FILE__,index,readValue,RpWarning, 0,0); + AlarmHandlingSetAlarm(EVENT_TYPE__MACHINE_INTERNAL_OVERTEMPERATURE, true); + } + + } + } + return OK; +} + + //#warning there is a need to separate the AC and DC heaters preparation! void HeatersControlStart(void) { + int i; if (HeatersRestart == false) { ReportWithPackageFilter(HeatersFilter,"HeatersControlStart ", __FILE__,__LINE__,0, RpMessage, 0, 0); HeatersRestart = true; HeatersStartControlTimer(); + for (i = 0; i< MAX_INTERNAL_ALARMS;i++) + { + if (ControlIdtoInternalId [i] == 0xFF) + { + ControlIdtoInternalId [i] = AddControlCallback( HeatersTestInternalAlarmsCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+i),0,0); + } + } } + } uint32_t LoadHeaterSetPoint(HeaterType HeaterType) { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 0b5b4791a..6d7f0df96 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -276,6 +276,7 @@ void IDS_Dispenser_Content_Init (void) //================================== } uint16_t seconds_counter = 0; +bool DispenserDataUpdated = false; uint32_t IDS_Dispenser_Store_Data (void) { uint32_t timing = msec_millisecondCounter; @@ -293,11 +294,12 @@ uint32_t IDS_Dispenser_Store_Data (void) // Report("IDS_Dispenser_Store_Data 0",__FILE__,(int)IDS_Dispenser_Data[0].totalconsumedinnanolitter,(int)IDS_Dispenser_Data[0].consumedinnanolitter,RpWarning,(int)IDS_Dispenser_Data[0].microsteps,0); // Report("IDS_Dispenser_Store_Data 4",__FILE__,(int)IDS_Dispenser_Data[4].totalconsumedinnanolitter,(int)IDS_Dispenser_Data[4].consumedinnanolitter,RpWarning,(int)IDS_Dispenser_Data[4].microsteps,0); //response_size = dispenser_data__pack(&IDSDispenserData, response_buffer); + EraseFlashSection(DISPENSERS_MAP_IN_FLASH,response_size+4); ReadAppAndProgram(DISPENSERS_MAP_IN_FLASH, 4,&response_size); ReadAppAndProgram(DISPENSERS_MAP_IN_FLASH+4, response_size, IDS_Dispenser_Data); Status = FileWrite(IDS_Dispenser_Data,response_size,DispenserStorePath); - + DispenserDataUpdated = false; REPORT_MSG(msec_millisecondCounter - timing, "Updating dispensers file - time"); return Status; } @@ -315,8 +317,9 @@ void IDS_Dispenser_Content_Calculation (char DispenserId) //double consumedintimeframe = (double)(CurrentDispenserSpeed[DispenserId]); //pulses only //consumedintimeframe = 10+DispenserId; IDS_Dispenser_Data[DispenserId].consumedinnanolitter += (CurrentDispenserSpeed[DispenserId]/10);//100 milliseconds ==> speed/10 - if (CurrentDispenserSpeed[DispenserId]>0.0) + if (CurrentDispenserSpeed[DispenserId]>0.1) { + DispenserDataUpdated = true; IDS_Dispenser_Data[DispenserId].totalconsumedinnanolitter += (CurrentDispenserSpeed[DispenserId]/10); if (seconds_counter%100 == 0) { @@ -325,7 +328,7 @@ void IDS_Dispenser_Content_Calculation (char DispenserId) } if (DispenserId == 0) { - if (seconds_counter++>=600)//36000)// - one hour) + if ((seconds_counter++>=600)&&(DispenserDataUpdated == true))//36000)// - one hour) { seconds_counter = 0; if (IDS_Dispenser_Data[DispenserId].consumedinnanolitter) @@ -336,6 +339,14 @@ void IDS_Dispenser_Content_Calculation (char DispenserId) } } } +void DispensersCollectionCall(void) +{ + int i; + for (i = 0; ipvinputfilterfactormode > MAX_CONTROL_SAMPLES) request->pvinputfilterfactormode = MAX_CONTROL_SAMPLES; - ReadAppAndProgram(&DispensersControl[Dispenser_i], sizeof(HardwarePidControl), request); + //ReadAppAndProgram(&DispensersControl[Dispenser_i], sizeof(HardwarePidControl), request); for (i = 0;i < DispensersControl[Dispenser_i].pvinputfilterfactormode; i++) DispenserSamples[Dispenser_i][i] = 0; //reset the samples value for control beginning @@ -581,6 +581,8 @@ c. Go to step 2.a x Segment.BrushStopsCount. bool pressureReady = false; int i; int NumofReadyDispensers = 0; + TimerMotors_t HW_Motor_Id; + float updatedSpeed,tempSpeed; //REPORT_MSG((int)DispenserPrepareControlId, "Prepare Callback"); DispenserBuildTimeCounter+=PRESSURE_READ_TIME_GAP; @@ -595,8 +597,24 @@ c. Go to step 2.a x Segment.BrushStopsCount. //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { + HW_Motor_Id = DispenserIdToMotorId[i]; if (GetDispenserPressure(i) > DispenserPreparePressure) + { NumofReadyDispensers++; + tempSpeed = CurrentDispenserSpeed[i]; + updatedSpeed = (tempSpeed*0.95>100)?tempSpeed*0.95:100; + MotorSetSpeed(HW_Motor_Id, updatedSpeed); + CurrentDispenserSpeed[i] = updatedSpeed; + Report("IDS reduce speed",__FILE__,i,(int)tempSpeed,RpWarning,(int)updatedSpeed,0); + } + else + { + tempSpeed = CurrentDispenserSpeed[i]; + updatedSpeed = (tempSpeed*1.1>1000)?tempSpeed*1.1:100; + MotorSetSpeed(HW_Motor_Id, updatedSpeed); + CurrentDispenserSpeed[i] = updatedSpeed; + Report("IDS accelerate speed",__FILE__,i,(int)tempSpeed,RpWarning,(int)updatedSpeed,0); + } } } @@ -804,7 +822,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); //IDS_Cleaning_Center_And_Stop_Rockers (int timeout,callback_fptr callback); } } - if (InterSegmentStartWFCFDispensers == InterSegmentStepsCount) + if ((InterSegmentStartWFCFDispensers > 0)&&(InterSegmentStartWFCFDispensers == InterSegmentStepsCount)) { Report("start dispensers at rate * WFCF",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); if (FileBrushStop) @@ -950,7 +968,8 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) InterSegmentStartRocking = 1000; InterSegmentCenterRockers = 3000; } - InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; + + InterSegmentStartWFCFDispensers = (lInterSegmentLength>5000)?lInterSegmentLength-5000:lInterSegmentLength; } } /*if (SegmentId == 0)//first segment - running the DTS out of the drier @@ -1279,6 +1298,26 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) IDS_Dispenser_Close_Valve_And_Stop_Motor(Dispenser_i,IDS_Valve_DistanceToSpoolValveReady); } + //cleaning + + 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)IntersegmentLength,0); + if (EnableCleaning == true) + { + InterSegmentStartSprayCleaner = 500; + InterSegmentStartRocking = 1000; + InterSegmentCenterRockers = 3000; + } + InterSegmentStartWFCFDispensers = 0; + return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c index 03c05e105..213902038 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c @@ -82,7 +82,8 @@ void Stub_DancerPositionRequest(MessageContainer* requestContainer) response.detailed_status = ERROR; // use the Reserved bits to send our errors response.has_general_status = true; } - StoreDancerConfigMessage(); + if (Dancer_Id == 2) + StoreDancerConfigMessage(); responseContainer = createContainer(MESSAGE_TYPE__StubDancerPositionResponse, requestContainer->token, true, &response, &stub_dancer_position_response__pack, &stub_dancer_position_response__get_packed_size); //free(request); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 9ef7f3d0d..d2f6170cf 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -59,7 +59,7 @@ ProcessParameters ProcessParametersClear,ProcessParametersRecover; uint8_t NumberOfDrierLoaderCycles = 0; uint32_t status = OK; - uint32_t ControlId = 0xFF; + uint32_t ControlId = 0xFF,PullerControlId = 0xFF,WinderControlId = 0xFF; uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM LoadStages); uint32_t ThreadLoadControlCBFunction(uint32_t index, uint32_t ReadValue); uint32_t Thread_Load_Dryer_UnLoading(void); @@ -173,6 +173,24 @@ } uint32_t Thread_Load_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_t BusyFlag) { + if(PullerControlId != 0xFF) + { + MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz); + RemoveControlCallback(PullerControlId, ThreadLoadControlCBFunction ); + PullerControlId = 0xFF; + } + if(WinderControlId != 0xFF) + { + MotorStop(ThreadMotorIdToMotorId[WINDER_MOTOR],Hard_Hiz); + RemoveControlCallback(WinderControlId, ThreadLoadControlCBFunction ); + WinderControlId = 0xFF; + } + /*Task_sleep(5) + MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); + MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);*/ + + MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz); + // Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); NumberOfDrierLoaderCycles=0; @@ -374,15 +392,14 @@ return OK; } - uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) + uint32_t Thread_Load_Dryer_MovetoEncoderPosition_Callback(uint32_t MotorId, uint32_t ReadValue) { - Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - REPORT_MSG(MotorId, "Thread_Load_Dryer_Loading_Callback Motor Id"); - MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,0,0); if(ControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); RemoveControlCallback(ControlId, ThreadLoadControlCBFunction ); + MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround); + ControlId = 0xFF; } if (CallbackCounter) @@ -399,6 +416,13 @@ } else LOG_ERROR(MotorId, "Thread_Load_HomingCallback Callback is already 0"); + + } + uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) + { + Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + //REPORT_MSG(MotorId, "Thread_Load_Dryer_Loading_Callback Motor Id"); + MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,10000); return OK; } @@ -413,6 +437,7 @@ // CurrentControlledSpeed[FEEDER_MOTOR] = 1000; numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; + Report("Thread Load State Machine step.",__FILE__,LoadStages,numberOfSteps,RpMessage,(int)(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius),0); MotorControlConfig[FEEDER_MOTOR].m_params.MAX = 1; MotorControlConfig[FEEDER_MOTOR].m_params.MIN = MotorsControl[FEEDER_MOTOR].outputproportionalpowerlimit*-1; MotorControlConfig[FEEDER_MOTOR].m_params.Kd = MotorsControl[FEEDER_MOTOR].derivativetime; @@ -432,6 +457,8 @@ MotorControlConfig[FEEDER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize); + MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4); + ControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); CallbackCounter++; MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, @@ -472,7 +499,7 @@ LoadArmInfo.LoadArmRounds = 0; uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 - SetOriginMotorSpeed(20); + SetOriginMotorSpeed(19); // OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; // CurrentControlledSpeed[FEEDER_MOTOR] = 1000; @@ -496,7 +523,7 @@ MotorControlConfig[POOLER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDRIVING].directionthreadwize); - ControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),FEEDER_DANCER,POOLER_MOTOR); + PullerControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR); //////////////////////// MotorControlConfig[WINDER_MOTOR].m_params.MAX = 1; MotorControlConfig[WINDER_MOTOR].m_params.MIN = MotorsControl[WINDER_MOTOR].outputproportionalpowerlimit*-1; @@ -515,18 +542,20 @@ MotorControlConfig[WINDER_MOTOR].m_mesuredParam = 0; MotorControlConfig[WINDER_MOTOR].m_preError = 0; MotorControlConfig[WINDER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage - MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDRIVING].directionthreadwize); + MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_WINDER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].directionthreadwize); - ControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+WINDER_MOTOR),FEEDER_DANCER,WINDER_MOTOR); + WinderControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+WINDER_MOTOR),WINDER_DANCER,WINDER_MOTOR); //////////////////////// + MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING].directionthreadwize); + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]); CallbackCounter++; //MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, // numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000); Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/2, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); + MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmBackLash = 0; @@ -623,7 +652,14 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t calculated_speed; double NormalizedError; - DancerId = FEEDER_DANCER;//ThreadMotorIdToDancerId[index]; + if (IfIndex>>8 != IfTypeThread) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; + + DancerId = ThreadMotorIdToDancerId[index]; if (ReadValue < 10) { Report("Dancer value read too small.",__FILE__,__LINE__,DancerId,RpError,ReadValue,0); @@ -634,12 +670,6 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) return OK; } TranslatedReadValue = ReadValue - DancersCfg[DancerId].zeropoint; - if (IfIndex>>8 != IfTypeThread) - { - LOG_ERROR (IfIndex, "Wrong Interface type"); - return 0xFFFFFFFF; - } - index = IfIndex&0xFF; if (index == POOLER_MOTOR) { //pooler dancer is right sided: data is opposite diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index a113e4dae..510168ab8 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -528,7 +528,7 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewsStopControlTimer(); //move the cart to the edge so the spool can be easily replaced //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); - MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); + //MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000); return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index cab3b592e..500ba9a39 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -19,6 +19,8 @@ #include "drivers/SSI_Comm/Dancer/Dancer.h" #include "drivers/Flash_ram/FlashProgram.h" +#include "drivers/Flash_ram/MCU_E2Prom.h" + #include "thread.h" MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]={0}; HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM] = {0}; @@ -162,6 +164,11 @@ uint32_t StoreDancerConfigMessage() DancerConfig.n_dancers++; DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } + MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); + MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); + MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); + Report("Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); + response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) { @@ -174,6 +181,7 @@ uint32_t StoreDancerConfigMessage() ReadAppAndProgram(DANCERS_MAP_IN_FLASH, sizeof(Dancers), Dancers); } + my_free(response_buffer); return Fresult; @@ -187,6 +195,7 @@ uint32_t LoadDancerConfigMessage() HardwareConfiguration *DancerConfig; int Dancer_i; HardwareDancer DancersCfg1[MAX_SYSTEM_DANCERS] = {0}; + HardwareDancer DancersCfg2[MAX_SYSTEM_DANCERS] = {0}; memcpy(DancersCfg1,(void *)DANCERS_MAP_IN_FLASH,sizeof(DancersCfg1)); @@ -196,16 +205,19 @@ uint32_t LoadDancerConfigMessage() DancerConfig = hardware_configuration__unpack(NULL, Bytes, buffer); for (Dancer_i = 0; Dancer_i < DancerConfig->n_dancers ; Dancer_i++) { - DancersCfg[Dancer_i].zeropoint = DancerConfig->dancers[Dancer_i]->zeropoint; + DancersCfg2[Dancer_i].zeropoint = DancerConfig->dancers[Dancer_i]->zeropoint; } hardware_configuration__free_unpacked(DancerConfig,NULL); free (buffer); } + MCU_E2PromRead(EEPROM_STORAGE_DANCER_0,&DancersCfg[0].zeropoint); + MCU_E2PromRead(EEPROM_STORAGE_DANCER_1,&DancersCfg[1].zeropoint); + MCU_E2PromRead(EEPROM_STORAGE_DANCER_2,&DancersCfg[2].zeropoint); + - if (DancersCfg[0].zeropoint != DancersCfg1[0].zeropoint) LOG_ERROR(DancersCfg[0].zeropoint,"DancersMismatch"); - else if (DancersCfg[1].zeropoint != DancersCfg1[1].zeropoint) LOG_ERROR(DancersCfg[1].zeropoint,"DancersMismatch"); - else if (DancersCfg[2].zeropoint != DancersCfg1[2].zeropoint) LOG_ERROR(DancersCfg[2].zeropoint,"DancersMismatch"); - else LOG_ERROR(DancersCfg[0].zeropoint,"Dancers Match!!"); + Report("Dancer 0 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg1[0].zeropoint,RpWarning,(int)DancersCfg2[0].zeropoint,0); + Report("Dancer 1 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[1].zeropoint,(int)DancersCfg1[1].zeropoint,RpWarning,(int)DancersCfg2[1].zeropoint,0); + Report("Dancer 2 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[2].zeropoint,(int)DancersCfg1[2].zeropoint,RpWarning,(int)DancersCfg2[2].zeropoint,0); return Fresult; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index eb1b751bb..528b83c1c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -539,6 +539,25 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) } BreakSensorCounter = 0; } + if (CurrentControlledSpeed[index] < (OriginalMotorSpd_2PPS[index]/3)) + { + BreakSensorCounter++; + BreakSensorLatchCounter++; + if (BreakSensorCounter>=BreakSensordebouncetimemilli) + { + //consider applying the debouce parameters later + usnprintf(TMessage, 60, "thread speed too low"); + JobEndReason = JOB_THREAD_BREAK; + ThreadControlActive = false; + SendJobProgress(0.0,0,false, TMessage); + SendSegmentFail(); + //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); + //EndState(CurrentJob,"ReadBreakSensor Error" ); + LOG_ERROR(index, "thread speed too low Error"); + return OK; + } + } + } } } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c index b3fc8c052..c7f4ee3b7 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c @@ -82,6 +82,9 @@ uint32_t PowerIdleCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) SetPowerMachineState(sttIDLE); //move to idle state PowerIdleSetIdle(); + if (SafeRemoveControlCallback(IdleControlId, PowerIdleCallBackFunction )==OK) + IdleControlId = 0xFF; + } } return OK; @@ -121,6 +124,10 @@ void PowerIdleOutOfIdleState(void) LOG_ERROR (1, "Turn Heaters active failed"); return ; } + if (IdleControlId == 0xFF) + IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + if (IdleControlId == 0xFF) + Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); } } -- cgit v1.3.1