aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-08-06 16:12:38 +0300
committerAvi Levkovich <avi@twine-s.com>2018-08-06 16:12:38 +0300
commit778408ff6140099aace10a915bc0296d71f967fe (patch)
tree40bbfabe96128d777f793f0b8d14b059d0f88ce2 /Software/Embedded_SW/Embedded/Modules/Thread
parent65d06cf7d023cfed8a1619cb2f81279b1d5096f8 (diff)
parentce34a07e9ae75c9172425322248dc2fd1754852e (diff)
downloadTango-778408ff6140099aace10a915bc0296d71f967fe.tar.gz
Tango-778408ff6140099aace10a915bc0296d71f967fe.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c18
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c11
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c15
5 files changed, 37 insertions, 15 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
index d37015b61..2aa0b220a 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
@@ -2,7 +2,6 @@
#ifndef MODULES_THREAD_THREAD_H_
#define MODULES_THREAD_THREAD_H_
-#include "../../Drivers/SSI_Comm/SSI_Comm.h"
#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/Hardware/HardwareMotor.pb-c.h"
#include "PMR/Hardware/HardwareMotorType.pb-c.h"
@@ -14,6 +13,8 @@
#include "PMR/Printing/JobSpoolType.pb-c.h"
#include "drivers/Motors/Motor.h"
+#include "drivers/SSI_Comm/ssi_comm.h"
+
#include "thread_ex.h"
typedef struct
@@ -35,6 +36,9 @@ extern TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM];
extern HardwareDancerType ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM];
extern HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM];
+extern bool BreakSensorenabled;
+extern int32_t BreakSensordebouncetimemilli;
+
extern HardwareMotor MotorsCfg[NUM_OF_MOTORS];
extern HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM];
//extern InternalWinderConfigStruc InternalWinderCfg;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 794559d57..486f8384f 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -168,7 +168,7 @@ numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__
uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction)
{
uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- float screw_speed = 0;
+ float screw_horizontal_speed = 0;
float RotationsPerSecond;
if (Counter)
@@ -178,14 +178,15 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction)
NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate);
REPORT_MSG(ScrewNumberOfSteps, "Head Backing");
ScrewNumberOfSteps--;
- screw_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage;
+ screw_horizontal_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 = dyeingspeed / (InternalWinderCfg.diameter * PI);
RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
// calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm.
- ScrewSpeed = screw_speed*RotationsPerSecond;
+ ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
+ CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
}
if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1))
@@ -258,7 +259,7 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue)
uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
{
//JobTicket* JobTicket = JobDetails;
- float screw_speed = 0;
+ float screw_horizontal_speed = 0;
float RotationsPerSecond;
if (dyeingspeed == 0)
@@ -275,15 +276,16 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
// * 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;
+ screw_horizontal_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 = dyeingspeed / (InternalWinderCfg.diameter * PI);
RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
// calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm.
- ScrewSpeed = screw_speed*RotationsPerSecond;
+ ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
- //screw_speed = InternalWinderCfg.milimetersperrotation
+ CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
+ //screw_horizontal_speed = InternalWinderCfg.milimetersperrotation
// * 2. determine optimal micro-step setting
// * 3. calculate cart travel length from winding parameters
// * 4. start move of travel length
@@ -292,7 +294,7 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId)
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);
+ // MotorSetSpeedWithCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW, screw_horizontal_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;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 7405a91d9..2961bd105 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -24,7 +24,9 @@ typedef enum threadMotorsEnum
extern double TotalProcessedLength;
uint32_t InternalWindingConfigMessage(JobSpool* request);
+uint32_t ThreadConfigBreakSensor(void *request);
+uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId);
uint32_t ThreadPrepareState(void *JobDetails);
uint32_t ThreadPreSegmentState(void *JobDetails);
uint32_t ThreadSegmentState(void *JobDetails, int SegmentId);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index c5f45da78..1b960dada 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -7,6 +7,7 @@
#include "PMR/Hardware/HardwareMotor.pb-c.h"
#include "PMR/Hardware/HardwareDancer.pb-c.h"
#include "PMR/Hardware/HardwareWinder.pb-c.h"
+#include "PMR/Hardware/HardwareBreakSensor.pb-c.h"
#include "PMR/Printing/JobSpool.pb-c.h"
#include "PMR/common/MessageContainer.pb-c.h"
@@ -20,6 +21,9 @@ double NormalizedErrorCoEfficient[MAX_THREAD_MOTORS_NUM] = {0};
int DancerStopActivityLimit[MAX_THREAD_MOTORS_NUM] = {0};
HardwareDancer DancersCfg[MAX_SYSTEM_DANCERS] = {0};
+bool BreakSensorenabled;
+int32_t BreakSensordebouncetimemilli;
+
HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_PID_CONTROL_TYPE__MotorFeeder,HARDWARE_PID_CONTROL_TYPE__MotorDryer,HARDWARE_PID_CONTROL_TYPE__MotorPooler,HARDWARE_PID_CONTROL_TYPE__MotorWinder,0};
//********************************************************************************************************************
@@ -96,7 +100,14 @@ uint32_t DancerConfigMessage(HardwareDancer * request)
return Dancer_i;
}
+uint32_t ThreadConfigBreakSensor(void *request)
+{
+ HardwareBreakSensor *SensorCfg = (HardwareBreakSensor*)request;
+ BreakSensorenabled = SensorCfg->enabled;
+ BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli;
+ return OK;
+}
uint32_t thread_init(void)
{
//memset (MotorsCfg,0,sizeof(MotorsCfg));
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index af9be2cc7..b536c93b0 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -20,8 +20,7 @@
#include "StateMachines/Printing/PrintingSTM.h"
#include "drivers/Motors/Motor.h"
-//#include "drivers/SSI_Comm/ssi_comm.h"
-#include "drivers/SSI_Comm/Dancer/Dancer.h"
+#include "drivers/Danser_SSI/ssi_comm.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/Heater/Heater.h"
#include "drivers/Motors/Motor.h"
@@ -562,12 +561,16 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
//MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING, OriginalMotorSpd_2PPS[FEEDER_MOTOR]);
//#warning rocker disabled
- if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].has_directionthreadwize)
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency)
+ {
MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 2);
- if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].has_directionthreadwize)
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 2);
+ }
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency)
+ {
MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 2);
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 2);
+ }
//#warning rocker disabled
// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO