diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-05-02 15:10:35 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-05-02 15:10:35 +0300 |
| commit | 706cc1daaea7e42dc3ad1e4587d61db042809de0 (patch) | |
| tree | d4d26a40418744b2d532b39a4c5c515a53941e8f /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | 66c9f04ccf86a2d6b2c141e9634e02b93e67a407 (diff) | |
| parent | 1b289dd323d223cadfb90bbf4a9f866840265d82 (diff) | |
| download | Tango-706cc1daaea7e42dc3ad1e4587d61db042809de0.tar.gz Tango-706cc1daaea7e42dc3ad1e4587d61db042809de0.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/Thread_Winder.c | 35 |
1 files changed, 27 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 d65156066..df88db3f9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -54,6 +54,9 @@ uint32_t ScrewControlId = 0xFF; InternalWinderConfigStruc InternalWinderCfg = {0}; +uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0; +uint32_t ScrewLocationRun[3]; + uint32_t Winder_Init(void) { ScrewTimerInterruptInit(); @@ -109,6 +112,10 @@ uint32_t Winder_Prepare(void) AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true); return ERROR; }*/ + + ScrewLocationRun[0] = 0; + ScrewLocationRun[1] = 0; + if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { //REPORT_MSG(LIMIT, "Winder_Prepare at limit"); @@ -136,6 +143,11 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); + //Read_Screw_Encoder(); + //ScrewLocationLimitSwitch = Screw_RotEnc.Position; + //REPORT_MSG(ScrewLocationLimitSwitch, "Winder_PrepareStage2 Encoder Location"); + + REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2"); if (ReadValue != LIMIT) { @@ -157,7 +169,13 @@ 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); + //Read_Screw_Encoder(); + //ScrewLocationStart = Screw_RotEnc.Position; + + REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); + ScrewCurrentDirection = false; + ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; @@ -230,6 +248,10 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) ScrewCurrentDirection = 1-ScrewCurrentDirection; CalculationDirectionChangeCounter++; + //REPORT_MSG(ScrewLocationRun[1] - ScrewLocationRun[0], "Screw Run NumberOfSteps"); + //usnprintf(ScrewStr, 100, "Winder Encoder: 0 0x%x 1 0x%x diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],abs(ScrewLocationRun[1] - ScrewLocationRun[0])); + //usnprintf(ScrewStr, 100, "Winder Encoder: 0 %d 1 %d diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],ScrewLocationRun[1] - ScrewLocationRun[0]); + //Report(ScrewStr,__FILE__,__LINE__,ScrewLocationLimitSwitch,RpWarning,ScrewLocationStart, 0); if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out { @@ -288,7 +310,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) //Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 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); + //Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0); } /********************************************************************************/ @@ -440,6 +462,9 @@ void ScrewTimerInterrupt(int ARG0) ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt ROM_IntMasterDisable(); + //Read_Screw_Encoder(); + //ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; + if (SCREW_TimerActivated == true) { ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); @@ -455,13 +480,7 @@ void ScrewTimerInterrupt(int ARG0) } ROM_IntMasterEnable(); Rotations+=0.03; - /*random++; - if (random >= 2) - random = -1;*/ - //Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0); - // - // Enable all interrupts. - // + return ; } |
