From d3ec73caf771511b361bf03e6247a9ff6052c12b Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 17 Feb 2019 18:09:58 +0200 Subject: working on thread load state machine --- .../Embedded/Modules/Thread/ThreadLoad.c | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index edfa3b0b9..a116bbd66 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -85,7 +85,7 @@ FRESULT Fresult = FR_OK; REPORT_MSG(LoadStages, "Thread Load State Machine step"); - LoadArmInfo.LoadArmBackLash = 40; + LoadArmInfo.LoadArmBackLash = 10; LoadArmInfo.LoadArmRounds = 0xFF; Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) @@ -100,6 +100,7 @@ } } + Report("Thread_Load_Init",__FILE__,__LINE__,LoadArmInfo.LoadArmBackLash,RpMessage,LoadArmInfo.LoadArmRounds,0); memcpy (&ProcessParametersRecover,&ProcessParametersKeep,sizeof(ProcessParameters)); //NumberOfDrierLoaderCycles = loadLoadArmParameters(); LoadStages++; @@ -156,6 +157,7 @@ { Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); //storeLoadArmParameters(); + SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); //set this point as the spool home LoadStages++; //ThreadLoadStateMachine(LoadStages); } @@ -168,6 +170,8 @@ NumberOfDrierLoaderCycles=0; //storeLoadArmParameters(); LoadStages++; + SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); //set this point as the spool home + //ThreadLoadStateMachine(LoadStages); return OK; } @@ -241,9 +245,9 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 20, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,4000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,20000); return OK; } @@ -252,9 +256,9 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 700, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 700, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,10000); return OK; } @@ -288,9 +292,9 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,4000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,20000); return OK; } @@ -340,6 +344,7 @@ //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; 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, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds, Thread_Load_HomingCallback, 100000); @@ -449,17 +454,18 @@ return OK; } -uint32_t ThreadLoadControlCBFunction(uint32_t index, uint32_t ReadValue) +uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //read value is the dancer angle int i; int DancerId; int32_t TranslatedReadValue, avreageSampleValue = 0; + int index=MAX_THREAD_MOTORS_NUM; //double tempcalcspeed = 0; uint32_t calculated_speed; double NormalizedError; - DancerId = ThreadMotorIdToDancerId[index]; + DancerId = FEEDER_DANCER;//ThreadMotorIdToDancerId[index]; if (ReadValue < 10) { Report("Dancer value read too small.",__FILE__,__LINE__,DancerId,RpError,ReadValue,0); @@ -470,11 +476,17 @@ uint32_t ThreadLoadControlCBFunction(uint32_t index, uint32_t ReadValue) return OK; } TranslatedReadValue = ReadValue - DancersCfg[DancerId].zeropoint; - if (index == POOLER_MOTOR) + 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 TranslatedReadValue = (-1*TranslatedReadValue); - } + }*/ //TranslatedReadValue = 0;//test MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue); MotorSamplePointer[index]++; -- cgit v1.3.1 From 1f1080370a2416d0ef6f762e273cad51758340db Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 18 Feb 2019 15:03:18 +0200 Subject: Version 1.3.7.3 INIT SEQUENCE - starts heating!. safe control remove in callbacks, watchdog is disabled during init sequence procedures, for now --- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 8 ++-- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded/Common/report/reportInit.c | 2 +- .../Drivers/I2C_Communication/DAC/Blower.c | 19 ++------ .../Embedded/Drivers/Motors/MotorActions.c | 28 ++++++------ .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 16 +------ Software/Embedded_SW/Embedded/Main.c | 4 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 2 +- .../Embedded/Modules/Control/MillisecTask.c | 5 +- .../Embedded_SW/Embedded/Modules/Control/control.c | 36 +++++++++++++++ .../Embedded_SW/Embedded/Modules/Control/control.h | 4 ++ .../Embedded/Modules/General/GeneralHardware.c | 30 +++++++++--- .../Embedded/Modules/General/GeneralHardware.h | 1 + .../Embedded_SW/Embedded/Modules/General/process.c | 50 +++++++++++++++++++- .../Embedded_SW/Embedded/Modules/General/process.h | 1 + .../Embedded/Modules/IDS/IDS_dispenser.c | 53 +++------------------- .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 15 +----- .../Embedded/Modules/Thread/ThreadLoad.c | 6 ++- .../Embedded/Modules/Thread/Thread_init.c | 2 +- .../StateMachines/Initialization/InitSequence.c | 12 ++--- .../stubs/embeddedparametersbuild.cs | 38 +++++++--------- 21 files changed, 185 insertions(+), 149 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index e029bf2ce..6378420fa 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -28,7 +28,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) { void* buffer = NULL; uint32_t Bytes = 0; - char SWINFOPath[100]; + char SWUpgradePath[100]; char FullPath[50]; FRESULT Fresult = FR_OK; int File_i; @@ -43,10 +43,10 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3}; - strcpy (SWINFOPath,request->path); - strcat(SWINFOPath,"/file1.pck"); + strcpy (SWUpgradePath,request->path); + strcat(SWUpgradePath,"/package.cfg"); - Fresult = FileRead(SWINFOPath, &Bytes, &buffer); + Fresult = FileRead(SWUpgradePath, &Bytes, &buffer); if (Fresult == FR_OK) { VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer); 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 c0b0493fc..67e678790 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,3,7,1}; +TangoVersion_t _gTangoVersion = {1,3,7,3}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index d5fe116a7..982b53443 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -138,7 +138,7 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer) */ uint32_t RESC = SysCtlResetCauseGet (); LOG_ERROR(RESC,"Reset Reason Register"); - SysCtlResetCauseClear(RESC); + /*SysCtlResetCauseClear(RESC);*/ return status; } uint32_t StopReportInitMessage(MessageContainer* requestContainer) 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 eced74d16..5534a710c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -160,6 +160,7 @@ uint32_t Turn_the_Blower_Off() return status; } +/* uint32_t mInitial_mV, mTarget_mV; uint32_t mInterval = eOneSecond*20; uint32_t BlowerControlId = 0xFF; @@ -170,22 +171,11 @@ uint32_t Gradual_Increase_Blower_Callback(uint32_t DispenserId, uint32_t ReadVal { Control_Voltage_To_Blower(mTarget_mV); Report("Finished Increasing blower",__FILE__,__LINE__,(int)mTarget_mV,RpWarning,(int)millisecondCounter,0); - if (RemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) - { - Report("Remove control callback",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + + if (SafeRemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) BlowerControlId = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)BlowerControlId,0); - if (RemoveControlCallback(GetControlLowDevice_i(),Gradual_Increase_Blower_Callback)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); - BlowerControlId = 0xFF; - } - else - Report("Remove control callback failed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); - } + Report("Remove control callback failed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); return OK; } mInitial_mV = mInitial_mV+100; @@ -226,6 +216,7 @@ uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) } return OK; } +*/ diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 9e8b7c0b1..fcbd9ff6e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -198,7 +198,7 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / { //stop this control loop REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction stopped"); - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz ); @@ -264,8 +264,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO if (BusyFlag == NOTBUSY) { //stop this control loop - //RemoveControlCallback(MotorControlId[MotorId], MotorMoveCallBackFunction ); - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -292,8 +291,7 @@ uint32_t MotorSetSpeedCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TO if (BusyFlag == 1) { //stop this control loop - //RemoveControlCallback(MotorControlId[MotorId], MotorSetSpeedCallBackFunction ); - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -306,7 +304,6 @@ uint32_t MotorSetSpeedCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TO } return OK; } - uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t LimitSwitch) //TODO { TimerMotors_t MotorId; @@ -324,11 +321,17 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit if ((LimitSwitch == LIMIT) ||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { //stop this control loop - //RemoveControlCallback(MotorControlId[MotorId], MotorMoveToLimitSwitchCallBackFunction ); - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); 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_RDANCER) + { + MotorStop(MotorId,Soft_Stop); //TODO in run time limit switch just reverse direction + } + else + { + MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction + } //possibly: start regular control (speed etc) //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); @@ -349,7 +352,6 @@ uint32_t MotorMovetoLimitSwitch (TimerMotors_t MotorId,bool direction, uint32_t if (MotorControlId[MotorId] != 0xFF) { - //RemoveControlCallback(MotorControlId[MotorId], MotorMoveToLimitSwitchCallBackFunction ); RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; @@ -393,8 +395,7 @@ uint32_t MotorMoveToBreakSensorCallBackFunction(uint32_t IfIndex, uint32_t Limit if (mBreakSensorCounter > BreakSensordebouncetimemilli) { //stop this control loop - //RemoveControlCallback(MotorControlId[MotorId], MotorMoveToBreakSensorCallBackFunction ); - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveHighControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction @@ -415,7 +416,6 @@ uint32_t MotorMovetoBreakSensor (TimerMotors_t MotorId,bool direction, uint32_t //assert (callback); if (MotorControlId[MotorId] != 0xFF) { - //RemoveControlCallback(MotorControlId[MotorId], MotorMoveToBreakSensorCallBackFunction ); RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; @@ -466,7 +466,7 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re //stop this control loop DancerValueDirection = false; DancerId = 0xFF; - RemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index 3cf9de832..162e4f990 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -340,22 +340,10 @@ uint32_t Valve3WayCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { EnableDisableDispenserValve((Valves_t)ValveId, DISABLE); //stop this control loop - if (RemoveControlCallback(Valve3WayControlId[ValveId], Valve3WayCallBackFunction )==OK) - { - //Report("Remove control callback",__FILE__,__LINE__,(int)ValveId,RpWarning,(int)Valve3WayControlId[ValveId],0); + if (SafeRemoveControlCallback(Valve3WayControlId[ValveId], Valve3WayCallBackFunction )==OK) Valve3WayControlId[ValveId] = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)Valve3WayControlId[ValveId],0); - if (RemoveControlCallback(GetControlLowDevice_i(),Valve3WayCallBackFunction)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)ValveId,RpWarning,(int)Valve3WayControlId[ValveId],0); - Valve3WayControlId[ValveId] = 0xFF; - } - else - Report("Remove control callback failed",__FILE__,__LINE__,(int)ValveId,RpWarning,(int)Valve3WayControlId[ValveId],0); - } + Report("Remove control callback failed",__FILE__,__LINE__,(int)ValveId,RpWarning,(int)Valve3WayControlId[ValveId],0); //call the module callback if (Valve3WayModuleCallback[ValveId]) diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index ff291867f..90fd245c0 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -221,7 +221,9 @@ int main(void) IDLE_TASK_package_init(); - HWControlId = AddControlCallback( MainHWInitCallBackFunction, 6* eOneSecond/*eHundredMillisecond*/, MainDummyFunction,0,0, 0 ); +// HWControlId = AddControlCallback( MainHWInitCallBackFunction, 2* eOneSecond/*eHundredMillisecond*/, MainDummyFunction,0,0, 0 ); + + Start_InitSequence(); BIOS_start(); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 4486c70ed..c9f4ac1ee 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -272,7 +272,7 @@ const AlarmHandlingItemStruc AlarmItem[MAX_SYSTEM_ALARMS]={ {eOneSecond,DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,"No cone in winder"} }; -char AlarmStorePath[50] = "0://SWInfo//AlarmPrm.msg"; +char AlarmStorePath[50] = "0://SysInfo//AlarmPrm.msg"; bool DispenserInUse[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; bool EventsNotificationRequestAccepted = false; diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 4f78d2134..e0462eb6c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -458,9 +458,12 @@ uint32_t MillisecLowLoop(uint32_t tick) { MillisecReadFromTempSensor(Sensor_i, NULL); } - if (watchdogCriticalAlarm == false) + if (GeneralHwReady == true) { + if (watchdogCriticalAlarm == false) + { Control_WD(ENABLE,5); //activate heaters/dispenser watchdog, 0.5 seconds + } } } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index b7521d796..93c989ab5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -282,6 +282,42 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF return deviceId; } +int SafeRemoveHighControlCallback(uint32_t deviceId , ControlCBFunction Callback) +{ + if (RemoveControlCallback(deviceId, Callback )!=OK) + { + Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlDevice_i(),RpWarning,(int)deviceId,0); + if (RemoveControlCallback(GetControlDevice_i(),Callback)==OK) + { + Report("Remove control callback fixed",__FILE__,__LINE__,(int)GetControlDevice_i(),RpWarning,(int)deviceId,0); + } + else + { + Report("Remove control callback failed",__FILE__,__LINE__,(int)GetControlDevice_i(),RpWarning,(int)deviceId,0); + return ERROR; + } + } + return OK; +} + +int SafeRemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback) +{ + if (RemoveControlCallback(deviceId, Callback )!=OK) + { + Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)deviceId,0); + if (RemoveControlCallback(GetControlLowDevice_i(),Callback)==OK) + { + Report("Remove control callback fixed",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)deviceId,0); + } + else + { + Report("Remove control callback failed",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)deviceId,0); + return ERROR; + } + } + return OK; +} + int RemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback) { if (deviceId == 0xFF) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 0bcaecb03..8d7e219ac 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -39,6 +39,10 @@ void ControlStop(void); void ControlStart(void); uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); +//The safe remove command can be used ONLY when called from the control callback itself +int SafeRemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback); +int SafeRemoveHighControlCallback(uint32_t deviceId , ControlCBFunction Callback); + uint32_t TemplateDataReadCBFunction (uint32_t deviceId, uint32_t Parameter1); uint32_t GetControlDevice_i(void); uint32_t GetControlLowDevice_i(void); diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 3fd6805cf..711fcdc33 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -42,10 +42,13 @@ uint32_t EmbeddedParametersInit(void); uint32_t EmbeddedParametersWrite(void * buffer, uint16_t size); uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest); +bool GeneralHwReady = false; + HardwareBlower BlowerCfg; -char *SW_INFO_DIR = "0://SWInfo"; +char *SW_INFO_DIR = "0://SysInfo"; +char *OLD_SW_INFO_DIR = "0://SWInfo"; -char HwConfigPath[50] = "0://SWInfo//GenHwCfg.msg"; +char HwConfigPath[50] = "0://SysInfo//GenHwCfg.cfg"; uint32_t HWConfigurationInit(void) { FRESULT Fresult = FR_OK; @@ -54,10 +57,24 @@ uint32_t HWConfigurationInit(void) uint32_t Bytes = 0,i,j,k=0; uint32_t status = OK; + Control_WD(ENABLE,250); Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { +/*************************************************************************/ + Fresult = f_mkdir(OLD_SW_INFO_DIR); + + Fresult = f_rename ("//SWINFO//GENHWCFG.MSG", "//SYSINFO//GENHWCFG.CFG"); + Fresult |= f_rename ("//SWINFO//ALARMPRM.MSG", "//SYSINFO//ALARMPRM.CFG"); + Fresult |= f_rename ("//SWINFO//EMBPARAM.MSG", "//SYSINFO//EMBPARAM.CFG"); + Fresult |= f_rename ("//SWINFO//PROCESSP.MSG", "//SYSINFO//PROCESSP.CFG"); + Fresult |= f_rename ("//SWINFO//DISPSTOR.MSG", "/SYSINFO//DISPSTOR.CFG"); + Fresult |= f_rename ("//SWINFO//DANCCFG.MSG", "//SYSINFO//DANCCFG.CFG"); + Fresult |= f_rename ("//SWINFO//LOADARM.MSG", "//SYSINFO//LOADARM.CFG"); + + /*************************************************************************/ FileHandle = my_malloc(sizeof(FIL)); + Fresult = FileOpen(HwConfigPath, &Bytes, FileHandle); if (Fresult == FR_OK) { @@ -89,7 +106,7 @@ uint32_t HWConfigurationInit(void) return Fresult; } -char EmbeddedParametersPath[50] = "0://SWInfo//EmbParam.msg"; +char EmbeddedParametersPath[50] = "0://SysInfo//EmbParam.cfg"; ConfigurationParameters EmbeddedParameters; void LoadConfigurationParameters(ConfigurationParameters *Params) { @@ -169,7 +186,7 @@ uint32_t GenHWControlId; uint32_t GenHWInitCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { int Dispenser_i; - /*Safe*/RemoveControlCallback(GenHWControlId, GenHWInitCallBackFunction ); + SafeRemoveControlCallback(GenHWControlId, GenHWInitCallBackFunction ); for (Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) { Read_MidTank_Pressure_Sensor(Dispenser_i); @@ -270,7 +287,7 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) BlowerCfg.enabled = false; } //from now on starting blower on INIT, so that the chiller does not freeze - if (BlowerCfg.enabled == true) + /*if (BlowerCfg.enabled == true) { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.heatingvoltage) @@ -278,7 +295,7 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) else Control_Voltage_To_Blower(BlowerCfg.voltage-500); - } + }*/ /* for (Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) @@ -291,6 +308,7 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) ControlStart(); AlarmHandlingStart(); //ThreadInitialTestStub(request); + GeneralHwReady = true; return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h index 99934500c..9aa5201dc 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h @@ -14,5 +14,6 @@ extern void HWSystemResetRequest(MessageContainer* requestContainer); uint32_t HWConfigurationInit(void); extern HardwareBlower BlowerCfg; +extern bool GeneralHwReady; #endif diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 6eef03bb4..a64558f55 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -18,6 +18,9 @@ #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" + double dyeingspeed = 0; @@ -32,12 +35,13 @@ int32_t tableindex = 0; #define MAX_ALLOWED_TEMPERATURE 280 +char ProcessParamsConfigPath[50] = "0://SysInfo//ProcessP.cfg"; + ProcessParameters ProcessParametersKeep; uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) { uint32_t status = 0; - int Disp_i; if (ProcessParams->dryerzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER; if (ProcessParams->dryerzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER; @@ -156,7 +160,8 @@ void ProcessRequestFunc(MessageContainer* requestContainer) 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); UploadProcessParametersResponse response = UPLOAD_PROCESS_PARAMETERS_RESPONSE__INIT; @@ -179,3 +184,44 @@ void ProcessRequestFunc(MessageContainer* requestContainer) upload_process_parameters_request__free_unpacked(request,NULL); } +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; + uint32_t status = OK; + + Fresult = f_mkdir(SW_INFO_DIR); + if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) + { + FileHandle = my_malloc(sizeof(FIL)); + Fresult = FileOpen(ProcessParamsConfigPath, &Bytes, FileHandle); + if (Fresult == FR_OK) + { + buffer = my_malloc (Bytes); + if (buffer) + { + for (i=0;i<=(Bytes/100);i++) + { + Fresult = f_read(FileHandle,&buffer[i*100],100,&j ); + k+=j; + } + if (k!=Bytes) + LOG_ERROR(k,"File read error"); + } +// UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, Bytes, buffer); +// ProcessParameters* ProcessParams = request->processparameters; + ProcessParameters* ProcessParams = process_parameters__unpack(NULL, Bytes, buffer); + if (Fresult ==OK) + { + Fresult = HandleProcessParameters(ProcessParams); + //memcpy (&ProcessParametersKeep,ProcessParams,sizeof(ProcessParameters)); + process_parameters__free_unpacked(ProcessParams,NULL); + } + free (buffer); + } + f_close(FileHandle); + } + return Fresult; +} diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.h b/Software/Embedded_SW/Embedded/Modules/General/process.h index 12f1f8461..c67bd49b3 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.h +++ b/Software/Embedded_SW/Embedded/Modules/General/process.h @@ -23,6 +23,7 @@ extern ProcessParameters ProcessParametersKeep; extern void ProcessRequestFunc(MessageContainer* requestContainer); extern uint32_t HandleProcessParameters(ProcessParameters* ProcessParams); +uint32_t ProcessParamsInit(void); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 5f733762c..ede6b0674 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -63,23 +63,10 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re if ((GetDispenserPressure(DispenserId)>=DispenserPreparePressure)||(DispenserPrepareTime[DispenserId]>=DispenserPrepareTimeout)) { - if (RemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_Build_Pressure_Callback )==OK) - { - Report("Remove control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + if (SafeRemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_Build_Pressure_Callback )==OK) DispenserControlId[DispenserId] = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)DispenserControlId[DispenserId],0); - if (RemoveControlCallback(GetControlLowDevice_i(),IDS_Dispenser_Build_Pressure_Callback)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - DispenserControlId[DispenserId] = 0xFF; - } - else - Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - } - + Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorStop(HW_Motor_Id,Hard_Hiz); CurrentDispenserSpeed[DispenserId] = 0; @@ -120,24 +107,10 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re uint32_t IDS_Dispenser_StopMotorCallback(uint32_t DispenserId, uint32_t ReadValue) { Report("IDS_Dispenser_Close_Valve_And_Stop_Motor callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); - if (RemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_StopMotorCallback )==OK) - { - Report("Remove control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + if (SafeRemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_StopMotorCallback )==OK) DispenserControlId[DispenserId] = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)DispenserControlId[DispenserId],0); - if (RemoveControlCallback(GetControlLowDevice_i(),IDS_Dispenser_StopMotorCallback)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - DispenserControlId[DispenserId] = 0xFF; - } - else - { - Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - } - } + Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorStop(HW_Motor_Id,Hard_Hiz); @@ -173,22 +146,10 @@ uint32_t IDS_Dispenser_OpenValveCallback(uint32_t DispenserId, uint32_t ReadValu { Report("IDS_Dispenser_Start_Motor_and_Open_Valve Callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); - if (RemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_OpenValveCallback )==OK) - { - Report("Remove control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + if (SafeRemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_OpenValveCallback )==OK) DispenserControlId[DispenserId] = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)DispenserControlId[DispenserId],0); - if (RemoveControlCallback(GetControlLowDevice_i(),IDS_Dispenser_OpenValveCallback)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - DispenserControlId[DispenserId] = 0xFF; - } - else - Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - } + Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); Report("Control3WayValvesWithCallback called ",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)0,0); Control3WayValvesWithCallback (DispenserId, OpenValve, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer @@ -222,7 +183,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee DispenserRunningData IDS_Dispenser_Data[MAX_SYSTEM_DISPENSERS]; DispenserData IDSDispenserData; DispenserRunningData **dispenserdata; -char DispenserStorePath[50] = "0://SWInfo//DispStor.msg"; +char DispenserStorePath[50] = "0://SysInfo//DispStor.cfg"; void IDS_Dispenser_Content_Init (void) { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 0262db6ff..8028a60ee 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -85,21 +85,10 @@ uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t deviceID, uint32_t ReadValue MotorSetMicroStep(deviceID, MotorsCfg[deviceID].microstep); HomingActive[DispenserId]= false; Report("End backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - if (RemoveControlCallback(DispenserHomingControlId[DispenserId], IDS_HomeDispenserBackMoveCallback )==OK) - { + if (SafeRemoveControlCallback(DispenserHomingControlId[DispenserId], IDS_HomeDispenserBackMoveCallback )==OK) DispenserHomingControlId[DispenserId] = 0xFF; - } else - { - Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)DispenserHomingControlId[DispenserId],0); - if (RemoveControlCallback(GetControlLowDevice_i(),IDS_HomeDispenserBackMoveCallback)==OK) - { - Report("Remove control callback fixed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserHomingControlId[DispenserId],0); - DispenserHomingControlId[DispenserId] = 0xFF; - } - else - Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserHomingControlId[DispenserId],0); - } + Report("Remove control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserHomingControlId[DispenserId],0); DispenserHomingTime[DispenserId]=0; } else diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index a116bbd66..87478d9cb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -69,7 +69,7 @@ uint32_t LoadArmBackLash; }LoadArmInfoStruc; LoadArmInfoStruc LoadArmInfo; - char LoadArmPath[50] = "0://SWInfo//LoadArm.msg"; + char LoadArmPath[50] = "0://SysInfo//LoadArm.cfg"; //RUN MOTOR TO SWITCH WITH TIMEOUT //RUN MOTOR TO BREAK SENSOR @@ -341,12 +341,14 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); LoadArmInfo.LoadArmRounds = 20; + uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 OriginalMotorSpd_2PPS[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; 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, - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds, Thread_Load_HomingCallback, 100000); + numberOfSteps, Thread_Load_HomingCallback, 100000); //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmBackLash = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index b414611ff..14a74ffbe 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -106,7 +106,7 @@ uint32_t MotorPidRequestMessage(HardwarePidControl* request) DancerStopActivityLimit[Motor_i] = temp/(2*PI*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].armlength); return OK; } -char DancerConfigPath[50] = "0://SWInfo//DancCfg.msg"; +char DancerConfigPath[50] = "0://SysInfo//DancCfg.cfg"; uint32_t StoreDancerConfigMessage() { diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index 9add5438d..3849eef01 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -31,7 +31,7 @@ INIT_SEQUENCE_RESET_REASON, INIT_SEQUENCE_BUILT_IN_TEST, INIT_SEQUENCE_INITIAL_BLOWER_ACTIVATION, - INIT_SEQUENCE_DISPENSER_PRESSURE_BIULDUP_TEST, + INIT_SEQUENCE_DISPENSER_PRESSURE_BUILDUP_TEST, INIT_SEQUENCE_THREAD_DETECTION, INIT_SEQUENCE_START_HEATING, INIT_SEQUENCE_MACHINE_READY_TO_DYE, @@ -45,7 +45,7 @@ uint32_t RESET_Cause = 0; void InitSequenceResetReason(void); uint32_t InitSequenceBuiltInTest(void); uint32_t InitSequenceInitialBlowerActivation(void); -uint32_t InitSequenceDispenserPressureBuildupTest(void); +uint32_t InitSequenceDispenserPressureBuildUpTest(void); uint32_t InitSequenceThreadDetection(void); uint32_t InitSequenceStartHeating(void); uint32_t InitSequenceMachineReadyToDye(void); @@ -119,11 +119,11 @@ uint32_t InitSequenceInitialBlowerActivation(void) Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.voltage) Control_Voltage_To_Blower(BlowerCfg.voltage); - HWControlId = AddControlCallback( InitSequenceBlowerCallBackFunction, 5* eOneSecond/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + HWControlId = AddControlCallback( InitSequenceBlowerCallBackFunction, 10* eOneSecond/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); } return OK; } -uint32_t InitSequenceDispenserPressureBuildupTest(void) +uint32_t InitSequenceDispenserPressureBuildUpTest(void) { InitStages++; InitSequenceStateMachine(InitStages); @@ -184,8 +184,8 @@ uint32_t InitSequenceStateMachine( INIT_SEQUENCE_STAGES_ENUM ReadValue) case INIT_SEQUENCE_INITIAL_BLOWER_ACTIVATION: InitSequenceInitialBlowerActivation(); break; - case INIT_SEQUENCE_DISPENSER_PRESSURE_BIULDUP_TEST: - InitSequenceDispenserPressureBuildupTest(); + case INIT_SEQUENCE_DISPENSER_PRESSURE_BUILDUP_TEST: + InitSequenceDispenserPressureBuildUpTest(); break; case INIT_SEQUENCE_THREAD_DETECTION: InitSequenceThreadDetection(); diff --git a/Software/Stubs Collection/stubs/embeddedparametersbuild.cs b/Software/Stubs Collection/stubs/embeddedparametersbuild.cs index a1c7268da..4d3f89c72 100644 --- a/Software/Stubs Collection/stubs/embeddedparametersbuild.cs +++ b/Software/Stubs Collection/stubs/embeddedparametersbuild.cs @@ -17,29 +17,23 @@ public void OnExecute(StubManager stubManager) { -ProcessParameters processParameters = new ProcessParameters(); -processParameters.DyeingSpeed = 40; -processParameters.MinInkUptake = 200; -processParameters.MaxInkUptake = 200; -processParameters.FeederTension = 0; -processParameters.PullerTension = 0; -processParameters.WinderTension = 0; -processParameters.MixerTemp = 80; -processParameters.HeadZone1Temp = 80; -processParameters.HeadZone2Temp = 110; -processParameters.HeadZone3Temp = 135; -processParameters.HeadZone4Temp = 135; -processParameters.HeadZone5Temp = 135; -processParameters.HeadZone6Temp = 140; -processParameters.DryerAirFlow = 0; -processParameters.DryerZone1Temp = 160; -processParameters.DryerZone2Temp = 0; -processParameters.DryerZone3Temp = 0; -processParameters.DryerBufferLength = 30; -processParameters.HeadAirFlow = 0; -processParameters.TableIndex = 0; +ConfigurationParameters configurationParameters = new ConfigurationParameters(); +configurationParameters.BreakSensorLimit = 10; +configurationParameters.DiagnosticCollectionLimit = 2; +configurationParameters.OverHeatCountLimit = 3; +configurationParameters.UnderHeatCountLimit = 3; +configurationParameters.CloseValveTimeout = 250; +configurationParameters.OpenValveTimeout = 250; +configurationParameters.InitialDispenserPressure = 0.1; +configurationParameters.InitialDispenserTimeout = 10000; +configurationParameters.InitialDispenserTimeLag = 100; +configurationParameters.DispenserBuildPressureSpeed = 500; +configurationParameters.DispenserBuildPressureLimit = 1.5; +configurationParameters.DispenserBuildPressureTimeout = 20000; +configurationParameters.DispenserBuildPressureLag = 50; + -File.WriteAllBytes("C:/temp/ProcessP.msg",processParameters.ToBytes()); +File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes()); } \ No newline at end of file -- cgit v1.3.1 From ff9d1f9c4e6b9ab3bdd96b7e4f526773023782c5 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 18 Feb 2019 23:26:05 +0200 Subject: load button connected to load functions --- .../Embedded_SW/Embedded/Modules/General/buttons.c | 41 +++++++++++----------- .../Embedded_SW/Embedded/Modules/General/buttons.h | 2 +- .../Embedded/Modules/Thread/ThreadLoad.c | 4 +-- .../Embedded/Modules/Thread/Thread_ex.h | 23 ++++++++++++ 4 files changed, 46 insertions(+), 24 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index f80727dfc..0550c8ca7 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -19,6 +19,7 @@ #include #include #include "Common/report/report.h" +#include "Modules/Thread/Thread_ex.h" #include "Modules/General/buttons.h" @@ -448,46 +449,46 @@ return 0; /*------ THREAD LOAD/UNLOAD ----------*/ -/* -int LoadStatMachine(enum PBstat PBAction, struct button *pBtn) + +int LoadStatMachine( PBstat PBAction, button *pBtn) { - switch (pBtn->PBstate) + switch (pBtn->state) { case sttRDY : - switch (pBtn->PBAction) + switch (pBtn->Action) { case (SHORTPB): case (LONGPB): case (REPLONGPB): - pBtn->PBstate = sttPRELOAD; - pBtn->PBcolor = BLINK; - if (doPreloading()) + pBtn->state = sttPRELOAD; + pBtn->color = BLINK; + if (ThreadLoadStateMachine( THREAD_LOAD_INIT)) { - pBtn->PBstate = sttPRELOAD ; // to do - pBtn->PBcolor = BLUE; + pBtn->state = sttPRELOAD ; // to do + pBtn->color = BLUE; } - else pBtn->PBstate = sttDISABLE ; + else pBtn->state = sttDISABLE ; break; default : break; } break; case sttPRELOAD: - switch (pBtn->PBAction) + switch (pBtn->Action) { case (SHORTPB): case (LONGPB): case (REPLONGPB): - if (doLoading()) + if (ThreadLoadStateMachine( THREAD_LOAD_INITIAL_TENSION)) { - pBtn->PBstate = sttLOADSUCSESS ; // to do - pBtn->PBcolor = BLUE; + pBtn->state = sttLOADSUCSESS ; // to do + pBtn->color = BLUE; } else { - pBtn->PBstate = sttLOADFAIL ; - pBtn->PBcolor = fastBILNK ; // to do + pBtn->state = sttLOADFAIL ; + pBtn->color = fastBILNK ; // to do } break; default : @@ -502,14 +503,12 @@ int LoadStatMachine(enum PBstat PBAction, struct button *pBtn) // break; default: //sttDISABLE - pBtn->PBcolor = colorOFF; + pBtn->color = colorOFF; break; } -ShortLongOffPB( threadPB, ret,struct button *pBtn); - - + return OK; } -*/ + void test_avi() { diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h index e7a611e9b..d0cea022c 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h @@ -34,7 +34,7 @@ typedef enum sttLOADFAIL } PBmachinState; -typedef struct +typedef struct Button { char bttn_name[10]; //option int bttn_status; // 0=release 1=press diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 87478d9cb..e89dc4c6d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -35,7 +35,7 @@ //#include //#include - typedef enum +/* typedef enum { THREAD_LOAD_INIT, THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, @@ -54,7 +54,7 @@ //KEEP NOTATION HOW MANY ROTATIONS IN THE DRYER THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING THREAD_LOAD_END - }THREAD_LOAD_STAGES_ENUM; + }THREAD_LOAD_STAGES_ENUM;*/ THREAD_LOAD_STAGES_ENUM LoadStages = THREAD_LOAD_INIT; ProcessParameters ProcessParametersClear,ProcessParametersRecover; uint8_t NumberOfDrierLoaderCycles = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index a22be25dc..cd71c73b1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -46,6 +46,29 @@ uint32_t Winder_Prepare(void); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); uint32_t Winder_End(void); +typedef enum +{ + THREAD_LOAD_INIT, + THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, + THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION,//USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINST STOPPER. MOVE SLOWLY + THREAD_LOAD_CENTER_HEAD_ROCKERS, //puthead cleaning rockers to middle position + THREAD_LOAD_OPEN_COVERS, //OPEN DYEING HEAD COVER AND DRYER LID + THREAD_LOAD_LIFT_DANCERS, + THREAD_LOAD_LIFT_ROCKERS, //MACHINE IS READY. SEND MESSAGE, START TIMER TO CLOSE LIDS, WAIT FOR OPERATOR RESPONSE + THREAD_LOAD_INITIAL_TENSION,//CHECK SPOOL PRESENCERUN WINDER UNTIL BREAK SENSOR IS IDENTIFIEING MOVEMENT FOR A SECOND + THREAD_LOAD_CLOSE_ROCKERS, + THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD + THREAD_LOAD_CLOSE_LIDS, + THREAD_LOAD_RESUME_HEATING, + THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT,//JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION + THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40 + //KEEP NOTATION HOW MANY ROTATIONS IN THE DRYER + THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING + THREAD_LOAD_END +}THREAD_LOAD_STAGES_ENUM; +uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue); + + void ThreadLoadPollRequest(MessageContainer* requestContainer); void ThreadLoadRequest(MessageContainer* requestContainer); -- cgit v1.3.1 From 3fcd0dbc6650749421f0390a60154c52254682e6 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 19 Feb 2019 10:35:55 +0200 Subject: PNR file updated in embedded. --- .../Embedded/Common/report/reportInit.c | 2 -- .../PMR/Debugging/DebugLogCategory.pb-c.c | 4 +-- .../PMR/Debugging/DebugLogCategory.pb-c.h | 2 +- .../FirmwareUpgrade/VersionFileDestination.pb-c.c | 18 ++++++++--- .../FirmwareUpgrade/VersionFileDestination.pb-c.h | 6 +++- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 4 ++- .../Embedded/Modules/Control/MillisecTask.c | 1 - .../Embedded_SW/Embedded/Modules/Control/control.c | 1 - .../Embedded/Modules/Thread/ThreadLoad.c | 5 ++- .../Embedded/StateMachines/Printing/JobSTM.c | 37 +++++++++------------- 10 files changed, 43 insertions(+), 37 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 982b53443..feb13504a 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -77,8 +77,6 @@ int ReportResponseFunc(char *message, /* The formatted message response.category = DEBUG_LOG_CATEGORY__Critical; break; case RpPrivate: - response.category = DEBUG_LOG_CATEGORY__Debug; - break; default: response.category = DEBUG_LOG_CATEGORY__Info; break; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.c index ebb901ba8..b651d2acb 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.c @@ -13,7 +13,7 @@ static const ProtobufCEnumValue debug_log_category__enum_values_by_number[5] = { "Warning", "DEBUG_LOG_CATEGORY__Warning", 1 }, { "Error", "DEBUG_LOG_CATEGORY__Error", 2 }, { "Critical", "DEBUG_LOG_CATEGORY__Critical", 3 }, - { "Debug", "DEBUG_LOG_CATEGORY__Debug", 4 }, + { "Safety", "DEBUG_LOG_CATEGORY__Safety", 4 }, }; static const ProtobufCIntRange debug_log_category__value_ranges[] = { {0, 0},{0, 5} @@ -21,9 +21,9 @@ static const ProtobufCIntRange debug_log_category__value_ranges[] = { static const ProtobufCEnumValueIndex debug_log_category__enum_values_by_name[5] = { { "Critical", 3 }, - { "Debug", 4 }, { "Error", 2 }, { "Info", 0 }, + { "Safety", 4 }, { "Warning", 1 }, }; const ProtobufCEnumDescriptor debug_log_category__descriptor = diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.h index d97b42d33..1fda3ab01 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugLogCategory.pb-c.h @@ -24,7 +24,7 @@ typedef enum _DebugLogCategory { DEBUG_LOG_CATEGORY__Warning = 1, DEBUG_LOG_CATEGORY__Error = 2, DEBUG_LOG_CATEGORY__Critical = 3, - DEBUG_LOG_CATEGORY__Debug = 4 + DEBUG_LOG_CATEGORY__Safety = 4 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DEBUG_LOG_CATEGORY) } DebugLogCategory; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.c index 3e45ece3e..daa5f09e2 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.c @@ -7,22 +7,30 @@ #endif #include "VersionFileDestination.pb-c.h" -static const ProtobufCEnumValue version_file_destination__enum_values_by_number[4] = +static const ProtobufCEnumValue version_file_destination__enum_values_by_number[8] = { { "MCU", "VERSION_FILE_DESTINATION__MCU", 0 }, { "FPGA1", "VERSION_FILE_DESTINATION__FPGA1", 1 }, { "FPGA2", "VERSION_FILE_DESTINATION__FPGA2", 2 }, { "FPGA3", "VERSION_FILE_DESTINATION__FPGA3", 3 }, + { "ConfigParams", "VERSION_FILE_DESTINATION__ConfigParams", 4 }, + { "ProcessParams", "VERSION_FILE_DESTINATION__ProcessParams", 5 }, + { "AlarmParams", "VERSION_FILE_DESTINATION__AlarmParams", 6 }, + { "GeneralHWConfigParams", "VERSION_FILE_DESTINATION__GeneralHWConfigParams", 7 }, }; static const ProtobufCIntRange version_file_destination__value_ranges[] = { -{0, 0},{0, 4} +{0, 0},{0, 8} }; -static const ProtobufCEnumValueIndex version_file_destination__enum_values_by_name[4] = +static const ProtobufCEnumValueIndex version_file_destination__enum_values_by_name[8] = { + { "AlarmParams", 6 }, + { "ConfigParams", 4 }, { "FPGA1", 1 }, { "FPGA2", 2 }, { "FPGA3", 3 }, + { "GeneralHWConfigParams", 7 }, { "MCU", 0 }, + { "ProcessParams", 5 }, }; const ProtobufCEnumDescriptor version_file_destination__descriptor = { @@ -31,9 +39,9 @@ const ProtobufCEnumDescriptor version_file_destination__descriptor = "VersionFileDestination", "VersionFileDestination", "", - 4, + 8, version_file_destination__enum_values_by_number, - 4, + 8, version_file_destination__enum_values_by_name, 1, version_file_destination__value_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.h index 83686d194..fbada1aee 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.h @@ -23,7 +23,11 @@ typedef enum _VersionFileDestination { VERSION_FILE_DESTINATION__MCU = 0, VERSION_FILE_DESTINATION__FPGA1 = 1, VERSION_FILE_DESTINATION__FPGA2 = 2, - VERSION_FILE_DESTINATION__FPGA3 = 3 + VERSION_FILE_DESTINATION__FPGA3 = 3, + VERSION_FILE_DESTINATION__ConfigParams = 4, + VERSION_FILE_DESTINATION__ProcessParams = 5, + VERSION_FILE_DESTINATION__AlarmParams = 6, + VERSION_FILE_DESTINATION__GeneralHWConfigParams = 7 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(VERSION_FILE_DESTINATION) } VersionFileDestination; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index c9f4ac1ee..de0bd5d1f 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -360,6 +360,8 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever //raise flag fr next job break; case DEBUG_LOG_CATEGORY__Critical: + case DEBUG_LOG_CATEGORY__Safety: + watchdogCriticalAlarm = true; /* //stop all dispensers @@ -416,7 +418,7 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever }*/ break; - case DEBUG_LOG_CATEGORY__Debug: + case DEBUG_LOG_CATEGORY__Info: default: //do nothing diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index e0462eb6c..e8a60a8c4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -44,7 +44,6 @@ Task_Handle Millisecond_Task_Handle; /******************** Definitions ********************************************/ -#define INVALID_MSG_ID 0xFFFF /******************** STRUCTURES AND ENUMs ********************************************/ typedef struct MillisecMotorData diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 93c989ab5..e4abc5e3c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -56,7 +56,6 @@ #include "control.h" #include "MillisecTask.h" /******************** Definitions ********************************************/ -#define INVALID_MSG_ID 0xFFFF #define MAX_TANGO_CONTROL_DEVICES 100 /******************** STRUCTURES AND ENUMs ********************************************/ diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index e89dc4c6d..0bc2d04de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -211,7 +211,10 @@ if (CallbackCounter == 0) { LoadStages++; - //ThreadLoadStateMachine(LoadStages); + if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call + { + //ThreadLoadStateMachine(LoadStages); + } } } else diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index cffe77000..08233ce9a 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -65,27 +65,27 @@ #include "Modules/control/control.h" -#define INVALID_MSG_ID 0xFFFF +#define MAX_TICKET_SIZE 10000 Mailbox_Handle JobmsgQ = NULL; -//static Clock_Handle JobClock; -//static Clock_Params jobclkParams; - JobEndReasonEnum JobEndReason = JOB_OK; ErrorCode JobError_to_ErrorCode[JOB_ERRORS_MAX+1] = {ERROR_CODE__NONE,ERROR_CODE__JOB_UNSPECIFIED_ERROR,ERROR_CODE__JOB_THREAD_BREAK,ERROR_CODE__JOB_WINDER_DANCER_FAIL, ERROR_CODE__JOB_POOLER_DANCER_FAIL,ERROR_CODE__JOB_FEEDER_DANCER_FAIL,ERROR_CODE__JOB_OUT_OF_DYE,ERROR_CODE__JOB_OTHER_ALARM, ERROR_CODE__JOB_TEMPERATURE_ALARM,ERROR_CODE__JOB_LS_ALARM,ERROR_CODE__JOB_PRESSURE_ALARM,ERROR_CODE__JOB_CURRENT_ALARM, ERROR_CODE__JOB_MOTOR_ALARM,ERROR_CODE__JOB_OTHER_ALARM}; -#define MAX_TICKET_SIZE 10000 -//char CurrentJobBuffer[MAX_TICKET_SIZE]; -JobTicket *CurrentJob = NULL;//(JobTicket *)CurrentJobBuffer; +JobTicket *CurrentJob = NULL; JobRequest *CurrentRequest = NULL; -//char PreviousJobBuffer[MAX_TICKET_SIZE]; -//JobTicket *PreviousJob = (JobTicket *)PreviousJobBuffer; - +double previousJobLength; +uint32_t StubControlId = 0xFF; +double StubLengthCounter = 0,StubLength = 0,StubSpeed=0; +JobTicket Ticket; +JobSegment *TSegment; +JobSpool *Tspool; +bool CopyConfigured[MAX_SYSTEM_MODULES]; +char ErrorMsg[100]; ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle}; @@ -342,16 +342,7 @@ void JobAbortFunc(MessageContainer* requestContainer) } -double previousJobLength; -char ErrorMsg[100]; -uint32_t StubControlId = 0xFF; -double StubLengthCounter = 0,StubLength = 0,StubSpeed=0; -//#include "PMR/Diagnostics/ThreadJoggingResponse.pb-c.h" -//#include "PMR/Diagnostics/ThreadAbortJoggingRequest.pb-c.h" -JobTicket Ticket; -JobSegment *TSegment; -JobSpool *Tspool; -bool CopyConfigured[MAX_SYSTEM_MODULES]; +//******************************************************************************************************************** uint32_t ThreadJoggingFunc(int speed) { ProcessParameters ProcessParametersCopy; @@ -621,7 +612,8 @@ void JobRequestFunc(MessageContainer* requestContainer) JobAlarmReason = AlarmHandlingPrepareJob(CurrentJob); if (JobAlarmReason ==OK) { - if (Ticket->processparameters) +#warning Process parameters in job request are not handled. push separately for now + /*if (Ticket->processparameters) { if (HandleProcessParameters(Ticket->processparameters)!= OK) { @@ -629,7 +621,8 @@ void JobRequestFunc(MessageContainer* requestContainer) error = ERROR_CODE__INVALID_PARAMETER; usnprintf(ErrorMsg, 100, "Hardware Parameters Not Set"); } - } + }*/ + REPORT_MSG(0,"Process parameters in job request are not handled. push separately for now"); if (Ticket->spool) { if (InternalWindingConfigMessage(Ticket->spool)!= OK) -- cgit v1.3.1 From 0135383d7f263d3c2cc70040d8a908b95341f42d Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 19 Feb 2019 18:54:58 +0200 Subject: fix init sequence, fix thread load --- .../Embedded/Modules/General/GeneralHardware.c | 7 +- .../Embedded/Modules/Thread/ThreadLoad.c | 98 +++++++++++++++++----- 2 files changed, 79 insertions(+), 26 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index fa1ad8fc2..d3d57ddb6 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -59,12 +59,13 @@ uint32_t HWConfigurationInit(void) uint8_t* buffer = NULL; uint32_t Bytes = 0,i,j,k=0; uint32_t status = OK; + UploadHardwareConfigurationRequest* UploadRequest; Control_WD(ENABLE,250); Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { -/*************************************************************************/ +/************************************************************************* Fresult = f_mkdir(OLD_SW_INFO_DIR); Fresult = f_rename ("//SWINFO//GENHWCFG.MSG", "//SYSINFO//GENHWCFG.CFG"); @@ -75,7 +76,7 @@ uint32_t HWConfigurationInit(void) Fresult |= f_rename ("//SWINFO//DANCCFG.MSG", "//SYSINFO//DANCCFG.CFG"); Fresult |= f_rename ("//SWINFO//LOADARM.MSG", "//SYSINFO//LOADARM.CFG"); - /*************************************************************************/ + *************************************************************************/ FileHandle = my_malloc(sizeof(FIL)); Fresult = FileOpen(HwConfigPath, &Bytes, FileHandle); @@ -92,7 +93,7 @@ uint32_t HWConfigurationInit(void) if (k!=Bytes) LOG_ERROR(k,"File read error"); } - UploadHardwareConfigurationRequest* UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); + UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); status = HWConfiguration(UploadRequest); if (status ==OK) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 0bc2d04de..a3630ded4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -37,23 +37,23 @@ /* typedef enum { - THREAD_LOAD_INIT, - THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, - THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION,//USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINST STOPPER. MOVE SLOWLY - THREAD_LOAD_CENTER_HEAD_ROCKERS, //puthead cleaning rockers to middle position - THREAD_LOAD_OPEN_COVERS, //OPEN DYEING HEAD COVER AND DRYER LID - THREAD_LOAD_LIFT_DANCERS, - THREAD_LOAD_LIFT_ROCKERS, //MACHINE IS READY. SEND MESSAGE, START TIMER TO CLOSE LIDS, WAIT FOR OPERATOR RESPONSE - THREAD_LOAD_INITIAL_TENSION,//CHECK SPOOL PRESENCERUN WINDER UNTIL BREAK SENSOR IS IDENTIFIEING MOVEMENT FOR A SECOND - THREAD_LOAD_CLOSE_ROCKERS, - THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD - THREAD_LOAD_CLOSE_LIDS, - THREAD_LOAD_RESUME_HEATING, - THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT,//JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION - THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40 + 0 THREAD_LOAD_INIT, + 1 THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, + 2 THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION,//USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINST STOPPER. MOVE SLOWLY + 3 THREAD_LOAD_CENTER_HEAD_ROCKERS, //puthead cleaning rockers to middle position + 4 THREAD_LOAD_OPEN_COVERS, //OPEN DYEING HEAD COVER AND DRYER LID + 5 THREAD_LOAD_LIFT_DANCERS, + 6 THREAD_LOAD_LIFT_ROCKERS, //MACHINE IS READY. SEND MESSAGE, START TIMER TO CLOSE LIDS, WAIT FOR OPERATOR RESPONSE + 7 THREAD_LOAD_INITIAL_TENSION,//CHECK SPOOL PRESENCERUN WINDER UNTIL BREAK SENSOR IS IDENTIFIEING MOVEMENT FOR A SECOND + 8 THREAD_LOAD_CLOSE_ROCKERS, + 9 THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD + 10 THREAD_LOAD_CLOSE_LIDS, + 11 THREAD_LOAD_RESUME_HEATING, + 12 THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT,//JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION + 13 THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40 //KEEP NOTATION HOW MANY ROTATIONS IN THE DRYER - THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING - THREAD_LOAD_END + 14 THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING + 15 THREAD_LOAD_END }THREAD_LOAD_STAGES_ENUM;*/ THREAD_LOAD_STAGES_ENUM LoadStages = THREAD_LOAD_INIT; ProcessParameters ProcessParametersClear,ProcessParametersRecover; @@ -104,7 +104,7 @@ memcpy (&ProcessParametersRecover,&ProcessParametersKeep,sizeof(ProcessParameters)); //NumberOfDrierLoaderCycles = loadLoadArmParameters(); LoadStages++; - //ThreadLoadStateMachine(LoadStages); + ThreadLoadStateMachine(LoadStages); return OK; } @@ -146,14 +146,14 @@ { // Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - NumberOfDrierLoaderCycles--; + /*NumberOfDrierLoaderCycles--; if (NumberOfDrierLoaderCycles) { Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround, Thread_Load_Set_Load_Arm_To_Start_Position_Callback,1000); } - else + else*/ { Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); //storeLoadArmParameters(); @@ -177,13 +177,16 @@ } uint32_t Thread_Load_Set_Load_Arm_To_Start_Position(void) { + uint32_t numberOfSteps = 0; REPORT_MSG(LoadStages, "Thread Load State Machine step"); if (LoadArmInfo.LoadArmRounds != 0xFF) { - Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 + 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_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,numberOfSteps,RpMessage,NumberOfDrierLoaderCycles,0); NumberOfDrierLoaderCycles = LoadArmInfo.LoadArmRounds; status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds, Thread_Load_Set_Load_Arm_To_Start_Position_Callback,1000); + numberOfSteps, Thread_Load_Set_Load_Arm_To_Start_Position_Callback,1000); } else //number of circles is not known - compare to position of the motor to verify location at the stopper { @@ -297,7 +300,7 @@ CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,4000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,20000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,10000); return OK; } @@ -340,6 +343,34 @@ MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 200, FEEDER_DANCER ,true, Thread_Load_HomingCallback,10000); return OK; } + + 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_HomingCallback Motor Id"); + if(ControlId != 0xFF) + { + MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); + RemoveControlCallback(ControlId, ThreadLoadControlCBFunction ); + ControlId = 0xFF; + } + if (CallbackCounter) + { + CallbackCounter--; + if (CallbackCounter == 0) + { + LoadStages++; + if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call + { + //ThreadLoadStateMachine(LoadStages); + } + } + } + else + LOG_ERROR(MotorId, "Thread_Load_HomingCallback Callback is already 0"); + return OK; + } + uint32_t Thread_Load_Dryer_Loading(void) { REPORT_MSG(LoadStages, "Thread Load State Machine step"); @@ -347,11 +378,32 @@ uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; + 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; + 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; + MotorControlConfig[FEEDER_MOTOR].m_params.Kp = MotorsControl[FEEDER_MOTOR].proportionalgain; + MotorControlConfig[FEEDER_MOTOR].m_params.Ki = MotorsControl[FEEDER_MOTOR].integraltime; + MotorControlConfig[FEEDER_MOTOR].m_params.IntegralErrorMultiplier = MotorsControl[FEEDER_MOTOR].setpointramprateorsoftstartramp; + MotorControlConfig[FEEDER_MOTOR].m_params.ProportionalErrorMultiplier = MotorsControl[FEEDER_MOTOR].outputonoffhysteresisvalue; + MotorControlConfig[FEEDER_MOTOR].m_params.epsilon = MotorsControl[FEEDER_MOTOR].epsilon; + MotorControlConfig[FEEDER_MOTOR].m_params.dt = MotorsControl[FEEDER_MOTOR].controloutputtype; + MotorControlConfig[FEEDER_MOTOR].m_ingnoreValue = MotorsControl[FEEDER_MOTOR].sensorcorrectionadjustment; // the minimal change required to change the motor speed in pulses + MotorControlConfig[FEEDER_MOTOR].m_calculatedError = 0; + MotorControlConfig[FEEDER_MOTOR].m_integral = 0; + MotorControlConfig[FEEDER_MOTOR].m_isEnabled = true; + MotorControlConfig[FEEDER_MOTOR].m_isReady = true; + MotorControlConfig[FEEDER_MOTOR].m_mesuredParam = 0; + MotorControlConfig[FEEDER_MOTOR].m_preError = 0; + 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); + 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, - numberOfSteps, Thread_Load_HomingCallback, 100000); + numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000); //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmBackLash = 0; -- cgit v1.3.1 From f4e0312f008e0ebc0c80a3b070d278de2683cf8f Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 19 Feb 2019 19:09:00 +0200 Subject: thread load corrections --- Software/Embedded_SW/Embedded/Modules/Thread/Thread.h | 2 ++ Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 5 +++-- Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c | 1 + Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 8c6164219..638611c8b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -74,5 +74,7 @@ uint32_t MotorPidRequestMessage(HardwarePidControl* request); uint32_t DancerConfigMessage(HardwareDancer * request); +void SetOriginMotorSpeed(float process_speed); + #endif //MODULES_THREAD_THREAD_H_ diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index a3630ded4..8792470d2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -377,8 +377,9 @@ LoadArmInfo.LoadArmRounds = 20; uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 - OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; - CurrentControlledSpeed[FEEDER_MOTOR] = 1000; + SetOriginMotorSpeed(15); +// OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; +// 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; MotorControlConfig[FEEDER_MOTOR].m_params.MAX = 1; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 14a74ffbe..435d7aef3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -128,6 +128,7 @@ uint32_t StoreDancerConfigMessage() Dancers[Dancer_i].has_hardwaredancertype = true; DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0,0); DancerConfig.n_dancers++; + DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index e15a27351..aee5fefac 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -75,7 +75,6 @@ void ThreadSegmentEnded(void); void ThreadInterSegmentEnded(void); void ThreadDistanceToSpoolEnded(void); uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue); -void SetOriginMotorSpeed(float process_speed); double KeepNormalizedError = 0; bool ThreadControlActive = false; -- cgit v1.3.1 From 164f933e7d115619488323c0e329cb57ee956734 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 20 Feb 2019 10:33:31 +0200 Subject: Loading improved --- .../Embedded/Modules/Thread/ThreadLoad.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 8792470d2..1c28a5447 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -203,11 +203,6 @@ { Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); REPORT_MSG(MotorId, "Thread_Load_HomingCallback Motor Id"); - if(ControlId != 0xFF) - { - RemoveControlCallback(ControlId, ThreadLoadControlCBFunction ); - ControlId = 0xFF; - } if (CallbackCounter) { CallbackCounter--; @@ -251,7 +246,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,4000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,20000); @@ -262,7 +257,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 700, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 700, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 700, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,10000); @@ -286,9 +281,9 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 500, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,10000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,10000); return OK; } @@ -347,7 +342,7 @@ 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_HomingCallback Motor Id"); + REPORT_MSG(MotorId, "Thread_Load_Dryer_Loading_Callback Motor Id"); if(ControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); @@ -377,7 +372,7 @@ LoadArmInfo.LoadArmRounds = 20; uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 - SetOriginMotorSpeed(15); + SetOriginMotorSpeed(19); // OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; // CurrentControlledSpeed[FEEDER_MOTOR] = 1000; @@ -415,7 +410,7 @@ uint32_t Thread_Load_Jog_ThreadStop(uint32_t index, uint32_t ReadValue) { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - RemoveControlCallback(ControlId, Thread_Load_Jog_ThreadStop ); + SafeRemoveControlCallback(ControlId, Thread_Load_Jog_ThreadStop ); ControlId = 0xFF; ThreadAbortJoggingFunc(); LoadStages++; @@ -426,7 +421,7 @@ //Jog Thread Shortly To Make Sure Spool Is Running. Report End Of Loading { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - ThreadJoggingFunc(40); + ThreadJoggingFunc(20); ControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*5,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } -- cgit v1.3.1