aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c70
1 files changed, 62 insertions, 8 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index a68995168..2bbc93523 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -46,7 +46,7 @@ uint32_t CalculationDirectionChangeCounter = 1; //holds the current number of ru
double WinderMotorSpeed[MAX_WINDER_SPEED_CALCULATION];
uint16_t WinderMotorSpeedCounter = 0;
bool WinderMotorSpeedRollOver = false;
-#define DEFAULT_SCREW_SPEED 1400
+#define DEFAULT_SCREW_SPEED 1200
double ScrewSpeed = DEFAULT_SCREW_SPEED;
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
@@ -270,10 +270,10 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
//double calcsteps = (ScrewRunningTime/SYS_CLK_FREQ)*ScrewSpeed;
//REPORT_MSG((abs(ScrewLocationRun[1] - ScrewLocationRun[0]), "Screw Run NumberOfSteps");
// usnprintf(ScrewStr, 100, "Winder Encoder: 0 0x%x 1 0x%x diff %d intent %d rot %d",ScrewLocationRun[0],ScrewLocationRun[1],abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,Rotations*10);
- usnprintf(ScrewStr, 150, "Winder Encoder:id, diff, intended, winderspeed, rotation, speed, time, mot speed {, %d, %d, %d, %d, %d, %d, %d, %d, }",CalculationDirectionChangeCounter,
- abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,(int)(WinderReferenceSpeed),(int)(Rotations*10),(int)ScrewSpeed,(int)ScrewRunningTime,(int)speedf);
+ //usnprintf(ScrewStr, 150, "Winder Encoder:id, diff, intended, winderspeed, rotation, speed, time, mot speed {, %d, %d, %d, %d, %d, %d, %d, %d, }",CalculationDirectionChangeCounter,
+ // abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,(int)(WinderReferenceSpeed),(int)(Rotations*10),(int)ScrewSpeed,(int)ScrewRunningTime,(int)speedf);
//usnprintf(ScrewStr, 100, "Winder Encoder: 0 %d 1 %d diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],ScrewLocationRun[1] - ScrewLocationRun[0]);
- Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0);
+ //Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0);
if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out
{
@@ -315,7 +315,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
tempScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
//ROM_IntMasterDisable();
- tempScrewSpeed = DEFAULT_SCREW_SPEED;
+ tempScrewSpeed = ScrewSpeed;
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
@@ -325,7 +325,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
if ((ScrewRunningTime != temp)||(ScrewSpeed != tempScrewSpeed))
{
ScrewSpeed = tempScrewSpeed;
- ScrewSpeed = DEFAULT_SCREW_SPEED;
+ //ScrewSpeed = DEFAULT_SCREW_SPEED;
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);
@@ -364,12 +364,12 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job)
{
ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);
-
+/*
// * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec)
// * calculate
// * 1. calculate speed according to JobTicket->processparameters->dyeingspeed
// * calculation input: traverse length in milimeters/pulses, number of rotations per traverse ==> length of traverse per rotation.
- ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
ScrewNumberOfSteps -= 100;
screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage;
// calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second.
@@ -384,7 +384,25 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
//REPORT_MSG(segmentfirst_speed,ScrewStr);
Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0);
SendJobProgress(0.0,0,false, ScrewStr);
+*/
+ // * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec)
+ // * calculate
+ // * 1. calculate speed according to JobTicket->processparameters->dyeingspeed
+ // * calculation input: traverse length in pulses, number of rotations per traverse ==> length of traverse per rotation.
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; //steps per winder cycle
+ // calculation input#2: number of rotations per second - speed/winder diameter. WE USE HERE 39 MM AS ATHE WINDER DIAMETER - SOME AVERAGE BETWEEN EMPTY AND FULL
+ RotationsPerSecond = (dyeingspeed*10.0)/(19.50*PI);
+ // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm.
+ ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
+ usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond*100,(int)screw_horizontal_speed*100,(int)ScrewSpeed);
+ //REPORT_MSG(segmentfirst_speed,ScrewStr);
+ Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0);
+ SendJobProgress(0.0,0,false, ScrewStr);
+ ScrewNumberOfSteps -= 100;
+
+ ///////////////////////
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed;
WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR];
@@ -419,6 +437,42 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
return OK;
}
+uint32_t ScrewDTSControlId = 0xFF;
+uint32_t WinderDistanceToSpoolEnded(uint32_t deviceID, uint32_t ReadValue)
+{
+ REPORT_MSG ((int)msec_millisecondCounter,"WinderDistanceToSpoolEnded called");
+}
+uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
+{
+ REPORT_MSG ((int)msec_millisecondCounter,"ScrewDTSCallback called");
+ SafeRemoveControlCallback(ScrewDTSControlId, ScrewDTSCallback);
+
+ if (ScrewControlId != 0xFF)
+ {
+ RemoveControlCallback(ScrewControlId,Screw100msecDirectionChange);
+ ScrewControlId = 0xFF;
+ }
+ CurrentControlledSpeed[SCREW_MOTOR] = 0;
+ ScrewsStopControlTimer();
+ //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);
+
+
+ return OK;
+}
+uint32_t WinderDistanceToSpoolState(void )
+{
+ double DTS_Time = ((dryerbufferlength*100)/dyeingspeed)*1000;//distance to spool time in milliseconds
+ REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState");
+
+ ScrewDTSControlId = AddControlCallback(ScrewDTSCallback, DTS_Time-800,TemplateDataReadCBFunction,0,0,0);
+ REPORT_MSG ((int)msec_millisecondCounter,"ScrewDTSCallback start");
+
+ return OK;
+}
+
uint32_t Winder_End(void)
{
//stop screw