diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-08-26 11:04:59 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-08-26 11:04:59 +0300 |
| commit | f851e980e49a4737e03335665b9c3a3a529ea326 (patch) | |
| tree | f9a2877bd8cd4886f9d5fa4a86805f47cf1e2fb1 /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | ce95311e3ca782c405591d12da7cf4366c8dcfb2 (diff) | |
| parent | d493603b5c99e0f0ba6858ba9011c83baa780d3b (diff) | |
| download | Tango-f851e980e49a4737e03335665b9c3a3a529ea326.tar.gz Tango-f851e980e49a4737e03335665b9c3a3a529ea326.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
3 files changed, 61 insertions, 31 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 931400aaa..c478b82de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -164,7 +164,7 @@ { if (Is_PP_Machine()) - kval_upperValue = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + kval_upperValue = 28; else kval_upperValue = 70; @@ -349,7 +349,10 @@ if (Head_Type != HEAD_TYPE_ARC) { CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000); + if (MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000)==ERROR) + { + Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_DH_LID,NO_LIMIT); + } } CallbackCounter++; //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000); @@ -395,8 +398,8 @@ { keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; - if (keepkvalrun>=25) - keepkvalrun = 25; + /*if (keepkvalrun>=25) + keepkvalrun = 25;*/ Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); @@ -428,6 +431,7 @@ if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) { REPORT_MSG(LIMIT, "No cone in winder"); + Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_WINDER,NO_LIMIT); //return ERROR; } CallbackCounter++; @@ -440,8 +444,8 @@ { keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; - if (keepkvalrun>=25) - keepkvalrun = 25; + /*if (keepkvalrun>=25) + keepkvalrun = 25;*/ Report("Thread_Load_Close_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); @@ -460,7 +464,7 @@ uint32_t Thread_Load_Close_Dancers(void) //Send Dancer Motors To Preset Location, Check That The Dancers Are On The Thread { - uint32_t current = 0; + uint32_t current = 1; REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Close_Dancers"); CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000); @@ -507,7 +511,7 @@ if (Head_Type != HEAD_TYPE_ARC) { CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000); } CallbackCounter++; // MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000); @@ -1227,11 +1231,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) index = IfIndex&0xFF; DancerId = ThreadMotorIdToDancerId[index]; - if (ReadValue < 10) + /*if (ReadValue < 10) { Report("Dancer value read too small.",__FILE__,__LINE__,DancerId,RpError,ReadValue,0); return OK; - } + }*/ if (ReadValue == 0x3FFF) { return OK; @@ -1242,6 +1246,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) //pooler dancer is right sided: data is opposite TranslatedReadValue = (-1*TranslatedReadValue); } + if (abs(TranslatedReadValue) > 0x2000) + { + TranslatedReadValue = 0x3FFF- TranslatedReadValue; //overcome zero environment + } + //TranslatedReadValue = 0;//test MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue); MotorSamplePointer[index]++; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index bb838a5bd..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,11 +200,15 @@ 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 - status = MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, 5/*LS_SPARE2_2*/, NULL,2000); - status = MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, 5/*LS_SPARE1_2*/, NULL,2000); - status = MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,2000); + 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; @@ -219,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(); @@ -228,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); } @@ -243,11 +249,20 @@ 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 - status |= MotorMoveWithCallback (SCREW_2_Motor,(1-MotorsCfg[SCREW_2_Motor].directionthreadwize), numOfSteps, NULL,1000); - status |= MotorMoveWithCallback (SCREW_3_Motor,(1-MotorsCfg[SCREW_3_Motor].directionthreadwize), numOfSteps, NULL,1000); - status |= MotorMoveWithCallback (SCREW_4_Motor,(1-MotorsCfg[SCREW_4_Motor].directionthreadwize), numOfSteps, NULL,1000); + 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 @@ -255,16 +270,17 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) } -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 -#ifdef FOUR_WINDERS + 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 +#endif*/ Task_sleep(5); #ifdef READ_SCREW_ENCODER Reset_Screw_Encoder(); @@ -275,12 +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 -#ifdef FOUR_WINDERS + 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 +#endif*/ ScrewCurrentDirection = false; #ifdef READ_SCREW_ENCODER @@ -289,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; } @@ -626,7 +643,7 @@ uint32_t Winder_End(void) #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 @@ -641,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 diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 72f369b64..79832120b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -702,7 +702,8 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) }*`/ }*/ calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; - calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR]; + if (index != WINDER_MOTOR) + calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR]; //calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*CurrentControlledSpeed[index]; if (0)//(JobCounter % 1000 == 0) //if (JobCounter < 100)//(FirstCalcInJob == true) @@ -869,6 +870,7 @@ int SecondFeederCorrection = 4; int PrepareWaitCount = 0; uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue) { +#ifndef FOUR_WINDERS MotorStop (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,Soft_Stop); //per L6470 errata between mov and run commands Report("Adjust_Right_TFU_Tension_2ndCallback x more steps",__FILE__,__LINE__,MotorId,RpMessage,SecondFeederCorrection,0); if (JobIsActive()==false) @@ -887,14 +889,16 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback Prepare Ready",__FILE__,__LINE__,2,RpWarning,PrepareWaitCount,0); PrepareReady(Module_Thread,ModuleDone); } - +#endif return OK; } uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) { +#ifndef FOUR_WINDERS Report("Adjust_Right_TFU_Tension_Callback",__FILE__,__LINE__,MotorId,RpMessage,0,0); MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,SecondFeederCorrection* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].microstep, Adjust_Right_TFU_Tension_2nd_Callback,1000); RTFU_Up = true; +#endif return OK; } |
