diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:22:12 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:22:12 +0300 |
| commit | 2f1579f22a700dc64533532d533dfacb3a3531d0 (patch) | |
| tree | f88cf8c1ae220e2d632965a9290ee788f3dcd3cc /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | |
| parent | 1061758f95b7ba633e6bcc2c3556b42f033b1a79 (diff) | |
| parent | bca898b563219f5d02fb7d611a49f2a20306f214 (diff) | |
| download | Tango-2f1579f22a700dc64533532d533dfacb3a3531d0.tar.gz Tango-2f1579f22a700dc64533532d533dfacb3a3531d0.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c new file mode 100644 index 000000000..05fb0a934 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -0,0 +1,92 @@ +/* + * Thread_Winder.c + * + * Created on: 25 במרץ 2018 + * Author: shlomo + */ +#include"include.h" +#include "thread.h" +#include "Drivers/Peripheral_GPIO/GPIO.h" +#include "drivers/Motors/Motor.h" +#include "StateMachines/Printing/PrintingSTM.h" +bool Winder_ScrewHoming = false; +uint32_t Winder_ScrewAtOffsetCallback(uint32_t NumberOfSteps); +uint32_t Winder_PrepareStage2(void); + +uint32_t Winder_Init(void) +{ + +} +uint32_t Winder_Prepare(void) +{ + uint32_t status; + /* + * 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 + * report ready to the job STM + */ + if (PollGPIO(GPI113_LS_SCREW_RIGHT)) + { + //go to prepare stage 2 + Winder_PrepareStage2(); + } + else + { + Winder_ScrewHoming = true; + status = MotorSetDirection(MOTOR_SCREW,1);//make sur to move the cart home + status = MotorSetSpeed(MOTOR_SCREW, MotorsCfg[SCREW_MOTOR].maxfreq, 8); + + } +} +uint32_t Winder_PrepareStage2(void) +{ + uint32_t status; + uint32_t numOfSteps = InternalWinderCfg.segmentoffsetpulses; + /* + * 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 + * 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); + + return status; + +} +uint32_t Winder_Print(void) +{ + /* + * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec) + * calculate + */ +} +uint32_t Winder_End(void) +{ + //stop screw +} +void Winder_ScrewHomeLimitSwitchInterrupt(void) +{ + uint32_t status; + if (Winder_ScrewHoming) + { + StopMotor(MOTOR_SCREW,3); //stop ASAP + } + status = MotorSetDirection(MOTOR_SCREW,0);//make sur to move the cart out +} +uint32_t Winder_ScrewAtOffsetCallback(uint32_t NumberOfSteps) +{ + if (NumberOfSteps == InternalWinderCfg.segmentoffsetpulses) + { + JobPrepareReady(Module_Winder, OK); + return OK; + } + else + { + //do we want to do something? + JobPrepareReady(Module_Winder, ERROR); + return ERROR; + } + +} + |
