aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-08-01 17:23:44 +0300
committerAvi Levkovich <avi@twine-s.com>2019-08-01 17:23:44 +0300
commit06c6cfec8af9c3b3f930da7fe4394ee885d24352 (patch)
tree2667eb76e8fb204db99608e91b49bf73d8b0ecd3 /Software/Embedded_SW/Embedded/Modules/Thread
parent42471da0b2a19c964fc2c3df39cc2e8a6aaf5e2e (diff)
parent18c4c73f8b654dca09e1333d1f6a35e4cbdc9b17 (diff)
downloadTango-06c6cfec8af9c3b3f930da7fe4394ee885d24352.tar.gz
Tango-06c6cfec8af9c3b3f930da7fe4394ee885d24352.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/ThreadLoad.c156
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c10
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h34
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c58
5 files changed, 171 insertions, 89 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index 837221274..5984618d9 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -48,15 +48,21 @@
8 THREAD_LOAD_CLOSE_ROCKERS,
9 THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD
10 THREAD_LOAD_CLOSE_LIDS,
- 11 THREAD_LOAD_RESUME_HEATING,
- 12 THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT, //JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION
- 13 THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40
+ 11 THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT, //JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION
+ 12 THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40
//KEEP NOTATION HOW MANY ROTATIONS IN THE DRYER
+ 13 THREAD_LOAD_RESUME_HEATING,
14 THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING
15 THREAD_LOAD_END
}THREAD_LOAD_STAGES_ENUM;*/
THREAD_LOAD_STAGES_ENUM LoadStages = THREAD_LOAD_INIT;
ProcessParameters ProcessParametersClear,ProcessParametersRecover;
+
+ int32_t keepmicrostep;
+ int32_t keepkvalrun;
+ uint8_t CallbackCounter = 0;
+ uint8_t TimeoutsCounter = 0;
+
uint8_t NumberOfDrierLoaderCycles = 0;
uint32_t status = OK;
uint32_t ControlId = 0xFF,PullerControlId = 0xFF,WinderControlId = 0xFF;
@@ -93,7 +99,7 @@
FRESULT Fresult = FR_OK;
REPORT_MSG(LoadStages, "Thread Load State Machine step");
- LoadArmInfo.LoadArmBackLash = 10;
+ LoadArmInfo.LoadArmBackLash = 5;
LoadArmInfo.LoadArmRounds = 0xFF;
Fresult = f_mkdir(SW_INFO_DIR);
if ((Fresult == FR_OK)||(Fresult == FR_EXIST))
@@ -133,6 +139,7 @@
ProcessParametersClear.headzone5temp = 0;
ProcessParametersClear.headzone6temp = 0;
ProcessParametersClear.dyeingspeed = 40;
+ ProcessParametersClear.dryerbufferlength = ProcessParametersKeep.dryerbufferlength;
if (HandleProcessParameters(&ProcessParametersClear)!= OK)
{
LOG_ERROR (LoadStages, "Thread_Load_Init failed");
@@ -163,7 +170,7 @@
}
else*/
{
- Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
//storeLoadArmParameters();
SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); //set this point as the spool home
LoadStages++;
@@ -173,6 +180,7 @@
}
uint32_t Thread_Load_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_t BusyFlag)
{
+
if(PullerControlId != 0xFF)
{
MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz);
@@ -192,7 +200,8 @@
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz);
// Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
- Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ CallbackCounter = 0;
+ Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
NumberOfDrierLoaderCycles=0;
//storeLoadArmParameters();
LoadStages++;
@@ -224,13 +233,21 @@
//Use Notation How Many Rotations In The Drier, Or Check Against Stopper. Move Slowly
return OK;
}
- uint8_t CallbackCounter = 0;
- uint8_t TimeoutsCounter = 0;
+ uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t BusyFlag)
+ {
+ CallbackCounter--;
+ Report("Thread_Load_Jog_Feeder_To_Middle_Point_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
+ //storeLoadArmParameters();
+ LoadStages++;
+ ThreadLoadStateMachine(LoadStages);
+
+ return OK;
+ }
uint32_t Thread_Load_HomingCallback(uint32_t MotorId, uint32_t ReadValue)
{
- Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
- REPORT_MSG(MotorId, "Thread_Load_HomingCallback Motor Id");
+ Report("Thread_Load_HomingCallback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
+// REPORT_MSG(MotorId, "Thread_Load_HomingCallback Motor Id");
if (CallbackCounter)
{
CallbackCounter--;
@@ -249,12 +266,12 @@
else
{
LoadStages++;
- if (LoadStages == THREAD_LOAD_LIFT_ROCKERS)
+ if (LoadStages == THREAD_LOAD_CLOSE_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);
+ MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepmicrostep);
+ MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepmicrostep);
+ MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepkvalrun);
+ MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepkvalrun);
}
if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this stage we should wait for user call
{
@@ -303,16 +320,18 @@
uint32_t Thread_Load_Lift_Rockers(void)
//Machine Is Ready. Send Message, Start Timer To Close Lids, Wait For Operator Response
{
+ keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep;
+ keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun;
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);
+ MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8);
+ MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 8);
+ MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 70);
+ MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 70);
Task_sleep(10);
CallbackCounter++;
- 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);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 400, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,20000);
CallbackCounter++;
- 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);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 400, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,20000);
return OK;
}
@@ -334,9 +353,9 @@
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,12000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,20000);
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,12000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LLOADING], Thread_Load_HomingCallback,20000);
return OK;
}
@@ -388,13 +407,20 @@
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
CallbackCounter++;
- MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 200, FEEDER_DANCER ,true, Thread_Load_HomingCallback,10000);
+ MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 100, FEEDER_DANCER ,true, Thread_Load_Jog_Feeder_To_Middle_Point_Callback,2000);
return OK;
}
uint32_t Thread_Load_Dryer_MovetoEncoderPosition_Callback(uint32_t MotorId, uint32_t ReadValue)
{
+ Report("Thread_Load_Dryer_MovetoEncoderPosition_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200);
+ if(ControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(ControlId, ThreadLoadControlCBFunction );
+ ControlId = 0xFF;
+ }
if (CallbackCounter)
{
CallbackCounter--;
@@ -410,17 +436,18 @@
else
LOG_ERROR(MotorId, "Thread_Load_HomingCallback Callback is already 0");
+ return OK;
}
uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue)
{
- Report("Thread Load State Machine Callback.",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
- if(ControlId != 0xFF)
+ Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,__LINE__,MotorId,RpMessage,CallbackCounter,0);
+ /*if(ControlId != 0xFF)
{
MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
RemoveControlCallback(ControlId, ThreadLoadControlCBFunction );
ControlId = 0xFF;
- }
- //REPORT_MSG(MotorId, "Thread_Load_Dryer_Loading_Callback Motor Id");
+ }*/
MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,10000);
return OK;
}
@@ -428,14 +455,17 @@
uint32_t Thread_Load_Dryer_Loading(void)
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
- LoadArmInfo.LoadArmRounds = 20;
- uint32_t numberOfSteps = 0;
+ LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
+ //LoadArmInfo.LoadArmRounds = 5;
+ float numberOfSteps = 0;
//Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40
SetOriginMotorSpeed(19);
// OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000;
// CurrentControlledSpeed[FEEDER_MOTOR] = 1000;
numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius;
+ numberOfSteps -= 100;
+ //numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*3.3*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius;
Report("Thread Load State Machine step.",__FILE__,LoadStages,numberOfSteps,RpMessage,(int)(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius),0);
MotorControlConfig[FEEDER_MOTOR].m_params.MAX = 1;
MotorControlConfig[FEEDER_MOTOR].m_params.MIN = MotorsControl[FEEDER_MOTOR].outputproportionalpowerlimit*-1;
@@ -459,14 +489,16 @@
MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4);
ControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR);
+ Report("AddControlCallback feeder",__FILE__,__LINE__,ControlId,RpMessage,IfTypeThread*0x100+FEEDER_MOTOR,0);
CallbackCounter++;
+ Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000);
//Keep Notation How Many Rotations In The Dryer
//LoadArmInfo.LoadArmBackLash = 0;
- LoadArmInfo.LoadArmRounds = 0xFF;
- FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath);
+ LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
+ //FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER);
return OK;
}
uint32_t Thread_Load_Jog_ThreadStop(uint32_t index, uint32_t ReadValue)
@@ -490,6 +522,25 @@
uint32_t Thread_Load_End(void)
{
REPORT_MSG(LoadStages,"Loading Ended");
+ if(ControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(ControlId, ThreadLoadControlCBFunction );
+ ControlId = 0xFF;
+ }
+ if(PullerControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(PullerControlId, ThreadLoadControlCBFunction );
+ PullerControlId = 0xFF;
+ }
+ if(WinderControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[WINDER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(WinderControlId, ThreadLoadControlCBFunction );
+ WinderControlId = 0xFF;
+ }
+ LoadStages = THREAD_LOAD_INIT;
return OK;
}
uint32_t Thread_Load_Dryer_UnLoading(void)
@@ -507,7 +558,7 @@
MotorControlConfig[POOLER_MOTOR].m_params.MIN = MotorsControl[POOLER_MOTOR].outputproportionalpowerlimit*-1;
MotorControlConfig[POOLER_MOTOR].m_params.Kd = MotorsControl[POOLER_MOTOR].derivativetime;
MotorControlConfig[POOLER_MOTOR].m_params.Kp = MotorsControl[POOLER_MOTOR].proportionalgain;
- MotorControlConfig[POOLER_MOTOR].m_params.Ki = MotorsControl[POOLER_MOTOR].integraltime;
+ MotorControlConfig[POOLER_MOTOR].m_params.Ki = 0;//MotorsControl[POOLER_MOTOR].integraltime;
MotorControlConfig[POOLER_MOTOR].m_params.IntegralErrorMultiplier = MotorsControl[POOLER_MOTOR].setpointramprateorsoftstartramp;
MotorControlConfig[POOLER_MOTOR].m_params.ProportionalErrorMultiplier = MotorsControl[POOLER_MOTOR].outputonoffhysteresisvalue;
MotorControlConfig[POOLER_MOTOR].m_params.epsilon = MotorsControl[POOLER_MOTOR].epsilon;
@@ -523,12 +574,13 @@
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDRIVING].directionthreadwize);
PullerControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR);
+ Report("AddControlCallback Puller",__FILE__,__LINE__,PullerControlId,RpMessage,IfTypeThread*0x100+POOLER_MOTOR,0);
////////////////////////
MotorControlConfig[WINDER_MOTOR].m_params.MAX = 1;
MotorControlConfig[WINDER_MOTOR].m_params.MIN = MotorsControl[WINDER_MOTOR].outputproportionalpowerlimit*-1;
MotorControlConfig[WINDER_MOTOR].m_params.Kd = MotorsControl[WINDER_MOTOR].derivativetime;
MotorControlConfig[WINDER_MOTOR].m_params.Kp = MotorsControl[WINDER_MOTOR].proportionalgain;
- MotorControlConfig[WINDER_MOTOR].m_params.Ki = MotorsControl[WINDER_MOTOR].integraltime;
+ MotorControlConfig[WINDER_MOTOR].m_params.Ki = 0;//MotorsControl[WINDER_MOTOR].integraltime;
MotorControlConfig[WINDER_MOTOR].m_params.IntegralErrorMultiplier = MotorsControl[WINDER_MOTOR].setpointramprateorsoftstartramp;
MotorControlConfig[WINDER_MOTOR].m_params.ProportionalErrorMultiplier = MotorsControl[WINDER_MOTOR].outputonoffhysteresisvalue;
MotorControlConfig[WINDER_MOTOR].m_params.epsilon = MotorsControl[WINDER_MOTOR].epsilon;
@@ -544,6 +596,7 @@
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_WINDER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].directionthreadwize);
WinderControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+WINDER_MOTOR),WINDER_DANCER,WINDER_MOTOR);
+ Report("AddControlCallback Winder",__FILE__,__LINE__,WinderControlId,RpMessage,IfTypeThread*0x100+WINDER_MOTOR,0);
////////////////////////
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING].directionthreadwize);
@@ -553,19 +606,23 @@
//MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
// numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000);
Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ LoadArmInfo.LoadArmBackLash = 5;
+
status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize),
MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000);
//Keep Notation How Many Rotations In The Dryer
//LoadArmInfo.LoadArmBackLash = 0;
- LoadArmInfo.LoadArmRounds = 0xFF;
- FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath);
+ LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
+ FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER);
return OK;
}
uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue)
{
REPORT_MSG(ReadValue,"ThreadLoadStateMachine");
+ if (LoadStages!=ReadValue)
+ LoadStages = ReadValue;
switch (ReadValue)
{
case THREAD_LOAD_INIT:
@@ -613,10 +670,6 @@
//LoadStages++;
Thread_Load_Close_Lids();
break;
- case THREAD_LOAD_RESUME_HEATING:
- //LoadStages++;
- Thread_Load_Resume_Heating();
- break;
case THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT://JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION
//LoadStages++;
Thread_Load_Jog_Feeder_To_Middle_Point();
@@ -626,6 +679,10 @@
//LoadStages++;
Thread_Load_Dryer_Loading();
break;
+ case THREAD_LOAD_RESUME_HEATING:
+ //LoadStages++;
+ Thread_Load_Resume_Heating();
+ break;
case THREAD_LOAD_JOG_THREAD: //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING
//LoadStages++;
Thread_Load_Jog_Thread();
@@ -640,6 +697,20 @@
}
return OK;
}
+uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue)
+{
+ Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0);
+ if (LoadStages > ReadValue)
+ {
+ ThreadLoadStateMachine(LoadStages+1);
+ }
+ else
+ {
+ ThreadLoadStateMachine(ReadValue);
+ }
+ return OK;
+}
+uint32_t LoadCounter = 0;
uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
@@ -699,6 +770,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
}
+/* LoadCounter++;
+ if ((LoadCounter % 5001) == 0)
+ {
+ Report("MotorSpeedUpdated",__FILE__,index,abs(TranslatedReadValue),RpWarning,(int)CurrentControlledSpeed[index],0);
+ }*/
return OK;
}
void ThreadLoadRequest(MessageContainer* requestContainer)
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 510168ab8..7e1312464 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -321,7 +321,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
ScrewNumberOfSteps--;
WindingConeLocation--;
- ReportWithPackageFilter(ThreadFilter,"Head Backing",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
+ // ReportWithPackageFilter(ThreadFilter,"Head Backing",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
}
}
else //next time going back
@@ -329,7 +329,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.SpoolBottomBackingRate == 0)
{
ScrewNumberOfSteps++;
- Report("Bottom Backing ",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
+ // Report("Bottom Backing ",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
}
}
/* if (WinderMotorSpeedRollOver)
@@ -364,11 +364,11 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed;
//ROM_IntMasterEnable();
//usnprintf(TempScrewStr, 100, "Winder: Horizon,Rotation, PPR, RPP{ %d, %d ,%d, %d} ",(int)screw_horizontal_speed,(int)RotationsPerSecond,(int)InternalWinderCfg.NumberOfRotationPerPassage,(int)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround);
- usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed);
+// usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed);
// Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]);
// #warning PID is now only proportional (above)
//Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 0);
- Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 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);
}
@@ -535,7 +535,7 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
}
uint32_t WinderDistanceToSpoolState(void )
{
- double DTS_Time = ((dryerbufferlength*100)/dyeingspeed)*1000;//distance to spool time in milliseconds
+ double DTS_Time = (dryerbufferCentimeters/dyeingspeed)*1000;//distance to spool time in milliseconds
REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState");
ScrewDTSControlId = AddControlCallback(ScrewDTSCallback, DTS_Time-WinderBackToBaseTime,TemplateDataReadCBFunction,0,0,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 167616afe..fabb823fc 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -50,25 +50,25 @@ uint32_t Winder_End(void);
typedef enum
{
- THREAD_LOAD_INIT,
- THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW,
- THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION,//USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINST STOPPER. MOVE SLOWLY
- THREAD_LOAD_CENTER_HEAD_ROCKERS, //puthead cleaning rockers to middle position
- THREAD_LOAD_OPEN_COVERS, //OPEN DYEING HEAD COVER AND DRYER LID
- THREAD_LOAD_LIFT_DANCERS,
- THREAD_LOAD_LIFT_ROCKERS, //MACHINE IS READY. SEND MESSAGE, START TIMER TO CLOSE LIDS, WAIT FOR OPERATOR RESPONSE
- THREAD_LOAD_INITIAL_TENSION,//CHECK SPOOL PRESENCERUN WINDER UNTIL BREAK SENSOR IS IDENTIFIEING MOVEMENT FOR A SECOND
- THREAD_LOAD_CLOSE_ROCKERS,
- THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD
- THREAD_LOAD_CLOSE_LIDS,
- THREAD_LOAD_RESUME_HEATING,
- THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT,//JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION
- THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40
+ /*01*/ THREAD_LOAD_INIT,
+ /*02*/ THREAD_LOAD_REDUCE_HEAT, //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW,
+ /*03*/ THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION,//USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINST STOPPER. MOVE SLOWLY
+ /*04*/ THREAD_LOAD_CENTER_HEAD_ROCKERS, //puthead cleaning rockers to middle position
+ /*05*/ THREAD_LOAD_OPEN_COVERS, //OPEN DYEING HEAD COVER AND DRYER LID
+ /*06*/ THREAD_LOAD_LIFT_DANCERS,
+ /*07*/ THREAD_LOAD_LIFT_ROCKERS, //MACHINE IS READY. SEND MESSAGE, START TIMER TO CLOSE LIDS, WAIT FOR OPERATOR RESPONSE
+ /*08*/ THREAD_LOAD_INITIAL_TENSION,//CHECK SPOOL PRESENCERUN WINDER UNTIL BREAK SENSOR IS IDENTIFIEING MOVEMENT FOR A SECOND
+ /*09*/ THREAD_LOAD_CLOSE_ROCKERS,
+ /*10*/ THREAD_LOAD_CLOSE_DANCERS, //SEND DANCER MOTORS TO PRESET LOCATION, CHECK THAT THE DANCERS ARE ON THE THREAD
+ /*11*/ THREAD_LOAD_CLOSE_LIDS,
+ /*12*/ THREAD_LOAD_JOG_FEEDER_TO_MIDDLE_POINT,//JOG THE FEEDER MOTOR UNTIL THE FEEDER DANCER IS AT MIDDLE POSITION
+ /*13*/ THREAD_LOAD_DRYER_LOADING, //START FEEDER PID, ROTATE LOADING ARM COUNTER THREAD DIRECTION X CIRCLES ACCORDING TO RML. FEEDER SPEED IS 40
//KEEP NOTATION HOW MANY ROTATIONS IN THE DRYER
- THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING
- THREAD_LOAD_END
+ /*14*/ THREAD_LOAD_RESUME_HEATING,
+ /*15*/ THREAD_LOAD_JOG_THREAD, //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING
+ /*16*/ THREAD_LOAD_END
}THREAD_LOAD_STAGES_ENUM;
-uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue);
+uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue);
bool ThreadLoadingActive(void);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index 500ba9a39..38c0f86f1 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -174,7 +174,7 @@ uint32_t StoreDancerConfigMessage()
{
response_size = hardware_configuration__pack(&DancerConfig, response_buffer);
}
- Fresult = FileWrite(response_buffer,response_size,DancerConfigPath);
+ Fresult = FileWrite(response_buffer,response_size,DancerConfigPath,BIOS_WAIT_FOREVER);
EraseFlashSection(DANCERS_MAP_IN_FLASH,1024);
for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++)
{
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 528b83c1c..a88ce61a5 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -259,32 +259,38 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
return 0xFFFFFFFF;
}
PoolerCurrentPosition = MotorGetPosition(ThreadMotorIdToMotorId[index]);
-// if (CurrentPosition == 0)
-// return OK; //unusable data
- if (Poolerinitialpos == 0xFFFF)
- {
+ //if (PoolerCurrentPosition != 0)
+ //{
+ if (Poolerinitialpos == 0xFFFF)
+ {
+ PoolerPreviousPosition = PoolerCurrentPosition;
+ Poolerinitialpos = 0;
+ }
+ prevprev = PoolerPreviousPosition;
+ positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition);
+ //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep;
PoolerPreviousPosition = PoolerCurrentPosition;
- Poolerinitialpos = 0;
- }
- prevprev = PreviousPosition;
- positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition);
- //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep;
- PoolerPreviousPosition = PoolerCurrentPosition;
- length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
- //if (InitialProcess == false)
- {
- PoolerTotalProcessedLength+= (length/100);
- TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
- }
- if (length > 1000)
- {
- usnprintf(Lenstr, 100, "pooler length huge: length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,PreviousPosition,prevprev);
- SendJobProgress(0.0,0,false, Lenstr);
- Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
- length = 0;
+ // total length = (position diff / full cycle) * pulley perimeter
+ //(positionDiff/pulseperround)*((2*PI*motor_Radius)
- }
+ //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep;
+ length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
+
+ if (length > 1000)
+ {
+ usnprintf(Lenstr, 100, "length huge: length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,PreviousPosition,prevprev);
+ SendJobProgress(0.0,0,false, Lenstr);
+ Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+ length = 0;
+
+ }
+
+ //}
+
+ length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
+ PoolerTotalProcessedLength+= (length/100);
+ TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
#ifndef FEEDER_LENGTH_CALCULATION
CurrentProcessedLength+=length;
@@ -914,8 +920,8 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId)
}
/*else if (InitialProcess==true)
{
- ThreadUpdateProcessLength (dryerbufferlength,(void *)ThreadPreSegmentEnded);
- REPORT_MSG (dryerbufferlength," ThreadPreSegmentState DTS length (sample)");
+ ThreadUpdateProcessLength (dryerbufferMeters,(void *)ThreadPreSegmentEnded);
+ REPORT_MSG (dryerbufferCentimeters," ThreadPreSegmentState DTS length (sample)");
SegmentState = false;
PreSegmentState = true;
DTSState = false;
@@ -977,7 +983,7 @@ uint32_t ThreadSegmentState(void *SegmentDetails, int SegmentId)
//********************************************************************************************************************
uint32_t ThreadDistanceToSpoolState(void )
{
- seglength = dryerbufferlength;
+ seglength = dryerbufferMeters;
REPORT_MSG (seglength,"ThreadDistanceToSpoolState");
//#ifdef FEEDER_LENGTH_CALCULATION
ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded);