aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-06-14 17:48:34 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-06-14 17:48:34 +0300
commit87973c0cc97ba449e2b17c92ff6eb68e2a28a871 (patch)
tree6c92affb59f3b784518f8f683ed332855a3ecddf /Software/Embedded_SW/Embedded/Modules
parent580cb401e8b31501cb3fbee1b9f59a67ad636633 (diff)
downloadTango-87973c0cc97ba449e2b17c92ff6eb68e2a28a871.tar.gz
Tango-87973c0cc97ba449e2b17c92ff6eb68e2a28a871.zip
thread winder improvements
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c8
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c3
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c41
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_I2C.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c173
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c4
8 files changed, 120 insertions, 124 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
index 9dc03601c..5ec7c6b16 100644
--- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
+++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
@@ -26,7 +26,6 @@
Task_Handle AlarmHandling_Task_Handle;
Mailbox_Handle AlarmHandlingMsgQ = NULL;
-static GateMutex_Handle gateAlarmHandlingDB;
/******************** Functions ********************************************/
//uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read);
@@ -57,13 +56,6 @@ void AlarmHandlingInit(void)
//memset(AlarmHandlingDatalog,0,sizeof(uint32_t)*MAX_TANGO_CONTROL_DEVICES);
- /*gateAlarmHandlingDB = GateMutex_create(NULL, &eb);
- if (gateAlarmHandlingDB == NULL)
- {
- System_abort("Could not create USB Wait gate");
- }*/
-
-
return;
}
void AlarmHandlingIterate(UArg arg0)
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index 847b777fa..a1de29b08 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
@@ -31,7 +31,6 @@
#include "drivers/FPGA/FPGA.h"
#include "modules/thread/thread_ex.h"
-#include "Drivers/Peripheral_GPIO/GPIO.h"
Task_Handle Millisecond_Task_Handle;
/******************** Definitions ********************************************/
@@ -237,6 +236,7 @@ uint32_t MillisecLoop(uint32_t tick)
FPGA_Read_limit_Switches_Registers();
//Read_FPGA_GPI_Rgisters();//FPGA_Read_limit_Switches();
#endif
+
temp += MotorActivity;
if (MotorActivity)
{
@@ -340,7 +340,6 @@ uint32_t MillisecLoop(uint32_t tick)
{
for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++)
MillisecReadFromTempSensor(Sensor_i, NULL);
- ACTIVITY_RED_LED_CHANGE_MODE;
}
if (Onesecond_Tick)
diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
index ff9acdb94..69ff06880 100644
--- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
@@ -486,7 +486,7 @@ uint32_t HeatersControlLoop(uint32_t tick)
{
//char str[100];
//uint8_t len = 0;
- int DcHeaterId,HeaterSliceCounter;
+ int DcHeaterId;
/*len = usnprintf(str, 100, "\r\n EightMilliSecondHeatersInterrupt SliceCounter %d Owner %d H1000 %d H2000 %d"
,SliceCounter,TimeSliceAllocation[SliceCounter],HeatersRestart,NumberOFSlicesInUse);
Report(str, __FILE__,__LINE__,0, RpMessage, SliceCounter, TimeSliceAllocation[SliceCounter]);
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
index 6739619a7..abd9794b8 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
@@ -35,6 +35,7 @@ double DispenserNormalizedErrorCoEfficient[MAX_SYSTEM_DISPENSERS] = {0};
HardwarePidControlType ThreadDispenserIdToControlId[MAX_SYSTEM_DISPENSERS] = { HARDWARE_PID_CONTROL_TYPE__Dispenser1,HARDWARE_PID_CONTROL_TYPE__Dispenser2,HARDWARE_PID_CONTROL_TYPE__Dispenser3,HARDWARE_PID_CONTROL_TYPE__Dispenser4,HARDWARE_PID_CONTROL_TYPE__Dispenser5,HARDWARE_PID_CONTROL_TYPE__Dispenser6,HARDWARE_PID_CONTROL_TYPE__Dispenser7,HARDWARE_PID_CONTROL_TYPE__Dispenser8};
+bool DispenserReady[MAX_SYSTEM_DISPENSERS] = {true};
/******************** STRUCTURES AND ENUMs ********************************************/
/******************** GLOBAL PARAMETERS ********************************************/
@@ -83,7 +84,7 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request)
//callback - calls printing stm with the result
// registration - 10 msec, dispenser pressure sensor
-// AddControlCallback(DeviceId2Heater[HeaterId], HeaterControlCBFunction, eHundredMillisecond);
+// AddControlCallback(DeviceId2Dispenser[DispenserId], DispenserControlCBFunction, eHundredMillisecond);
// start the dispenser pressure building - move up in a TBD speed, valve closed
//Dispenser Speed control
//callback - handles speed
@@ -94,7 +95,7 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request)
//********************************************************************************************************************
uint32_t IDSPrepareState(void *JobDetails)
{
- int Motor_i, HW_Motor_Id, Pid_Id;
+ int Motor_i, HW_Motor_Id, Pid_Id,i;
//start IDS control for all motors
for (Motor_i = 0;Motor_i < MAX_SYSTEM_DISPENSERS;Motor_i++)
{
@@ -117,6 +118,11 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request)
MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); //set the dispenser to the
#warning activate valve
+ /*Start the dispensers to build initial pressure
+ * check different handling for dispensers that participate in the first segment and idle dispensers
+ * start control for initial pressure
+ *
+ */
//ValveCommand (Enable,MixerDirection);
#ifdef DEBUG_TEST_FUNCTIONS
// add control here
@@ -124,16 +130,33 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request)
#endif
}
//set 3 dancers to the profile positions
+ for (i = 0; i < MAX_SYSTEM_DISPENSERS; i++)
+ {
+ DispenserReady[i] = true;
+ }
return OK;
}
+ void DispenserPrepareReady(void)
+ {
+ int i;
+ for (i=0;i<MAX_SYSTEM_DISPENSERS;i++)
+ {
+ if (DispenserReady[i] == false)
+ {
+ return; //not all configured Dispensers are ready
+ }
+ }
+ PrepareReady(Module_IDS,ModuleDone);
+ }
//********************************************************************************************************************
uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId)
{
//set the speed only before the first segment, speed is constant accros job
JobTicket* JobTicket = JobDetails;
- int Dispenser_i, HW_Motor_Id;
+ int Dispenser_i;
+ TimerMotors_t HW_Motor_Id;
int segmentfirst_speed;
int CurrentSegment = 0;
JobBrushStopId = 0;
@@ -148,12 +171,12 @@ int CurrentSegment = 0;
OriginalDispenserSpd_2PPS[Dispenser_i] = (int)Dispenser_speed;
}
//ControlStart();
- // set the new speed in the dryer Dispenser to the speed of the new segment
MotorSetSpeed(HW_Motor_Id, OriginalDispenserSpd_2PPS[HW_Motor_Id]);
// activate control fr all motors
- //set speed for both rocker motors
- //wait for all motors to get to the required speed (set the target speed for the control to check)
+ /* wait for all dispensers to get to the required pressure
+ * move the presegment ready when all dispensers are ready.
+ */
//call the job state machine when the thread system is ready
PreSegmentReady(Module_IDS,ModuleDone);
@@ -170,12 +193,10 @@ int CurrentSegment = 0;
uint32_t IDSEndState(void *JobDetails)
{
int Motor_i;
- for ( Motor_i = 0;Motor_i < MAX_THREAD_MOTORS_NUM;Motor_i++)
+ for ( Motor_i = 0;Motor_i < MAX_SYSTEM_DISPENSERS;Motor_i++)
{
- StopMotor(ThreadMotorIdToMotorId[Motor_i],Hard_Hiz);
+ StopMotor(DispenserIdToMotorId[Motor_i],Hard_Hiz);
}
- StopMotor(HARDWARE_MOTOR_TYPE__MOTO_RLOADING,Hard_Hiz);
- StopMotor(HARDWARE_MOTOR_TYPE__MOTO_LLOADING,Hard_Hiz);
return OK;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
index 669df84a5..49c7d0d3b 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
@@ -16,8 +16,6 @@
#include "Stub_Status.h"
-#include "drivers/Motors/Motor.h"
-
void Stub_CartridgeReadRequest(MessageContainer* requestContainer)
{
uint32_t status = NOT_SUPPORTED;
@@ -25,12 +23,7 @@ void Stub_CartridgeReadRequest(MessageContainer* requestContainer)
StubCartridgeReadRequest* request = stub_cartridge_read_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
- MillisecStart();
- ControlStart();
-
- //MotorMovetoLimitSwitch (14,1, 1000, 32, MotorSetSpeedCallBackFunction);
- MotorSetSpeed( 15, 1000);
- //request->cartridgeid
+ //request->cartridgeid
writeLine("cartridge Request: ");
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_I2C.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_I2C.c
index 9584ee39b..9202d9936 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_I2C.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_I2C.c
@@ -119,7 +119,7 @@ void Stub_I2CWriteBytesRequest(MessageContainer* requestContainer)
//----------------------
- status = I2C_Write(request->i2cid, request->slaveaddress, I2C_W_buf, request->n_bytestwrite);
+ status = Write_I2C(request->i2cid, request->slaveaddress, I2C_W_buf, request->n_bytestwrite);
//--------------------------
@@ -159,7 +159,7 @@ void Stub_I2CReadBytesRequest(MessageContainer* requestContainer)
response.slaveaddress = request->slaveaddress;
response.has_slaveaddress = true;
- status = I2C_Read(request->i2cid, request->slaveaddress, I2C_R_buf, request->numberofbytestoread);
+ status = Read_I2C(request->i2cid, request->slaveaddress, I2C_R_buf, request->numberofbytestoread);
//response.readbyte = I2C_control(request->i2cid, request->slaveaddress, request->readorwrite,request->bytetowrite );
//response.has_readbyte= true;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 37f60e8cf..f80f26e53 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -20,65 +20,30 @@ bool Winder_ScrewHoming = false;
uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag);
uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue);
-bool ScrewCurrentDirection = false;
-double ScrewSpeed = 0;
+bool ScrewCurrentDirection = false; //holds current screw direction
+bool BusyfirstCall = true; //Ignores first call after activating the screw - too early
+double ScrewSpeed = 0; //ScrewSpeed
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
uint32_t Winder_Init(void)
{
return OK;
}
-uint32_t Winder_Test2(uint32_t deviceID, uint32_t ReadValue);
-uint32_t Winder_Test1(uint32_t deviceID, uint32_t ReadValue)
-{
- uint32_t status;
- uint32_t numOfSteps = InternalWinderCfg.segmentoffsetpulses;
- uint32_t position;
- /*
- * 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
- */
- MotorGetPositionFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
- //deley TODO
- SysCtlDelay(100000);
- position = Fpga_Spi[HARDWARE_MOTOR_TYPE__MOTO_SCREW].RX_MISO;//MotorGetPositionFromFPGA_Res(Motor_Id);
-
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed/10, GPI_LS_SCREW_LEFT, Winder_Test2);
-// status |= MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW, numOfSteps, Winder_ScrewAtOffsetCallback);
- //set motor location 0 here
- return status;
-
-}
-uint32_t Winder_Test2(uint32_t deviceID, uint32_t ReadValue)
-{
- uint32_t status;
- uint32_t numOfSteps = InternalWinderCfg.segmentoffsetpulses;
- uint32_t position;
- /*
- * 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
- */
- MotorGetPositionFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
- //deley TODO
- SysCtlDelay(100000);
- position = Fpga_Spi[HARDWARE_MOTOR_TYPE__MOTO_SCREW].RX_MISO;//MotorGetPositionFromFPGA_Res(Motor_Id);
-
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed/10, GPI_LS_SCREW_RIGHT, Winder_Test1);
- //status |= MotorMoveSteps (HARDWARE_MOTOR_TYPE__MOTO_SCREW, numOfSteps, Winder_ScrewAtOffsetCallback);
- //set motor location 0 here
- return status;
+/*
+ *uint32_t Winder_Prepare(void *JobDetails)
-}
-uint32_t Winder_Prepare(void *JobDetails)
+ * 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 status = 0;
- JobTicket* JobTicket = JobDetails;
+ //JobTicket* JobTicket = JobDetails;
- float process_speed = JobTicket->processparameters->dyeingspeed;
-// double ScrewSpeed = (50 * MotorsCfg[SCREW_MOTOR].pulseperround * MotorsCfg[SCREW_MOTOR].microstep)/(2*PI* MotorsCfg[SCREW_MOTOR].pulleyradius);
- double ScrewSpeed = (process_speed*20 );//* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulseperround)/(2*PI* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius);
+ //float process_speed = JobTicket->processparameters->dyeingspeed;
+ double ScrewSpeed = 500;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now
/*
* 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.
@@ -87,41 +52,67 @@ uint32_t Winder_Prepare(void *JobDetails)
*/
if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT)
{
- //go to prepare stage 2
Winder_PrepareStage2(0,0);
}
else
{
Winder_ScrewHoming = true;
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_LEFT, Winder_PrepareStage2);
-// status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed/10, GPI_LS_SCREW_RIGHT, Winder_Test1);
+ status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2);
}
return status;
}
+/*
+ * uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
+ * 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
+ */
+
uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
{
uint32_t status=OK;
uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- /*
- * 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(HARDWARE_MOTOR_TYPE__MOTO_SCREW,(1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize));//make sur to move the cart out
- //status |= StopMotor(HARDWARE_MOTOR_TYPE__MOTO_SCREW,0);
- status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback);
- //status |= MotorMoveSteps (HARDWARE_MOTOR_TYPE__MOTO_SCREW, numOfSteps, Winder_ScrewAtOffsetCallback);
- //set motor location 0 here
+
+ status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback);
+ //set motor location 0 here
return status;
}
-uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
+uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
{
- return PreSegmentReady(Module_Winder,ModuleDone);
+ SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
+
+ ScrewCurrentDirection = false;
+ BusyfirstCall = true;
+ ScrewSpeed = 0;
+ ScrewControlId = 0xFF;
+ ScrewNumberOfSteps = 0;
+ DirectionChangeCounter = 0;
+
+ PrepareReady(Module_Winder, ModuleDone);
+ return OK;
}
+
+/*
+ * this is the main operational function of the screw - run back and forth until stopped
+ */
+/*
+
+bool ScrewCurrentDirection = false;
+bool BusyfirstCall = true;
+double ScrewSpeed = 0;
+uint32_t ScrewControlId = 0xFF;
+uint32_t ScrewNumberOfSteps = 0;
+uint32_t DirectionChangeCounter = 0;
+*/
+
uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
+ if (BusyfirstCall)
+ {
+ BusyfirstCall = false;
+ return;
+ }
//ScrewCurrentDirection: false moves out, true moves home
if (BusyFlag == NOTBUSY)
{
@@ -133,11 +124,25 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
ScrewCurrentDirection = false;
}
- MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep); //process: set point 0, set max speed, move to the specified length, return back.
+ 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);
+ *
+ */
+ /*
+ * calculate cone shape according to DirectionChangeCounter and update ScrewNumberOfSteps
+ */
return OK;
}
+
+uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
+{
+ return PreSegmentReady(Module_Winder,ModuleDone);
+}
+
uint32_t Winder_Presegment(void *JobDetails)
{
JobTicket* JobTicket = JobDetails;
@@ -146,35 +151,26 @@ uint32_t Winder_Presegment(void *JobDetails)
float RotationsPerSecond;
ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);
-// double ScrewSpeed = (process_speed * MotorsCfg[SCREW_MOTOR].pulseperround * MotorsCfg[SCREW_MOTOR].microstep)/(2*PI* MotorsCfg[SCREW_MOTOR].pulleyradius);
- //double ScrewSpeed = (process_speed * MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulseperround)/(2*PI* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius);
-/*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.
+ // * 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);
+ RotationsPerSecond = process_speed / (InternalWinderCfg.diameter * PI);
// 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;
+ ScrewSpeed = screw_speed*RotationsPerSecond;
+
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
//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 (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep); //process: set point 0, set max speed, move to the specified length, return back.
- ScrewControlId = AddControlCallback(ScrewDirectionChange, eTenMilliSecond,MotorControlGetnBusyState,(IfTypeMotors*0x100+HARDWARE_MOTOR_TYPE__MOTO_SCREW), HARDWARE_MOTOR_TYPE__MOTO_SCREW, 0);
+ ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
+ MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,ScrewNumberOfSteps); //process: set point 0, set max speed, move to the specified length, return back.
+ ScrewControlId = AddControlCallback(ScrewDirectionChange, eOneMillisecond,MotorControlGetnBusyState,(IfTypeMotors*0x100+HARDWARE_MOTOR_TYPE__MOTO_SCREW), HARDWARE_MOTOR_TYPE__MOTO_SCREW, 0);
// MotorSetSpeedWithCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW, screw_speed,WinderPresegmentReady);
//in a callback: calculate backing rate for top and bottom, update point 0, update passing length, call the appropriate move to 0 / move;
@@ -185,6 +181,7 @@ uint32_t Winder_Presegment(void *JobDetails)
uint32_t Winder_End(void)
{
//stop screw
+ ScrewNumberOfSteps = 0;
RemoveControlCallback(ScrewControlId,ScrewDirectionChange);
return StopMotor (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
}
@@ -202,10 +199,4 @@ void Winder_ScrewOutLimitSwitchInterrupt(void)
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
}
-uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
-{
- SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
- PrepareReady(Module_Winder, ModuleDone);
- return OK;
-}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index fdae44171..7b5da0e65 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -165,7 +165,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
totalLength+=length;
}
-#warning control disabled
+//#warning control disabled
CurrentProcessedLength+=length;
PosDif[MotorDataIndex] = CurrentPosition;
@@ -297,7 +297,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
avreageSampleValue += MotorSamples[index][i];
avreageSampleValue = avreageSampleValue / MotorsControl[index].pvinputfilterfactormode;
//Stop Execution if the dancer moves too much
-#warning need to disable this in the first second of the job execution
+
if ((abs(avreageSampleValue)> DancerStopActivityLimit[index])&&(JobCounter > eOneSecond))
{
EndState(CurrentJob);