aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-07-01 09:20:52 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-07-01 09:20:52 +0300
commitc0fd8dcc53e45aa5aa0095cc2c8c5f39a34f7886 (patch)
treeda928ff13c0e2396b5c1dca42c90010c876b2b8f /Software/Embedded_SW/Embedded/Modules/Thread
parent6aac50de73d56076303065e17046833247985cf8 (diff)
parent27081ed8160540b63f19a3328822a9550da4ce02 (diff)
downloadTango-c0fd8dcc53e45aa5aa0095cc2c8c5f39a34f7886.tar.gz
Tango-c0fd8dcc53e45aa5aa0095cc2c8c5f39a34f7886.zip
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h3
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c152
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c16
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c99
5 files changed, 206 insertions, 68 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
index 0093a5a2a..230d06601 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
@@ -52,6 +52,9 @@ extern HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM];
extern bool BreakSensorenabled;
extern int32_t BreakSensordebouncetimemilli;
+extern bool SampleWinding;
+
+
//extern MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS];
extern HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM];
//extern InternalWinderConfigStruc InternalWinderCfg;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 297cea44b..8943e5d30 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -36,6 +36,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue);
void ScrewTimerInterruptInit(void);
void ScrewsStopControlTimer (void);
void ScrewsStartControlTimer (void);
+void ScrewTimerInterrupt(int);
bool Winder_ScrewHoming = false;
bool ScrewCurrentDirection = false; //holds current screw direction
@@ -58,6 +59,7 @@ InternalWinderConfigStruc InternalWinderCfg = {0};
uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0;
uint32_t ScrewLocationRun[3];
+bool SampleWinding = false;
uint32_t Winder_Init(void)
{
ScrewTimerInterruptInit();
@@ -92,8 +94,10 @@ uint32_t InternalWindingConfigMessage(JobSpool* request)
* 1. move home to the limit switch (check that the cart is clear from the limit switch, start moving, with acceleration to maximal speed. enable interrupt on the limit switch, upon interrupt stop.
* report ready to the job STM
*/
-uint32_t Winder_Prepare(void)
+uint32_t Winder_Prepare(void *JobDetails)
{
+ JobTicket* JobTicket = JobDetails;
+
uint32_t status = 0;
//JobTicket* JobTicket = JobDetails;
//float process_speed = JobTicket->processparameters->dyeingspeed;
@@ -117,6 +121,11 @@ uint32_t Winder_Prepare(void)
ScrewLocationRun[0] = 0;
ScrewLocationRun[1] = 0;
+ if (JobTicket->has_samplewinding == true)
+ {
+ SampleWinding = JobTicket->samplewinding;
+ SampleWinding = true;
+ }
if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT)
{
//REPORT_MSG(LIMIT, "Winder_Prepare at limit");
@@ -167,7 +176,6 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
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);
MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands
@@ -179,6 +187,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
ScrewLocationStart = Screw_RotEnc.Position;
REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location");
+ SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
ScrewCurrentDirection = false;
ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;
@@ -267,6 +276,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
ScrewCurrentDirection = 1-ScrewCurrentDirection;
CalculationDirectionChangeCounter++;
+ 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);
@@ -348,10 +359,14 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
{
return PreSegmentReady(Module_Winder,ModuleDone);
}
+uint32_t WinderSamplesSegmentCallback(uint32_t SegmentDetails, uint32_t SegmentId)
+{
+ ScrewTimerInterrupt(0);
+ return OK;
+}
uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
{
- //JobTicket* JobTicket = JobDetails;
double screw_horizontal_speed = 0;
double RotationsPerSecond;
double temp = 0;
@@ -361,78 +376,110 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId)
return ERROR;
}
- 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)
+ if ((SegmentId == 0)||(SampleWinding)) // 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 -= 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.
- //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI);
- 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;
+ ScrewCurrentDirection = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize;
+ if ((SegmentId > 0)&&(SampleWinding))
+ {
+ InternalWinderCfg.segmentoffsetpulses = 120;
+ MotorGotoWithBusyCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW,true, (InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1)), WinderSamplesSegmentCallback,2000); //TODO
+ Report("ScrewsMotorGoTo direction,speed ", __FILE__,__LINE__,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1), RpMessage, ScrewSpeed, 0);
+ InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples
+ InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ JobSegment* Segment = SegmentDetails;
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/3);
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- //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;
+ //three passages during the segment
+ }
+ else if (SampleWinding) //first segment
+ {
+ //InternalWinderCfg.segmentoffsetpulses = 120;
+ InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples
+ InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ JobSegment* Segment = SegmentDetails;
+ InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw
+ ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/20);
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ }
+ else if ((SegmentId == 0)&&(SampleWinding == false))
+ {
+ /*
+ // * 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 -= 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.
+ //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI);
+ 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;
+ ScrewNumberOfSteps -= 100;
+ Add100 = false;
+ LOG_ERROR(Add100, "Add100 = false");
+ }
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;
+ ScrewDirectionChangeCounter = 1;
+ CalculationDirectionChangeCounter = 1;
+ memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) );
+ WinderMotorSpeedCounter=0;
+ TotalWinderSpeed = 0;
+ WinderMotorSpeedRollOver=false;
///////////////////////
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed;
WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR];
//screw_horizontal_speed = InternalWinderCfg.milimetersperrotation
- // * 2. determine optimal micro-step setting
- // * 3. calculate cart travel length from winding parameters
- // * 4. start move of travel length
- // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed
+ // * 2. determine optimal micro-step setting
+ // * 3. calculate cart travel length from winding parameters
+ // * 4. start move of travel length
+ // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed
temp = SYS_CLK_FREQ;
temp *= ScrewNumberOfSteps;
temp /= ScrewSpeed;
ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed;
- REPORT_MSG(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps");
- REPORT_MSG(ScrewRunningTime,"Winder pre segment - ScrewRunningTime");
-// MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
+ REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps");
+ REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime");
+ //MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
//ScrewDirection = 1-ScrewDirection;
REPORT_MSG(SegmentId,"Winder pre segment - SegmentId");
REPORT_MSG(ScrewSpeed,"Winder pre segment - ScrewSpeed");
//MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
ScrewsStartControlTimer ();
- ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0);
- ScrewDirectionChangeCounter = 1;
- CalculationDirectionChangeCounter = 1;
- memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) );
- WinderMotorSpeedCounter=0;
- TotalWinderSpeed = 0;
- WinderMotorSpeedRollOver=false;
- Add100 = false;
- LOG_ERROR(Add100, "Add100 = false");
}
+ if (SegmentId == 0)
+ {
+ ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0);
+ }
PreSegmentReady(Module_Winder,ModuleDone);
return OK;
@@ -560,6 +607,7 @@ void ScrewTimerInterrupt(int ARG0)
TimerDisable(Screw_timerBase, TIMER_A);
}
ROM_IntMasterEnable();
+ //Report("ScrewsStartControlTimer direction,speed ", __FILE__,__LINE__,ScrewCurrentDirection, RpMessage, ScrewSpeed, 0);
//MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
//Rotations+=0.03;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index ead318758..167616afe 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -22,6 +22,7 @@ typedef enum threadMotorsEnum
}threadMotorsEnum;
extern double TotalProcessedLength;
+extern double PoolerTotalProcessedLength;
void ThreadSetBreakSensorLimit(int limit);
@@ -42,8 +43,9 @@ uint32_t LoadDancerConfigMessage(void);
//uint32_t MotorPidRequestMessage(HardwarePidControl* request);
uint32_t Winder_Init(void);
-uint32_t Winder_Prepare(void);
+uint32_t Winder_Prepare(void *JobDetails);
uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId);
+uint32_t WinderDistanceToSpoolState(void );
uint32_t Winder_End(void);
typedef enum
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index b741f33f3..529e4d260 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -17,6 +17,7 @@
#include "Common/SWUpdate/FileSystem.h"
#include "drivers/Flash_Memory/fatfs/ff.h"
#include "drivers/SSI_Comm/Dancer/Dancer.h"
+#include "drivers/Flash_ram/FlashProgram.h"
#include "thread.h"
MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]={0};
@@ -151,6 +152,12 @@ uint32_t StoreDancerConfigMessage()
response_size = hardware_configuration__pack(&DancerConfig, response_buffer);
}
Fresult = FileWrite(response_buffer,response_size,DancerConfigPath);
+ EraseFlashSection(DANCERS_MAP_IN_FLASH,1024);
+ for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++)
+ {
+ ReadAppAndProgram(DANCERS_MAP_IN_FLASH, sizeof(Dancers), Dancers);
+ }
+
my_free(response_buffer);
return Fresult;
@@ -163,6 +170,9 @@ uint32_t LoadDancerConfigMessage()
HardwareConfiguration *DancerConfig;
int Dancer_i;
+ HardwareDancer DancersCfg1[MAX_SYSTEM_DANCERS] = {0};
+
+ memcpy(DancersCfg1,(void *)DANCERS_MAP_IN_FLASH,sizeof(DancersCfg1));
Fresult = FileRead(DancerConfigPath, &Bytes, &buffer);
if (Fresult == FR_OK)
@@ -175,6 +185,12 @@ uint32_t LoadDancerConfigMessage()
hardware_configuration__free_unpacked(DancerConfig,NULL);
free (buffer);
}
+
+ if (DancersCfg[0].zeropoint != DancersCfg1[0].zeropoint) LOG_ERROR(DancersCfg[0].zeropoint,"DancersMismatch");
+ else if (DancersCfg[1].zeropoint != DancersCfg1[1].zeropoint) LOG_ERROR(DancersCfg[1].zeropoint,"DancersMismatch");
+ else if (DancersCfg[2].zeropoint != DancersCfg1[2].zeropoint) LOG_ERROR(DancersCfg[2].zeropoint,"DancersMismatch");
+ else LOG_ERROR(DancersCfg[0].zeropoint,"Dancers Match!!");
+
return Fresult;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 502832cd3..5efc3798e 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -67,6 +67,7 @@ double PoolerLengthCalculationMultiplier;
double TempPoolerTotalProcessedLength = 0.0;
double TempTotalProcessedLength = 0.0;
+bool InitialProcess = false;
bool PrepareState = false;
// job parameters
bool EnableLubrication = false;
@@ -148,10 +149,12 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
double length = 0.0;
int index = MAX_THREAD_MOTORS_NUM;
- // if (ThreadControlActive == false)
- // return OK;
- // if (PrepareState == true)
- // return OK;
+#ifndef FEEDER_LENGTH_CALCULATION
+ if (ThreadControlActive == false)
+ return OK;
+ if (PrepareState == true)
+ return OK;
+#endif
if (IfIndex>>8 != IfTypeThread)
{
LOG_ERROR (IfIndex, "Wrong Interface type");
@@ -194,13 +197,14 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
}
+ TotalProcessedLength += (length/100);
+ TempTotalProcessedLength = TotalProcessedLength;
+#ifdef FEEDER_LENGTH_CALCULATION
CurrentProcessedLength+=length;
- static int pooler_counter = 0;
- pooler_counter++;
- TotalProcessedLength+= (length/100);
- TempTotalProcessedLength = TotalProcessedLength;
- if (pooler_counter%10 == 0)
+ static int feeder_counter = 0;
+ feeder_counter++;
+ if (feeder_counter%10 == 0)
{
if (PrepareState == true)
{
@@ -225,18 +229,22 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
ProcessedLengthFuncPtr();
}
-return OK;
+#endif
+
+ return OK;
}
uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
- uint32_t positionDiff = 0;
+ uint32_t positionDiff = 0,prevprev;
double length = 0.0;
int index = MAX_THREAD_MOTORS_NUM;
+#ifdef FEEDER_LENGTH_CALCULATION
if (ThreadControlActive == false)
return OK;
if (PrepareState == true)
return OK;
+#endif
if (IfIndex>>8 != IfTypeThread)
{
LOG_ERROR (IfIndex, "Wrong Interface type");
@@ -258,13 +266,56 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
PoolerPreviousPosition = PoolerCurrentPosition;
Poolerinitialpos = 0;
}
+ prevprev = PreviousPosition;
positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition);
//positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep;
PoolerPreviousPosition = PoolerCurrentPosition;
length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
- PoolerTotalProcessedLength+= (length/100);
- TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
+ //if (InitialProcess == false)
+ {
+ PoolerTotalProcessedLength+= (length/100);
+ TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
+ }
+ if (length > 1000)
+ {
+ usnprintf(Lenstr, 100, "pooler 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;
+
+ }
+#ifndef FEEDER_LENGTH_CALCULATION
+ CurrentProcessedLength+=length;
+
+ static int puller_counter = 0;
+ puller_counter++;
+ if (puller_counter%10 == 0)
+ {
+ if (PrepareState == true)
+ {
+ //later - add temperatures
+ TemperatureListString(Lenstr);
+
+ SendJobProgress(0.0,0,false, Lenstr);
+ }
+ else
+ {
+ SendJobProgress(PoolerTotalProcessedLength,0,false, NULL);
+ }
+
+ }
+ if ((CurrentProcessedLength>=CurrentRequestedLength )&&(CurrentRequestedLength > 0.0))
+ {
+ usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ SendJobProgress(0.0,0,false, Lenstr);
+ Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+ // segment/intersegment/distance to spool finished
+ if (ProcessedLengthFuncPtr)
+ ProcessedLengthFuncPtr();
+
+ }
+#endif
return OK;
}
@@ -632,7 +683,6 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request)
ThreadPreSegmentState(request,0);
return OK;
}
-bool InitialProcess = false;
//********************************************************************************************************************
uint32_t ThreadPrepareState(void *JobDetails)
@@ -780,6 +830,12 @@ void SetOriginMotorSpeed(float process_speed)
MotorSpeedSamples[Motor_i][i] = motor_speed;
}
}
+void ThreadPreSegmentEnded(void)
+{
+ InitialProcess = false;
+ REPORT_MSG (0,"First ThreadPreSegmentEnded");
+ PreSegmentReady(Module_Thread,ModuleDone);
+}
//********************************************************************************************************************
uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId)
@@ -834,6 +890,14 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId)
PreSegmentState = true;
DTSState = false;
}
+ /*else if (InitialProcess==true)
+ {
+ ThreadUpdateProcessLength (dryerbufferlength,(void *)ThreadPreSegmentEnded);
+ REPORT_MSG (dryerbufferlength," ThreadPreSegmentState DTS length (sample)");
+ SegmentState = false;
+ PreSegmentState = true;
+ DTSState = false;
+ }*/
else
{
ThreadUpdateProcessLength (0,(void *)NULL);
@@ -893,7 +957,12 @@ uint32_t ThreadDistanceToSpoolState(void )
{
seglength = dryerbufferlength;
REPORT_MSG (seglength,"ThreadDistanceToSpoolState");
+//#ifdef FEEDER_LENGTH_CALCULATION
ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded);
+/*#else
+ ThreadUpdateProcessLength (0,(void *)NULL); //move DTS to job start
+ DistanceToSpoolReady(Module_Thread,ModuleDone);
+#endif*/
SegmentState = false;
PreSegmentState = false;
DTSState = true;
@@ -940,7 +1009,7 @@ char Endstr[150];
LOG_ERROR (ControlIdtoMotorId[Motor_i],"Remove Control failed");
}
}
- Task_sleep(10);
+ Task_sleep(10);
for ( Motor_i = 0;Motor_i <= WINDER_MOTOR;Motor_i++)
{
MotorStop(ThreadMotorIdToMotorId[Motor_i],Hard_Hiz);