aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2019-06-05 10:51:23 +0300
committerMirta <mirta@twine-s.com>2019-06-05 10:51:23 +0300
commit6effa882fd25b0b4f9d44d143a0e66f04ae075fc (patch)
treee3c9e80815ac77436deefa52e5f06d3100a5f268 /Software/Embedded_SW/Embedded/Modules/Thread
parentf2b43686dc1dae61fbb053e31928712d9805194c (diff)
parentf9567b74a6fa6db7b4203dac0f79ebb7555f1512 (diff)
downloadTango-6effa882fd25b0b4f9d44d143a0e66f04ae075fc.tar.gz
Tango-6effa882fd25b0b4f9d44d143a0e66f04ae075fc.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c172
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c31
6 files changed, 152 insertions, 65 deletions
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 f1c8956ff..2bbc93523 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 1200
+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;
+int flipflop = 0;
+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 == 0)
+ {
+ MotorGetSpeedFromFPGA1(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
}
+ else if (flipflop == 1)
+ {
+ speedf = MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
+ }
+ flipflop ++;
if (ScrewDirectionChangeCounter == CalculationDirectionChangeCounter)
return OK;
+ //deley TODO
+ flipflop = 0;
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,42 +294,46 @@ 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 = ScrewSpeed;
+
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);
- //usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed);
+ usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed);
// Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]);
// #warning PID is now only proportional (above)
//Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 0);
- //Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 0);
+ Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 0);
//REPORT_MSG(temp , "new winder speed");
//Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0);
}
@@ -340,12 +364,12 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job)
{
ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);
-
+/*
// * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec)
// * calculate
// * 1. calculate speed according to JobTicket->processparameters->dyeingspeed
// * calculation input: traverse length in milimeters/pulses, number of rotations per traverse ==> length of traverse per rotation.
- ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
ScrewNumberOfSteps -= 100;
screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage;
// calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second.
@@ -353,13 +377,32 @@ 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);
//REPORT_MSG(segmentfirst_speed,ScrewStr);
Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0);
SendJobProgress(0.0,0,false, ScrewStr);
+*/
+ // * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec)
+ // * calculate
+ // * 1. calculate speed according to JobTicket->processparameters->dyeingspeed
+ // * calculation input: traverse length in pulses, number of rotations per traverse ==> length of traverse per rotation.
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; //steps per winder cycle
+ // calculation input#2: number of rotations per second - speed/winder diameter. WE USE HERE 39 MM AS ATHE WINDER DIAMETER - SOME AVERAGE BETWEEN EMPTY AND FULL
+ RotationsPerSecond = (dyeingspeed*10.0)/(19.50*PI);
+ // 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;
+ usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond*100,(int)screw_horizontal_speed*100,(int)ScrewSpeed);
+ //REPORT_MSG(segmentfirst_speed,ScrewStr);
+ Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0);
+ SendJobProgress(0.0,0,false, ScrewStr);
+ ScrewNumberOfSteps -= 100;
+
+ ///////////////////////
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed;
WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR];
@@ -394,6 +437,42 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
return OK;
}
+uint32_t ScrewDTSControlId = 0xFF;
+uint32_t WinderDistanceToSpoolEnded(uint32_t deviceID, uint32_t ReadValue)
+{
+ REPORT_MSG ((int)msec_millisecondCounter,"WinderDistanceToSpoolEnded called");
+}
+uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
+{
+ REPORT_MSG ((int)msec_millisecondCounter,"ScrewDTSCallback called");
+ SafeRemoveControlCallback(ScrewDTSControlId, ScrewDTSCallback);
+
+ if (ScrewControlId != 0xFF)
+ {
+ RemoveControlCallback(ScrewControlId,Screw100msecDirectionChange);
+ ScrewControlId = 0xFF;
+ }
+ CurrentControlledSpeed[SCREW_MOTOR] = 0;
+ ScrewsStopControlTimer();
+ //move the cart to the edge so the spool can be easily replaced
+ //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0);
+ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000);
+
+
+ return OK;
+}
+uint32_t WinderDistanceToSpoolState(void )
+{
+ double DTS_Time = ((dryerbufferlength*100)/dyeingspeed)*1000;//distance to spool time in milliseconds
+ REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState");
+
+ ScrewDTSControlId = AddControlCallback(ScrewDTSCallback, DTS_Time-800,TemplateDataReadCBFunction,0,0,0);
+ REPORT_MSG ((int)msec_millisecondCounter,"ScrewDTSCallback start");
+
+ return OK;
+}
+
uint32_t Winder_End(void)
{
//stop screw
@@ -458,20 +537,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 +560,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..b741f33f3 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};
@@ -56,7 +56,7 @@ uint32_t MotorsConfigMessage(HardwareMotor * request)
MotorsCfg[Motor_i].pulseperround = request->pulseperround;
MotorsCfg[Motor_i].pulleyradius = request->pulleyradius;
MotorsCfg[Motor_i].configword = request->configword;
- if(MotorDriverResponse[Motor_i].DriverType == VoltageCombinedMotDriver)
+ if(MotorDriverResponse[Motor_i].DriverType == CombinrdMotDriver)
{
MotorsCfg[Motor_i].directionthreadwize = !(request->directionthreadwize);//PowerSTEP01
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 25485290b..4743008e5 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];
@@ -114,7 +114,10 @@ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Rea
if (Current_Read < Previous_Read)
+ {
Time_Pass = (MAX_COUNTER - Previous_Read) + Current_Read + 1;
+ Report("Length rollover",__FILE__,__LINE__,(int)Current_Read,RpWarning,(int)Previous_Read,0);
+ }
else
Time_Pass = Current_Read - Previous_Read;
@@ -186,6 +189,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 +279,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 +301,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 +309,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 +397,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 +555,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 +591,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
#endif
}
else
+ {
MotorFailedSample[index]++;
+ //LOG_ERROR(index,"No change in speed");
+ }
}
@@ -595,7 +602,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
//********************************************************************************************************************
-uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId)
+double ThreadGetMotorSpeed(threadMotorsEnum MotorId)
{
return CurrentControlledSpeed[MotorId];
}
@@ -767,7 +774,7 @@ void SetOriginMotorSpeed(float process_speed)
//MotorControlConfig[Motor_i].m_SetParam = motor_speed;
OriginalMotorSpd_2PPS[Motor_i] = (int) motor_speed;
CurrentControlledSpeed[Motor_i] = (int) motor_speed;
- Report("Original Speed",__FILE__,Motor_i,motor_speed,RpWarning,process_speed,0);
+ //Report("Original Speed",__FILE__,Motor_i,motor_speed,RpWarning,process_speed,0);
for (i = 0; i <= MAX_CONTROL_SAMPLES; i++)
MotorSpeedSamples[Motor_i][i] = motor_speed;