aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-08-14 15:11:15 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-08-14 15:11:15 +0300
commit517b7d9643f336d498fada274d6666da38e42c06 (patch)
tree985bca29a489d6ff1cb92a6abe09362b90144237 /Software/Embedded_SW/Embedded/Modules/Thread
parenta4350b6fd0854e467838a42be89fa343d0b659c1 (diff)
downloadTango-517b7d9643f336d498fada274d6666da38e42c06.tar.gz
Tango-517b7d9643f336d498fada274d6666da38e42c06.zip
Version 1.4.3.7 VOC sensors, disable saving dispenser data to flash during a job (winder jump), screw encoder data,power off and init improved.
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 7e1312464..0ed0f5318 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,6 +272,8 @@ int flipflop = 0;
uint32_t motspeed;
float speedf;
int WinderCalculation = 0;
+float WinderRunAverage = 0.0,WinderRunSum = 0.0;
+int WinderRunSamples = 0;
uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
//uint32_t Steps;
@@ -266,6 +281,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
double screw_horizontal_speed = 0;
double RotationsPerSecond;
double Averagewinderspeed = 0;
+ int WinderRun;
+
// {
// TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter];
@@ -302,13 +319,28 @@ 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
+ 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
@@ -321,7 +353,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
ScrewNumberOfSteps--;
WindingConeLocation--;
- // ReportWithPackageFilter(ThreadFilter,"Head Backing",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
+ ReportWithPackageFilter(ThreadFilter,"Head Backing",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
}
}
else //next time going back
@@ -329,7 +361,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.SpoolBottomBackingRate == 0)
{
ScrewNumberOfSteps++;
- // Report("Bottom Backing ",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
+ Report("Bottom Backing ",__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewNumberOfSteps, 0);
}
}
/* if (WinderMotorSpeedRollOver)
@@ -617,11 +649,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++;