aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-07-27 15:39:26 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-07-27 15:39:26 +0300
commit5e59906df60d82248da4ae47677ed59d56fb605a (patch)
tree8585548197bfada234b7ded17028aba9563c32de /Software/Embedded_SW/Embedded/Modules/Thread
parent3210901f7aa313cfe1eb2c303b539d6e7d1f2324 (diff)
parentc947fa4b4999b1368ee500c3349ef6e8fce3f0b5 (diff)
downloadTango-5e59906df60d82248da4ae47677ed59d56fb605a.tar.gz
Tango-5e59906df60d82248da4ae47677ed59d56fb605a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h3
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c86
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c2
3 files changed, 70 insertions, 21 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
index 3a7045a6e..c912bca21 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
@@ -85,5 +85,8 @@ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Rea
void SetOriginMotorSpeed(float process_speed);
+uint32_t ThreadPrepare_Tension (int DancerId, double tension);
+
+
#endif //MODULES_THREAD_THREAD_H_
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index f5bc45d85..01c70d42f 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -116,6 +116,7 @@
bool InitCalled = false;
uint32_t LoadArmRounds;
+ int CurrentlyLoaded = 0;
uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM LoadStages);
uint32_t ThreadLoadControlCBFunction(uint32_t index, uint32_t ReadValue);
uint32_t ThreadLoadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue);
@@ -210,7 +211,7 @@
{
if(Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)
{
- WHS_Set_SetPoint_Q_value(headairflow/2);
+ WHS_Set_SetPoint_Q_value(headairflow*2/3);
}
else
{
@@ -226,6 +227,20 @@
}
return OK;
}
+ uint32_t Thread_Load_Set_Load_Arm_To_Stopper_OnError_Callback(uint32_t deviceID, uint32_t BusyFlag)
+ {
+
+ Report("Thread_Load_Set_Load_Arm_To_Stopper_OnError_Callback time",__FILE__,msec_millisecondCounter - UnloadingStart,msec_millisecondCounter,RpMessage,UnloadingStart,0);
+
+ Report("Thread_Load_Set_Load_Arm_To_Stopper_OnError_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
+ NumberOfDrierLoaderCycles=0;
+ //storeLoadArmParameters();
+ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop);
+ SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); //set this point as the spool home
+ MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
+
+ return OK;
+ }
uint32_t Thread_Load_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_t BusyFlag)
{
@@ -448,23 +463,35 @@
uint32_t Thread_Load_Close_Dancers(void)
//Send Dancer Motors To Preset Location, Check That The Dancers Are On The Thread
{
+ uint32_t current = 0;
REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Close_Dancers");
CallbackCounter++;
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,10000);
- CallbackCounter++;
- MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1, 500);
// 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,25000);
- MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, ((int)windertension*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].microstep), Thread_Load_HomingCallback,20000);
- status |= MCU_E2PromProgram(EEPROM_WINDER_TENSION_POSITION,(int)windertension);
- if (Is_PP_Machine() == true) //PP machine - new LTFU
+ status |= MCU_E2PromRead(EEPROM_WINDER_TENSION_POSITION,&current);
+
+ ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__LeftDancer, windertension);
+/* if (current!=windertension)
{
CallbackCounter++;
- MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2, 500);
- MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].directionthreadwize, ((int)pullertension*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].microstep), Thread_Load_HomingCallback,20000);
- status |= MCU_E2PromProgram(EEPROM_PULLER_TENSION_POSITION,(int)pullertension);
- }
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1, 500);
+ MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, ((int)windertension*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].microstep), Thread_Load_HomingCallback,20000);
+ status |= MCU_E2PromProgram(EEPROM_WINDER_TENSION_POSITION,(int)windertension);
+ }*/
+ if (Is_PP_Machine() == true) //PP machine - new LTFU
+ {
+ ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__MiddleDancer, pullertension);
+ /*status |= MCU_E2PromRead(EEPROM_PULLER_TENSION_POSITION,&current);
+ if (current!=pullertension)
+ {
+ CallbackCounter++;
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2, 500);
+ MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_LDANCER2, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].directionthreadwize, ((int)pullertension*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER2].microstep), Thread_Load_HomingCallback,20000);
+ status |= MCU_E2PromProgram(EEPROM_PULLER_TENSION_POSITION,(int)pullertension);
+ }*/
+ }
return OK;
}
uint32_t Thread_Load_Close_Lids(void)
@@ -494,7 +521,8 @@
{
Report("Thread_Load_Close_actuators",__FILE__,__LINE__,LOW,RpMessage,true,0);
Trigger_Head_Actuators_Control(ACTOT, LOW,false);
- Trigger_Head_Actuators_Control(ACTIN, LOW,false);
+ //Trigger_Head_Actuators_Control(ACTIN, LOW,false);
+ HeadCard_Actuators_Relocate();
}
return OK;
}
@@ -502,6 +530,7 @@
{
REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Resume_Heating");
ActivateHeadMagnet();
+ HeadCard_Actuators_Relocate();
if (HandleProcessParameters(&ProcessParametersRecover,false)!= OK)
{
@@ -600,7 +629,7 @@
{
numberOfCycles++;
- Report("Thread_Load_Dryer_Loading_Callback",__FILE__,(int)TotalLoadedLen,(int)DrierPrevLocation,RpMessage,ReadValue,0);
+ Report("Thread_Load_Dryer_Loading_Callback",__FILE__,(int)TotalLoadedLen,(int)DrierPrevLocation,RpMessage,numberOfCycles,0);
if ((fabs (TotalLoadedLen -DrierPrevLocation)>50 )&&(ReadValue == NOTBUSY))
{
@@ -611,6 +640,7 @@
{
return OK;
}
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles+CurrentlyLoaded);
if (numberOfCycles<LoadArmRounds)
{
MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
@@ -618,8 +648,7 @@
}
else
{
- MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,30000);
- MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles);
+ MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,30000,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize);
Report("Store Number of cycles in drier",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmRounds,0);
}
}
@@ -628,7 +657,7 @@
TryAgain = true;
SecondTry = false;
Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmRounds,0);
- MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles);
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles+CurrentlyLoaded);
TimeoutsCounter = 0;
CallbackCounter = 0;
load.color = fastBILNK;
@@ -659,7 +688,6 @@
{
REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Dryer_Loading");
- int CurrentlyLoaded = 0;
if (dryerbufferlength)
LoadArmRounds = (int)dryerbufferlength;
if (LoadArmRounds <= 2)
@@ -797,12 +825,14 @@
}
Screw_Dir = 1-Screw_Dir;
// movement of the screw while unloading the thread from the dryer to the spool
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,13000);
+ AlarmHandlingSetAlarm (EVENT_TYPE__SCREW_MOTOR_LIMIT_TIMEOUT,OFF); //handle alarm detection and operation
+ status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,20000);
return OK;
}
uint32_t Thread_Load_Dryer_UnLoading_Callback(uint32_t MotorId, uint32_t ReadValue)
{
+ bool direction;
numberOfCycles++;
uint32_t temp = Read_Dryer_ENC_Position();
Report("Thread_Load_Dryer_UnLoading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0);
@@ -818,12 +848,13 @@
Report("Thread_Load_Dryer_UnLoading cycles",__FILE__,numberOfCycles,LoadArmRounds,RpMessage,0,0);
if (numberOfCycles<LoadArmRounds)
{
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmRounds-numberOfCycles);
MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
numberOfSteps, Thread_Load_Dryer_UnLoading_Callback, 10000);
}
else //done enough cycles, go to the center point
{
- MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Set_Load_Arm_To_Stopper_Callback,30000);
+ MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Set_Load_Arm_To_Stopper_Callback,30000,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize);
MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,0);
Report("Store Number of cycles in drier",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmRounds,0);
}
@@ -831,7 +862,23 @@
else //timeout or no movement
{
Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmRounds,0);
- MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmRounds-numberOfCycles);
+ if (SecondTry == true)
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,0);
+ else
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmRounds-numberOfCycles);
+ if (abs(temp -DrierPrevLocation)<200)
+ {
+ if (temp<DrierPrevLocation)
+ direction = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize;
+ else
+ direction = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize;
+ MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Set_Load_Arm_To_Stopper_OnError_Callback,3000,direction);
+
+ }
+ else
+ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop);
+
+
TimeoutsCounter = 0;
CallbackCounter = 0;
/*if(PullerControlId != 0xFF)
@@ -853,7 +900,6 @@
MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);*/
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz);
- MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop);
load.color = fastBILNK;
usnprintf(LoadErrorMsg, 100, "Stage %s - Drier load arm timeout",LoadStagesStr[LoadStages]);
Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index e1f887303..39ff91558 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -145,7 +145,7 @@ uint32_t MotorPidRequestMessage(HardwarePidControl* request)
NormalizedErrorCoEfficient[Motor_i] = NormalizedErrorCoEfficient[Motor_i] / temp;
// uint32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES];
temp = 1<<(DancersCfg[ThreadMotorIdToDancerId[Motor_i]].resolutionbits);
- temp = (temp*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].maximalmovementmm*3/2);
+ temp = (temp*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].maximalmovementmm);//*3/2);
DancerStopActivityLimit[Motor_i] = temp/(2*PI*DancersCfg[ThreadMotorIdToDancerId[Motor_i]].armlength);
return OK;
}