diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-11-17 16:01:31 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-11-17 16:01:31 +0200 |
| commit | 19ac98b8c46b352fd99fa7c8f320fae6e1572b99 (patch) | |
| tree | 744881075b837310cdf0b7399946e952c1dc782b /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | c70273e22beeee78b6ba7e60c365f1f860fc7848 (diff) | |
| parent | 5c147231611ca2a99702152ad3073524347a24b9 (diff) | |
| download | Tango-19ac98b8c46b352fd99fa7c8f320fae6e1572b99.tar.gz Tango-19ac98b8c46b352fd99fa7c8f320fae6e1572b99.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
5 files changed, 114 insertions, 39 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 63072e4d8..cdb726b5e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -49,6 +49,7 @@ #include "PMR/ThreadLoading/TryThreadLoadingResponse.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h" +#include "PMR/ThreadLoading/AttemptThreadJoggingResponse.pb-c.h" //#include <stdint.h> //#include <stdbool.h> @@ -1597,3 +1598,52 @@ uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) return OK; } +uint8_t attemptJogCounter = 0; +#define ATTEMPT_JOG_TIMEOUT 18 +char AttemptJoggingToken[36+1] = {0}; + +uint32_t AttemptThreadJoggingCallback(uint32_t index, uint32_t ReadValue) +{ + AttemptThreadJoggingResponse response = ATTEMPT_THREAD_JOGGING_RESPONSE__INIT; + MessageContainer responseContainer; + + attemptJogCounter++; + Report("AttemptThreadJoggingCallback",__FILE__,attemptJogCounter,JobEndReason,RpWarning,(int)JobIsActive(),0); + if (attemptJogCounter<ATTEMPT_JOG_TIMEOUT) + { + if (JobIsActive() == true)//jog still preparing/running + return OK; + } + if (JobEndReason == JOB_OK) + ThreadAbortJoggingFunc(); + else + { + responseContainer.has_error = true; + responseContainer.error = getJobError_to_ErrorCode(JobEndReason); + } + SafeRemoveControlCallback(LoadingControlId, AttemptThreadJoggingCallback ); + LoadingControlId = 0xFF; + + if (AttemptJoggingToken[0]) + { + responseContainer = createContainer(MESSAGE_TYPE__AttemptThreadJoggingResponse, AttemptJoggingToken, true, &response, &attempt_thread_jogging_response__pack, &attempt_thread_jogging_response__get_packed_size); + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + SendChars((char*)container_buffer, container_size); + } + return OK; + +} +uint32_t AttemptThreadJoggingFunc(MessageContainer* requestContainer) +{ + attemptJogCounter = 0; + if(requestContainer) + ustrncpy (AttemptJoggingToken, requestContainer->token,36); + Report("AttemptThreadJoggingFunc",__FILE__,__LINE__,0xFF,RpWarning,(int)ATTEMPT_JOG_TIMEOUT,0); + LoadingControlId = AddControlCallback("Load jog",AttemptThreadJoggingCallback, eOneSecond,TemplateDataReadCBFunction,0,0,0); + ThreadJoggingFunc(30); + return OK; +} + diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index a6cb25c45..8ecb3f404 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -141,6 +141,25 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) * report ready to the job STM */ int Screw_wait_counter; +uint32_t Winder_Check_Cone(void) +{ + if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) + { + REPORT_MSG(LIMIT, "No cone in winder"); + if (Is_PP_Machine()) + { + if (IgnoreConeMissing == false) + { + //JobEndReason = JOB_THREAD_BREAK; + usnprintf(AlarmReasonStr, 100, "No cone in winder"); + //PrepareReady(Module_Winder,ModuleFail); + AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true); + return JOB_THREAD_BREAK; + } + } + } + return JOB_OK; +} uint32_t Winder_Prepare(void *JobDetails) { JobTicket* JobTicket = JobDetails; @@ -159,7 +178,7 @@ uint32_t Winder_Prepare(void *JobDetails) * report ready to the job STM */ - if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) + /*if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) { REPORT_MSG(LIMIT, "No cone in winder"); if (Is_PP_Machine()) @@ -173,7 +192,7 @@ uint32_t Winder_Prepare(void *JobDetails) return ERROR; } } - } + }*/ #ifdef READ_SCREW_ENCODER ScrewLocationRun[0] = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 5d69e2980..11a92ab63 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -46,13 +46,14 @@ uint32_t ThreadEndState(); bool Set_Thread_Rockers_Bypass (int value); -uint32_t StoreDancerConfigMessage(void); +uint32_t StoreDancerConfigMessage(int DancerId); 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_Check_Cone(void); uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); uint32_t WinderDistanceToSpoolState(void ); @@ -88,7 +89,10 @@ uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer); uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer); uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer); uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer); +uint32_t AttemptThreadJoggingFunc(MessageContainer* requestContainer); + void ThreadCheckArcHeadCovers(void); uint32_t Thread_Load_End(void); +uint32_t ThreadLoadingRestartReport(void); //sending after a failure in the finalizing stage #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 1920db03a..8d798b402 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -188,40 +188,36 @@ uint32_t MotorPidRequestMessage(HardwarePidControl* request) } char DancerConfigPath[50] = "0://SysInfo//DancCfg.cfg"; -uint32_t StoreDancerConfigMessage() +uint32_t StoreDancerConfigMessage(int DancerId) { uint32_t status = OK; // FRESULT Fresult = FR_OK; //HardwareConfiguration DancerConfig; HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; - // uint8_t* response_buffer; +#ifdef FOUR_WINDERS + uint8_t DancerAddress[MAX_SYSTEM_DANCERS] = {EEPROM_STORAGE_DANCER_0,EEPROM_STORAGE_DANCER_1,EEPROM_STORAGE_DANCER_2,EEPROM_STORAGE_DANCER_3,EEPROM_STORAGE_DANCER_4}; +#else + uint8_t DancerAddress[MAX_SYSTEM_DANCERS] = {EEPROM_STORAGE_DANCER_0,EEPROM_STORAGE_DANCER_1,EEPROM_STORAGE_DANCER_2}; +#endif // size_t response_size = 0; - int Dancer_i; + int Dancer_i = DancerId; //hardware_configuration__init(&DancerConfig); //DancerConfig.dancers = (HardwareDancer**)my_malloc(sizeof(HardwareDancer*)*MAX_SYSTEM_DANCERS); - for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++) - { - hardware_dancer__init(&Dancers[Dancer_i]); - //DancerConfig.dancers[Dancer_i] = &Dancers[Dancer_i]; - Dancers[Dancer_i].has_zeropoint = true; - Dancers[Dancer_i].hardwaredancertype = Dancer_i; - Dancers[Dancer_i].has_hardwaredancertype = true; - Dancers[Dancer_i].zeropoint=Control_Read_Dancer_Position(Dancer_i,0); - //DancerConfig.n_dancers++; - DancersCfg[Dancer_i].zeropoint = Dancers[Dancer_i].zeropoint; - DancersCfg[Dancer_i].zeropoint = Control_Read_Dancer_Position(Dancer_i,0); - } + hardware_dancer__init(&Dancers[Dancer_i]); + //DancerConfig.dancers[Dancer_i] = &Dancers[Dancer_i]; + Dancers[Dancer_i].has_zeropoint = true; + Dancers[Dancer_i].hardwaredancertype = Dancer_i; + Dancers[Dancer_i].has_hardwaredancertype = true; + Dancers[Dancer_i].zeropoint=Control_Read_Dancer_Position(Dancer_i,0); + //DancerConfig.n_dancers++; + DancersCfg[Dancer_i].zeropoint = Dancers[Dancer_i].zeropoint; + DancersCfg[Dancer_i].zeropoint = Control_Read_Dancer_Position(Dancer_i,0); - status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); - status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); - status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); - Report("~~~~~~Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); -#ifdef FOUR_WINDERS - status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_3,DancersCfg[HARDWARE_DANCER_3].zeropoint); - status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_4,DancersCfg[HARDWARE_DANCER_4].zeropoint); - Report("~~~~~~Store eeprom 1",__FILE__,__LINE__,(int)DancersCfg[HARDWARE_DANCER_3].zeropoint,RpWarning,(int)DancersCfg[HARDWARE_DANCER_4].zeropoint,0); -#endif + + + status |= MCU_E2PromProgram(DancerAddress[Dancer_i],DancersCfg[Dancer_i].zeropoint); + Report("~~~~~~Store eeprom",__FILE__,__LINE__,Dancer_i,RpWarning,(int)DancersCfg[Dancer_i].zeropoint,0); /* response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index bc4e6cb8f..5fee72dc7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -337,7 +337,7 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) }**/ //} -#ifdef BTSR_NO_TFU +#ifdef BTSR_NO_PULLER_TFU if (CurrentControlledSpeed[WINDER_MOTOR]>100) length = dyeingspeed/10; #endif @@ -917,7 +917,7 @@ uint32_t Release_Right_TFU_TensionCallback(uint32_t deviceID, uint32_t BusyFlag) uint32_t Release_Right_TFU_Tension() { uint32_t status = OK; -#ifndef BTSR_NO_TFU +#ifndef BTSR_NO_FEEDER_TFU if (RTFU_Up == true) { Report("Release_Right_TFU_Tension",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].pulseperround/4,0); @@ -931,7 +931,7 @@ int SecondFeederCorrection = 4; int PrepareWaitCount = 0; uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue) { -#ifndef BTSR_NO_TFU +#ifndef BTSR_NO_FEEDER_TFU 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) @@ -955,7 +955,7 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa } uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) { -#ifndef BTSR_NO_TFU +#ifndef BTSR_NO_FEEDER_TFU 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; @@ -966,7 +966,7 @@ uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) uint32_t Adjust_Right_TFU_Tension(double tension) { uint32_t status = OK; -#ifndef BTSR_NO_TFU +#ifndef BTSR_NO_FEEDER_TFU if (tension > 0.5) //0 = lower position, 1 = high position { if (FPGA_Read_limit_Switches(GPI_LS_RDANCER_UP) == NO_LIMIT) @@ -1093,11 +1093,13 @@ uint32_t ThreadPrepareState(void *JobDetails) IntersegmentLength = JobTicket->intersegmentlength; PrepareWaitCount = 0; -#ifndef BTSR_NO_TFU status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__LeftDancer, windertension); ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpWarning,(int)windertension,0); +#ifndef BTSR_NO_PULLER_TFU status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__MiddleDancer, pullertension); ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Puller",__FILE__,HARDWARE_DANCER_TYPE__MiddleDancer,PrepareWaitCount,RpWarning,(int)pullertension,0); +#endif +#ifndef BTSR_NO_FEEDER_TFU status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__RightDancer, feedertension); ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Feeder",__FILE__,HARDWARE_DANCER_TYPE__RightDancer,PrepareWaitCount,RpWarning,(int)feedertension,0); #endif @@ -1219,7 +1221,7 @@ uint32_t ThreadPrepareState(void *JobDetails) ///////////////////////////////////////////////////// MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); -#ifndef BTSR_NO_TFU +#ifndef BTSR_NO_FEEDER_TFU if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { ReportWithPackageFilter(ThreadFilter,"Feeder Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0); @@ -1233,6 +1235,7 @@ uint32_t ThreadPrepareState(void *JobDetails) SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } #endif +#ifndef BTSR_NO_PULLER_TFU if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { ReportWithPackageFilter(ThreadFilter,"Puller Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0); @@ -1246,7 +1249,8 @@ uint32_t ThreadPrepareState(void *JobDetails) PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep); PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } -#ifndef BTSR_NO_TFU +#endif +#ifndef BTSR_NO_FEEDER_TFU if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { if (ControlIdtoMotorId[Motor_i] != 0xFF) @@ -1261,6 +1265,8 @@ uint32_t ThreadPrepareState(void *JobDetails) //AddControlCallback(NULL,ThreadControlSpeedReadFunction, eHundredMillisecond,MotorGetSpeedFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); #endif } +#endif +#ifndef BTSR_NO_PULLER_TFU if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will n//ot be controlled { if (ControlIdtoMotorId[Motor_i] != 0xFF) @@ -1332,22 +1338,22 @@ uint32_t UpdatePidDuringRun(HardwarePidControl *request) return ERROR; - if (request->derivativetime == true) + if (request->has_derivativetime == true) { MotorControlConfig[Motor_i].m_params.Kd = request->derivativetime; ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kd",__FILE__,Motor_i,(int)(request->derivativetime),RpWarning,0,0); } - if (request->proportionalgain == true) + if (request->has_proportionalgain == true) { MotorControlConfig[Motor_i].m_params.Kp = request->proportionalgain; ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kp",__FILE__,Motor_i,(int)(request->proportionalgain),RpWarning,0,0); } - if (request->integraltime == true) + if (request->has_integraltime == true) { MotorControlConfig[Motor_i].m_params.Ki = request->integraltime; ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Ki",__FILE__,Motor_i,(int)(request->integraltime),RpWarning,0,0); } - if (request->epsilon == true) + if (request->has_epsilon == true) { MotorControlConfig[Motor_i].m_params.epsilon = request->epsilon; ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun epsilon",__FILE__,Motor_i,(int)(request->epsilon*10000),RpWarning,0,0); |
