aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-12-17 14:54:33 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-12-17 14:54:33 +0200
commit5cb32e4d23885b476f34547f2bc36e4b057ead0e (patch)
tree9894b12576343b3d233de7f194c85cb93bb77049 /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
parent3b2d3e0e07b6115b143fb8d4a48cb94bb1e17f95 (diff)
downloadTango-5cb32e4d23885b476f34547f2bc36e4b057ead0e.tar.gz
Tango-5cb32e4d23885b476f34547f2bc36e4b057ead0e.zip
Winder bugs. improved trace, improved control (callback invoked after time requested elabsed)
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index d92e6a330..2b6d3aaea 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -124,7 +124,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
- REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2");
+ REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2");
status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback);
//set motor location 0 here
@@ -141,7 +141,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
ScrewSpeed = 0;
ScrewControlId = 0xFF;
ScrewNumberOfSteps = 0;
- REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback");
+ 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;
@@ -175,15 +175,20 @@ InternalWinderCfg.segmentoffsetpulses
numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
*/
char ScrewStr[100];
+//char TempScrewStr[100];
+double WinderReferenceSpeed=0;
+int32_t TotalWinderSpeed=0;
uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
- uint32_t Steps,i,winderspeed=0;
+ uint32_t Steps,i;
double temp;
- uint32_t WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR];
- float screw_horizontal_speed = 0;
- float RotationsPerSecond;
+ double screw_horizontal_speed = 0;
+ double RotationsPerSecond;
+ int32_t Averagewinderspeed = 0;
+ TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter];
WinderMotorSpeed[WinderMotorSpeedCounter] = CurrentControlledSpeed[WINDER_MOTOR];
+ TotalWinderSpeed+=WinderMotorSpeed[WinderMotorSpeedCounter];
if (WinderMotorSpeedCounter++>=MAX_WINDER_SPEED_CALCULATION)
{
WinderMotorSpeedCounter=0;
@@ -215,18 +220,18 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
}
if (WinderMotorSpeedRollOver)
{
- for (i=0;i<MAX_WINDER_SPEED_CALCULATION;i++)
+ /*for (i=0;i<MAX_WINDER_SPEED_CALCULATION;i++)
{
- winderspeed+=WinderMotorSpeed[i];
- }
- winderspeed/=MAX_WINDER_SPEED_CALCULATION;
+ TotalWinderSpeed+=WinderMotorSpeed[i];
+ }*/
+ Averagewinderspeed = TotalWinderSpeed/MAX_WINDER_SPEED_CALCULATION;
//REPORT_MSG(winderspeed, "WinderSpeedUpdated");
- Report("WinderSpeedUpdated",__FILE__,__LINE__,winderspeed,RpWarning,ScrewNumberOfSteps,0);
+ Report("WinderSpeedUpdated",__FILE__,__LINE__,TotalWinderSpeed,RpWarning,Averagewinderspeed,0);
- WinderReferenceSpeed = winderspeed;
+ WinderReferenceSpeed = Averagewinderspeed;
}
screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage;
- RotationsPerSecond = WinderReferenceSpeed / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
+ RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
temp = SYS_CLK_FREQ;
@@ -234,9 +239,11 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
temp /= ScrewSpeed;
if (ScrewRunningTime != temp)
{
- usnprintf(ScrewStr, 254, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",ScrewNumberOfSteps,ScrewSpeed,temp,WinderReferenceSpeed);
+ //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);
// 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_MSG(temp , "new winder speed");
//Report("new winder speed",__FILE__,__LINE__,temp,RpWarning,ScrewSpeed,0);
@@ -256,9 +263,8 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
{
//JobTicket* JobTicket = JobDetails;
- float screw_horizontal_speed = 0;
- float RotationsPerSecond;
- char Message[80];
+ double screw_horizontal_speed = 0;
+ double RotationsPerSecond;
double temp = 0;
if (dyeingspeed == 0)
{
@@ -282,13 +288,14 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
- usnprintf(Message, 80, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed);
- //REPORT_MSG(segmentfirst_speed,Message);
- //Report(Message,__FILE__,__LINE__,Dispenser_i,RpWarning,segmentfirst_speed,0);
- SendJobProgress(0.0,0,false, Message);
+ 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);
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
@@ -311,6 +318,7 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
CalculationDirectionChangeCounter = 1;
memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) );
WinderMotorSpeedCounter=0;
+ TotalWinderSpeed = 0;
WinderMotorSpeedRollOver=false;
}
PreSegmentReady(Module_Winder,ModuleDone);