diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-06-04 10:29:10 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-06-04 10:29:10 +0300 |
| commit | 922546a39a76280382a82607ed1f54e565f1d71e (patch) | |
| tree | 19fd4cfb950bd3b3496f9a58144e98e6f1e94e78 /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | 08e54b8c5cc6339f0abd2b478a9eff99a7318e14 (diff) | |
| parent | 2a0e5736df4a6514baeea815152528632c285478 (diff) | |
| download | Tango-922546a39a76280382a82607ed1f54e565f1d71e.tar.gz Tango-922546a39a76280382a82607ed1f54e565f1d71e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
3 files changed, 67 insertions, 10 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 diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 0acb587b2..b741f33f3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -56,7 +56,7 @@ uint32_t MotorsConfigMessage(HardwareMotor * request) MotorsCfg[Motor_i].pulseperround = request->pulseperround; MotorsCfg[Motor_i].pulleyradius = request->pulleyradius; MotorsCfg[Motor_i].configword = request->configword; - if(MotorDriverResponse[Motor_i].DriverType == VoltageCombinedMotDriver) + if(MotorDriverResponse[Motor_i].DriverType == CombinrdMotDriver) { MotorsCfg[Motor_i].directionthreadwize = !(request->directionthreadwize);//PowerSTEP01 } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index a285d4194..4743008e5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -114,7 +114,10 @@ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Rea if (Current_Read < Previous_Read) + { Time_Pass = (MAX_COUNTER - Previous_Read) + Current_Read + 1; + Report("Length rollover",__FILE__,__LINE__,(int)Current_Read,RpWarning,(int)Previous_Read,0); + } else Time_Pass = Current_Read - Previous_Read; @@ -771,7 +774,7 @@ void SetOriginMotorSpeed(float process_speed) //MotorControlConfig[Motor_i].m_SetParam = motor_speed; OriginalMotorSpd_2PPS[Motor_i] = (int) motor_speed; CurrentControlledSpeed[Motor_i] = (int) motor_speed; - Report("Original Speed",__FILE__,Motor_i,motor_speed,RpWarning,process_speed,0); + //Report("Original Speed",__FILE__,Motor_i,motor_speed,RpWarning,process_speed,0); for (i = 0; i <= MAX_CONTROL_SAMPLES; i++) MotorSpeedSamples[Motor_i][i] = motor_speed; |
