aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-12-23 10:54:31 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-12-23 10:54:31 +0200
commite1a2dde7fe9c728dfb3247b34d89b947b4132fd2 (patch)
tree3da73f505433bb9c0617970d018a80e881fc486e /Software/Embedded_SW/Embedded/Modules
parentb6d9b453d2f14f1bbcc3b907d6cc30b513370e5a (diff)
downloadTango-e1a2dde7fe9c728dfb3247b34d89b947b4132fd2.tar.gz
Tango-e1a2dde7fe9c728dfb3247b34d89b947b4132fd2.zip
support stop loading message and some fixes to the thread loading
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c11
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c14
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c234
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c2
9 files changed, 236 insertions, 46 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
index eea72d6b5..5c16bda14 100644
--- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
+++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
@@ -1114,7 +1114,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick)
if ((doubleValue >= (float)(AlarmItem[Alarm_i].AlarmValue*CurrentAlarmHighLimit)) || (doubleValue <= (float)(AlarmItem[Alarm_i].AlarmValue*CurrentAlarmLowLimit)))
{
Status = true;
- ReportWithPackageFilter(AlarmFilter,"OverCurrent Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)(doubleValue*100), 0);
+ if (AlarmState[Alarm_i].Status == false)
+ ReportWithPackageFilter(AlarmFilter,"OverCurrent Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,(int)(AlarmItem[Alarm_i].AlarmValue*100), RpMessage, (int)(doubleValue*100), 0);
}
}
else
@@ -1122,7 +1123,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick)
if (doubleValue <= 0.1)
{
Status = true;
- ReportWithPackageFilter(AlarmFilter,"loop break Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)(doubleValue*100), 0);
+ if (AlarmState[Alarm_i].Status == false)
+ ReportWithPackageFilter(AlarmFilter,"loop break Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,(int)(AlarmItem[Alarm_i].AlarmValue*100), RpMessage, (int)(doubleValue*100), 0);
}
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index 1605092e5..fb3fd1afb 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
@@ -442,7 +442,7 @@ uint32_t MillisecLoop(uint32_t tick)
/*else if(Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID) - move to the function control_HeadCard_PT100
{
//HeadCard_Toggle_PT100(Sensor_i);
- //deley??
+ //delay??
//HeadADCPT100_SendReadDataCommand(Sensor_i);
}
else if(Sensor_i < MAX_WHS_CARD_TEMP_SENS_ID)
diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
index 6b2cf0021..61767c2d6 100644
--- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
+++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
@@ -386,9 +386,9 @@ void DiagnosticTenMsecCollection(void)
/*if (JobIsActive()== false)
return;*/
- DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0,0));
- DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0,0));
- DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0,0));
+ DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0));
+ DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0));
+ DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0));
DiagnosticLoadDancerError(WINDER_DANCER,ThreadGetMotorCalculatedError(WINDER_DANCER));
DiagnosticLoadDancerError(POOLER_DANCER,ThreadGetMotorCalculatedError(POOLER_DANCER));
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
index 9fdcaaf1f..28bb191fe 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
@@ -1308,6 +1308,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId)
uint32_t SegmentNumOfBrushStops = 0;
double BrushStopTime = 0;
+uint32_t BrushStopCounter = 0;
void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers)
{
@@ -1383,6 +1384,13 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue)
int n_dispensers = 0;
JobSegment* Segment = (void *)IfIndex;
+ if(BrushStopCounter++ < BrushStopTime)
+ {
+ return OK;
+ }
+ BrushStopCounter = 0;
+
+
if (JobEndSequence == true)
{
Report("JobEndSequence",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)SegmentNumOfBrushStops,0);
@@ -1478,7 +1486,8 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId)
JobBrushStopId++;
if ((BrushStopTime)&&(SegmentNumOfBrushStops > 1))
{
- BrushStopControlId = AddControlCallback(NULL, IDSBrushStopRestartCallback, BrushStopTime,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 );
+ BrushStopCounter = BrushStopTime+10; //move the IDS brush stop handling to highest priority in timing
+ BrushStopControlId = AddControlCallback(NULL, IDSBrushStopRestartCallback, eOneMillisecond,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 );
if (BrushStopControlId == 0xFF)
{
Report("Add control callback failed",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)0,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
index 45cc80dff..6fd2e0eb1 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
@@ -14,6 +14,7 @@
#include "drivers/adc_sampling/adc.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/ADC_Sampling/adc.h"
+#include "drivers/Flash_ram/MCU_E2Prom.h"
#include "Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.h"
#include "Drivers/I2C_Communication/Head_Card/Fan/fan_click.h"
@@ -254,6 +255,19 @@ void Stub_ProgressRequest(MessageContainer* requestContainer)
}
else
+ if(request->amount == 0xB1) //fast refresh for pressure
+ {
+ LOG_ERROR(request->delay,"Set loading arm center");
+ Read_Dryer_ENC_Position();
+ Task_sleep(500);
+ Read_Dryer_ENC_Position();
+ Task_sleep(500);
+
+ response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,Read_Dryer_ENC_Position(0,0));
+ response.has_progress = true;
+
+ }
+ else
if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off
{
PowerOffInit();
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
index 13b98bcb0..f3eb9cb60 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c
@@ -40,6 +40,8 @@
#include "PMR/ThreadLoading/StartThreadLoadingResponse.pb-c.h"
#include "PMR/ThreadLoading/ContinueThreadLoadingRequest.pb-c.h"
#include "PMR/ThreadLoading/ContinueThreadLoadingResponse.pb-c.h"
+#include "PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h"
+#include "PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h"
//#include <stdint.h>
//#include <stdbool.h>
@@ -86,6 +88,7 @@
uint32_t ThreadLoadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue);
uint32_t Thread_Load_Dryer_UnLoading(void);
uint32_t ThreadLoadingReport(void);
+ bool ThreadLoaded(void);
typedef struct
{
@@ -115,7 +118,7 @@
//uint32_t Bytes = 0;
//FRESULT Fresult = FR_OK;
REPORT_MSG(LoadStages, "Thread Load State Machine step");
-
+ load.color = BLINK;
LoadStatus = OK;
LoadArmInfo.LoadArmBackLash = MCU_E2PromDryerBacklashRead();
REPORT_MSG(LoadArmInfo.LoadArmBackLash, "Thread Load MCU_E2PromDryerBacklashRead");
@@ -125,8 +128,10 @@
//EEPROM_STORAGE_DRYER_CYCLES
MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds);
- if (LoadArmInfo.LoadArmRounds <= 2)
- LoadArmInfo.LoadArmRounds = 20;
+ Read_Dryer_ENC_Position();
+
+ //if (LoadArmInfo.LoadArmRounds <= 2)
+ // LoadArmInfo.LoadArmRounds = 20;
Report("MotorMovetoEncoderPosition",__FILE__,__LINE__,LoadArmInfo.LoadArmRounds,RpWarning,LoadArmInfo.LoadArmBackLash,0);
/*Fresult = f_mkdir(SW_INFO_DIR);
@@ -225,7 +230,7 @@
WinderControlId = 0xFF;
}
- MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz);
+ MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
/*Task_sleep(5)
MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);*/
@@ -301,7 +306,6 @@
if (CallbackCounter)
{
CallbackCounter--;
- load.color = BLINK;
if (ReadValue != LIMIT)
{
//returned with a timeout
@@ -321,7 +325,6 @@
else
{
LoadStages++;
- load.color = colorON;
if (LoadStages == THREAD_LOAD_CLOSE_DANCERS)
{
MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold);
@@ -332,7 +335,7 @@
}
else
{
- load.color = fastBILNK;
+ load.color = colorON;
ThreadLoadingReport();
}
}
@@ -402,6 +405,7 @@
uint32_t Thread_Load_Initial_Tension(void) //Check Spool Presence, run Winder Until Break Sensor Is Identifieing Movement For A Second
{
REPORT_MSG(LoadStages, "Thread Load State Machine step");
+ load.color = BLINK;
if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT)
{
REPORT_MSG(LIMIT, "No cone in winder");
@@ -525,30 +529,57 @@
}
float numberOfSteps = 0;
float numberOfCycles = 0;
+ uint32_t DrierPrevLocation = 0;
uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue)
{
numberOfCycles++;
- //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
- //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0);
- if (LoadStages != THREAD_LOAD_DRYER_LOADING)
+ uint32_t temp = Control_Read_Dryer_Position(0,0);
+ if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY))
{
- return OK;
- }
- if (numberOfCycles<LoadArmInfo.LoadArmRounds)
- {
- MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
- numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000);
+ DrierPrevLocation = temp;
+ //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0);
+ if (LoadStages != THREAD_LOAD_DRYER_LOADING)
+ {
+ return OK;
+ }
+ if (numberOfCycles<LoadArmInfo.LoadArmRounds)
+ {
+ MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
+ numberOfSteps, Thread_Load_Dryer_Loading_Callback, 10000);
+ }
+ else
+ {
+ MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,10000);
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles);
+ Report("Store Number of cycles in drier",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0);
+ }
}
else
{
- MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Dryer_MovetoEncoderPosition_Callback,10000);
+ LOG_ERROR(LoadStages,"Load sequence timeout - drier loading");
+ Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0);
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles);
+ TimeoutsCounter = 0;
+ load.color = fastBILNK;
+ usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM);
+ LoadStatus = ERROR;
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200);
+ if(LoadingControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(LoadingControlId, ThreadLoadControlCBFunction );
+ LoadingControlId = 0xFF;
+ }
+ if (SpeedTControlId != 0xFF)
+ {
+ RemoveControlCallback(SpeedTControlId, ThreadLoadLengthCBFunction );
+ SpeedTControlId = 0xFF;
+ }
+ Report("Total Feeder load",__FILE__,__LINE__,dryerbufferCentimeters,RpMessage,TotalLoadedLen,0);
+
+ ThreadLoadingReport();
}
- /*if(LoadingControlId != 0xFF)
- {
- MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
- RemoveControlCallback(LoadingControlId, ThreadLoadControlCBFunction );
- LoadingControlId = 0xFF;
- }*/
return OK;
}
@@ -565,7 +596,8 @@
// OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000;
// CurrentControlledSpeed[FEEDER_MOTOR] = 1000;
- MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds);
+ //MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds);
+ MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierPrevLocation);
numberOfCycles = 0;
numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/**LoadArmInfo.LoadArmRounds*/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius;
// numberOfSteps -= 100;
@@ -607,8 +639,8 @@
CallbackCounter++;
Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0);
MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
- numberOfSteps-400, Thread_Load_Dryer_Loading_Callback, 100000);
-
+ numberOfSteps-400, Thread_Load_Dryer_Loading_Callback, 10000);
+//shlomo
//Keep Notation How Many Rotations In The Dryer
//LoadArmInfo.LoadArmBackLash = 0;
//LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
@@ -668,8 +700,13 @@
MotorStopAction(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID);
MotorStopAction(HARDWARE_MOTOR_TYPE__MOTO_DH_LID);
MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop);
+ if (LoadStages!=THREAD_LOAD_END)
+ {
+ usnprintf(LoadErrorMsg, 100, "Load sequence stopped by user on stage %d",LoadStages);
+ LoadStatus = ERROR;
+ }
LoadStages = THREAD_LOAD_INIT;
- load.color = colorOFF;
+ load.color = colorON;
return OK;
}
FPGA_GPI_ENUM screw[2] = {GPI_LS_SCREW_LEFT,GPI_LS_SCREW_RIGHT};
@@ -682,13 +719,71 @@
return OK;
}
Screw_Dir = 1-Screw_Dir;
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,15000);
+ status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000);
+ return OK;
+ }
+ uint32_t Thread_Load_Dryer_UnLoading_Callback(uint32_t MotorId, uint32_t ReadValue)
+ {
+ numberOfCycles++;
+ uint32_t temp = Control_Read_Dryer_Position(0,0);
+ if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY))
+ {
+ DrierPrevLocation = temp;
+ //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
+ //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0);
+ if (LoadStages != THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION)
+ {
+ return OK;
+ }
+ if (numberOfCycles<LoadArmInfo.LoadArmRounds)
+ {
+ MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
+ numberOfSteps, Thread_Load_Dryer_UnLoading_Callback, 10000);
+ }
+ else
+ {
+ MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Thread_Load_Set_Load_Arm_To_Stopper_Callback,10000);
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-numberOfCycles);
+ Report("Store Number of cycles in drier",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0);
+ }
+ }
+ else
+ {
+ LOG_ERROR(LoadStages,"Load sequence timeout - drier Unloading");
+ Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0);
+ MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-numberOfCycles);
+ TimeoutsCounter = 0;
+ if(PullerControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(PullerControlId, ThreadLoadControlCBFunction );
+ PullerControlId = 0xFF;
+ }
+ if(WinderControlId != 0xFF)
+ {
+ MotorStop(ThreadMotorIdToMotorId[WINDER_MOTOR],Hard_Hiz);
+ RemoveControlCallback(WinderControlId, ThreadLoadControlCBFunction );
+ WinderControlId = 0xFF;
+ }
+
+ MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW);
+ /*Task_sleep(5)
+ MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);
+ MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);*/
+
+ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz);
+ load.color = fastBILNK;
+ usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM);
+ LoadStatus = ERROR;
+ ThreadLoadingReport();
+ }
+ return OK;
}
uint32_t Thread_Load_Dryer_UnLoading(void)
{
REPORT_MSG(LoadStages, "Thread UnLoad State Machine step");
- LoadArmInfo.LoadArmRounds = 0;
+ //LoadArmInfo.LoadArmRounds = 0;
//uint32_t numberOfSteps = 0;
//Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40
SetOriginMotorSpeed(22);
@@ -715,7 +810,7 @@
MotorControlConfig[POOLER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage
MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDRIVING].directionthreadwize);
- PullerControlId = AddControlCallback(NULL,ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR);
+ PullerControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR);
Report("AddControlCallback Puller",__FILE__,__LINE__,PullerControlId,RpMessage,IfTypeThread*0x100+POOLER_MOTOR,0);*/
////////////////////////
MotorControlConfig[WINDER_MOTOR].m_params.MAX = 1;
@@ -747,16 +842,27 @@
CallbackCounter++;
//MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
// numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000);
+ //Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0);
+ //MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles);
+//shlomo
UnloadingStart = msec_millisecondCounter;
+ numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/**LoadArmInfo.LoadArmRounds*/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius;
+ numberOfCycles = 0;
+
+ MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierPrevLocation);
+
Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0);
- status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize),
- MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000);
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius);
+// status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize),
+// MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000);
+ MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,
+ numberOfSteps-400, Thread_Load_Dryer_UnLoading_Callback, 10000);
Screw_Dir = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize;
- status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,15000);
+ status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000);
//Keep Notation How Many Rotations In The Dryer
- LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
+ //LoadArmInfo.LoadArmRounds = (int)dryerbufferlength;
load.color = BLINK;
return OK;
}
@@ -764,6 +870,7 @@
uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue)
{
REPORT_MSG(ReadValue,"ThreadLoadStateMachine");
+ ThreadLoaded();
if (LoadStages!=ReadValue)
LoadStages = ReadValue;
switch (ReadValue)
@@ -976,7 +1083,9 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
}
- /* if (index == POOLER_MOTOR)
+ /*
+
+ if (index == POOLER_MOTOR)
{
if ((TranslatedReadValue)<(-1200))
{
@@ -1012,6 +1121,33 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}*/
return OK;
}
+bool ThreadLoaded(void)
+{
+ uint32_t ReadValue;
+
+ int32_t PoolerValue,WinderValue,FeederValue;
+ //this function tests if there is a thread in the machine. all dancers are in lowermost position then there is no thread.
+
+ ReadValue = Control_Read_Dancer_Position(FEEDER_DANCER,0);
+ FeederValue = ReadValue - DancersCfg[FEEDER_DANCER].zeropoint;
+ Report("Feeder out",__FILE__,FeederValue,ReadValue,RpWarning,(int)DancersCfg[FEEDER_DANCER].zeropoint,0);
+ ReadValue = Control_Read_Dancer_Position(WINDER_DANCER,0);
+ WinderValue = ReadValue - DancersCfg[WINDER_DANCER].zeropoint;
+ Report("Winder out",__FILE__,WinderValue,ReadValue,RpWarning,(int)DancersCfg[WINDER_DANCER].zeropoint,0);
+ ReadValue = Control_Read_Dancer_Position(POOLER_DANCER,0);
+ PoolerValue = ReadValue - DancersCfg[POOLER_DANCER].zeropoint;
+ //pooler dancer is right sided: data is opposite
+ PoolerValue = (-1*PoolerValue);
+ Report("Puller out",__FILE__,PoolerValue,ReadValue,RpWarning,(int)DancersCfg[POOLER_DANCER].zeropoint,0);
+
+ if (((PoolerValue)<(-1200))&&((WinderValue)<(-1200))&&((FeederValue)<(-1200)))
+ {
+ Report("Thread is out",__FILE__,(-1*PoolerValue),(-1*WinderValue),RpWarning,(-1*FeederValue),0);
+ return true;
+ }
+ else
+ return false;
+}
void ThreadLoadRequest(MessageContainer* requestContainer)
{
//#ifdef DEBUG_TEST_FUNCTIONS
@@ -1119,6 +1255,7 @@ uint32_t ThreadLoadingReport(void)
}
}
else return ERROR;
+ Report("ThreadLoadingReport",__FILE__,MessageState,response.state,RpWarning,(int)LoadStages,0);
//-------------------------------------------------------------------------------------------
responseContainer = createContainer(MESSAGE_TYPE__StartThreadLoadingResponse, ThreadLoadingToken, last, &response, &start_thread_loading_response__pack, &start_thread_loading_response__get_packed_size);
@@ -1137,6 +1274,7 @@ uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer)
StartThreadLoadingRequest *request = start_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
ustrncpy (ThreadLoadingToken, requestContainer->token,36);
MessageState = 1;
+ Report("StartThreadLoadingFunc",__FILE__,__LINE__,0,RpWarning,(int)LoadStages,0);
ThreadLoadingReport();
return OK;
@@ -1149,6 +1287,14 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer)
MessageContainer responseContainer;
MessageState = 2;
ThreadLoadingReport();
+ if (request->processparameters)
+ {
+ dryerbufferlength = request->processparameters->dryerbufferlength;
+ LoadArmInfo.LoadArmRounds = (int)(request->processparameters->dryerbufferlength);
+
+ }
+ Report("ContinueThreadLoadingFunc",__FILE__,__LINE__,(int)(request->processparameters->dryerbufferlength),RpWarning,(int)LoadStages,0);
+
responseContainer = createContainer(MESSAGE_TYPE__ContinueThreadLoadingResponse, requestContainer->token, true, &Cresponse, &continue_thread_loading_response__pack, &continue_thread_loading_response__get_packed_size);
responseContainer.continuous = false;
uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
@@ -1158,3 +1304,21 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer)
return OK;
}
+uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer)
+{
+ StopThreadLoadingRequest *request = stop_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+ StopThreadLoadingResponse Cresponse = STOP_THREAD_LOADING_RESPONSE__INIT;
+ MessageContainer responseContainer;
+ MessageState = 2;
+ Thread_Load_End();
+ Report("StopThreadLoadingFunc",__FILE__,__LINE__,(int)(request->processparameters->dryerbufferlength),RpWarning,(int)LoadStages,0);
+
+ responseContainer = createContainer(MESSAGE_TYPE__StopThreadLoadingResponse, requestContainer->token, true, &Cresponse, &stop_thread_loading_response__pack, &stop_thread_loading_response__get_packed_size);
+ responseContainer.continuous = false;
+ uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ my_free(responseContainer.data.data);
+ SendChars((char*)container_buffer, container_size);
+ return OK;
+
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 4db985954..f0b709ff2 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -143,9 +143,9 @@ uint32_t Winder_Prepare(void *JobDetails)
if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT)
{
REPORT_MSG(LIMIT, "No cone in winder");
- // PrepareReady(Module_Winder,ModuleFail);
- // AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true);
- // return ERROR;
+ PrepareReady(Module_Winder,ModuleFail);
+ AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true);
+ return ERROR;
}
#ifdef READ_SCREW_ENCODER
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index cc0bf6c77..dd9395248 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -76,6 +76,7 @@ void ThreadLoadRequest(MessageContainer* requestContainer);
uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer);
uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer);
+uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer);
uint32_t Thread_Load_End(void);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index 0df950f34..fb3b78752 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -170,7 +170,7 @@ uint32_t StoreDancerConfigMessage()
Dancers[Dancer_i].has_zeropoint = true;
Dancers[Dancer_i].hardwaredancertype = Dancer_i;
Dancers[Dancer_i].has_hardwaredancertype = true;
- DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0,0);
+ DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0);
DancerConfig.n_dancers++;
DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint;
}