aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-06-17 13:53:39 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-06-17 13:53:39 +0300
commit55387f5654403fff0ca3173f5bfcd69a12825ed8 (patch)
treec44a89f97a7fb1495eb20ef383f74fc064864c9b /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
parent401131666124c2df283fb66db80a24843b8115fa (diff)
downloadTango-55387f5654403fff0ca3173f5bfcd69a12825ed8.tar.gz
Tango-55387f5654403fff0ca3173f5bfcd69a12825ed8.zip
preparation for sample winding, preparation for work with FLASH instead of FFS
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c150
1 files changed, 98 insertions, 52 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 297cea44b..4f6585f2a 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -58,6 +58,7 @@ InternalWinderConfigStruc InternalWinderCfg = {0};
uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0;
uint32_t ScrewLocationRun[3];
+bool SampleWinding = false;
uint32_t Winder_Init(void)
{
ScrewTimerInterruptInit();
@@ -92,8 +93,10 @@ 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
*/
-uint32_t Winder_Prepare(void)
+uint32_t Winder_Prepare(void *JobDetails)
{
+ JobTicket* JobTicket = JobDetails;
+
uint32_t status = 0;
//JobTicket* JobTicket = JobDetails;
//float process_speed = JobTicket->processparameters->dyeingspeed;
@@ -117,6 +120,11 @@ uint32_t Winder_Prepare(void)
ScrewLocationRun[0] = 0;
ScrewLocationRun[1] = 0;
+ if (JobTicket->has_samplewinding == true)
+ {
+ SampleWinding = JobTicket->samplewinding;
+ SampleWinding = true;
+ }
if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT)
{
//REPORT_MSG(LIMIT, "Winder_Prepare at limit");
@@ -167,7 +175,6 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
{
- //SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency);
MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands
@@ -179,6 +186,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
ScrewLocationStart = Screw_RotEnc.Position;
REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location");
+ SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
ScrewCurrentDirection = false;
ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;
@@ -267,6 +275,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
ScrewCurrentDirection = 1-ScrewCurrentDirection;
CalculationDirectionChangeCounter++;
+ if (SampleWinding)
+ return OK;
//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);
@@ -348,10 +358,13 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
{
return PreSegmentReady(Module_Winder,ModuleDone);
}
+uint32_t WinderSamplesSegmentCallback(uint32_t SegmentDetails, uint32_t SegmentId)
+{
+ ScrewTimerInterrupt(0);
+}
uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
{
- //JobTicket* JobTicket = JobDetails;
double screw_horizontal_speed = 0;
double RotationsPerSecond;
double temp = 0;
@@ -361,78 +374,110 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
return ERROR;
}
- 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)
+ if ((SegmentId == 0)||(SampleWinding)) // 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 -= 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.
- //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI);
- RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
- // 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;
- ScrewSpeed = DEFAULT_SCREW_SPEED;
+ ScrewCurrentDirection = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize;
+ if ((SegmentId > 0)&&(SampleWinding))
+ {
+ InternalWinderCfg.segmentoffsetpulses = 120;
+ MotorGotoWithBusyCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW,true, (InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1)), WinderSamplesSegmentCallback,2000); //TODO
+ Report("ScrewsMotorGoTo direction,speed ", __FILE__,__LINE__,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep, RpMessage, ScrewSpeed, 0);
+ InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples
+ InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ JobSegment* Segment = SegmentDetails;
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/3);
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
- usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed);
- //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;
+ //three passages during the segment
+ }
+ else if (SampleWinding) //first segment
+ {
+ //InternalWinderCfg.segmentoffsetpulses = 120;
+ InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples
+ InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ JobSegment* Segment = SegmentDetails;
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/20);
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ }
+ else if ((SegmentId == 0)&&(SampleWinding == false))
+ {
+ /*
+ // * 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 -= 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.
+ //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI);
+ RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
+ // 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;
+ ScrewSpeed = DEFAULT_SCREW_SPEED;
+
+ //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
+ usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed);
+ //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;
+ ScrewNumberOfSteps -= 100;
+ Add100 = false;
+ LOG_ERROR(Add100, "Add100 = false");
+ }
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;
+ ScrewDirectionChangeCounter = 1;
+ CalculationDirectionChangeCounter = 1;
+ memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) );
+ WinderMotorSpeedCounter=0;
+ TotalWinderSpeed = 0;
+ WinderMotorSpeedRollOver=false;
///////////////////////
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed;
WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR];
//screw_horizontal_speed = InternalWinderCfg.milimetersperrotation
- // * 2. determine optimal micro-step setting
- // * 3. calculate cart travel length from winding parameters
- // * 4. start move of travel length
- // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed
+ // * 2. determine optimal micro-step setting
+ // * 3. calculate cart travel length from winding parameters
+ // * 4. start move of travel length
+ // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed
temp = SYS_CLK_FREQ;
temp *= ScrewNumberOfSteps;
temp /= ScrewSpeed;
ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed;
- REPORT_MSG(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps");
- REPORT_MSG(ScrewRunningTime,"Winder pre segment - ScrewRunningTime");
-// MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
+ REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps");
+ REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime");
+ //MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
//ScrewDirection = 1-ScrewDirection;
REPORT_MSG(SegmentId,"Winder pre segment - SegmentId");
REPORT_MSG(ScrewSpeed,"Winder pre segment - ScrewSpeed");
//MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
ScrewsStartControlTimer ();
- ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0);
- ScrewDirectionChangeCounter = 1;
- CalculationDirectionChangeCounter = 1;
- memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) );
- WinderMotorSpeedCounter=0;
- TotalWinderSpeed = 0;
- WinderMotorSpeedRollOver=false;
- Add100 = false;
- LOG_ERROR(Add100, "Add100 = false");
}
+ if (SegmentId == 0)
+ {
+ ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0);
+ }
PreSegmentReady(Module_Winder,ModuleDone);
return OK;
@@ -560,6 +605,7 @@ void ScrewTimerInterrupt(int ARG0)
TimerDisable(Screw_timerBase, TIMER_A);
}
ROM_IntMasterEnable();
+ //Report("ScrewsStartControlTimer direction,speed ", __FILE__,__LINE__,ScrewCurrentDirection, RpMessage, ScrewSpeed, 0);
//MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
//Rotations+=0.03;