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