aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c82
1 files changed, 80 insertions, 2 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index a119b0b16..33086b636 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -1,7 +1,7 @@
/*
* Thread_Winder.c
*
- * Created on: 25 áîøõ 2018
+ * Created on: 25 áîøõ 2018
* Author: shlomo
*/
#include"include.h"
@@ -11,6 +11,8 @@
#include "StateMachines/Printing/PrintingSTM.h"
#include "Modules/Control/Control.h"
+#include "Common/report/report.h"
+
#include "drivers/FPGA/FPGA.h"
#include "drivers/FPGA/FPGA_SPI_Comm.h"
@@ -27,10 +29,35 @@ uint32_t ScrewControlId = 0xFF;
uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone
uint32_t DirectionChangeCounter = 0; //holds the current number of runs of the screw - will be used to build the cone
+InternalWinderConfigStruc InternalWinderCfg = {0};
+
uint32_t Winder_Init(void)
{
return OK;
}
+
+
+uint32_t InternalWinderConfigMessage(HardwareWinder* request)
+{
+ uint32_t status = PASSED;
+
+ InternalWinderCfg.milimetersperrotation = request->millimeterperrotation;
+
+ return status;
+}
+uint32_t InternalWindingConfigMessage(JobSpool* request)
+{
+ uint32_t status = PASSED;
+
+ InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses;
+ InternalWinderCfg.spoolbackingrate = request->backingrate;
+ InternalWinderCfg.startoffsetpulses = request->startoffsetpulses;
+ InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate;
+ InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage;
+ InternalWinderCfg.diameter = request->diameter;
+
+ return status;
+}
/*
*uint32_t Winder_Prepare(void *JobDetails)
@@ -107,7 +134,56 @@ uint32_t ScrewControlId = 0xFF;
uint32_t ScrewNumberOfSteps = 0;
uint32_t DirectionChangeCounter = 0;
*/
+/*
+ InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses;
+ InternalWinderCfg.spoolbackingrate = request->backingrate;
+ InternalWinderCfg.startoffsetpulses = request->startoffsetpulses;
+ InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate;
+ InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage;
+ *
+Calculate the number of steps.
+Initial home position = ...
+Initial out movement = ScrewNumberOfSteps
+if DirectionChangeCounter %= backingrate : reduce one from the ScrewNumberOfSteps
+if DirectionChangeCounter %= bottombackingrate && direction was out: ADD one to the ScrewNumberOfSteps,
+// WRONG? if the flag is raised - lower it and reduce one from the ScrewNumberOfSteps
+30:100 - 70
+30:99 - 69
+30:98 - 68
+29:98 - 69
+29:97 -68
+InternalWinderCfg.segmentoffsetpulses
+ int32_t backingrate;
+ int32_t bottombackingrate;
+
+numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+*/
+uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction)
+{
+ uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ if (Counter)
+ {
+ if (Counter%InternalWinderCfg.spoolbackingrate == 0)
+ {
+ NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate);
+ REPORT_MSG(ScrewNumberOfSteps, "Head Backing");
+ ScrewNumberOfSteps--;
+ }
+ if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 0))
+ {
+ if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize)
+ {
+ NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate);
+ ScrewNumberOfSteps++;
+ REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing");
+ }
+
+ }
+ }
+ return CalculateNumberOfSteps;
+
+}
uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
if (BusyfirstCall)
@@ -118,6 +194,7 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
//ScrewCurrentDirection: false moves out, true moves home
if (BusyFlag == NOTBUSY)
{
+ CalculateNumberOfSteps (DirectionChangeCounter++, ScrewCurrentDirection);
if (ScrewCurrentDirection == false)
{
ScrewCurrentDirection = true;
@@ -127,7 +204,6 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
ScrewCurrentDirection = false;
}
MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,ScrewNumberOfSteps); //process: set point 0, set max speed, move to the specified length, return back.
- DirectionChangeCounter++;
}
/*
* calculate new ScrewSpeed and call MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
@@ -197,6 +273,7 @@ uint32_t Winder_End(void)
void Winder_ScrewHomeLimitSwitchInterrupt(void)
{
uint32_t status;
+ //handle glitch - send information to the next time that the motor stops
if (Winder_ScrewHoming)
{
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); //stop ASAP
@@ -205,6 +282,7 @@ void Winder_ScrewHomeLimitSwitchInterrupt(void)
}
void Winder_ScrewOutLimitSwitchInterrupt(void)
{
+ //handle glitch - send information to the next time that the motor stops
uint32_t status;
status = MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out
}