diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-26 18:13:17 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-26 18:13:17 +0300 |
| commit | d7d99dc7d1fa11845c5d4df3bbff16fec33b406c (patch) | |
| tree | 9cae8240e225014d35f661880aec17cca8c69486 /Software/Embedded_SW | |
| parent | 77e72b9d16522648a350a95382309e9692434011 (diff) | |
| download | Tango-d7d99dc7d1fa11845c5d4df3bbff16fec33b406c.tar.gz Tango-d7d99dc7d1fa11845c5d4df3bbff16fec33b406c.zip | |
Version 1.4.0.2 improve winding (simplify). incorporate screw encoder reading. fix length/time problem between IDS and Thread.
Diffstat (limited to 'Software/Embedded_SW')
18 files changed, 237 insertions, 107 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 68745b390..68500ac88 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -154,7 +154,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) // memcpy (&ReceivedFileHandle,request->uploadid,sizeof(ReceivedFileHandle)); //if (ReceivedFileHandle == FileHandle) //{ - KeepAliveOneSecondCounter = 0; + Control_WD(ENABLE,10); //activate heaters/dispenser watchdog, 0.5 seconds + KeepAliveOneSecondCounter = 0; Fresult = f_write(ReceivedFileHandle,request->buffer.data,request->buffer.len,&WrittenBytes ); lFresult = Fresult; if(Fresult != FR_OK) diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 21c7eb041..b2590abab 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,4,0,0}; +TangoVersion_t _gTangoVersion = {1,4,0,2}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 26f6d5c56..5cfaddb1e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -225,6 +225,17 @@ void FPGA_GetClrMotStat_Cmd(TimerMotors_t _motorId) } +void FPGA_GetFPGAMotSpeed_Cmd(TimerMotors_t _motorId) +{ + uint32_t temp; + Fpga_Spi[_motorId].TX_MOSI = x_GET_PARAM | x_SPEED; + Fpga_Spi[_motorId].TX_MOSI = Fpga_Spi[_motorId].TX_MOSI << 24;// move the command to the MSB TODO necessary??? + //Fpga_Spi[_motorId].AMT_OF_Words = 1; + temp = Fpga_Spi[_motorId].TX_MOSI; + + MillisecReadFromMotor(_motorId, temp, 4, MotorGetSpeedFromFPGA_Callback); +} + void FPGA_GetMotSpeed_Cmd(TimerMotors_t _motorId) { Fpga_Spi[_motorId].TX_MOSI = x_GET_PARAM | x_SPEED; @@ -769,7 +780,9 @@ void FPGA_SetMotSpeedDirect(TimerMotors_t _motorId)//Run Fpga_Spi[_motorId].TX_MOSI = temp; Fpga_Spi[_motorId].AMT_OF_Words = 4; - FPGA_SPI_Transnit(_motorId); + //FPGA_SPI_Transnit(_motorId); + MotorSendFPGARequest(_motorId,temp, 4); //returns -1 on busy or other error + } void FPGA_SetMotMaxSpeed(TimerMotors_t _motorId)//Mov { diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h index e2937e597..114d24a85 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h @@ -14,6 +14,7 @@ uint32_t Read_Motors_Driver_Type(TimerMotors_t i); void FPGA_GetClrMotStat_Cmd(TimerMotors_t _motorId); void FPGA_GetMotSpeed_Cmd(TimerMotors_t _motorId); void FPGA_Get_ADC_OUT_Cmd(TimerMotors_t _motorId); +void FPGA_GetFPGAMotSpeed_Cmd(TimerMotors_t _motorId); void FPGA_Get_Res(TimerMotors_t _motorId); void FPGA_GetBusy(); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 106e60316..202021282 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -117,9 +117,13 @@ uint32_t MotorSetDirection(TimerMotors_t _motorId,bool _direction) return OK; } -uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq)//TODO MicroSteps? +uint32_t MotorSetSpeed(TimerMotors_t _motorId, float _freq)//TODO MicroSteps? { - int RunSpeed = SpdCalc(_freq); + if (_motorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW) + { + LOG_ERROR ((int)_freq, "SCREW SET SPEED CALLED"); + } + uint32_t RunSpeed = SpdCalc(_freq); #ifdef EVALUATION_BOARD Run_Value = RunSpeed; Mot_Run(); @@ -130,9 +134,9 @@ uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq)//TODO MicroSteps? return OK; } -uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, uint32_t _freq) +uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, float _freq) { - int RunSpeed = SpdCalc(_freq); + uint32_t RunSpeed = SpdCalc(_freq); MotorDriverRequest[_motorId].Speed = RunSpeed; FPGA_SetMotSpeedDirect(_motorId); @@ -140,7 +144,7 @@ uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, uint32_t _freq) } -uint32_t MotorGetSpeed(TimerMotors_t _motorId) +float MotorGetSpeed(TimerMotors_t _motorId) { return MotorDriverResponse[_motorId].Speed; } @@ -174,6 +178,25 @@ uint32_t MotorGetPositionFromFPGA_Callback(TimerMotors_t _motorId,uint32_t Data) return MotorDriverResponse[_motorId].Position; } +uint32_t MotorGetSpeedFromFPGA1(TimerMotors_t _motorId) +{ + #ifdef EVALUATION_BOARD + MotorDriverResponse[_motorId].Speed = (CurrentSpdCalc(Get_Param(x_SPEED))); + return (uint32_t)(MotorDriverResponse[_motorId].Speed); + #else + FPGA_GetFPGAMotSpeed_Cmd(_motorId); + return OK; + #endif +} +float MotorGetSpeedFromFPGA_Callback(TimerMotors_t _motorId,uint32_t Data) +{ + #ifndef EVALUATION_BOARD + // FPGA_Get_Res(_motorId); + MotorDriverResponse[_motorId].Speed = CurrentSpdCalc(Data); + #endif + return MotorDriverResponse[_motorId].Speed; +} + //uint32_t MotorGetPositionFromFPGA_Res(TimerMotors_t _motorId) //{ // #ifndef EVALUATION_BOARD @@ -190,20 +213,19 @@ uint32_t MotorGetSpeedFromFPGA(TimerMotors_t _motorId) // MotorDriverResponse[_motorId].Speed = (float)(CurrentSpdCalc(MotFPGA_Spi.RX_MISO)); // return MotorDriverResponse[_motorId].Speed; #ifdef EVALUATION_BOARD - uint32_t temp = (uint32_t)(CurrentSpdCalc(Get_Param(x_SPEED))); - MotorDriverResponse[_motorId].Speed = temp; - return temp; + MotorDriverResponse[_motorId].Speed = (CurrentSpdCalc(Get_Param(x_SPEED))); + return (uint32_t)(MotorDriverResponse[_motorId].Speed); #else FPGA_GetMotSpeed_Cmd(_motorId); return OK; #endif } -uint32_t MotorGetSpeedFromFPGA_Res(TimerMotors_t _motorId) +float MotorGetSpeedFromFPGA_Res(TimerMotors_t _motorId) { #ifndef EVALUATION_BOARD FPGA_Get_Res(_motorId); - MotorDriverResponse[_motorId].Speed = (float)(CurrentSpdCalc(Fpga_Spi[_motorId].RX_MISO)); + MotorDriverResponse[_motorId].Speed = CurrentSpdCalc(Fpga_Spi[_motorId].RX_MISO); #endif return MotorDriverResponse[_motorId].Speed; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index 894f60c09..81cc7828b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h @@ -96,7 +96,7 @@ typedef struct typedef struct { bool Direction; - uint32_t Speed; + float Speed; uint32_t Position; uint32_t Status; uint8_t MicroSteps; @@ -125,14 +125,14 @@ uint32_t MotorGetDirection(TimerMotors_t _motorId); uint32_t MotorSetDirection(TimerMotors_t _motorId,bool _direction); -uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq); -uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, uint32_t _freq); // call directly and not from millisec task +uint32_t MotorSetSpeed(TimerMotors_t _motorId, float _freq); +uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, float _freq); // call directly and not from millisec task uint32_t MotorSetMaxSpeed(TimerMotors_t _motorId, uint32_t MaxSpeed); uint32_t MotorSetMicroStep(TimerMotors_t _motorId, uint32_t microstep); -uint32_t MotorGetSpeed(TimerMotors_t _motorId); +float MotorGetSpeed(TimerMotors_t _motorId); uint32_t MotorGetADC(TimerMotors_t _motorId); uint32_t MotorGetPosition(TimerMotors_t _motorId); @@ -142,7 +142,10 @@ uint32_t MotorGetPositionFromFPGA_Callback(TimerMotors_t _motorId,uint32_t Data) //uint32_t MotorGetPositionFromFPGA_Res(TimerMotors_t _motorId); uint32_t MotorGetSpeedFromFPGA(TimerMotors_t _motorId); -uint32_t MotorGetSpeedFromFPGA_Res(TimerMotors_t _motorId); +float MotorGetSpeedFromFPGA_Res(TimerMotors_t _motorId); +uint32_t MotorGetSpeedFromFPGA1(TimerMotors_t _motorId); +float MotorGetSpeedFromFPGA_Callback(TimerMotors_t _motorId,uint32_t Data); + uint32_t MotorGetADCFromFPGA(TimerMotors_t _motorId); uint32_t MotorGetADCFromFPGA_Res(TimerMotors_t _motorId); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c index dd9841777..6c1b647be 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c @@ -11,7 +11,7 @@ float PIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_P error = _setPoint - _mesuredParam; //In case of error too small then stop integration - if(abs(error) > params->epsilon) + if(fabs(error) > params->epsilon) { *_integral = *_integral + error*params->dt; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index a5165e7f2..4dbd2e89e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -44,6 +44,7 @@ uint32_t IDSPrepareState(void *JobDetails); void IDSPrepareStart(void); uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId); +uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId); uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId); uint32_t IDSDistanceToSpoolState(void); uint32_t IDSEndState(void); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index efedfe545..1d395ec8c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -850,6 +850,40 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); } return OK; } +uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId) +{ + JobDescriptionFileSegment* PrevSegment = SegmentDetails; + uint32_t status = OK; + JobDescriptionFileBrushStop * tFileBrushStop; + int Brush_i; + +//check and close previous segment + if (PrevSegment) + { + if (JobBrushStopId<PrevSegment->brushstopscount) //we did not finish reading the brushstops of the previous segment + { + Report("Unhandled brushstops remained",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)PrevSegment->brushstopscount,0); + //REPORT_MSG (Segment->brushstopscount, "Segment->brushstopscount"); + for (Brush_i=JobBrushStopId;Brush_i<PrevSegment->brushstopscount;Brush_i++) + { + if (status == ERROR) + break; + tFileBrushStop = GetNextBrushStopFromJobFile(); + if (tFileBrushStop) + { + FreeBrushStopFileData(tFileBrushStop); + Report("Unhandled brushstops handled",__FILE__,__LINE__,(int)Brush_i,RpWarning,(int)PrevSegment->brushstopscount,0); + } + else + { + status = ERROR; + break; + } + }//for brushstops + } + } + return status; +} uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) { JobSegment* Segment = SegmentDetails; @@ -864,7 +898,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) /* wait for all dispensers to get to the required pressure * move the presegment ready when all dispensers are ready. */ - REPORT_MSG(SegmentId,"IDSPreSegmentState"); + REPORT_MSG(Segment->n_brushstops,"IDSPreSegmentState"); if (JobBrushStopId>=Segment->n_brushstops) { LOG_ERROR(Segment->n_brushstops,"Error JobBrushStopId"); @@ -873,7 +907,6 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) return ERROR; } - if ((EnableIntersegment == true)&&(IntersegmentLength>0)) { Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away @@ -1026,7 +1059,7 @@ void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) /*IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId, segmentfirst_speed, NULL);*/ - Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer + //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); CurrentDispenserSpeed[DispenserId] = segmentfirst_speed; usnprintf(IdsMessage, 80, @@ -1034,7 +1067,7 @@ void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) DispenserId, (int) Dispensers[Dispenser_i]->nanolitterpersecond, (int) Dispensers[Dispenser_i]->nanoliterperpulse, - (int) segmentfirst_speed,Dispensers[Dispenser_i]->dispenserstepdivision,MotorsCfg[HW_Motor_Id].microstep); + (int) (segmentfirst_speed*1000),Dispensers[Dispenser_i]->dispenserstepdivision,MotorsCfg[HW_Motor_Id].microstep); //REPORT_MSG(segmentfirst_speed,IdsMessage); Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); //SendJobProgress(0.0, 0, false, IdsMessage); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c index 0854aba40..53a860970 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c @@ -449,7 +449,7 @@ void Stub_MotorSpeedRequest(MessageContainer* requestContainer) //deley TODO SysCtlDelay(10000); //response.speed = (double)(CurrentSpdCalc(MotorGetSpeedFromFPGA_Res(Motor_Id))); - response.speed = MotorGetSpeedFromFPGA_Res(Motor_Id); + response.speed = (double)(MotorGetSpeedFromFPGA_Res(Motor_Id)); #endif ////////////////////////////////////////////////////////////////// diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 19201c708..0093a5a2a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -56,8 +56,8 @@ extern int32_t BreakSensordebouncetimemilli; extern HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM]; //extern InternalWinderConfigStruc InternalWinderCfg; extern HardwareDancer DancersCfg[MAX_SYSTEM_DANCERS]; -extern uint32_t CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM]; -extern int OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM]; +extern double CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM]; +extern double OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM]; #define MAX_CONTROL_SAMPLES 10 extern int32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; @@ -65,7 +65,7 @@ extern int MotorSamplePointer[MAX_THREAD_MOTORS_NUM]; extern double NormalizedErrorCoEfficient[MAX_THREAD_MOTORS_NUM]; extern int DancerStopActivityLimit[MAX_THREAD_MOTORS_NUM]; extern MotorControlConfig_t MotorControlConfig[MAX_THREAD_MOTORS_NUM]; -extern int32_t MotorSpeedSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; +extern double MotorSpeedSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; extern int MotorSpeedSamplePointer[MAX_THREAD_MOTORS_NUM]; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index ab5075ab9..66d6baed5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -594,7 +594,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) MotorControlConfig[index].m_calculatedError = (-1*MotorControlConfig[index].m_calculatedError); }*/ calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; - if (abs(calculated_speed-CurrentControlledSpeed[index])> MotorControlConfig[index].m_ingnoreValue) + if (fabs(calculated_speed-CurrentControlledSpeed[index])> MotorControlConfig[index].m_ingnoreValue) { CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 66c2e1659..9ebc32f57 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -43,10 +43,11 @@ uint32_t ScrewDirectionChangeCounter = 1; //holds the current number of runs of //uint32_t ScrewChangeCounter = 0; //uint32_t ScrewChangeLimit = 0; uint32_t CalculationDirectionChangeCounter = 1; //holds the current number of runs of the screw - will be used to build the cone -uint16_t WinderMotorSpeed[MAX_WINDER_SPEED_CALCULATION]; +double WinderMotorSpeed[MAX_WINDER_SPEED_CALCULATION]; uint16_t WinderMotorSpeedCounter = 0; bool WinderMotorSpeedRollOver = false; -double ScrewSpeed = 0; +#define DEFAULT_SCREW_SPEED 1400 +double ScrewSpeed = DEFAULT_SCREW_SPEED; double ScrewRunningTime = 0; uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone bool SCREW_TimerActivated = false; @@ -96,7 +97,7 @@ uint32_t Winder_Prepare(void) uint32_t status = 0; //JobTicket* JobTicket = JobDetails; //float process_speed = JobTicket->processparameters->dyeingspeed; - double ScrewSpeed = 1500;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now + double ScrewSpeed = DEFAULT_SCREW_SPEED;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); /* @@ -143,9 +144,9 @@ 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"); + 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"); @@ -169,8 +170,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; + MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands + Task_sleep(5); + Reset_Screw_Encoder(); + Task_sleep(5); + Read_Screw_Encoder(); + Task_sleep(5); + ScrewLocationStart = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); @@ -180,7 +186,6 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; REPORT_MSG(millisecondCounter, "Winder_ScrewAtOffsetCallback"); - MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands PrepareReady(Module_Winder, ModuleDone); return OK; } @@ -212,26 +217,28 @@ InternalWinderCfg.segmentoffsetpulses numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; */ -char ScrewStr[100]; +char ScrewStr[150]; //char TempScrewStr[100]; double WinderReferenceSpeed=0; -int32_t TotalWinderSpeed=0; +double TotalWinderSpeed=0; bool Add100 = false; double Rotations = 6.0; +bool flipflop = false; +uint32_t motspeed; +float speedf; +int WinderCalculation = 0; uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { //uint32_t Steps; double temp,tempScrewSpeed; double screw_horizontal_speed = 0; double RotationsPerSecond; - int32_t Averagewinderspeed = 0; + double Averagewinderspeed = 0; - //ScrewChangeCounter++; - //if ((ScrewChangeCounter>3)&&(ScrewChangeCounter<(ScrewChangeLimit-2))) //do not take the winder speed near the limits - { - TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter]; - WinderMotorSpeed[WinderMotorSpeedCounter] = CurrentControlledSpeed[WINDER_MOTOR]; - TotalWinderSpeed+=WinderMotorSpeed[WinderMotorSpeedCounter]; +// { +// TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter]; +// WinderMotorSpeed[WinderMotorSpeedCounter] = CurrentControlledSpeed[WINDER_MOTOR]; +// TotalWinderSpeed+=WinderMotorSpeed[WinderMotorSpeedCounter]; if (WinderMotorSpeedCounter++>=MAX_WINDER_SPEED_CALCULATION) { if (WinderMotorSpeedRollOver == false) @@ -239,20 +246,34 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) Add100 = true; LOG_ERROR(Add100, "Add100 = true"); } - WinderMotorSpeedCounter=0; +// WinderMotorSpeedCounter=0; WinderMotorSpeedRollOver=true; } +// } + if (flipflop) + { + speedf = MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } + else + { + MotorGetSpeedFromFPGA1(HARDWARE_MOTOR_TYPE__MOTO_SCREW); + } + flipflop = 1-flipflop; if (ScrewDirectionChangeCounter == CalculationDirectionChangeCounter) return OK; + //deley TODO + 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])); + //double calcsteps = (ScrewRunningTime/SYS_CLK_FREQ)*ScrewSpeed; + //REPORT_MSG((abs(ScrewLocationRun[1] - ScrewLocationRun[0]), "Screw Run NumberOfSteps"); +// usnprintf(ScrewStr, 100, "Winder Encoder: 0 0x%x 1 0x%x diff %d intent %d rot %d",ScrewLocationRun[0],ScrewLocationRun[1],abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,Rotations*10); + usnprintf(ScrewStr, 150, "Winder Encoder:id, diff, intended, winderspeed, rotation, speed, time, mot speed {, %d, %d, %d, %d, %d, %d, %d, %d, }",CalculationDirectionChangeCounter, + abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,(int)(WinderReferenceSpeed),(int)(Rotations*10),(int)ScrewSpeed,(int)ScrewRunningTime,(int)speedf); //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); + Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out { @@ -265,8 +286,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.spoolbackingrate == 0) { ScrewNumberOfSteps--; - REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); - + Report("Head Backing",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0); } } else //next time going back @@ -274,34 +294,38 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.SpoolBottomBackingRate == 0) { ScrewNumberOfSteps++; - REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing ScrewNumberOfSteps"); + Report("Bottom Backing ",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0); } } - if (WinderMotorSpeedRollOver) + /* if (WinderMotorSpeedRollOver) { - /*for (i=0;i<MAX_WINDER_SPEED_CALCULATION;i++) + if (WinderCalculation%60000 == 0)//100 minutes { - TotalWinderSpeed+=WinderMotorSpeed[i]; - }*/ - Averagewinderspeed = TotalWinderSpeed/MAX_WINDER_SPEED_CALCULATION; - //REPORT_MSG(winderspeed, "WinderSpeedUpdated"); - //Report("WinderSpeedUpdated",__FILE__,__LINE__,TotalWinderSpeed,RpWarning,Averagewinderspeed,0); - - WinderReferenceSpeed = Averagewinderspeed; - } + Averagewinderspeed = TotalWinderSpeed/MAX_WINDER_SPEED_CALCULATION; + //Report("WinderSpeedUpdated",__FILE__,__LINE__,(int)TotalWinderSpeed,RpWarning,(int)Averagewinderspeed,0); + WinderReferenceSpeed = Averagewinderspeed; + } + WinderCalculation++; + }*/ + //WinderReferenceSpeed = 1000; + //ScrewNumberOfSteps = 1000; screw_horizontal_speed = ScrewNumberOfSteps / Rotations;//InternalWinderCfg.NumberOfRotationPerPassage; - if (Rotations > 6.6)//7.0) - Rotations = 6.0; + // if (Rotations > 6.6)//7.0) + // Rotations = 6.0; RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; tempScrewSpeed = screw_horizontal_speed*RotationsPerSecond; //ROM_IntMasterDisable(); + tempScrewSpeed = DEFAULT_SCREW_SPEED; + CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; + temp = SYS_CLK_FREQ; temp *= ScrewNumberOfSteps; temp /= tempScrewSpeed; if ((ScrewRunningTime != temp)||(ScrewSpeed != tempScrewSpeed)) { ScrewSpeed = tempScrewSpeed; + ScrewSpeed = DEFAULT_SCREW_SPEED; ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; //ROM_IntMasterEnable(); //usnprintf(TempScrewStr, 100, "Winder: Horizon,Rotation, PPR, RPP{ %d, %d ,%d, %d} ",(int)screw_horizontal_speed,(int)RotationsPerSecond,(int)InternalWinderCfg.NumberOfRotationPerPassage,(int)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround); @@ -353,6 +377,7 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; + ScrewSpeed = DEFAULT_SCREW_SPEED; //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); @@ -372,12 +397,12 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) temp *= ScrewNumberOfSteps; temp /= ScrewSpeed; ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed; - REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); - REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); + REPORT_MSG(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); + REPORT_MSG(ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); // MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); //ScrewDirection = 1-ScrewDirection; REPORT_MSG(SegmentId,"Winder pre segment - SegmentId"); - REPORT_MSG((int)ScrewSpeed,"Winder pre segment - ScrewSpeed"); + REPORT_MSG(ScrewSpeed,"Winder pre segment - ScrewSpeed"); //MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); ScrewsStartControlTimer (); ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0); @@ -458,20 +483,20 @@ void ScrewsStartControlTimer (void) return; } -int random = 0; + 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) { + Read_Screw_Encoder(); ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); - MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed+random); + MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; // ScrewChangeCounter = 0; // ScrewChangeLimit = ScrewRunningTime/12000000; ScrewDirectionChangeCounter++; @@ -481,7 +506,8 @@ void ScrewTimerInterrupt(int ARG0) TimerDisable(Screw_timerBase, TIMER_A); } ROM_IntMasterEnable(); - Rotations+=0.03; + //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + //Rotations+=0.03; return ; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 91eedeb6b..ead318758 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -28,7 +28,7 @@ void ThreadSetBreakSensorLimit(int limit); uint32_t InternalWindingConfigMessage(JobSpool* request); uint32_t ThreadConfigBreakSensor(void *request); -uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId); +double ThreadGetMotorSpeed(threadMotorsEnum MotorId); double ThreadGetMotorCalculatedError(int DancerId); uint32_t ThreadPrepareState(void *JobDetails); uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 265c751c6..0acb587b2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -22,7 +22,7 @@ MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]={0}; HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM] = {0}; -int32_t MotorSpeedSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES] = {0}; +double MotorSpeedSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES] = {0}; int MotorSpeedSamplePointer[MAX_THREAD_MOTORS_NUM] = {0}; int32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES] = {0}; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 25485290b..a285d4194 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -39,7 +39,7 @@ //by recieved esign flow of the user from the UI /////////////////////////////////////////////////////////////////////////////////////////// -uint32_t CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; +double CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; 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}; HardwareDancerType ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM] = {FEEDER_DANCER,NUM_OF_DANCERS,POOLER_DANCER,WINDER_DANCER,NUM_OF_DANCERS}; @@ -48,7 +48,7 @@ uint32_t SpeedControlId=0xFF; uint32_t PoolerSpeedControlId=0xFF; double DancerError[NUM_OF_DANCERS] = {0.0}; -int OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM] = {0}; +double OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM] = {0}; uint32_t JobCounter = 0; MotorControlConfig_t MotorControlConfig[MAX_THREAD_MOTORS_NUM]; @@ -186,6 +186,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) usnprintf(Lenstr, 100, "length huge: length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,PreviousPosition,prevprev); SendJobProgress(0.0,0,false, Lenstr); Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); + length = 0; } @@ -275,7 +276,7 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) int index=MAX_THREAD_MOTORS_NUM; int32_t i, avreageSampleValue = 0; //double tempcalcspeed = 0; - uint32_t calculated_speed; + double calculated_speed; float speed = getSensorSpeedData(); if (IfIndex>>8 != IfTypeThread) { @@ -297,7 +298,7 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); //SetMotorFreq (index, MotorControlConfig[index].m_calculatedError); calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; - if (abs(calculated_speed-CurrentControlledSpeed[index])>2) + if (fabs(calculated_speed-CurrentControlledSpeed[index])>2) { CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); @@ -305,7 +306,7 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) } return OK; } -uint32_t _speed; +float _speed; uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) { int index; @@ -393,7 +394,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) int DancerId; int32_t TranslatedReadValue, avreageSampleValue = 0,avreageMotorSampleValue = 0; //double tempcalcspeed = 0; - uint32_t calculated_speed; + double calculated_speed; double NormalizedError; if (ThreadControlActive == false) @@ -551,17 +552,17 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; //calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*CurrentControlledSpeed[index]; #ifndef TEST_PID_THREAD - if (abs(calculated_speed-CurrentControlledSpeed[index])> MotorControlConfig[index].m_ingnoreValue) + if (fabs(calculated_speed-CurrentControlledSpeed[index])> MotorControlConfig[index].m_ingnoreValue) #else if (index == FEEDER_MOTOR) //feeder unit handles errors opposite to left unit #endif { CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); - if (((JobCounter % 2000) == index*100)&&(index == WINDER_MOTOR)) //feeder unit handles errors opposite to left unit + /*if (((JobCounter % 2000) == index*100)&&(index == WINDER_MOTOR)) //feeder unit handles errors opposite to left unit { - Report("MotorSpeedUpdated",__FILE__,index,OriginalMotorSpd_2PPS[index],RpWarning,CurrentControlledSpeed[index],0); - } + Report("MotorSpeedUpdated",__FILE__,index,(int)OriginalMotorSpd_2PPS[index],RpWarning,(int)CurrentControlledSpeed[index],0); + }*/ #ifdef TEST_PID_THREAD int len; if ((JobCounter % 2000) == index*100) @@ -587,7 +588,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) #endif } else + { MotorFailedSample[index]++; + //LOG_ERROR(index,"No change in speed"); + } } @@ -595,7 +599,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) } //******************************************************************************************************************** -uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId) +double ThreadGetMotorSpeed(threadMotorsEnum MotorId) { return CurrentControlledSpeed[MotorId]; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 7269354f9..7ad887925 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -782,23 +782,6 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes { responseContainer.has_error = true; responseContainer.error = JobError_to_ErrorCode[JobEndReason]; - switch (JobEndReason) - { - case JOB_THREAD_BREAK: - AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); - break; - case JOB_POOLER_DANCER_FAIL: - AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_PULLER_DANCER,true); - break; - case JOB_FEEDER_DANCER_FAIL: - AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_FEEDER_DANCER,true); - break; - case JOB_WINDER_DANCER_FAIL: - AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_WINDER_DANCER,true); - break; - default: - break; - } } if (JobAbortedByUser == true) { @@ -827,6 +810,26 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes CurrentRequest = NULL; } JobStopReporting(); + if(JobEndReason != JOB_OK) + { + switch (JobEndReason) + { + case JOB_THREAD_BREAK: + AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); + break; + case JOB_POOLER_DANCER_FAIL: + AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_PULLER_DANCER,true); + break; + case JOB_FEEDER_DANCER_FAIL: + AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_FEEDER_DANCER,true); + break; + case JOB_WINDER_DANCER_FAIL: + AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_WINDER_DANCER,true); + break; + default: + break; + } + } JobMessageStruc JobMessage; JobMessage.messageId = PrintingResultsOk; @@ -841,6 +844,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes } void JobStopReporting(void) { + LOG_ERROR(0,"JobStopReporting"); JobToken[0] = 0; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 46241c3a0..2aa260e9f 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -665,7 +665,7 @@ void PrintSTMMsgHandler(void * msg) if (SegmentId >= n_segments) { if (dryerbufferlength == 0) - EndState(CurrentJob, "Job Ended"); + EndState(CurrentJob, "Job Ended"); else DistanceToSpoolState(CurrentJob); } @@ -673,12 +673,34 @@ void PrintSTMMsgHandler(void * msg) { if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) { - if (Segment->base.descriptor->sizeof_message != 40) - LOG_ERROR (Segment->base.descriptor->sizeof_message, "Segment size error. not freeing"); + if ((Segment) && (Segment->base.descriptor->sizeof_message != 40)) + LOG_ERROR(SegmentId, "Error releasing Segment"); else if (Segment) - FreeSegmentFileData(Segment); + { + if (IDSCheckSegmentData(Segment, SegmentId) == OK) + { + FreeSegmentFileData(Segment); + } + else + { + JobEndReason = JOB_OTHER_ALARM; + if (dryerbufferlength == 0) + EndState(CurrentJob, "Job Ended"); + else + DistanceToSpoolState(CurrentJob); + } + + } Segment = GetNextSegmentFromJobFile(); + if (Segment == NULL) + { + JobEndReason = JOB_OTHER_ALARM; + if (dryerbufferlength == 0) + EndState(CurrentJob, "Job Ended"); + else + DistanceToSpoolState(CurrentJob); + } SSegment.length = Segment->length; SSegment.has_length = Segment->has_length; SSegment.n_brushstops = Segment->brushstopscount; |
