aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
committerAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
commit338edba081dba2a2aefb634811be1cc84ec93d64 (patch)
tree0021538796c254a8eab8527e8461a2e831e68c1c /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
parent49ddda1cc22d6cbb72f499b37e5db32c95252dfa (diff)
downloadTango-338edba081dba2a2aefb634811be1cc84ec93d64.tar.gz
Tango-338edba081dba2a2aefb634811be1cc84ec93d64.zip
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c75
1 files changed, 66 insertions, 9 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 420141d5b..1ce27115d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -133,6 +133,7 @@ uint32_t InternalWindingConfigMessage(JobSpool* request)
* 1. move home to the limit switch (check that the cart is clear from the limit switch, start moving, with acceleration to maximal speed. enable interrupt on the limit switch, upon interrupt stop.
* report ready to the job STM
*/
+int Screw_wait_counter;
uint32_t Winder_Prepare(void *JobDetails)
{
JobTicket* JobTicket = JobDetails;
@@ -199,7 +200,16 @@ uint32_t Winder_Prepare(void *JobDetails)
//REPORT_MSG(ScrewSpeed, "Winder_Prepare");
Winder_ScrewHoming = true;
//REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit");
+ Screw_wait_counter=1;
status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2,2000);
+#ifdef FOUR_WINDERS
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, Winder_PrepareStage2,2000);
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, Winder_PrepareStage2,2000);
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, Winder_PrepareStage2,2000);
+#endif
}
return status;
}
@@ -214,7 +224,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
uint32_t status=OK;
uint32_t numOfSteps = WindingConeLocation*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
+ //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
#ifdef READ_SCREW_ENCODER
Read_Screw_Encoder();
@@ -223,11 +233,12 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
#endif
REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2");
+ Screw_wait_counter--;
if (ReadValue != LIMIT)
{
if (JobIsActive()==true)
{
- LOG_ERROR(ReadValue,"Screw failed to reach the limit switch!!");
+ LOG_ERROR(deviceID,"Screw failed to reach the limit switch!!");
//returned with a timeout
Winder_ScrewAtOffsetCallback(0,0);
}
@@ -238,18 +249,38 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
}
else
{
+ if (Screw_wait_counter!=0)
+ {
+ ReportWithPackageFilter(ThreadFilter,"waiting for winders",__FILE__,__LINE__,Screw_wait_counter,RpWarning,deviceID, 0);
+ return status;
+ }
+ Screw_wait_counter++;
status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+#ifdef FOUR_WINDERS
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_2_Motor,(1-MotorsCfg[SCREW_2_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_3_Motor,(1-MotorsCfg[SCREW_3_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_4_Motor,(1-MotorsCfg[SCREW_4_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+#endif
}
//set motor location 0 here
return status;
}
-uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
+uint32_t Winder_ScrewAtOffsetCallback(uint32_t MotorId, uint32_t BusyFlag)
{
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency);
+ Screw_wait_counter--;
- MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands
+ MotorStop (MotorId,Soft_Hiz); //per L6470 errata between mov and run commands
+/*#ifdef FOUR_WINDERS
+ MotorStop(SCREW_2_Motor, Hard_Hiz);
+ MotorStop(SCREW_3_Motor, Hard_Hiz);
+ MotorStop(SCREW_4_Motor, Hard_Hiz);
+#endif*/
Task_sleep(5);
#ifdef READ_SCREW_ENCODER
Reset_Screw_Encoder();
@@ -260,7 +291,12 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location");
#endif
- SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
+ SetMotHome(MotorId); //set this point as the spool home
+/*#ifdef FOUR_WINDERS
+ SetMotHome(SCREW_2_Motor);
+ SetMotHome(SCREW_3_Motor);
+ SetMotHome(SCREW_4_Motor);
+#endif*/
ScrewCurrentDirection = false;
#ifdef READ_SCREW_ENCODER
@@ -269,8 +305,9 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
ScrewSpeed = 0;
ScrewControlId = 0xFF;
ScrewNumberOfSteps = 0;
- REPORT_MSG(millisecondCounter, "Winder_ScrewAtOffsetCallback");
- PrepareReady(Module_Winder, ModuleDone);
+ ReportWithPackageFilter(ThreadFilter,"Winder_ScrewAtOffsetCallback",__FILE__,millisecondCounter,Screw_wait_counter,RpWarning,MotorId, 0);
+ if (Screw_wait_counter == 0)
+ PrepareReady(Module_Winder, ModuleDone);
return OK;
}
@@ -565,6 +602,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
//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);
+#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);
+#endif
return OK;
}
@@ -594,9 +636,14 @@ uint32_t Winder_End(void)
//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);
MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //bug #2709
+#ifdef FOUR_WINDERS
+ MotorAbortMovetoLimitSwitch (SCREW_2_Motor);
+ MotorAbortMovetoLimitSwitch (SCREW_3_Motor);
+ MotorAbortMovetoLimitSwitch (SCREW_4_Motor);
+#endif
return OK;
}
-void Winder_ScrewHomeLimitSwitchInterrupt(void)
+/*void Winder_ScrewHomeLimitSwitchInterrupt(void)
{
//uint32_t status;
//handle glitch - send information to the next time that the motor stops
@@ -611,7 +658,7 @@ void Winder_ScrewOutLimitSwitchInterrupt(void)
//handle glitch - send information to the next time that the motor stops
//uint32_t status;
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out
-}
+}*/
uint32_t Screw_timerBase = TIMER3_BASE; //Timer handle
@@ -655,7 +702,17 @@ void ScrewTimerInterrupt(int ARG0)
{
ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime);
MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
+#ifdef FOUR_WINDERS
+ MotorSetDirection (SCREW_2_Motor, ScrewCurrentDirection);
+ MotorSetDirection (SCREW_3_Motor, ScrewCurrentDirection);
+ MotorSetDirection (SCREW_4_Motor, ScrewCurrentDirection);
+#endif
MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
+#ifdef FOUR_WINDERS
+ MotorSetSpeedDirect (SCREW_2_Motor, ScrewSpeed);
+ MotorSetSpeedDirect (SCREW_3_Motor, ScrewSpeed);
+ MotorSetSpeedDirect (SCREW_4_Motor, ScrewSpeed);
+#endif
#ifdef READ_SCREW_ENCODER
Read_Screw_Encoder();
ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;