diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
3 files changed, 48 insertions, 11 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 7d4b66dfb..1f9897905 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -17,6 +17,9 @@ #include "Modules/General/process.h" #include "Modules/control/pidalgo.h" +#include "Modules/heaters/heaters_ex.h" +#include "StateMachines/Initialization/InitSequence.h" + #include "PMR/Hardware/HardwareMotor.pb-c.h" #include "PMR/Hardware/HardwareMotorType.pb-c.h" #include "PMR/Hardware/HardwareDancerType.pb-c.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 7e1312464..e01d12a05 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -59,10 +59,11 @@ static uint32_t WindingConeLocation; static uint32_t WinderBackToBaseTime = 800; InternalWinderConfigStruc InternalWinderCfg = {0}; - +#define READ_SCREW_ENCODER +#ifdef READ_SCREW_ENCODER uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0; uint32_t ScrewLocationRun[3]; - +#endif bool SampleWinding = false; uint32_t Winder_Init(void) { @@ -89,6 +90,8 @@ uint32_t InternalWinderConfigMessage(HardwareWinder* request) return status; } +char ScrewStr[150]; + uint32_t InternalWindingConfigMessage(JobSpool* request) { uint32_t status = PASSED; @@ -99,6 +102,9 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*2;//request->rotationsperpassage; 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); + Report(ScrewStr,__FILE__,__LINE__,(int)InternalWinderCfg.diameter,RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); return status; } @@ -132,8 +138,10 @@ uint32_t Winder_Prepare(void *JobDetails) return ERROR; }*/ +#ifdef READ_SCREW_ENCODER ScrewLocationRun[0] = 0; ScrewLocationRun[1] = 0; +#endif if (( KeepWindingCone == false)||(WindingConeLocation == 0)) { WindingConeLocation = InternalWinderCfg.startoffsetpulses; @@ -176,10 +184,11 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); +#ifdef READ_SCREW_ENCODER Read_Screw_Encoder(); ScrewLocationLimitSwitch = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationLimitSwitch, "Winder_PrepareStage2 Encoder Location"); - +#endif REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2"); if (ReadValue != LIMIT) @@ -203,6 +212,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands Task_sleep(5); +#ifdef READ_SCREW_ENCODER Reset_Screw_Encoder(); Task_sleep(5); Read_Screw_Encoder(); @@ -210,10 +220,13 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewLocationStart = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); +#endif SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home ScrewCurrentDirection = false; +#ifdef READ_SCREW_ENCODER ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; +#endif ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; @@ -249,7 +262,7 @@ InternalWinderCfg.segmentoffsetpulses numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; */ -char ScrewStr[150]; + //char TempScrewStr[100]; double WinderReferenceSpeed=0; double TotalWinderSpeed=0; @@ -259,13 +272,17 @@ int flipflop = 0; uint32_t motspeed; float speedf; int WinderCalculation = 0; +#ifdef READ_SCREW_ENCODER +float WinderRunAverage = 0.0,WinderRunSum = 0.0; +int WinderRunSamples = 0; +#endif uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { //uint32_t Steps; double temp,tempScrewSpeed; double screw_horizontal_speed = 0; double RotationsPerSecond; - double Averagewinderspeed = 0; + //double Averagewinderspeed = 0; // { // TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter]; @@ -302,13 +319,29 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) if (SampleWinding) return OK; //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); +#ifdef READ_SCREW_ENCODER + int WinderRun; + WinderRun = abs(ScrewLocationRun[1] - ScrewLocationRun[0]); + if ((WinderRun < 50000)&&(Add100 == false)) + { + WinderRunSum+=WinderRun; + WinderRunSamples++; + WinderRunAverage = WinderRunSum/WinderRunSamples; + if ((fabs(WinderRun-WinderRunAverage)>=30)||(WinderRunSamples%100 == 0)) + { + usnprintf(ScrewStr, 150, "curr,sum,avg,samples {Winder Encoder:, %d, %d, %d, %d, %d}",WinderRun,(int)WinderRunSum,(int)WinderRunAverage,(int)WinderRunSamples, + (int)(100*WinderRun/ScrewNumberOfSteps)); + Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); + } + } + //Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); + //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__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); - +#endif if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out { if (Add100 == true) //once per job @@ -617,11 +650,13 @@ void ScrewTimerInterrupt(int ARG0) 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); +#ifdef READ_SCREW_ENCODER + Read_Screw_Encoder(); ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; +#endif // ScrewChangeCounter = 0; // ScrewChangeLimit = ScrewRunningTime/12000000; ScrewDirectionChangeCounter++; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index a88ce61a5..59542ec38 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -288,7 +288,6 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) //} - length = (double)(positionDiff)*PoolerLengthCalculationMultiplier; PoolerTotalProcessedLength+= (length/100); TempPoolerTotalProcessedLength = PoolerTotalProcessedLength; #ifndef FEEDER_LENGTH_CALCULATION @@ -452,7 +451,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) //read value is the dancer angle int i,index=MAX_THREAD_MOTORS_NUM; int DancerId; - int32_t TranslatedReadValue, avreageSampleValue = 0,avreageMotorSampleValue = 0; + int32_t TranslatedReadValue, avreageSampleValue = 0;//,avreageMotorSampleValue = 0; //double tempcalcspeed = 0; double calculated_speed; double NormalizedError; |
