aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-07-06 16:52:05 +0300
committerShlomo Hecht <shlomo@twine-s.com>2020-07-06 16:52:05 +0300
commita52e0e1b4f0b981af32427cb7b2044f5cedd9829 (patch)
tree7ac5ec2ac6ceb7d8f4621cc693822a56ffce855b /Software/Embedded_SW/Embedded/Modules/Thread
parentcfa09b21e9ea44b2276d261238b6c999bdebc4c3 (diff)
downloadTango-a52e0e1b4f0b981af32427cb7b2044f5cedd9829.tar.gz
Tango-a52e0e1b4f0b981af32427cb7b2044f5cedd9829.zip
Version 1.4.6.35 - Pack Mid alpha
============================ Arc head - activate arc heaters gradually stop FPGA Reinit after 20 trials Head cleaning - move actuators (with stub - 0xAD7) fix RML PID support head open prevent job - (with stub - 0xAD6) add stub to overrule cone missing - 0xAD8
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c13
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c170
6 files changed, 105 insertions, 92 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
index d1d23598f..3a7045a6e 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
@@ -76,7 +76,6 @@ extern int MotorSpeedSamplePointer[MAX_THREAD_MOTORS_NUM];
uint32_t InternalWinderConfigMessage(HardwareWinder* request);
uint32_t MotorsConfigMessage( HardwareConfiguration* HW_request);
uint32_t InternalWindingConfigMessage(JobSpool* request);
-uint32_t ThreadInitialTestStub(HardwareMotor * request);
uint32_t MotorPidRequestMessage(HardwarePidControl* request);
void SetKeepWindingCone(bool value);
void SetWinderBackToBaseTime(uint32_t value);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index 2b65ca806..f5bc45d85 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -204,6 +204,7 @@
strcpy(LoadErrorMsg,"Thread_Load_Reduce_Heat failed");
LoadStatus = ERROR;
TryAgain = true;
+ //ThreadLoadButton(LoadStages);
}
else
{
@@ -300,6 +301,7 @@
LoadStatus = ERROR;
ThreadLoadingReport();
TryAgain = true;
+ //ThreadLoadButton(LoadStages);
}
else
{
@@ -544,6 +546,7 @@
LoadStatus = ERROR;
ThreadLoadingReport();
TryAgain = true;
+ //ThreadLoadButton(LoadStages);
}
}
@@ -647,6 +650,7 @@
Report("Total Feeder load",__FILE__,__LINE__,dryerbufferCentimeters,RpMessage,TotalLoadedLen,0);
ThreadLoadingReport();
+ //ThreadLoadButton(LoadStages);
}
return OK;
}
@@ -857,6 +861,7 @@
LoadStatus = ERROR;
TryAgain = true;
ThreadLoadingReport();
+ //ThreadLoadButton(LoadStages);
}
return OK;
}
@@ -971,7 +976,7 @@
uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue)
{
REPORT_MSG(ReadValue,"ThreadLoadStateMachine");
- ThreadLoaded();
+ //ThreadLoaded();
ThreadLoadingReport();
if (LoadStages!=ReadValue)
@@ -1089,7 +1094,7 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue)
Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0);
ThreadLoadStateMachine(LoadStages);
}
- else
+ else if (SecondTry == true)
{
SecondTry = false;
Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 80ca05cb7..92b953db5 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -54,7 +54,7 @@ double ScrewRunningTime = 0;
uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone
bool SCREW_TimerActivated = false;
uint32_t ScrewControlId = 0xFF;
-
+bool IgnoreConeMissing = false;
static bool KeepWindingCone = false;
@@ -156,10 +156,13 @@ uint32_t Winder_Prepare(void *JobDetails)
REPORT_MSG(LIMIT, "No cone in winder");
if (Is_PP_Machine())
{
- JobEndReason = JOB_THREAD_BREAK;
- PrepareReady(Module_Winder,ModuleFail);
- AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true);
- return ERROR;
+ if (IgnoreConeMissing == false)
+ {
+ JobEndReason = JOB_THREAD_BREAK;
+ PrepareReady(Module_Winder,ModuleFail);
+ AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true);
+ return ERROR;
+ }
}
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 4081b53f2..4339c5312 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -24,6 +24,7 @@ typedef enum threadMotorsEnum
extern double TotalProcessedLength;
extern double PoolerTotalProcessedLength;
extern int SecondFeederCorrection;
+extern bool SkipOpenLids,IgnoreConeMissing;
void ThreadSetBreakSensorLimit(int limit);
@@ -37,7 +38,6 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId);
uint32_t ThreadSegmentState(void *SegmentDetails, int SegmentId);
uint32_t ThreadDistanceToSpoolState(void);
uint32_t ThreadEndState();
-uint32_t ThreadInitialTestStub();
bool Set_Thread_Rockers_Bypass (int value);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index 760a0726b..e1f887303 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -112,8 +112,6 @@ uint32_t MotorsConfigMessage(HardwareConfiguration * HWrequest)
{
IDS_Dispenser_Init(Motor_i-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1);
}
-// if (Motor_i == MOTOR_RDRIVING)
-// ThreadInitialTestStub(request);
}
return status;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index d762e507f..42a56ae8a 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -423,7 +423,67 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue)
}
return OK;
}
+uint16_t BreakSensorCounter = 0;
+uint16_t BreakSensorLatchCounter = 0;
+char TMessage[150];
+uint32_t checkBreakSensor(uint32_t index)
+{
+ if (BreakSensorenabled == true)
+ {
+ if (JobCounter > eOneSecond)
+ {
+ if (ReadBreakSensor()==ERROR)
+ {
+ BreakSensorCounter++;
+ BreakSensorLatchCounter++;
+ if (BreakSensorCounter>=BreakSensordebouncetimemilli)
+ {
+ //consider applying the debouce parameters later
+ usnprintf(TMessage, 60, "ReadBreakSensor Error");
+ //BreakSensordebouncetimemilli
+ JobEndReason = JOB_THREAD_BREAK;
+ ThreadControlActive = false;
+ SendJobProgress(0.0,0,false, TMessage);
+ SendSegmentFail();
+ //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true);
+ //EndState(CurrentJob,"ReadBreakSensor Error" );
+ ReportWithPackageFilter(ThreadFilter,"ReadBreakSensor Error",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
+ return ERROR;
+ } //passed limit
+ }//ReadBreakSensor()==ERROR
+ else //reset counter - we are looking for consequent calls
+ {
+ if (BreakSensorCounter)
+ {
+ ReportWithPackageFilter(ThreadFilter,"ReadBreakSensor Spike",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
+ }
+ BreakSensorCounter = 0;
+ }
+ if (CurrentControlledSpeed[index] < (OriginalMotorSpd_2PPS[index]/3))
+ {
+ BreakSensorCounter++;
+ BreakSensorLatchCounter++;
+ if (BreakSensorCounter>=BreakSensordebouncetimemilli)
+ {
+ //consider applying the debouce parameters later
+ usnprintf(TMessage, 60, "thread speed too low");
+ JobEndReason = JOB_THREAD_BREAK;
+ ThreadControlActive = false;
+ SendJobProgress(0.0,0,false, TMessage);
+ SendSegmentFail();
+ //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true);
+ //EndState(CurrentJob,"ReadBreakSensor Error" );
+ ReportWithPackageFilter(ThreadFilter,"thread speed too low Error",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
+ return ERROR;
+ }
+ }
+
+ }
+ }
+ return OK;
+
+}
int controlIndex = 0;
bool keepdata = true;
int32_t KeepReadValue = 0;
@@ -477,10 +537,7 @@ void testDancersControl()
}
#endif
int MotorFailedSample[MAX_THREAD_MOTORS_NUM] = {0,0,0,0,0};
-char TMessage[150];
//char time[150];
-uint16_t BreakSensorCounter = 0;
-uint16_t BreakSensorLatchCounter = 0;
bool FirstCalcInJob = true;
uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
@@ -510,6 +567,11 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
index = IfIndex&0xFF;
+ if (index == POOLER_MOTOR) //move break sensor handling up to ensure handling even if tiing control is > 1 msec
+ {
+ if (checkBreakSensor(index) == ERROR)
+ return OK;
+ }
if (MotorTiming[index]>1)
{
MotorTimer[index]++;
@@ -571,61 +633,6 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
avreageSampleValue += MotorSamples[index][i];
avreageSampleValue = avreageSampleValue / (int)MotorsControl[index].pvinputfilterfactormode;
- if (BreakSensorenabled == true)
- {
- if (index == POOLER_MOTOR)
- {
- if (JobCounter > eOneSecond)
- {
- if (ReadBreakSensor()==ERROR)
- {
- BreakSensorCounter++;
- BreakSensorLatchCounter++;
- if (BreakSensorCounter>=BreakSensordebouncetimemilli)
- {
- //consider applying the debouce parameters later
- usnprintf(TMessage, 60, "ReadBreakSensor Error");
- //BreakSensordebouncetimemilli
- JobEndReason = JOB_THREAD_BREAK;
- ThreadControlActive = false;
- SendJobProgress(0.0,0,false, TMessage);
- SendSegmentFail();
- //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true);
- //EndState(CurrentJob,"ReadBreakSensor Error" );
- ReportWithPackageFilter(ThreadFilter,"ReadBreakSensor Error",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
- return OK;
- } //passed limit
- }//ReadBreakSensor()==ERROR
- else //reset counter - we are looking for consequent calls
- {
- if (BreakSensorCounter)
- {
- ReportWithPackageFilter(ThreadFilter,"ReadBreakSensor Spike",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
- }
- BreakSensorCounter = 0;
- }
- if (CurrentControlledSpeed[index] < (OriginalMotorSpd_2PPS[index]/3))
- {
- BreakSensorCounter++;
- BreakSensorLatchCounter++;
- if (BreakSensorCounter>=BreakSensordebouncetimemilli)
- {
- //consider applying the debouce parameters later
- usnprintf(TMessage, 60, "thread speed too low");
- JobEndReason = JOB_THREAD_BREAK;
- ThreadControlActive = false;
- SendJobProgress(0.0,0,false, TMessage);
- SendSegmentFail();
- //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true);
- //EndState(CurrentJob,"ReadBreakSensor Error" );
- ReportWithPackageFilter(ThreadFilter,"thread speed too low Error",__FILE__,BreakSensorCounter,(int)index,RpError,(int)JobCounter,0);
- return OK;
- }
- }
-
- }
- }
- }
//Stop Execution if the dancer moves too much
if ((abs(avreageSampleValue)> DancerStopActivityLimit[index])&&(JobCounter > eOneSecond))
@@ -783,15 +790,6 @@ double ThreadGetMotorCalculatedError(int DancerId)
}
//********************************************************************************************************************
-uint32_t ThreadInitialTestStub(HardwareMotor * request)
-{
-
-
- //MotorsConfigMessage(request);
- ThreadPrepareState(request);
- ThreadPreSegmentState(request,0);
- return OK;
-}
uint32_t HandleJobThreadControlParameters(ThreadParameters* ThreadParams)
{
if (ThreadParams == NULL)
@@ -799,21 +797,21 @@ uint32_t HandleJobThreadControlParameters(ThreadParameters* ThreadParams)
return OK;
}
if(ThreadParams->feederp)
- MotorControlConfig[FEEDER_MOTOR].m_params.Kd = ThreadParams->feederp;
+ MotorControlConfig[FEEDER_MOTOR].m_params.Kp = ThreadParams->feederp;
if(ThreadParams->feederi)
MotorControlConfig[FEEDER_MOTOR].m_params.Ki = ThreadParams->feederi;
if(ThreadParams->feederd)
MotorControlConfig[FEEDER_MOTOR].m_params.Kd = ThreadParams->feederd;
if(ThreadParams->pullerp)
- MotorControlConfig[POOLER_MOTOR].m_params.Kd = ThreadParams->pullerp;
+ MotorControlConfig[POOLER_MOTOR].m_params.Kp = ThreadParams->pullerp;
if(ThreadParams->pulleri)
MotorControlConfig[POOLER_MOTOR].m_params.Ki = ThreadParams->pulleri;
if(ThreadParams->pullerd)
MotorControlConfig[POOLER_MOTOR].m_params.Kd = ThreadParams->pullerd;
if(ThreadParams->winderp)
- MotorControlConfig[WINDER_MOTOR].m_params.Kd = ThreadParams->winderp;
+ MotorControlConfig[WINDER_MOTOR].m_params.Kp = ThreadParams->winderp;
if(ThreadParams->winderi)
MotorControlConfig[WINDER_MOTOR].m_params.Ki = ThreadParams->winderi;
if(ThreadParams->winderd)
@@ -951,7 +949,8 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
return status;
}
//********************************************************************************************************************
- uint32_t ThreadPrepareState(void *JobDetails)
+bool SkipOpenLids = true;
+uint32_t ThreadPrepareState(void *JobDetails)
{
int Motor_i,i, HW_Motor_Id, Pid_Id;
JobTicket* JobTicket = JobDetails;
@@ -1016,22 +1015,30 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
//return ERROR;
}*/
- if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) == LIMIT)&&(JoggingJobActive == false))
+// if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) == LIMIT)&&(JoggingJobActive == false))
+ if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT)&&(JoggingJobActive == false))
{
if(Head_Type != HEAD_TYPE_STAPLE_SPUN)
{
ReportWithPackageFilter(ThreadFilter,"Dyeing head is wide open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpError,LIMIT,0);
- JobEndReason = JOB_LIDS_OPEN;
- PrepareReady(Module_Thread,ModuleFail);
- return ERROR;
+ if (SkipOpenLids == false)
+ {
+ JobEndReason = JOB_LIDS_OPEN;
+ PrepareReady(Module_Thread,ModuleFail);
+ return ERROR;
+ }
}
}
- if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) == LIMIT)&&(JoggingJobActive == false))
+// if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) == LIMIT)&&(JoggingJobActive == false))
+ if ((FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) != LIMIT)&&(JoggingJobActive == false))
{
ReportWithPackageFilter(ThreadFilter,"Dryer lid is wide open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpError,LIMIT,0);
- JobEndReason = JOB_LIDS_OPEN;
- PrepareReady(Module_Thread,ModuleFail);
- return ERROR;
+ if (SkipOpenLids == false)
+ {
+ JobEndReason = JOB_LIDS_OPEN;
+ PrepareReady(Module_Thread,ModuleFail);
+ return ERROR;
+ }
}
//start thread control for all motors
@@ -1057,6 +1064,8 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
MotorControlConfig[Motor_i].m_preError = 0;
MotorControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage
+ HandleJobThreadControlParameters(JobTicket->threadparameters); //OVERRIDES CONFIGURATION PARAMETERS!!!
+
temp_dt = MotorControlConfig[Motor_i].m_params.dt/0.001;
MotorTiming[Motor_i] = (int)temp_dt;
if (MotorTiming[Motor_i])
@@ -1068,7 +1077,7 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
for (i = 0;i < (int)MotorsControl[Motor_i].pvinputfilterfactormode; i++)
{
//if (Motor_i == DRYER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
- MotorSamples[Motor_i][i] = Control_Read_Dancer_Position(ThreadMotorIdToDancerId[Motor_i],0); //reset the samples value for control beginning
+ MotorSamples[Motor_i][i] = 0;
// else if ((Motor_i == POOLER_MOTOR)||(Motor_i == FEEDER_MOTOR))
// MotorSamples[Motor_i][i] = DancersCfg[ThreadMotorIdToDancerId[Motor_i]].zeropoint;
//MotorSpeedSamples[Motor_i][i] = 0;
@@ -1148,7 +1157,6 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
if (Motor_i == ThreadMotorIdToMotorId[DRYER_MOTOR]) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
continue;
}
- HandleJobThreadControlParameters(JobTicket->threadparameters); //OVERRIDES CONFIGURATION PARAMETERS!!!
#ifdef TEST_PID_THREAD
testDancersControl();