aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-12-17 14:39:26 +0200
committerAvi Levkovich <avi@twine-s.com>2020-12-17 14:39:26 +0200
commitf0f46e7e560cf5e9999e5ba9904634f01176f27e (patch)
tree961affaea885d7306faca197a72c20f4811d7b8c /Software/Embedded_SW/Embedded/Modules/Thread
parenta84ca31290b18ef2a9ec4c197d86573bb13adb03 (diff)
parentd9ee0b8e11f15c2b3bae068767516bc84a5ca4ed (diff)
downloadTango-f0f46e7e560cf5e9999e5ba9904634f01176f27e.tar.gz
Tango-f0f46e7e560cf5e9999e5ba9904634f01176f27e.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c30
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c20
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c12
4 files changed, 51 insertions, 15 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index f2ca4e8d7..ffbb504db 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -247,7 +247,8 @@
}
uint32_t Thread_Load_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_t BusyFlag)
{
- uint32_t angle, temp = Read_Dryer_ENC_Position();
+ uint32_t temp = Read_Dryer_ENC_Position();
+ int angle;
ReportWithPackageFilter(DiagnosticsFilter,"Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,(int)numberOfCycles,(int)DrierPrevLocation,RpMessage,temp,0);
@@ -258,12 +259,14 @@
{
CallbackCounter--;
}
- if ((abs(angle)>14000 )&&(BusyFlag == NOTBUSY)) // OK - take another round
+ if (abs(angle)<10 ) // OK
{
Report("Thread_Load_Set_Load_Arm_To_Stopper time",__FILE__,msec_millisecondCounter - UnloadingStart,msec_millisecondCounter,RpMessage,UnloadingStart,0);
Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
NumberOfDrierLoaderCycles=0;
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,0);
+
//storeLoadArmParameters();
LoadStages++;
@@ -272,7 +275,7 @@
else
{
load.color = fastBILNK;
- usnprintf(LoadErrorMsg, 100, "Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM]);
+ usnprintf(LoadErrorMsg, 100, "^Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM]);
Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0);
LoadStatus = ERROR;
@@ -317,7 +320,7 @@
{
TimeoutsCounter = 0;
load.color = fastBILNK;
- usnprintf(LoadErrorMsg, 100, "Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]);
+ usnprintf(LoadErrorMsg, 100, "/Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]);
Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0);
LoadStatus = ERROR;
@@ -687,7 +690,7 @@
TimeoutsCounter = 0;
CallbackCounter = 0;
load.color = fastBILNK;
- usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]);
+ usnprintf(LoadErrorMsg, 100, "$Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]);
Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0);
LoadStatus = ERROR;
MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200);
@@ -729,6 +732,13 @@
{
LoadArmRounds -= CurrentlyLoaded;
}
+ if (LoadArmRounds == CurrentlyLoaded)
+ {
+ Report("Thread_Load_Dryer_Loading no need for cycles",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
+ LoadStages++;
+ ThreadLoadStateMachine(LoadStages);
+ return OK;
+ }
ThreadMotorIdToMotorId[FEEDER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_RDRIVING ;
ThreadMotorIdToMotorId[DRYER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING;
@@ -932,7 +942,7 @@
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz);
load.color = fastBILNK;
- usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]);
+ usnprintf(LoadErrorMsg, 100, "&Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]);
Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0);
Report("Dryer unloading timeout(1) or no movement",__FILE__,temp,DrierPrevLocation,RpWarning,ReadValue,0);
LoadStatus = ERROR;
@@ -1489,6 +1499,8 @@ uint32_t ThreadLoadingRestartReport(void) //sending after a failure in the final
if (ThreadLoadingToken[0] == 0)
return OK;
+ if (LoadStages == THREAD_LOAD_INIT)
+ return OK;
ThreadLoadingRestartFlag = true;
response.has_state = true;
@@ -1520,6 +1532,12 @@ uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer)
{
responseContainer = createContainer(MESSAGE_TYPE__TryThreadLoadingResponse, requestContainer->token, true, &Cresponse, &try_thread_loading_response__pack, &try_thread_loading_response__get_packed_size);
responseContainer.continuous = false;
+ if (JobIsActive()||(MachineReadyForHeating == false)||(FPGABurningActive==true))
+ {
+ responseContainer.has_error = true;
+ responseContainer.error = ERROR_CODE__GENERAL_ERROR;
+ responseContainer.errormessage = "The machine is not ready for loading";
+ }
uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
size_t container_size = message_container__pack(&responseContainer, container_buffer);
my_free(responseContainer.data.data);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index a75241671..03bc9d24d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -50,6 +50,7 @@ bool WinderMotorSpeedRollOver = false;
int StartWinderCalculation = 0;
#define DEFAULT_SCREW_SPEED 1200
double ScrewSpeed = DEFAULT_SCREW_SPEED;
+double RetreatTime = 0;
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;
@@ -635,6 +636,7 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
temp *= ScrewNumberOfSteps;
temp /= ScrewSpeed;
ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed;
+ RetreatTime = ScrewNumberOfSteps*1000/ScrewSpeed;
REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps");
REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime");
//MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
@@ -673,11 +675,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
//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);
//MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,RetreatTime*2);
#ifdef FOUR_WINDERS
- MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,2000);
- MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,2000);
- MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,2000);
+ MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,RetreatTime*2);
+ MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,RetreatTime*2);
+ MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,RetreatTime*2);
#endif
return OK;
@@ -685,10 +687,14 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
uint32_t WinderDistanceToSpoolState(void )
{
double DTS_Time = (dryerbufferCentimeters/dyeingspeed)*1000;//distance to spool time in milliseconds
- REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState");
+ double WinderBackTimeBySpeed = WinderBackToBaseTime;
+ WinderBackTimeBySpeed *= 50;
+ WinderBackTimeBySpeed /= dyeingspeed;
+ Report("WinderDistanceToSpoolState start", __FILE__,DTS_Time,RetreatTime, RpMessage, (int)WinderBackTimeBySpeed, 0);
+ //REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState");
- ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackToBaseTime,TemplateDataReadCBFunction,0,0,0);
- Report("ScrewDTSCallback start", __FILE__,DTS_Time,msec_millisecondCounter, RpMessage, WinderBackToBaseTime, 0);
+ ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-RetreatTime,TemplateDataReadCBFunction,0,0,0);
+ Report("ScrewDTSCallback start", __FILE__,DTS_Time,msec_millisecondCounter, RpMessage, (int)WinderBackTimeBySpeed, 0);
return OK;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 11a92ab63..4ce48a639 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -9,6 +9,10 @@
#define WINDER_DANCER HARDWARE_DANCER_TYPE__LeftDancer
#define POOLER_DANCER HARDWARE_DANCER_TYPE__MiddleDancer
#define FEEDER_DANCER HARDWARE_DANCER_TYPE__RightDancer
+#define WINDER_2_DANCER HARDWARE_DANCER_TYPE__FourthDancer
+#define WINDER_3_DANCER HARDWARE_DANCER_TYPE__ThirdDancer
+#define WINDER_4_DANCER HARDWARE_DANCER_TYPE__RightDancer
+
#define NUM_OF_DANCERS NUM_OF_ROTENC
//} DANCER_ENUM;
typedef enum threadMotorsEnum
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index ba505493d..4ced1e5fe 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -629,6 +629,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//pooler dancer is right sided: data is opposite
TranslatedReadValue = (-1*TranslatedReadValue);
}
+#ifdef BTSR_ROTATED_WINDER_TFU
+ if (index == WINDER_MOTOR)
+ TranslatedReadValue = (-1*TranslatedReadValue);
+#endif
#ifdef FOUR_WINDERS
if (index == WINDER_MOTOR)
{
@@ -653,7 +657,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
TranslatedReadValue = (-1*TranslatedReadValue);
}*/
#endif
- if (index == POOLER_MOTOR)
+ if (index == WINDER_MOTOR)
{
//pooler dancer is right sided: data is opposite
JobCounter++;
@@ -710,6 +714,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
NormalizedError = (-1*NormalizedError);
}
+/*#ifdef BTSR_ROTATED_WINDER_TFU
+ if (index == WINDER_MOTOR)
+ TranslatedReadValue = (-1*TranslatedReadValue);
+#endif*/
MotorControlConfig[index].m_mesuredParam = NormalizedError;
DancerError[DancerId] = NormalizedError;
@@ -1061,7 +1069,7 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension)
return status;
}
//********************************************************************************************************************
-bool SkipOpenLids = true;
+bool SkipOpenLids = false;
uint32_t ThreadPrepareState(void *JobDetails)
{
int Motor_i,i, HW_Motor_Id, Pid_Id;