diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-06 12:34:55 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-06 12:34:55 +0200 |
| commit | 26b6af221609c7126a73351e415d7017613c31ae (patch) | |
| tree | 9a74999e7334ff07bfea8cbe9354e83b12e1e915 /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | 0e9b372b364a9d8307dd194ac06e7d9a22c58576 (diff) | |
| download | Tango-26b6af221609c7126a73351e415d7017613c31ae.tar.gz Tango-26b6af221609c7126a73351e415d7017613c31ae.zip | |
some fixes from 1.4.5.110 (Beta +)
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
3 files changed, 36 insertions, 18 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 40000b8bb..25c36f3fd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -359,6 +359,7 @@ else { LoadStages++; + LoadStatus = OK; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -558,6 +559,8 @@ CallbackCounter--; if (CallbackCounter == 0) { + LoadStatus = OK; + LoadStages++; if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call { @@ -681,7 +684,8 @@ //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); TotalLoadedLen = 0; - SpeedTControlId = AddControlCallback(NULL,ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + DrierPrevLocation = 200; //initial safe value + SpeedTControlId = AddControlCallback(ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -709,12 +713,13 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(NULL,Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) { REPORT_MSG(LoadStages,"Loading Ended"); + ThreadLoadingReport(); if(LoadingControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); @@ -752,6 +757,7 @@ usnprintf(LoadErrorMsg, 100, "Load sequence stopped by user on stage %d",LoadStages); LoadStatus = ERROR; } + LoadStages = THREAD_LOAD_INIT; load.color = colorON; return OK; @@ -766,21 +772,19 @@ return OK; } Screw_Dir = 1-Screw_Dir; - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000); + status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,13000); return OK; } uint32_t Thread_Load_Dryer_UnLoading_Callback(uint32_t MotorId, uint32_t ReadValue) { numberOfCycles++; - uint32_t temp = Control_Read_Dryer_Position(0,0); - Report("Thread_Load_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); - if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) + uint32_t temp = Read_Dryer_ENC_Position(); + Report("Thread_Load_Dryer_UnLoading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); + //Report("Thread_Load_Dryer_UnLoading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); + if ((abs (temp -DrierPrevLocation)>1000 )&&(ReadValue == NOTBUSY)) { DrierPrevLocation = temp; - //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); if (LoadStages != THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION) { return OK; @@ -801,7 +805,7 @@ { LOG_ERROR(LoadStages,"Load sequence timeout - drier Unloading"); Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0); - MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-numberOfCycles); + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-(numberOfCycles-2));//it takes two cycles to identify a stop of the arm TimeoutsCounter = 0; CallbackCounter = 0; if(PullerControlId != 0xFF) @@ -826,12 +830,14 @@ load.color = fastBILNK; usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); LoadStatus = ERROR; + TryAgain = true; ThreadLoadingReport(); } return OK; } uint32_t Thread_Load_Dryer_UnLoading(void) { + uint32_t temp; REPORT_MSG(LoadStages, "Thread UnLoad State Machine step"); //LoadArmInfo.LoadArmRounds = 0; //uint32_t numberOfSteps = 0; @@ -899,9 +905,10 @@ numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/**LoadArmInfo.LoadArmRounds*/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; numberOfCycles = 0; - MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierPrevLocation); - - Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage, LoadArmInfo.LoadArmRounds,0); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&temp); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + DrierPrevLocation = temp; + Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,DrierPrevLocation,RpMessage, LoadArmInfo.LoadArmRounds,0); MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius); // status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), // MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); @@ -1002,7 +1009,6 @@ ThreadLoadingReport(); break; case THREAD_LOAD_END: - MessageState = 0; LoadStages = THREAD_LOAD_END; Thread_Load_End(); break; @@ -1025,23 +1031,27 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) return ERROR; } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); + Report("ThreadLoadButton params",__FILE__,LoadStatus,TryAgain,RpMessage,SecondTry,0); if (LoadStatus == ERROR) { if ((SecondTry == false)&&(TryAgain == true)) { LoadStatus = OK; SecondTry = true; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages); } else { SecondTry = false; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages+1); } } else { - ThreadLoadStateMachine(ReadValue); + Report("Calling State machine status OK",__FILE__,ReadValue,LoadStatus,RpMessage,SecondTry,0); + ThreadLoadStateMachine(LoadStages); } return OK; } @@ -1145,7 +1155,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index f0b709ff2..78092ae2b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -61,6 +61,7 @@ static bool KeepWindingCone = false; static uint32_t WindingConeLocation; static uint32_t WinderBackToBaseTime = 800; +float NumberOfRotationPerPassage = 0.0; InternalWinderConfigStruc InternalWinderCfg = {0}; //#define READ_SCREW_ENCODER #ifdef READ_SCREW_ENCODER @@ -106,12 +107,17 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) InternalWinderCfg.spoolbackingrate = request->backingrate; InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*2;//request->rotationsperpassage; + InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*3;//request->rotationsperpassage; if (request->rotationsperpassage > 6.1) InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; + if (NumberOfRotationPerPassage > 1) + { + InternalWinderCfg.NumberOfRotationPerPassage = NumberOfRotationPerPassage; + Report("Rotation per passage set from stub",__FILE__,__LINE__,(int)(request->rotationsperpassage*1000),RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); + } InternalWinderCfg.diameter = request->diameter; usnprintf(ScrewStr, 150, "WindingConfig start,offset,head,tail {, %d, %d, %d, %d, %d}",InternalWinderCfg.startoffsetpulses,(int)InternalWinderCfg.segmentoffsetpulses, - (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate); + (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000)); Report(ScrewStr,__FILE__,__LINE__,(int)InternalWinderCfg.diameter,RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); return status; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index dd9395248..420b782b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -42,6 +42,8 @@ uint32_t StoreDancerConfigMessage(void); uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); +extern float NumberOfRotationPerPassage; //debug for rotation per passage trials + uint32_t Winder_Init(void); uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); |
