diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-01-08 13:54:36 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-01-08 13:54:36 +0200 |
| commit | 9016d57f876a70952dda4419d68b568b586ef0ec (patch) | |
| tree | d9985a59e28ccb36cee2d8cdf486ca524e59660b /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | 5a06b997b7ef29c566bad2bc65f927e9443c3888 (diff) | |
| parent | f070724e30040ae7cc3fada4c4492ed9e80f8106 (diff) | |
| download | Tango-9016d57f876a70952dda4419d68b568b586ef0ec.tar.gz Tango-9016d57f876a70952dda4419d68b568b586ef0ec.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
4 files changed, 161 insertions, 52 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 23b915016..0aff26320 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -74,6 +74,8 @@ int32_t keepkvalrun,keepkvalhold; uint8_t CallbackCounter = 0; uint8_t TimeoutsCounter = 0; + bool SecondTry = false,TryAgain = false; + int MessageState = 0; //0 - none, 1 = start, 2 = continue uint32_t UnloadingStart = 0; uint8_t NumberOfDrierLoaderCycles = 0; @@ -112,7 +114,8 @@ else return false; } - uint32_t Thread_Load_Init(void) + bool InitCalled = false; + uint32_t Thread_Load_Init(THREAD_LOAD_STAGES_ENUM Stage) { //void* buffer = NULL; //uint32_t Bytes = 0; @@ -128,7 +131,8 @@ //EEPROM_STORAGE_DRYER_CYCLES MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); - Read_Dryer_ENC_Position(); + + Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); //if (LoadArmInfo.LoadArmRounds <= 2) // LoadArmInfo.LoadArmRounds = 20; @@ -151,8 +155,12 @@ StopInitSequence(); memcpy (&ProcessParametersRecover,&ProcessParametersKeep,sizeof(ProcessParameters)); //NumberOfDrierLoaderCycles = loadLoadArmParameters(); - LoadStages++; - ThreadLoadStateMachine(LoadStages); + if (Stage == THREAD_LOAD_INIT) + { + LoadStages++; + ThreadLoadStateMachine(LoadStages); + } + InitCalled = true; return OK; } @@ -179,6 +187,7 @@ LOG_ERROR (LoadStages, "Thread_Load_Init failed"); strcpy(LoadErrorMsg,"Thread_Load_Init failed"); LoadStatus = ERROR; + TryAgain = true; } else { @@ -273,13 +282,37 @@ //Use Notation How Many Rotations In The Drier, Or Check Against Stopper. Move Slowly return OK; }*/ - uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t BusyFlag) + uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t Condition) { - CallbackCounter--; - Report("Thread_Load_Jog_Feeder_To_Middle_Point_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); - //storeLoadArmParameters(); - LoadStages++; - ThreadLoadStateMachine(LoadStages); + if (Condition == true) + { + CallbackCounter--; + Report("Thread_Load_Jog_Feeder_To_Middle_Point_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + //storeLoadArmParameters(); + LoadStages++; + ThreadLoadStateMachine(LoadStages); + } + else + { + CallbackCounter--; + Report("Thread_Load_Jog_Feeder_To_Middle_Point TimeOut!",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + //storeLoadArmParameters(); + if (SecondTry == true) + { + LoadStages++; + ThreadLoadStateMachine(LoadStages); + LoadStatus = OK; + } + else + { + TimeoutsCounter = 0; + load.color = fastBILNK; + usnprintf(LoadErrorMsg, 100, "Thread_Load_Jog_Feeder_To_Middle_Point TimeOut!"); + LoadStatus = ERROR; + ThreadLoadingReport(); + TryAgain = true; + } + } return OK; } @@ -321,10 +354,12 @@ usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, MotorId); LoadStatus = ERROR; ThreadLoadingReport(); + TryAgain = true; } else { LoadStages++; + LoadStatus = OK; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -371,10 +406,10 @@ uint32_t Thread_Load_Lift_Dancers(void) { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; + /*keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 40); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000);*/ CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); @@ -387,8 +422,17 @@ keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; if (keepkvalrun>=25) keepkvalrun = 25; + + Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); + Report("Thread_Load_Lift_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); + Report("Thread_Load_Lift_right dancer",__FILE__,__LINE__,0,RpMessage,0,0); + keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; + MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 40); + CallbackCounter++; + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 22, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); + REPORT_MSG(LoadStages, "Thread Load State Machine step"); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 8); @@ -489,7 +533,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 100, FEEDER_DANCER ,true, Thread_Load_Jog_Feeder_To_Middle_Point_Callback,2000); + MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 100, FEEDER_DANCER ,true, Thread_Load_Jog_Feeder_To_Middle_Point_Callback,4000); return OK; } @@ -515,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 { @@ -529,14 +575,16 @@ } float numberOfSteps = 0; float numberOfCycles = 0; - uint32_t DrierPrevLocation = 0; + double DrierPrevLocation = 0; uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) { numberOfCycles++; - uint32_t temp = Control_Read_Dryer_Position(0,0); - if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) + + Report("Thread_Load_Dryer_Loading_Callback",__FILE__,(int)TotalLoadedLen,(int)DrierPrevLocation,RpMessage,ReadValue,0); + + if ((fabs (TotalLoadedLen -DrierPrevLocation)>50 )&&(ReadValue == NOTBUSY)) { - DrierPrevLocation = temp; + DrierPrevLocation = TotalLoadedLen ; //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_DRYER_LOADING) @@ -558,6 +606,8 @@ else { LOG_ERROR(LoadStages,"Load sequence timeout - drier loading"); + TryAgain = true; + SecondTry = false; Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0); MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles); TimeoutsCounter = 0; @@ -634,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("Thread length",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); @@ -662,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("Load jog",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); @@ -705,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; @@ -719,19 +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); - 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; @@ -752,8 +805,9 @@ { 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) { MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz); @@ -776,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; @@ -849,17 +905,18 @@ 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,NumberOfDrierLoaderCycles,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); MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, numberOfSteps-400, Thread_Load_Dryer_UnLoading_Callback, 10000); - Screw_Dir = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize; - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000); + Screw_Dir = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize; + status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,20000); //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; @@ -877,11 +934,24 @@ { case THREAD_LOAD_INIT: //LoadStages++; - Thread_Load_Init(); + MessageState = 1; + + Thread_Load_Init(ReadValue); break; case THREAD_LOAD_REDUCE_HEAT: //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, //LoadStages++; + MessageState = 1; + if (InitCalled == false) + { + REPORT_MSG(ReadValue,"Thread_Load_Init called from 1"); + Thread_Load_Init(ReadValue); + } + else + { + REPORT_MSG(ReadValue,"Thread_Load_Init called from 0"); + } Thread_Load_Reduce_Heat(); + InitCalled = false; break; case THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION://USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINS STOPPER. MOVE SLOWLY //LoadStages++; @@ -961,13 +1031,27 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) return ERROR; } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); - if (LoadStages > ReadValue) + Report("ThreadLoadButton params",__FILE__,LoadStatus,TryAgain,RpMessage,SecondTry,0); + if (LoadStatus == ERROR) { - ThreadLoadStateMachine(LoadStages+1); + 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; } @@ -1071,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 = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((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 { @@ -1209,7 +1293,7 @@ void ThreadLoadPollRequest(MessageContainer* requestContainer) stub_heating_test_poll_request__free_unpacked(request,NULL); } char ThreadLoadingToken[36+1] = {0}; -int MessageState = 0; //0 - none, 1 = start, 2 = continue +char DefaultErrSrt[] = "OK"; uint32_t ThreadLoadingReport(void) { MessageContainer responseContainer; @@ -1219,7 +1303,14 @@ uint32_t ThreadLoadingReport(void) if (ThreadLoadingToken[0] == 0) return OK; - if (MessageState == 1) + if (MessageState == 0) + { + response.has_state = true; + response.state = THREAD_LOADING_STATE__None; + response.errorreason = DefaultErrSrt; + + } + else if (MessageState == 1) { response.has_state = true; if (LoadStatus == OK) @@ -1228,6 +1319,7 @@ uint32_t ThreadLoadingReport(void) if (LoadStages == THREAD_LOAD_INITIAL_TENSION) { response.state = THREAD_LOADING_STATE__ReadyForLoading; + response.errorreason = DefaultErrSrt; } } else @@ -1242,10 +1334,11 @@ uint32_t ThreadLoadingReport(void) if (LoadStatus == OK) { response.state = THREAD_LOADING_STATE__Finalizing; - if (LoadStages >= THREAD_LOAD_JOG_THREAD) + if (LoadStages > THREAD_LOAD_JOG_THREAD) { response.state = THREAD_LOADING_STATE__Completed; - last = true; + response.errorreason = DefaultErrSrt; + //last = true; } } else @@ -1273,7 +1366,7 @@ uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer) { StartThreadLoadingRequest *request = start_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (ThreadLoadingToken, requestContainer->token,36); - MessageState = 1; + //MessageState = 1; Report("StartThreadLoadingFunc",__FILE__,__LINE__,0,RpWarning,(int)LoadStages,0); ThreadLoadingReport(); return OK; @@ -1301,6 +1394,10 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); + if (LoadStages == THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call + { + ThreadLoadStateMachine(LoadStages); + } return OK; } @@ -1311,7 +1408,7 @@ uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) MessageContainer responseContainer; MessageState = 2; Thread_Load_End(); - Report("StopThreadLoadingFunc",__FILE__,__LINE__,0,RpWarning,(int)LoadStages,0); + Report("StopThreadLoadingFunc",__FILE__,__LINE__,0xFF,RpWarning,(int)LoadStages,0); responseContainer = createContainer(MESSAGE_TYPE__StopThreadLoadingResponse, requestContainer->token, true, &Cresponse, &stop_thread_loading_response__pack, &stop_thread_loading_response__get_packed_size); responseContainer.continuous = false; 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); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index dd31e9cda..45ab2cb19 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -41,7 +41,11 @@ double CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; +#ifndef DRIER_CONTROL_TEST +TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#else TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#endif HardwareDancerType ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM] = {FEEDER_DANCER,NUM_OF_DANCERS,POOLER_DANCER,WINDER_DANCER,NUM_OF_DANCERS}; uint32_t ControlIdtoMotorId [MAX_THREAD_MOTORS_NUM] = {0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t SpeedControlId=0xFF; @@ -143,7 +147,7 @@ void ThreadUpdateProcessLength (double length, void *Funcptr) CurrentProcessedLength = 0; ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; } -char Lenstr[150]; +char Lenstr[160]; uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { uint32_t positionDiff = 0,prevprev; @@ -300,12 +304,12 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { if (PrepareState == true) { -#ifdef Use_Head_Card - strcpy(Lenstr,"Heating up"); -#else +//#ifdef Use_Head_Card +// strcpy(Lenstr,"Heating up"); +//#else //later - add temperatures TemperatureListString(Lenstr); -#endif +//#endif SendJobProgress(0.0,0,false, Lenstr); } else @@ -602,7 +606,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; DancerError[DancerId] = NormalizedError; - MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((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 { @@ -848,7 +852,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) } // if (HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled // AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],0); - if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled + if (Motor_i == ThreadMotorIdToMotorId[DRYER_MOTOR]) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled continue; } #ifdef TEST_PID_THREAD @@ -897,7 +901,7 @@ uint32_t ThreadDryerRampUp(uint32_t IfIndex, uint32_t BusyFlag) ControlIdtoMotorId[DRYER_MOTOR] = 0xFF; } - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); //ReportWithPackageFilter(ThreadFilter,"ThreadDryerRampUp",__FILE__,ControlIdtoMotorId[DRYER_MOTOR],(int)InitialDryerSpeed,RpWarning,(int)OriginalMotorSpd_2PPS[DRYER_MOTOR],0); @@ -927,7 +931,7 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) DrierDivider = dyeingspeed/5; //ramp up drier in 5 cm/sec steps ReportWithPackageFilter(ThreadFilter,"Drier ramp up",__FILE__,__LINE__,(int)dyeingspeed,RpWarning,(int)DrierDivider,0); InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/DrierDivider; - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback("DryerRampUp",ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); #endif #ifdef HUNDRED_MICROSECONDS_DANCER_READ |
