aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-03-29 15:46:42 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-03-29 15:46:42 +0300
commitfd16e827fd4d59636798c4cd4a7ebd00c3cb146f (patch)
treee284c218e6c4bfbede448fb18e6c5e598c44ceaf /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
parent08bd4400dfd45245ae301b5cb28103322ddf865a (diff)
downloadTango-fd16e827fd4d59636798c4cd4a7ebd00c3cb146f.tar.gz
Tango-fd16e827fd4d59636798c4cd4a7ebd00c3cb146f.zip
State machine handling
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 05fb0a934..9474ee44d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -15,11 +15,11 @@ uint32_t Winder_PrepareStage2(void);
uint32_t Winder_Init(void)
{
-
+ return OK;
}
uint32_t Winder_Prepare(void)
{
- uint32_t status;
+ uint32_t status = 0;
/*
* 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.
* 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done
@@ -34,9 +34,9 @@ uint32_t Winder_Prepare(void)
{
Winder_ScrewHoming = true;
status = MotorSetDirection(MOTOR_SCREW,1);//make sur to move the cart home
- status = MotorSetSpeed(MOTOR_SCREW, MotorsCfg[SCREW_MOTOR].maxfreq, 8);
-
+ status |= MotorSetSpeed(MOTOR_SCREW, MotorsCfg[SCREW_MOTOR].maxfreq, 8);
}
+ return status;
}
uint32_t Winder_PrepareStage2(void)
{
@@ -48,22 +48,53 @@ uint32_t Winder_PrepareStage2(void)
* report ready to the job STM
*/
status = MotorSetDirection(MOTOR_SCREW,0);//make sur to move the cart out
- status |= MotorMoveSteps (MOTOR_SCREW, numOfSteps, Winder_ScrewAtOffsetCallback);
- status |= MotorSetSpeed(MOTOR_SCREW, MotorsCfg[SCREW_MOTOR].maxfreq, 8);
-
+ //status |= MotorMoveSteps (MOTOR_SCREW, numOfSteps, Winder_ScrewAtOffsetCallback);
+ //set motor location 0 here
return status;
}
-uint32_t Winder_Print(void)
+uint32_t Winder_Print(void *JobDetails)
{
- /*
- * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec)
- * calculate
- */
+ JobTicket* JobTicket = JobDetails;
+ int process_speed = JobTicket->processparameters->dyeingspeed;
+ int dryer_speed = process_speed * MotorsCfg[DRYER_MOTOR].ratio2dryerspeed; //set dryer_speed_translation_here
+ float screw_speed = 0;
+ float RotationsPerSecond;
+
+/*typedef struct
+{
+ uint32_t startoffsetpulses;
+ uint32_t spoolbackingrate;
+ uint32_t segmentoffsetpulses;
+ uint32_t milimetersperrotation;
+ int32 SpoolBottomBackingRate;// the angle of the bottom of the spool
+ double NumberOfRotationPerPassage; // how many rotations per spool passage
+}InternalWinderConfigStruc;
+ * */
+// * 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.
+ screw_speed = InternalWinderCfg.segmentoffsetpulses / 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 = process_speed / (InternalWinderCfg.diameter * 3.1416);
+ // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm.
+ screw_speed = screw_speed*RotationsPerSecond;
+ //screw_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
+
+ //MotorMove (InternalWinderCfg.segmentoffsetpulses,screw_speed); process: set point 0, set max speed, move to the specified length, return back.
+ //in a callback: calculate backing rate for top and bottom, update point 0, update passing length, call the appropriate move to 0 / move;
+
+ return OK;
}
uint32_t Winder_End(void)
{
//stop screw
+ StopMotor (MOTOR_SCREW,1);
}
void Winder_ScrewHomeLimitSwitchInterrupt(void)
{
@@ -78,13 +109,13 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t NumberOfSteps)
{
if (NumberOfSteps == InternalWinderCfg.segmentoffsetpulses)
{
- JobPrepareReady(Module_Winder, OK);
+ PrepareReady(Module_Winder, OK);
return OK;
}
else
{
//do we want to do something?
- JobPrepareReady(Module_Winder, ERROR);
+ PrepareReady(Module_Winder, ERROR);
return ERROR;
}