aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
committerAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
commit338edba081dba2a2aefb634811be1cc84ec93d64 (patch)
tree0021538796c254a8eab8527e8461a2e831e68c1c /Software/Embedded_SW/Embedded/Modules/Thread
parent49ddda1cc22d6cbb72f499b37e5db32c95252dfa (diff)
downloadTango-338edba081dba2a2aefb634811be1cc84ec93d64.tar.gz
Tango-338edba081dba2a2aefb634811be1cc84ec93d64.zip
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread.h10
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c53
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c75
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c95
4 files changed, 196 insertions, 37 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
index c912bca21..aea0dd93a 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h
@@ -42,6 +42,15 @@ typedef struct
PID_Config_Params m_params;
}MotorControlConfig_t;
+#ifdef FOUR_WINDERS
+#define SCREW_2_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE2_1
+#define SCREW_3_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE1_1
+#define SCREW_4_Motor HARDWARE_MOTOR_TYPE__MOTO_RDANCER
+#define Winder_2_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE2_2
+#define Winder_3_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE1_2
+#define Winder_4_Motor HARDWARE_MOTOR_TYPE__MOTO_RLOADARM
+#endif
+
#define MAX_THREAD_FEED_MOTORS (WINDER_MOTOR+1)
#define MAX_SYSTEM_DANCERS (HARDWARE_DANCER_TYPE__RightDancer+1)
@@ -84,6 +93,7 @@ uint32_t DancerConfigMessage(HardwareDancer * request);
uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read);
void SetOriginMotorSpeed(float process_speed);
+uint32_t UpdatePidDuringRun(HardwarePidControl *hardwarepidcontrol);
uint32_t ThreadPrepare_Tension (int DancerId, double tension);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index c7ec8a58c..c478b82de 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -164,7 +164,7 @@
{
if (Is_PP_Machine())
- kval_upperValue = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun;
+ kval_upperValue = 28;
else
kval_upperValue = 70;
@@ -208,7 +208,7 @@
{
if(Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD)
{
- WHS_Set_SetPoint_Q_value(headairflow*2/3);
+ WHS_Set_SetPoint_Q_value(headairflow);
}
else
{
@@ -349,7 +349,10 @@
if (Head_Type != HEAD_TYPE_ARC)
{
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000);
+ if (MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000)==ERROR)
+ {
+ Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_DH_LID,NO_LIMIT);
+ }
}
CallbackCounter++;
//MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000);
@@ -366,8 +369,8 @@
if (Head_Type == HEAD_TYPE_FLAT)
{
Report("Thread_Load_Lift_actuators",__FILE__,__LINE__,LOW,RpMessage,false,0);
- Trigger_Head_Actuators_Control(ACT_IN_AND_OUT, LOW,true);
- //Trigger_Head_Actuators_Control(ACTIN, LOW,true);
+ Trigger_Head_Actuators_Stub(ACTOT, ENABLE, UP);
+ Trigger_Head_Actuators_Stub(ACTIN, ENABLE, UP);
}
return OK;
}
@@ -395,8 +398,8 @@
{
keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep;
keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun;
- if (keepkvalrun>=25)
- keepkvalrun = 25;
+ /*if (keepkvalrun>=25)
+ keepkvalrun = 25;*/
Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0);
@@ -428,6 +431,7 @@
if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT)
{
REPORT_MSG(LIMIT, "No cone in winder");
+ Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_WINDER,NO_LIMIT);
//return ERROR;
}
CallbackCounter++;
@@ -440,8 +444,8 @@
{
keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep;
keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun;
- if (keepkvalrun>=25)
- keepkvalrun = 25;
+ /*if (keepkvalrun>=25)
+ keepkvalrun = 25;*/
Report("Thread_Load_Close_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0);
MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8);
@@ -460,7 +464,7 @@
uint32_t Thread_Load_Close_Dancers(void)
//Send Dancer Motors To Preset Location, Check That The Dancers Are On The Thread
{
- uint32_t current = 0;
+ uint32_t current = 1;
REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Close_Dancers");
CallbackCounter++;
MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000);
@@ -500,14 +504,14 @@
if (Head_Type == HEAD_TYPE_FLAT)
{
Report("Thread_Load_Close_actuators",__FILE__,__LINE__,LOW,RpMessage,true,0);
- Trigger_Head_Actuators_Control(ACTOT, LOW,false);
- //Trigger_Head_Actuators_Control(ACTIN, LOW,false);
+ Trigger_Head_Actuators_Stub(ACTOT, ENABLE, DOWN);
+ //Trigger_Head_Actuators_Stub(ACTIN, ENABLE, DOWN);
HeadCard_Actuators_Relocate();
}
if (Head_Type != HEAD_TYPE_ARC)
{
CallbackCounter++;
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000);
}
CallbackCounter++;
// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000);
@@ -1227,11 +1231,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
index = IfIndex&0xFF;
DancerId = ThreadMotorIdToDancerId[index];
- if (ReadValue < 10)
+ /*if (ReadValue < 10)
{
Report("Dancer value read too small.",__FILE__,__LINE__,DancerId,RpError,ReadValue,0);
return OK;
- }
+ }*/
if (ReadValue == 0x3FFF)
{
return OK;
@@ -1242,6 +1246,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//pooler dancer is right sided: data is opposite
TranslatedReadValue = (-1*TranslatedReadValue);
}
+ if (abs(TranslatedReadValue) > 0x2000)
+ {
+ TranslatedReadValue = 0x3FFF- TranslatedReadValue; //overcome zero environment
+ }
+
//TranslatedReadValue = 0;//test
MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue);
MotorSamplePointer[index]++;
@@ -1344,10 +1353,16 @@ void ThreadLoadRequest(MessageContainer* requestContainer)
responseContainer = createContainer(MESSAGE_TYPE__StubHeatingTestResponse, requestContainer->token, false, &response, &stub_heating_test_response__pack, &stub_heating_test_response__get_packed_size);
container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
-
int LoadStage = (int)request->dryerzone1temp;
- LoadStages = LoadStage;
- ThreadLoadStateMachine(LoadStage);
+ if (request->hardwarepidcontrol1!=NULL)
+ {
+ UpdatePidDuringRun(request->hardwarepidcontrol1);
+ }
+ else
+ {
+ LoadStages = LoadStage;
+ ThreadLoadStateMachine(LoadStage);
+ }
/*if (status)
{
@@ -1463,7 +1478,7 @@ uint32_t ThreadLoadingReport(void)
uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer)
{
- TryThreadLoadingRequest *request = continue_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+ TryThreadLoadingRequest *request = try_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
TryThreadLoadingResponse Cresponse = TRY_THREAD_LOADING_RESPONSE__INIT;
MessageContainer responseContainer;
MessageState = 2;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 420141d5b..1ce27115d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -133,6 +133,7 @@ uint32_t InternalWindingConfigMessage(JobSpool* request)
* 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
*/
+int Screw_wait_counter;
uint32_t Winder_Prepare(void *JobDetails)
{
JobTicket* JobTicket = JobDetails;
@@ -199,7 +200,16 @@ uint32_t Winder_Prepare(void *JobDetails)
//REPORT_MSG(ScrewSpeed, "Winder_Prepare");
Winder_ScrewHoming = true;
//REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit");
+ Screw_wait_counter=1;
status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2,2000);
+#ifdef FOUR_WINDERS
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, Winder_PrepareStage2,2000);
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, Winder_PrepareStage2,2000);
+ Screw_wait_counter++;
+ status = MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, Winder_PrepareStage2,2000);
+#endif
}
return status;
}
@@ -214,7 +224,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
uint32_t status=OK;
uint32_t numOfSteps = WindingConeLocation*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
+ //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
#ifdef READ_SCREW_ENCODER
Read_Screw_Encoder();
@@ -223,11 +233,12 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
#endif
REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2");
+ Screw_wait_counter--;
if (ReadValue != LIMIT)
{
if (JobIsActive()==true)
{
- LOG_ERROR(ReadValue,"Screw failed to reach the limit switch!!");
+ LOG_ERROR(deviceID,"Screw failed to reach the limit switch!!");
//returned with a timeout
Winder_ScrewAtOffsetCallback(0,0);
}
@@ -238,18 +249,38 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
}
else
{
+ if (Screw_wait_counter!=0)
+ {
+ ReportWithPackageFilter(ThreadFilter,"waiting for winders",__FILE__,__LINE__,Screw_wait_counter,RpWarning,deviceID, 0);
+ return status;
+ }
+ Screw_wait_counter++;
status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+#ifdef FOUR_WINDERS
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_2_Motor,(1-MotorsCfg[SCREW_2_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_3_Motor,(1-MotorsCfg[SCREW_3_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+ Screw_wait_counter++;
+ status |= MotorMoveWithCallback (SCREW_4_Motor,(1-MotorsCfg[SCREW_4_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000);
+#endif
}
//set motor location 0 here
return status;
}
-uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
+uint32_t Winder_ScrewAtOffsetCallback(uint32_t MotorId, uint32_t BusyFlag)
{
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency);
+ Screw_wait_counter--;
- MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands
+ MotorStop (MotorId,Soft_Hiz); //per L6470 errata between mov and run commands
+/*#ifdef FOUR_WINDERS
+ MotorStop(SCREW_2_Motor, Hard_Hiz);
+ MotorStop(SCREW_3_Motor, Hard_Hiz);
+ MotorStop(SCREW_4_Motor, Hard_Hiz);
+#endif*/
Task_sleep(5);
#ifdef READ_SCREW_ENCODER
Reset_Screw_Encoder();
@@ -260,7 +291,12 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location");
#endif
- SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
+ SetMotHome(MotorId); //set this point as the spool home
+/*#ifdef FOUR_WINDERS
+ SetMotHome(SCREW_2_Motor);
+ SetMotHome(SCREW_3_Motor);
+ SetMotHome(SCREW_4_Motor);
+#endif*/
ScrewCurrentDirection = false;
#ifdef READ_SCREW_ENCODER
@@ -269,8 +305,9 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
ScrewSpeed = 0;
ScrewControlId = 0xFF;
ScrewNumberOfSteps = 0;
- REPORT_MSG(millisecondCounter, "Winder_ScrewAtOffsetCallback");
- PrepareReady(Module_Winder, ModuleDone);
+ ReportWithPackageFilter(ThreadFilter,"Winder_ScrewAtOffsetCallback",__FILE__,millisecondCounter,Screw_wait_counter,RpWarning,MotorId, 0);
+ if (Screw_wait_counter == 0)
+ PrepareReady(Module_Winder, ModuleDone);
return OK;
}
@@ -565,6 +602,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag)
//MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0);
//MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000);
+#ifdef FOUR_WINDERS
+ MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,2000);
+ MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,2000);
+ MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,2000);
+#endif
return OK;
}
@@ -594,9 +636,14 @@ uint32_t Winder_End(void)
//MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0);
//MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //bug #2709
+#ifdef FOUR_WINDERS
+ MotorAbortMovetoLimitSwitch (SCREW_2_Motor);
+ MotorAbortMovetoLimitSwitch (SCREW_3_Motor);
+ MotorAbortMovetoLimitSwitch (SCREW_4_Motor);
+#endif
return OK;
}
-void Winder_ScrewHomeLimitSwitchInterrupt(void)
+/*void Winder_ScrewHomeLimitSwitchInterrupt(void)
{
//uint32_t status;
//handle glitch - send information to the next time that the motor stops
@@ -611,7 +658,7 @@ void Winder_ScrewOutLimitSwitchInterrupt(void)
//handle glitch - send information to the next time that the motor stops
//uint32_t status;
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out
-}
+}*/
uint32_t Screw_timerBase = TIMER3_BASE; //Timer handle
@@ -655,7 +702,17 @@ void ScrewTimerInterrupt(int ARG0)
{
ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime);
MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection);
+#ifdef FOUR_WINDERS
+ MotorSetDirection (SCREW_2_Motor, ScrewCurrentDirection);
+ MotorSetDirection (SCREW_3_Motor, ScrewCurrentDirection);
+ MotorSetDirection (SCREW_4_Motor, ScrewCurrentDirection);
+#endif
MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed);
+#ifdef FOUR_WINDERS
+ MotorSetSpeedDirect (SCREW_2_Motor, ScrewSpeed);
+ MotorSetSpeedDirect (SCREW_3_Motor, ScrewSpeed);
+ MotorSetSpeedDirect (SCREW_4_Motor, ScrewSpeed);
+#endif
#ifdef READ_SCREW_ENCODER
Read_Screw_Encoder();
ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 2bdf1b17f..98147f6b2 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -696,7 +696,8 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}*`/
}*/
calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index];
- calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR];
+ if (index != WINDER_MOTOR)
+ calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR];
//calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*CurrentControlledSpeed[index];
if (0)//(JobCounter % 1000 == 0)
//if (JobCounter < 100)//(FirstCalcInJob == true)
@@ -728,6 +729,14 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}*/
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
+#ifdef FOUR_WINDERS
+ if (index == WINDER_MOTOR)
+ {
+ MotorSetSpeed(Winder_2_Motor, calculated_speed);
+ MotorSetSpeed(Winder_3_Motor, calculated_speed);
+ MotorSetSpeed(Winder_4_Motor, calculated_speed);
+ }
+#endif
}
else
{
@@ -841,19 +850,21 @@ uint32_t Release_Right_TFU_TensionCallback(uint32_t deviceID, uint32_t BusyFlag)
uint32_t Release_Right_TFU_Tension()
{
uint32_t status = OK;
+#ifndef FOUR_WINDERS
if (RTFU_Up == true)
{
Report("Release_Right_TFU_Tension",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].pulseperround/4,0);
RTFU_Up = false;
status = MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].pulseperround/4* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].microstep, Release_Right_TFU_TensionCallback,1000);
}
-
+#endif
return status;
}
int SecondFeederCorrection = 4;
int PrepareWaitCount = 0;
uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue)
{
+#ifndef FOUR_WINDERS
MotorStop (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,Soft_Stop); //per L6470 errata between mov and run commands
Report("Adjust_Right_TFU_Tension_2ndCallback x more steps",__FILE__,__LINE__,MotorId,RpMessage,SecondFeederCorrection,0);
if (JobIsActive()==false)
@@ -872,20 +883,23 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa
ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback Prepare Ready",__FILE__,__LINE__,2,RpWarning,PrepareWaitCount,0);
PrepareReady(Module_Thread,ModuleDone);
}
-
+#endif
return OK;
}
uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue)
{
+#ifndef FOUR_WINDERS
Report("Adjust_Right_TFU_Tension_Callback",__FILE__,__LINE__,MotorId,RpMessage,0,0);
MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,SecondFeederCorrection* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].microstep, Adjust_Right_TFU_Tension_2nd_Callback,1000);
RTFU_Up = true;
+#endif
return OK;
}
uint32_t Adjust_Right_TFU_Tension(double tension)
{
uint32_t status = OK;
+#ifndef FOUR_WINDERS
if (tension > 0.5) //0 = lower position, 1 = high position
{
if (FPGA_Read_limit_Switches(GPI_LS_RDANCER_UP) == NO_LIMIT)
@@ -895,7 +909,7 @@ uint32_t Adjust_Right_TFU_Tension(double tension)
Report("Adjust_Right_TFU_Tension",__FILE__,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,PrepareWaitCount,0);
}
}
-
+#endif
return status;
}
uint32_t ThreadPrepare_TensionCallback (int MotorId, double tension)
@@ -1013,11 +1027,11 @@ uint32_t ThreadPrepareState(void *JobDetails)
PrepareWaitCount = 0;
status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__LeftDancer, windertension);
- ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpFatalError,(int)windertension,0);
+ ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpWarning,(int)windertension,0);
status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__MiddleDancer, pullertension);
- ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Puller",__FILE__,HARDWARE_DANCER_TYPE__MiddleDancer,PrepareWaitCount,RpFatalError,(int)pullertension,0);
+ ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Puller",__FILE__,HARDWARE_DANCER_TYPE__MiddleDancer,PrepareWaitCount,RpWarning,(int)pullertension,0);
status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__RightDancer, feedertension);
- ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Feeder",__FILE__,HARDWARE_DANCER_TYPE__RightDancer,PrepareWaitCount,RpFatalError,(int)feedertension,0);
+ ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Feeder",__FILE__,HARDWARE_DANCER_TYPE__RightDancer,PrepareWaitCount,RpWarning,(int)feedertension,0);
FirstCalcInJob = true;
if(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].speedmaster == false)
@@ -1034,14 +1048,14 @@ uint32_t ThreadPrepareState(void *JobDetails)
/*if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT)
{
- ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpFatalError,LIMIT,0);
+ ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpWarning,LIMIT,0);
//JobEndReason = JOB_LIDS_OPEN;
//PrepareReady(Module_Thread,ModuleFail);
//return ERROR;
}
if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) != LIMIT)
{
- ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpFatalError,LIMIT,0);
+ ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpWarning,LIMIT,0);
//JobEndReason = JOB_LIDS_OPEN;
//PrepareReady(Module_Thread,ModuleFail);
//return ERROR;
@@ -1120,6 +1134,7 @@ uint32_t ThreadPrepareState(void *JobDetails)
/////////////////////////////////////////////////////
MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize);
+#ifndef FOUR_WINDERS
if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
{
ReportWithPackageFilter(ThreadFilter,"Feeder Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
@@ -1132,6 +1147,7 @@ uint32_t ThreadPrepareState(void *JobDetails)
LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
}
+#endif
if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
{
ReportWithPackageFilter(ThreadFilter,"Puller Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
@@ -1145,6 +1161,7 @@ uint32_t ThreadPrepareState(void *JobDetails)
PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
}
+#ifndef FOUR_WINDERS
if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
{
if (ControlIdtoMotorId[Motor_i] != 0xFF)
@@ -1159,6 +1176,7 @@ uint32_t ThreadPrepareState(void *JobDetails)
//AddControlCallback(NULL,ThreadControlSpeedReadFunction, eHundredMillisecond,MotorGetSpeedFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
#endif
}
+#endif
if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will n//ot be controlled
{
if (ControlIdtoMotorId[Motor_i] != 0xFF)
@@ -1196,7 +1214,57 @@ uint32_t ThreadPrepareState(void *JobDetails)
//set 3 dancers to the profile positions
return OK;
}
+uint32_t UpdatePidDuringRun(HardwarePidControl *request)
+{
+ int Motor_i = MAX_THREAD_MOTORS_NUM,i;
+ double temp_dt;
+ for (i=0;i<MAX_THREAD_MOTORS_NUM;i++)
+ {
+ if (ThreadMotorIdToControlId[i] == request->hardwarepidcontroltype)
+ {
+ Motor_i = i;
+ break;
+ }
+ }
+ if (Motor_i == MAX_THREAD_MOTORS_NUM)
+ return ERROR;
+
+
+ if (request->derivativetime == true)
+ {
+ MotorControlConfig[Motor_i].m_params.Kd = request->derivativetime;
+ ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kd",__FILE__,Motor_i,(int)(request->derivativetime),RpWarning,0,0);
+ }
+ if (request->proportionalgain == true)
+ {
+ MotorControlConfig[Motor_i].m_params.Kp = request->proportionalgain;
+ ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kp",__FILE__,Motor_i,(int)(request->proportionalgain),RpWarning,0,0);
+ }
+ if (request->integraltime == true)
+ {
+ MotorControlConfig[Motor_i].m_params.Ki = request->integraltime;
+ ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Ki",__FILE__,Motor_i,(int)(request->integraltime),RpWarning,0,0);
+ }
+ if (request->epsilon == true)
+ {
+ MotorControlConfig[Motor_i].m_params.epsilon = request->epsilon;
+ ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun epsilon",__FILE__,Motor_i,(int)(request->epsilon*10000),RpWarning,0,0);
+ }
+ if (request->has_controloutputtype == true)
+ {
+ MotorControlConfig[Motor_i].m_params.dt = request->controloutputtype;
+ temp_dt = MotorControlConfig[Motor_i].m_params.dt/0.001;
+ MotorTiming[Motor_i] = (int)temp_dt;
+ if (MotorTiming[Motor_i])
+ {
+ MotorTimer[Motor_i] = MotorTiming[Motor_i]-1;
+ }
+ ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun dt",__FILE__,Motor_i,(int)(request->controloutputtype*1000),RpWarning,temp_dt,0);
+ }
+//////////////////////////////////////////////////
+ return OK;
+}
void SetOriginMotorSpeed(float process_speed)
{
int Motor_i, HW_Motor_Id;
@@ -1451,6 +1519,15 @@ char Endstr[150];
for ( Motor_i = 0;Motor_i <= WINDER_MOTOR;Motor_i++)
{
MotorStop(ThreadMotorIdToMotorId[Motor_i],Hard_Hiz);
+#ifdef FOUR_WINDERS
+ if (Motor_i == WINDER_MOTOR)
+ {
+ MotorStop(Winder_2_Motor, Hard_Hiz);
+ MotorStop(Winder_3_Motor, Hard_Hiz);
+ MotorStop(Winder_4_Motor, Hard_Hiz);
+ }
+#endif
+
}
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_RLOADING,Hard_Hiz);
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_LLOADING,Hard_Hiz);