aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-04-16 00:38:18 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-04-16 00:38:18 +0300
commita43abd7769c1dd19b2bfe4f9d09d8226da396516 (patch)
treea692defe22a6eb75f1ee0d2caf539300d8dceb9c /Software/Embedded_SW/Embedded/Modules/Thread
parentb54e81b157edff62414a8a8e3fb9e82964f0c5d1 (diff)
parent9d9aa53284fd93fc8590d2ff85741c7f4a95947b (diff)
downloadTango-a43abd7769c1dd19b2bfe4f9d09d8226da396516.tar.gz
Tango-a43abd7769c1dd19b2bfe4f9d09d8226da396516.zip
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c28
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c8
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c37
4 files changed, 62 insertions, 13 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index 74a07e99c..ab5075ab9 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -78,6 +78,13 @@
//RUN MOTOR A FULL CYCLE
//RUN A MOTOR NUMBER OF STEPS
//RUN CONTROL FOR A SINGLE DANCER
+ bool ThreadLoadingActive(void)
+ {
+ if ((LoadStages > THREAD_LOAD_INIT)&&(LoadStages < THREAD_LOAD_END))
+ return true;
+ else
+ return false;
+ }
uint32_t Thread_Load_Init(void)
{
void* buffer = NULL;
@@ -200,6 +207,7 @@
}
uint8_t CallbackCounter = 0;
uint8_t TimeoutsCounter = 0;
+
uint32_t Thread_Load_HomingCallback(uint32_t MotorId, uint32_t ReadValue)
{
Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
@@ -222,6 +230,13 @@
else
{
LoadStages++;
+ if (LoadStages == THREAD_LOAD_LIFT_ROCKERS)
+ {
+ 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
{
//ThreadLoadStateMachine(LoadStages);
@@ -237,9 +252,9 @@
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD], Thread_Load_HomingCallback,10000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD].directionthreadwize, 80, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD], Thread_Load_HomingCallback,10000);
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH], Thread_Load_HomingCallback,10000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH].directionthreadwize, 80, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH], Thread_Load_HomingCallback,10000);
return OK;
}
uint32_t Thread_Load_Open_Covers(void)
@@ -270,10 +285,15 @@
//Machine Is Ready. Send Message, Start Timer To Close Lids, Wait For Operator Response
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
+ 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);
+ 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 a41ffb79f..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)
@@ -454,7 +454,7 @@ void ScrewTimerInterrupt(int ARG0)
TimerDisable(Screw_timerBase, TIMER_A);
}
ROM_IntMasterEnable();
- Rotations+=0.05;
+ Rotations+=0.03;
/*random++;
if (random >= 2)
random = -1;*/
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 69ac4b6ad..d7ce917c0 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -67,9 +67,11 @@ typedef enum
THREAD_LOAD_END
}THREAD_LOAD_STAGES_ENUM;
uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue);
+bool ThreadLoadingActive(void);
void ThreadLoadPollRequest(MessageContainer* requestContainer);
void ThreadLoadRequest(MessageContainer* requestContainer);
+
#endif
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 4131fbca5..a4208ad25 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:
@@ -711,7 +717,7 @@ void SetOriginMotorSpeed(float process_speed)
uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId)
{
//set the speed only before the first segment, speed is constant across all job segments and intersegments
- JobSegment* Segment = SegmentDetails;
+ //JobSegment* Segment = SegmentDetails;
float process_speed = dyeingspeed;
if (dyeingspeed == 0)
@@ -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();