diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-04-02 17:45:24 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-04-02 17:45:24 +0300 |
| commit | af528190fe45befc34e95c9b4e2bfc4806569dfa (patch) | |
| tree | 08a1cdd2a3cd6d938228dacf4a99aba8b52ecd3a /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | 2f85ba08c917d63ba8b7df96c38803d25b00460b (diff) | |
| parent | 3f6aecd92ceca69ffa5fc07ea0bbe93fd4097c85 (diff) | |
| download | Tango-af528190fe45befc34e95c9b4e2bfc4806569dfa.tar.gz Tango-af528190fe45befc34e95c9b4e2bfc4806569dfa.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
3 files changed, 41 insertions, 22 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 53ab0e8a2..3ee248fba 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -200,10 +200,6 @@ } uint8_t CallbackCounter = 0; uint8_t TimeoutsCounter = 0; - uint8_t LeftMicrostepKeep = 0; - uint8_t LeftkvalKeep = 0; - uint8_t RightMicrostepKeep = 0; - uint8_t RightkvalKeep = 0; uint32_t Thread_Load_HomingCallback(uint32_t MotorId, uint32_t ReadValue) { @@ -229,10 +225,10 @@ LoadStages++; if (LoadStages == THREAD_LOAD_LIFT_ROCKERS) { - MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, RightMicrostepKeep); - MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, LeftMicrostepKeep); - //MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, RightkvalKeep); - //MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, LeftkvalKeep); + MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep); + MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].microstep); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].microstep); } if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this stage we should wait for user call { @@ -282,19 +278,15 @@ //Machine Is Ready. Send Message, Start Timer To Close Lids, Wait For Operator Response { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - LeftMicrostepKeep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].microstep; - LeftkvalKeep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].kvalrun; - RightMicrostepKeep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; - RightkvalKeep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1); - //MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 35); - //MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 35); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 35); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 35); Task_sleep(10); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,12000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 50, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,25000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,12000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 50, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,25000); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index d8564963c..1f7836ea5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -288,7 +288,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) //Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 0); //Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 0); //REPORT_MSG(temp , "new winder speed"); - Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0); +// Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0); } /********************************************************************************/ @@ -382,8 +382,8 @@ uint32_t Winder_End(void) CurrentControlledSpeed[SCREW_MOTOR] = 0; ScrewsStopControlTimer(); //move the cart to the edge so the spool can be easily replaced - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); - + //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); + MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); return OK; } void Winder_ScrewHomeLimitSwitchInterrupt(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 9f5ece15a..07a32b2a6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -83,6 +83,11 @@ void ThreadInterSegmentEnded(void); void ThreadDistanceToSpoolEnded(void); uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue); +bool SegmentState = false; +bool PreSegmentState = false; +bool DTSState = false; +void SendSegmentFail(void); + double KeepNormalizedError = 0; bool ThreadControlActive = false; ////////////////////////Slow Motor State//////////////////////////////////// @@ -128,6 +133,7 @@ uint32_t Poolerinitialpos = 0xFFFF; void ThreadUpdateProcessLength (double length, void *Funcptr) { + REPORT_MSG(length,"ThreadUpdateProcessLength"); CurrentRequestedLength = length*100;//Centimetres CurrentProcessedLength = 0; ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; @@ -436,7 +442,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) JobEndReason = JOB_THREAD_BREAK; ThreadControlActive = false; SendJobProgress(0.0,0,false, TMessage); - SegmentReady(Module_Thread,ModuleFail); + SendSegmentFail(); //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); //EndState(CurrentJob,"ReadBreakSensor Error" ); LOG_ERROR(index, "ReadBreakSensor Error"); @@ -466,7 +472,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId; SendJobProgress(0.0,0,false, TMessage); //EndState(CurrentJob,TMessage ); - SegmentReady(Module_Thread,ModuleFail); + SendSegmentFail(); /*switch (index) { case POOLER_MOTOR: @@ -750,10 +756,13 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) //set speed for both rocker motors //wait for all motors to get to the required speed (set the target speed for the control to check) //call the job state machine when the thread system is ready - if ((InitialProcess==false) && (EnableIntersegment == true) && (IntersegmentLength >= 1.0)) //fix - avoid intersegment length 0 + if ((InitialProcess==false) && (EnableIntersegment == true)) //&& (IntersegmentLength >= 1.0)) //fix - avoid intersegment length 0 {//add initial presegment and cleaning before first segment ThreadUpdateProcessLength (IntersegmentLength,(void *)ThreadInterSegmentEnded); REPORT_MSG (IntersegmentLength," ThreadPreSegmentState IntersegmentLength"); + SegmentState = false; + PreSegmentState = true; + DTSState = false; } else { @@ -766,6 +775,17 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) return OK; } int REPSegmentId = 0; +void SendSegmentFail(void) +{ + if (SegmentState == true) + SegmentReady(Module_Thread,ModuleFail); + else if (PreSegmentState == true) + PreSegmentReady(Module_Thread,ModuleFail); + else if (DTSState == true) + DistanceToSpoolReady(Module_Thread,ModuleFail); + +} + void ThreadInterSegmentEnded(void) { REPORT_MSG (REPSegmentId,"ThreadInterSegmentEnded"); @@ -792,6 +812,9 @@ uint32_t ThreadSegmentState(void *SegmentDetails, int SegmentId) CurrentSegmentId = SegmentId; REPORT_MSG (seglength," ThreadSegmentState"); ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded); + SegmentState = true; + PreSegmentState = false; + DTSState = false; return OK; } @@ -801,6 +824,9 @@ uint32_t ThreadDistanceToSpoolState(void ) seglength = dryerbufferlength; REPORT_MSG (seglength,"ThreadDistanceToSpoolState"); ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); + SegmentState = false; + PreSegmentState = false; + DTSState = true; return OK; } @@ -816,6 +842,7 @@ char Endstr[150]; Report(Endstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); ThreadUpdateProcessLength (0.0,(void *)NULL); + TotalProcessedLength = 0.0; SetOriginMotorSpeed(0); #ifdef HUNDRED_MICROSECONDS_DANCER_READ MillisecLogClose(); |
