From 7b7200235e2b78ac518860adcb04a59bebbdd54c Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Wed, 1 Jan 2020 14:28:35 +0200 Subject: Add head heaters + PT100 to I2C task + add semaphores to head PT100 ADC --- Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index f3eb9cb60..fb5de9011 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -1311,7 +1311,7 @@ uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) MessageContainer responseContainer; MessageState = 2; Thread_Load_End(); - Report("StopThreadLoadingFunc",__FILE__,__LINE__,(int)(request->processparameters->dryerbufferlength),RpWarning,(int)LoadStages,0); + Report("StopThreadLoadingFunc",__FILE__,__LINE__,(int)11,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; -- cgit v1.3.1 From 0e9b372b364a9d8307dd194ac06e7d9a22c58576 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 2 Jan 2020 14:52:39 +0200 Subject: some fixes from Beta + --- .../Embedded/Communication/CommunicationTask.c | 11 +- .../Embedded/Drivers/Motors/MotorActions.c | 16 ++- .../Embedded/Drivers/USB_Communication/USBCDCD.c | 1 + .../Embedded/Modules/Control/MillisecTask.c | 3 +- .../Embedded_SW/Embedded/Modules/Control/PIDAlgo.c | 44 +----- .../Embedded_SW/Embedded/Modules/Control/PIDAlgo.h | 1 - .../Embedded_SW/Embedded/Modules/Control/control.c | 9 +- .../Modules/Diagnostics/DiagnosticsHoming.c | 4 +- .../Embedded_SW/Embedded/Modules/General/buttons.c | 76 +++++++---- .../Embedded/Modules/Heaters/Heaters_init.c | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 26 +--- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 4 +- Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 12 +- .../Embedded/Modules/Stubs_Handler/Progress.c | 19 ++- .../Modules/Stubs_Handler/Stub_FPGARWReg.c | 20 ++- .../Embedded/Modules/Thread/ThreadLoad.c | 147 ++++++++++++++++----- .../Embedded/Modules/Thread/Thread_print.c | 12 +- .../Initialization/PowerOffSequence.c | 92 ++++++++----- .../Embedded/StateMachines/Printing/JobSTM.c | 2 +- .../Embedded/StateMachines/Printing/PrintingSTM.c | 43 +++--- 20 files changed, 352 insertions(+), 192 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index de10a4c99..99debf806 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -56,6 +56,7 @@ uint32_t initArray(size_t initialSize) inBuffer[10].buffer = CommRxBuffer; inBuffer[10].used = 0; inBuffer[10].size = initialSize; + //Report("initArray", __FILE__, 10, inBuffer[10].size, RpWarning, (int)0, 0); return 10; } else if (SerialBufferUsed[11] == false) @@ -64,6 +65,7 @@ uint32_t initArray(size_t initialSize) inBuffer[11].buffer = CommRxBuffer; inBuffer[11].used = 0; inBuffer[11].size = initialSize; + //Report("initArray", __FILE__, 10, inBuffer[10].size, RpWarning, (int)0, 0); return 11; } else return 0xFF; @@ -84,6 +86,7 @@ uint32_t initArray(size_t initialSize) inBuffer[i].buffer = (char *)&CommShortRxBuffer[i]; inBuffer[i].used = 0; inBuffer[i].size = initialSize; + //Report("initArray", __FILE__, i, inBuffer[i].size, RpWarning, (int)0, 0); return i; } } @@ -96,11 +99,11 @@ uint32_t initArray(size_t initialSize) bool insertArray(uint32_t buffer,char element) { - if (buffer>=12) + /*if (buffer>=12) { LOG_ERROR(buffer,"insertArray"); return false; - } + }*/ SerialBuffer *a = &inBuffer[buffer]; // a->used is the number of used entries, because a->array[a->used++] updates a->used only *after* the array has been accessed. // Therefore a->used can go up to a->size @@ -110,6 +113,8 @@ bool insertArray(uint32_t buffer,char element) void freeArray(uint32_t buffer) { + //Report("freeArray", __FILE__, buffer, inBuffer[buffer].size, RpWarning, (int)0, 0); + SerialBufferUsed[buffer] = false; } @@ -152,7 +157,7 @@ void communicationTask(UArg arg0, UArg arg1) //ui32RxCount = 0; - CommunicationRxMsgQ = Mailbox_create(sizeof(CommRxMessageStruc), 4, NULL,NULL); + CommunicationRxMsgQ = Mailbox_create(sizeof(CommRxMessageStruc), 20, NULL,NULL); /* Block while the device is NOT connected to the USB */ // Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 08ffac91f..b58bba677 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -356,7 +356,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea //CallbackCalls = 0; } Read_Dryer_ENC_Position(); - if (abs(ReadValue - DrierZeroPosition)<1) + if (abs(ReadValue - DrierZeroPosition)<2) { Report("MotorMoveToDrierPosition end",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); //stop this control loop @@ -427,6 +427,7 @@ uint32_t MotorSetSpeedWithCallback (TimerMotors_t MotorId, uint32_t _freq, callb uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO { uint32_t MotorId; + uint32_t Busy = BusyFlag; if (IfIndex>>8 != IfTypeMotors) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -462,11 +463,12 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO if ((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0)) { Report("motor timeout",__FILE__,__LINE__,MotorId,RpMessage,MotorTimeout[MotorId],0); + Busy = BUSY; } //call the module callback if (MotorCallback[MotorId]) { - MotorCallback[MotorId](MotorId,BusyFlag); + MotorCallback[MotorId](MotorId,Busy); } } @@ -759,7 +761,9 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re Condition = true; } - if (Condition == true) //thread running identified + MotorTimeout[MotorId]+=MotorTimeLag[MotorId]; + + if ((Condition == true)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) //thread running identified { //stop this control loop DancerValueDirection = false; @@ -774,7 +778,7 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re //call the module callback if (MotorCallback[MotorId]) - MotorCallback[MotorId](MotorId,ReadValue); + MotorCallback[MotorId](MotorId,Condition); } return OK; } @@ -791,6 +795,10 @@ uint32_t MotorMovetoDancerPosition (TimerMotors_t MotorId,bool direction, uint32 //SetMotorSpeed (deviceId, parameter); DancerValueDirection = dancervaluedirection; DancerId = dancerid; + MotorTimeout[MotorId] = 0; + MotorTimeLag[MotorId] = eTenMillisecond; + MotorTimeLimit[MotorId] = timeout; + MotorSetDirection( MotorId, direction); MotorSetSpeed(MotorId, Freq); MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToDancerPositionCallBackFunction, eTenMillisecond , Control_Read_Dancer_Position,(IfTypeMotors*0x100+MotorId), DancerId, 0 ); diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 3079b85d9..d6756934b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -45,6 +45,7 @@ #include #include "Common/Utilities/Utils.h" +#include "Common/SWUpdate/FileSystem.h" #include "Communication/CommunicationTask.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index aa8f29451..5cccc5b45 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -54,6 +54,7 @@ #include "Communication/Connection.h" #include "Modules/General/buttons.h" +#include "Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.h" Task_Handle Millisecond_Task_Handle; /******************** Definitions ********************************************/ @@ -527,7 +528,7 @@ int MillisecGetTemperatures (TEMPERATURE_SENSOR_ID_ENUM SensorId) return 0; return TemperatureCalc[SensorId]; } -bool RapidPressureRead = false; +bool RapidPressureRead = true; float PressureSum[MAX_SYSTEM_DISPENSERS]; float PressureMin[MAX_SYSTEM_DISPENSERS]; float PressureMax[MAX_SYSTEM_DISPENSERS]; diff --git a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c index 6c1b647be..3d1d353c2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.c @@ -2,41 +2,6 @@ #include "PIDAlgo.h" float PIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_Params *params, float *_pre_error, float *_integral) -{ - float error; - float derivative; - float output; - - //Calculate P,I,D - error = _setPoint - _mesuredParam; - - //In case of error too small then stop integration - if(fabs(error) > params->epsilon) - { - *_integral = *_integral + error*params->dt; - } - - derivative = (error - *_pre_error)/params->dt; - - output = params->Kp*error + params->Ki**_integral + params->Kd*derivative; - - //Saturation Filter - if(output > params->MAX) - { - output = params->MAX; - } - else if(output < params->MIN) - { - output = params->MIN; - } - - //Update error - *_pre_error = error; - - return output; -} - -float AdvancedPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_Params *params, float *_pre_error, float *_integral) { float error; float derivative; @@ -70,7 +35,7 @@ float AdvancedPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_ return output; } - +/* float TestPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_Params *params, float *_pre_error, float *_integral) { float error; @@ -81,14 +46,14 @@ float TestPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Conf error = _setPoint - _mesuredParam; //ITerm+= (ki * error); *_integral = *_integral + (error*params->Ki); - /* if(ITerm > outMax) + /`* if(ITerm > outMax) { ITerm= outMax; } else if(ITerm < outMin) { ITerm= outMin; - } */ + } *`/ if(*_integral > params->MAX) { *_integral = params->MAX; @@ -100,7 +65,7 @@ float TestPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Conf // double dInput = (input - lastInput); derivative = error - *_pre_error; - /*Compute PID Output*/ + /`*Compute PID Output*`/ // double output = kp * error + ITerm- kd * dInput; output = params->Kp*error/params->ProportionalErrorMultiplier + *_integral/params->IntegralErrorMultiplier + params->Kd*derivative; @@ -119,3 +84,4 @@ float TestPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Conf return output; } +*/ diff --git a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.h b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.h index 4792be9ec..4f94f3612 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/PIDAlgo.h @@ -17,6 +17,5 @@ typedef struct }PID_Config_Params; float PIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_Params *params, float *_pre_error, float *_integral); -float AdvancedPIDAlgorithmCalculation(float _setPoint,float _mesuredParam , PID_Config_Params *params, float *_pre_error, float *_integral); #endif /* MODULES_PIDALGO_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index b75e44001..0d73c9c93 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -181,9 +181,12 @@ uint32_t ControlActivityLed( uint32_t Parameter1) { FPGA_WD_Occurred = false; AlarmHandlingSetAlarm(EVENT_TYPE__FPGA_WATCHDOG_ACTIVATED,true); - JobEndReason = JOB_MOTOR_ALARM; - SendJobProgress(0.0,0,false, "Hardware Failure Error"); - AbortJob("FPGA Watchdog Error"); + if (JobIsActive()) + { + JobEndReason = JOB_MOTOR_ALARM; + SendJobProgress(0.0,0,false, "Hardware Failure Error"); + AbortJob("FPGA Watchdog Error"); + } ReportWithPackageFilter(FPGAFilter, "FPGA Watchdog Error",__FILE__,__LINE__,0,RpError, 0,0); ACTIVITY_GREEN_LED_ON; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 033f9daf1..c58d54a8c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -45,7 +45,7 @@ uint32_t MotorHomingRequestCallback(uint32_t deviceID, uint32_t ReadValue) MotorHomingResponse response = MOTOR_HOMING_RESPONSE__INIT; responseContainer = createContainer(MESSAGE_TYPE__MotorHomingResponse, HomingToken[deviceID], true, &response, &motor_homing_response__pack, &motor_homing_response__get_packed_size); - responseContainer.continuous = false; + responseContainer.continuous = true; 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); @@ -141,7 +141,7 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) responseContainer.error = ERROR_CODE__INVALID_PROCESS_ID; responseContainer.errormessage = "Job Active or incorrect motor ID"; responseContainer = createContainer(MESSAGE_TYPE__MotorHomingResponse, requestContainer->token, true, &response, &motor_homing_response__pack, &motor_homing_response__get_packed_size); - responseContainer.continuous = false; + responseContainer.continuous = true; 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); diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index 22af2b07e..d8c68b345 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -226,7 +226,8 @@ uint32_t Buttons_Init(void) strcpy(load.bttn_name, "load"); load.bttn_status = RELEASE; // 0=RELEASE 1=PRESS load.Action = OFFPB ; //OFFPB,short,long,count,replong - load.color = colorOFF; //colorOFF, BLUE, BLINK, + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ + load.color = colorON; //colorOFF, BLUE, BLINK, load.state = sttRDY; // load.count = 0; @@ -338,6 +339,13 @@ uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue) LoadLongPress( &load ); break; default: + if (ThreadLoadingActive() == false) + { + if (JobIsActive()) + load.color = colorOFF; + else + load.color = colorON; + } break; } return OK; @@ -528,29 +536,29 @@ uint32_t LoadStatMachine( button *pBtn) switch (pBtn->state) { case sttRDY : - ReportWithPackageFilter(GeneralFilter,"------------ load.state = sttRDY -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0); -/* switch (pBtn->Action) - { - case (SHORTPB): - case (LONGPB): - case (REPLONGPB): - pBtn->state = sttPRELOAD; - pBtn->color = BLINK;*/ - if (ThreadLoadButton( THREAD_LOAD_INIT)== OK) - { - pBtn->state = sttPRELOAD ; // to do - pBtn->color = colorON; - Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ - } - else - { - // pBtn->state = sttDISABLE ; - Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ - } - /*break; - default : - break; - }*/ +// ReportWithPackageFilter(GeneralFilter,"------------ load.state = sttRDY -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0); +///* switch (pBtn->Action) +// { +// case (SHORTPB): +// case (LONGPB): +// case (REPLONGPB): +// pBtn->state = sttPRELOAD; +// pBtn->color = BLINK;*/ +// if (ThreadLoadButton( THREAD_LOAD_INIT)== OK) +// { +// pBtn->state = sttPRELOAD ; // to do +// pBtn->color = colorON; +// Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ +// } +// else +// { +// // pBtn->state = sttDISABLE ; +// Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ +// } +// /*break; +// default : +// break; +// }*/ break; case sttPRELOAD: ReportWithPackageFilter(GeneralFilter,"------------ load.state = sttPRELOAD -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0); @@ -650,7 +658,25 @@ void test_avi() uint32_t LoadLongPress( button *pBtn) { ReportWithPackageFilter(GeneralFilter,"------------ load.state = LoadLongPress -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0); - Thread_Load_End(); + switch (pBtn->state) + { + case sttRDY : + ReportWithPackageFilter(GeneralFilter,"------------ load.state = sttRDY -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0); + if (ThreadLoadButton( THREAD_LOAD_INIT)== OK) + { + pBtn->state = sttPRELOAD ; // to do + pBtn->color = colorON; + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ + } + else + { + // pBtn->state = sttDISABLE ; + Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ + } + break; + default: + Thread_Load_End(); + } return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c index d7fc0703a..78ae37eef 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c @@ -45,7 +45,7 @@ typedef enum { }HEATERS_EVENTS_ENUM; */ /******************** GLOBAL PARAMETERS ********************************************/ -HeaterPIDControlConfig HeaterControl[HEATER_TYPE_MAX_HEATERS] = {0,0,0,0,0,0,0,0,0,0,0,0}; +HeaterPIDControlConfig HeaterControl[HEATER_TYPE_MAX_HEATERS] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; bool AcHeaterConfigured[MAX_AC_HEATERS] = {0,0,0}; int NumberOFSlicesInUse = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 71fd9a428..50796d3c9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -1110,16 +1110,8 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) } else { - if (HeaterPIDConfig[index].m_params.IntegralErrorMultiplier == 0) - { - HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - } - else - { - HeaterPIDConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - } + HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, + &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); //} // len = usnprintf(ACheatstr, 254, "ACD Id, Temp , Integral, Output{ %d, %d ,%d, %d} ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); // ReportWithPackageFilter(HeatersFilter,logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); @@ -1272,16 +1264,8 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) } else { - if (HeaterPIDConfig[index].m_params.IntegralErrorMultiplier == 0) - { - HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - } - else - { - HeaterPIDConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - } + HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, + &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); } // error[index][Counter[index]] = HeaterPIDConfig[index].m_preError; @@ -1469,7 +1453,7 @@ uint32_t HeatersControlLoop(uint32_t tick) SliceCounter++; if (SliceCounter >= NumberOFSlicesInUse) SliceCounter = 0; - //Trigger_HeaterWriting(); + return OK; } /****************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 28bb191fe..00d740c7e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -159,7 +159,7 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request) DispenserControlConfig[Dispenser_i].m_isReady = true; DispenserControlConfig[Dispenser_i].m_mesuredParam = 0; DispenserControlConfig[Dispenser_i].m_preError = 0; - DispenserControlConfig[Dispenser_i].m_SetParam = 1.65;//need to update SetParams on presegment stage + DispenserControlConfig[Dispenser_i].m_SetParam = DispensersCtrl[Dispenser_i].outputproportionalcycletime;//need to update SetParams on presegment stage return OK; @@ -169,7 +169,7 @@ uint32_t IDS_Pid_Testing_Func(uint32_t DispenserId, uint32_t ReadValue) { float calculated_speed; DispenserControlConfig[DispenserId].m_mesuredParam = MillisecGetPressures(DispenserId); - DispenserControlConfig[DispenserId].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)DispenserControlConfig[DispenserId].m_SetParam , (float)DispenserControlConfig[DispenserId].m_mesuredParam, + DispenserControlConfig[DispenserId].m_calculatedError = PIDAlgorithmCalculation((float)DispenserControlConfig[DispenserId].m_SetParam , (float)DispenserControlConfig[DispenserId].m_mesuredParam, &DispenserControlConfig[DispenserId].m_params, &DispenserControlConfig[DispenserId].m_preError, &DispenserControlConfig[DispenserId].m_integral); DispenserControlConfig[DispenserId].m_calculatedError = (-1*DispenserControlConfig[DispenserId].m_calculatedError); calculated_speed = (1-DispenserControlConfig[DispenserId].m_calculatedError)*CurrentDispenserSpeed[DispenserId]; diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index c6128b0cb..15117e616 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -32,6 +32,10 @@ bool IFS_TimeOutAlarm(bool status); bool ColorMatch(); bool MidTankValvesAction(bool action); +bool IFS_MidTankFilling(void) +{ + return (IFS_info.Ink.time_out > 0); +} //RfidTagContent TagContent[MAX_CARTRIDGES]; NFC_Tag NFCTag[MAX_CARTRIDGES]; @@ -230,8 +234,8 @@ bool MidTankValvesAction(bool action) //Cartridge_MidTank_ON of Cartridge_MidTan { Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); } -#warning check that the dispenser is not in homing before CLOSING the air valve - Valve_Set(IDS_Id_to_AirValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON + if (IDS_IsHomingActive(IFS_info.Ink.cart_color)==false) + Valve_Set(IDS_Id_to_AirValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON Valve_Set(IDS_Id_to_CartrideValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON ret = true; @@ -396,7 +400,9 @@ uint32_t MidTankCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) uint32_t MidTankReading(void) { MidTankCounter = 0; - MidTankReadControlId = AddControlCallback("MidTankRead", MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + if (IFS_info.Ink.time_out > 0) + return ERROR; + MidTankReadControlId = AddControlCallback( MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 8d0a23f23..013d22968 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -24,7 +24,7 @@ #include "Modules/IFS/ifs.h" #include "Modules/IDS/ids_ex.h" #include "Modules/Control/MillisecTask.h" - +#include "modules/thread/thread_ex.h" #include #include #include @@ -276,11 +276,26 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) } else - if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off + if(request->amount == 0xB2) //fast refresh for pressure + { + LOG_ERROR(request->delay,"Set loading arm cycles"); + + response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,request->delay); + response.has_progress = true; + + } + else + if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off { PowerOffInit(); } else + if(request->amount == 0xF1) + { + LOG_ERROR(request->delay,"NumberOfRotationPerPassage"); + NumberOfRotationPerPassage = (float)(request->delay)/1000; + } + else { response.has_progress = true; int i = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c index 2fd85db09..a058d54f9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c @@ -24,6 +24,8 @@ #include "drivers/FPGA/FPGA.h" #include "drivers/FPGA/FPGA_Comm.h" +#include "control/control.h" + void Stub_FpgaReadRegRequest(MessageContainer* requestContainer) { @@ -67,10 +69,19 @@ void Stub_FpgaReadRegRequest(MessageContainer* requestContainer) //free(requestContainer); } +uint32_t value = 0,ctlId; +uint32_t ResetCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + SafeRemoveControlCallback(ctlId, ResetCallBackFunction ); + volatile short *ptr = (volatile short *)(FPGA3_BASE | 0x3D0); + *ptr = (value & 0xFFFF); + return OK; +} void Stub_FpgaWriteRegRequest(MessageContainer* requestContainer) { uint32_t status = PASSED; + volatile short *ptr; MessageContainer responseContainer; @@ -82,9 +93,14 @@ void Stub_FpgaWriteRegRequest(MessageContainer* requestContainer) } else { - volatile short *ptr; + value = request->value; ptr = (volatile short *) (request->address); - *ptr = (request->value & 0xFFFF); + if (request->address == (FPGA3_BASE | 0x3D0)) + { + ctlId = AddControlCallback( ResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,ptr,ptr, 0 ); + } + else + *ptr = (request->value & 0xFFFF); } StubFpgaWriteRegResponse response = STUB_FPGA_WRITE_REG_RESPONSE__INIT; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index fb5de9011..40000b8bb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -74,6 +74,8 @@ int32_t keepkvalrun,keepkvalhold; uint8_t CallbackCounter = 0; uint8_t TimeoutsCounter = 0; + bool SecondTry = false,TryAgain = false; + int MessageState = 0; //0 - none, 1 = start, 2 = continue uint32_t UnloadingStart = 0; uint8_t NumberOfDrierLoaderCycles = 0; @@ -112,7 +114,8 @@ else return false; } - uint32_t Thread_Load_Init(void) + bool InitCalled = false; + uint32_t Thread_Load_Init(THREAD_LOAD_STAGES_ENUM Stage) { //void* buffer = NULL; //uint32_t Bytes = 0; @@ -128,7 +131,8 @@ //EEPROM_STORAGE_DRYER_CYCLES MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); - Read_Dryer_ENC_Position(); + + Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); //if (LoadArmInfo.LoadArmRounds <= 2) // LoadArmInfo.LoadArmRounds = 20; @@ -151,8 +155,12 @@ StopInitSequence(); memcpy (&ProcessParametersRecover,&ProcessParametersKeep,sizeof(ProcessParameters)); //NumberOfDrierLoaderCycles = loadLoadArmParameters(); - LoadStages++; - ThreadLoadStateMachine(LoadStages); + if (Stage == THREAD_LOAD_INIT) + { + LoadStages++; + ThreadLoadStateMachine(LoadStages); + } + InitCalled = true; return OK; } @@ -179,6 +187,7 @@ LOG_ERROR (LoadStages, "Thread_Load_Init failed"); strcpy(LoadErrorMsg,"Thread_Load_Init failed"); LoadStatus = ERROR; + TryAgain = true; } else { @@ -273,13 +282,37 @@ //Use Notation How Many Rotations In The Drier, Or Check Against Stopper. Move Slowly return OK; }*/ - uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t BusyFlag) + uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t Condition) { - CallbackCounter--; - Report("Thread_Load_Jog_Feeder_To_Middle_Point_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); - //storeLoadArmParameters(); - LoadStages++; - ThreadLoadStateMachine(LoadStages); + if (Condition == true) + { + CallbackCounter--; + Report("Thread_Load_Jog_Feeder_To_Middle_Point_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + //storeLoadArmParameters(); + LoadStages++; + ThreadLoadStateMachine(LoadStages); + } + else + { + CallbackCounter--; + Report("Thread_Load_Jog_Feeder_To_Middle_Point TimeOut!",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + //storeLoadArmParameters(); + if (SecondTry == true) + { + LoadStages++; + ThreadLoadStateMachine(LoadStages); + LoadStatus = OK; + } + else + { + TimeoutsCounter = 0; + load.color = fastBILNK; + usnprintf(LoadErrorMsg, 100, "Thread_Load_Jog_Feeder_To_Middle_Point TimeOut!"); + LoadStatus = ERROR; + ThreadLoadingReport(); + TryAgain = true; + } + } return OK; } @@ -321,6 +354,7 @@ usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, MotorId); LoadStatus = ERROR; ThreadLoadingReport(); + TryAgain = true; } else { @@ -371,10 +405,10 @@ uint32_t Thread_Load_Lift_Dancers(void) { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; + /*keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 40); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000);*/ CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); @@ -387,8 +421,17 @@ keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; if (keepkvalrun>=25) keepkvalrun = 25; + + Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); + Report("Thread_Load_Lift_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); + Report("Thread_Load_Lift_right dancer",__FILE__,__LINE__,0,RpMessage,0,0); + keepkvalhold = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].kvalhold; + MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 40); + CallbackCounter++; + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 22, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); + REPORT_MSG(LoadStages, "Thread Load State Machine step"); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 8); @@ -489,7 +532,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 100, FEEDER_DANCER ,true, Thread_Load_Jog_Feeder_To_Middle_Point_Callback,2000); + MotorMovetoDancerPosition (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 100, FEEDER_DANCER ,true, Thread_Load_Jog_Feeder_To_Middle_Point_Callback,4000); return OK; } @@ -529,14 +572,16 @@ } float numberOfSteps = 0; float numberOfCycles = 0; - uint32_t DrierPrevLocation = 0; + double DrierPrevLocation = 0; uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) { numberOfCycles++; - uint32_t temp = Control_Read_Dryer_Position(0,0); - if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) + + Report("Thread_Load_Dryer_Loading_Callback",__FILE__,(int)TotalLoadedLen,(int)DrierPrevLocation,RpMessage,ReadValue,0); + + if ((fabs (TotalLoadedLen -DrierPrevLocation)>50 )&&(ReadValue == NOTBUSY)) { - DrierPrevLocation = temp; + DrierPrevLocation = TotalLoadedLen ; //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) @@ -558,6 +603,8 @@ else { LOG_ERROR(LoadStages,"Load sequence timeout - drier loading"); + TryAgain = true; + SecondTry = false; Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0); MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles); TimeoutsCounter = 0; @@ -727,6 +774,8 @@ { numberOfCycles++; uint32_t temp = Control_Read_Dryer_Position(0,0); + Report("Thread_Load_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); + //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) { DrierPrevLocation = temp; @@ -754,6 +803,7 @@ 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; + CallbackCounter = 0; if(PullerControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz); @@ -851,15 +901,15 @@ MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierPrevLocation); - Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage, LoadArmInfo.LoadArmRounds,0); 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,30000); + Screw_Dir = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize; + status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,20000); //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; @@ -877,11 +927,24 @@ { case THREAD_LOAD_INIT: //LoadStages++; - Thread_Load_Init(); + MessageState = 1; + + Thread_Load_Init(ReadValue); break; case THREAD_LOAD_REDUCE_HEAT: //HEATERS OFF, DRYER BLOWER OFF, BLOWER LOW, //LoadStages++; + MessageState = 1; + if (InitCalled == false) + { + REPORT_MSG(ReadValue,"Thread_Load_Init called from 1"); + Thread_Load_Init(ReadValue); + } + else + { + REPORT_MSG(ReadValue,"Thread_Load_Init called from 0"); + } Thread_Load_Reduce_Heat(); + InitCalled = false; break; case THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION://USE NOTATION HOW MANY ROTATIONS IN THE DRYER, OR CHECK AGAINS STOPPER. MOVE SLOWLY //LoadStages++; @@ -939,6 +1002,7 @@ ThreadLoadingReport(); break; case THREAD_LOAD_END: + MessageState = 0; LoadStages = THREAD_LOAD_END; Thread_Load_End(); break; @@ -961,9 +1025,19 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) return ERROR; } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); - if (LoadStages > ReadValue) + if (LoadStatus == ERROR) { - ThreadLoadStateMachine(LoadStages+1); + if ((SecondTry == false)&&(TryAgain == true)) + { + LoadStatus = OK; + SecondTry = true; + ThreadLoadStateMachine(LoadStages); + } + else + { + SecondTry = false; + ThreadLoadStateMachine(LoadStages+1); + } } else { @@ -1071,7 +1145,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { @@ -1209,7 +1283,7 @@ void ThreadLoadPollRequest(MessageContainer* requestContainer) stub_heating_test_poll_request__free_unpacked(request,NULL); } char ThreadLoadingToken[36+1] = {0}; -int MessageState = 0; //0 - none, 1 = start, 2 = continue +char DefaultErrSrt[] = "OK"; uint32_t ThreadLoadingReport(void) { MessageContainer responseContainer; @@ -1219,7 +1293,14 @@ uint32_t ThreadLoadingReport(void) if (ThreadLoadingToken[0] == 0) return OK; - if (MessageState == 1) + if (MessageState == 0) + { + response.has_state = true; + response.state = THREAD_LOADING_STATE__None; + response.errorreason = DefaultErrSrt; + + } + else if (MessageState == 1) { response.has_state = true; if (LoadStatus == OK) @@ -1228,6 +1309,7 @@ uint32_t ThreadLoadingReport(void) if (LoadStages == THREAD_LOAD_INITIAL_TENSION) { response.state = THREAD_LOADING_STATE__ReadyForLoading; + response.errorreason = DefaultErrSrt; } } else @@ -1242,10 +1324,11 @@ uint32_t ThreadLoadingReport(void) if (LoadStatus == OK) { response.state = THREAD_LOADING_STATE__Finalizing; - if (LoadStages >= THREAD_LOAD_JOG_THREAD) + if (LoadStages > THREAD_LOAD_JOG_THREAD) { response.state = THREAD_LOADING_STATE__Completed; - last = true; + response.errorreason = DefaultErrSrt; + //last = true; } } else @@ -1273,7 +1356,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; + //MessageState = 1; Report("StartThreadLoadingFunc",__FILE__,__LINE__,0,RpWarning,(int)LoadStages,0); ThreadLoadingReport(); return OK; @@ -1301,6 +1384,10 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); + if (LoadStages == THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call + { + ThreadLoadStateMachine(LoadStages); + } return OK; } @@ -1311,7 +1398,7 @@ uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) MessageContainer responseContainer; MessageState = 2; Thread_Load_End(); - Report("StopThreadLoadingFunc",__FILE__,__LINE__,(int)11,RpWarning,(int)LoadStages,0); + Report("StopThreadLoadingFunc",__FILE__,__LINE__,0xFF,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; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index dd31e9cda..0a3a9e149 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -143,7 +143,7 @@ void ThreadUpdateProcessLength (double length, void *Funcptr) CurrentProcessedLength = 0; ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; } -char Lenstr[150]; +char Lenstr[160]; uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { uint32_t positionDiff = 0,prevprev; @@ -300,12 +300,12 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { if (PrepareState == true) { -#ifdef Use_Head_Card - strcpy(Lenstr,"Heating up"); -#else +//#ifdef Use_Head_Card +// strcpy(Lenstr,"Heating up"); +//#else //later - add temperatures TemperatureListString(Lenstr); -#endif +//#endif SendJobProgress(0.0,0,false, Lenstr); } else @@ -602,7 +602,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; DancerError[DancerId] = NormalizedError; - MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index fac05fe2b..1fb77a540 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -10,6 +10,7 @@ #include "PMR/Power/StartPowerDownResponse.pb-c.h" #include "PMR/Power/AbortPowerDownResponse.pb-c.h" #include "PMR/Power/PowerDownState.pb-c.h" +#include "PMR/MachineStatus/MachineStatus.pb-c.h" #include "modules/General/GeneralHardware.h" #include "modules/General/Safety.h" @@ -21,23 +22,23 @@ #include "modules/heaters/heaters_ex.h" #include "modules/Diagnostics/Diagnostics.h" #include "Modules/General/process.h" -#include "PMR/MachineStatus/MachineStatus.pb-c.h" #include "Modules/General/MachineStatus.h" - #include "Modules/Thread/Thread_ex.h" +#include "Modules/Control/MillisecTask.h" +#include "Modules/heaters/heaters_ex.h" + #include "Common/SWUpdate/FirmwareUpgrade.h" -#include "StateMachines/Printing/PrintingSTM.h" -#include "PowerIdle.h" -#include "InitSequence.h" #include "drivers/I2C_Communication/DAC/Blower.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "drivers/Heater/TemperatureSensor.h" #include "drivers/Valves/Valve.h" -#include "heaters/heaters_ex.h" +#include "StateMachines/Printing/PrintingSTM.h" +#include "PowerIdle.h" +#include "InitSequence.h" #include "PowerOffSequence.h" /* typedef enum @@ -58,6 +59,7 @@ POWER_OFF_MAX, }POWER_OFF_STAGES_ENUM; */ + POWER_OFF_STAGES_ENUM PowerOffMachineState = POWER_OFF_INIT,StoredMachineState = POWER_OFF_INIT; uint32_t PowerOffControlId = 0xFF; uint32_t WaitForProcessControlId = 0xFF; @@ -333,40 +335,46 @@ uint32_t PowerOffSetValvePosition(void) PowerOffMachineState++; return OK; } +double StoreMax = 500; +uint32_t MaxTemp = 0; /*******************************************************************************************************/ uint32_t PowerOffWaitForTemperatureCallback(uint32_t IfIndex, uint32_t BusyFlag) { - uint32_t MaxTemp = 0,readTemp; - readTemp = TemperatureSensorRead( MIXER_PT100); + uint32_t readTemp; + MaxTemp = 0; + readTemp = MillisecGetTemperatures( MIXER_PT100); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP1); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DYEINGH_TEMP1); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP2); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DYEINGH_TEMP2); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP3); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DYEINGH_TEMP3); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP4); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DYEINGH_TEMP4); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP5); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DYEINGH_TEMP5); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( HEAD6_PT100); + readTemp = MillisecGetTemperatures( HEAD6_PT100); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DRYER_TEMP1); + readTemp = MillisecGetTemperatures( TEMP_SENSE_ANALOG_DRYER_TEMP1); if ((readTemp>= MaxTemp)&&(readTemp < 28000)) MaxTemp = readTemp; - + if (StoreMax == 500) + StoreMax = MaxTemp; if ((MaxTemp>PowerOffTemperatureThreshold)&&(WaitForProcessCounter++<3600)) { Report("On going cooling down, wait for end of cooling",__FILE__,__LINE__,(int)MaxTemp,RpWarning,(int)WaitForProcessCounter,0); resetIdleCounter(); + if (WaitForProcessCounter%10 == 2) + PowerDownUpdate(POWER_OFF_WAIT_FOR_TEMPERATURE); } else { @@ -381,6 +389,7 @@ uint32_t PowerOffWaitForTemperatureCallback(uint32_t IfIndex, uint32_t BusyFlag) uint32_t PowerOffWaitForTemperature(void) { Report("PowerOff Wait For Temperature",__FILE__,__LINE__,(int)PowerOffTemperatureThreshold,RpWarning,(int)3600,0); + StoreMax = 500; if (WaitForProcessControlId == 0xFF) { WaitForProcessCounter = 0; @@ -497,65 +506,81 @@ uint32_t PowerDownUpdate(POWER_OFF_STAGES_ENUM stage) { uint32_t status = NOT_SUPPORTED; + double calulate; + int result; MessageContainer responseContainer; - StartPowerDownResponse response = START_POWER_DOWN_REQUEST__INIT; + StartPowerDownResponse response = START_POWER_DOWN_RESPONSE__INIT; bool last = false; if (PowerDownToken[0] == 0) return OK; response.has_state = true; response.has_progresspercentage = true; - response.message = "Hello world"; switch (stage) { case POWER_OFF_INIT: response.state = stage +1; response.progresspercentage = 0.0; + response.message = "Initializing"; break; case POWER_OFF_HEAD_CLEAN: response.state = stage +1; response.progresspercentage = 5.0; + response.message = "Clean head"; break; case POWER_OFF_MIXER_FLUSH: response.state = stage +1; response.progresspercentage = 20.0; + response.message = "Flush mixer"; break; case POWER_OFF_HEATERS_OFF: response.state = stage +1; response.progresspercentage = 22.0; + response.message = "Heaters off"; break; case POWER_OFF_STORE_DATA: response.state = stage +1; response.progresspercentage = 23.0; + response.message = "Store data"; break; case POWER_OFF_WAIT_FOR_PROCESSES: //wait for waste emptying: ink filling: thread loading response.state = stage +1; response.progresspercentage = 30.0; + response.message = "Wait for processes"; break; case POWER_OFF_STOP_RUNNING_JOB: response.state = stage +1; response.progresspercentage = 31.0; + response.message = "Stop running job"; break; case POWER_OFF_SET_VALVE_POSITION: response.state = stage +1; response.progresspercentage = 32.0; + response.message = "Valves"; break; case POWER_OFF_WAIT_FOR_TEMPERATURE: response.state = stage +1; - response.progresspercentage = 33.0; + calulate = (double)((StoreMax-MaxTemp)/(StoreMax-PowerOffTemperatureThreshold))*64.0; + result = (int)calulate; + response.progresspercentage = 33.0 + result; + Report("Wait calculation",__FILE__,MaxTemp,(int)response.progresspercentage,RpWarning,(int)result,0); + response.message = "Wait for cooling down"; break; case POWER_OFF_TURN_OFF_DRYER_FAN: response.state = stage +1; response.progresspercentage = 97.0; + response.message = "Drier fan off"; break; case POWER_OFF_TURN_OFF_COOLER: response.state = stage +1; response.progresspercentage = 98.0; + response.message = "Cooler off"; break; case POWER_OFF_TURN_OFF_BLOWER: response.state = stage +1; response.progresspercentage = 99.0; + response.message = "Blower off"; break; case POWER_OFF_POWER_OFF: case POWER_OFF_ERROR: @@ -563,8 +588,10 @@ uint32_t PowerDownUpdate(POWER_OFF_STAGES_ENUM stage) response.state = stage +1; response.progresspercentage = 100.0; last = true; + response.message = "end of process"; break; } + Report("PowerDownUpdate",__FILE__,last,(int)response.progresspercentage,RpWarning,(int)stage,0); responseContainer = createContainer(MESSAGE_TYPE__StartPowerDownResponse, PowerDownToken, last, &response, &start_power_down_response__pack, &start_power_down_response__get_packed_size); responseContainer.continuous = true; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); @@ -595,6 +622,16 @@ void PowerDownStopReporting(void) { PowerDownToken[0] = 0; } +uint32_t ctlId; +uint32_t AbortPowerDownResetCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + SafeRemoveControlCallback(ctlId, AbortPowerDownResetCallBackFunction ); + /*volatile short *ptr = (volatile short *)(0x60000800 | 0x3D0); + *ptr = 0;*/ + Power_Reset(); + return OK; +} + uint32_t AbortPowerDownFunc(MessageContainer* requestContainer) { @@ -602,10 +639,10 @@ uint32_t AbortPowerDownFunc(MessageContainer* requestContainer) AbortPowerDownRequest* request = abort_power_down_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - AbortPowerDownResponse response = ABORT_POWER_DOWN_REQUEST__INIT; + AbortPowerDownResponse response = ABORT_POWER_DOWN_RESPONSE__INIT; //TODO Handle the request!!!! - PowerDownStopReporting(); + //PowerDownStopReporting(); responseContainer = createContainer(MESSAGE_TYPE__AbortPowerDownResponse, requestContainer->token, false, &response, &abort_power_down_response__pack, &abort_power_down_response__get_packed_size); responseContainer.continuous = true; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); @@ -614,17 +651,10 @@ uint32_t AbortPowerDownFunc(MessageContainer* requestContainer) //USBCDCD_sendData(container_buffer, container_size,10); SendChars((char*)container_buffer, container_size); - Report("HWSystemResetRequest", __FILE__,__LINE__,0, RpMessage, 2, 0); - - //ROM_SysCtlDelay(SYS_CLK_FREQ); - Task_sleep(2000); - - //ROM_SysCtlDelay(SYS_CLK_FREQ); - Task_sleep(2000); + PowerDownUpdate(POWER_OFF_CANCELLED); - SysCtlReset(); - - HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ; + ctlId = AddControlCallback( AbortPowerDownResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + Report("HWSystemResetRequest", __FILE__,__LINE__,0, RpMessage, 2, 0); return OK; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 83f4f032e..3ac39d390 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -800,7 +800,6 @@ void JobRequestFunc(MessageContainer* requestContainer) if (status == PASSED) { Report("Job Request ",__FILE__,__LINE__,Ticket->processparameters->dyeingspeed,RpWarning,n_segments, Ticket->intersegmentlength); - OpenJobFile(); StartJob(CurrentJob); } } @@ -1150,6 +1149,7 @@ Void jobTask(UArg arg0, UArg arg1) PowerIdleOutOfIdleState(); SetMachineStatus(MACHINE_STATE__PreparingJob); JobResumed = false; + OpenJobFile(); setmachineActive(true); PrepareState (CurrentJob); break; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 587b1d2e8..b209208a3 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -777,34 +777,47 @@ void PrintSTMMsgHandler(void * msg) LOG_ERROR(SegmentId, "Error releasing Segment"); else if (Segment) { - if (IDSCheckSegmentData(Segment, SegmentId) == OK) + if (SegmentIdPointer) //do not perform after a rewind { - FreeSegmentFileData(Segment); + if (IDSCheckSegmentData(Segment, SegmentId) == OK) + { + FreeSegmentFileData(Segment); + } + else + { + JobEndReason = JOB_OTHER_ALARM; + if (dryerbufferlength <= 0.1) + EndState(CurrentJob, "Job Ended"); + else + DistanceToSpoolState(CurrentJob); + } } else - { - JobEndReason = JOB_OTHER_ALARM; - if (dryerbufferlength <= 0.1) - EndState(CurrentJob, "Job Ended"); - else - DistanceToSpoolState(CurrentJob); - } - + Report("not checking after a rewind ",__FILE__,__LINE__, SegmentId,RpMessage,SegmentIdPointer,0); + } + else + { + LOG_ERROR(SegmentId, "Error Segment is null"); } Segment = GetNextSegmentFromJobFile(); - if (Segment == NULL) + if ((Segment == NULL)||(Segment->length <0.1)) { + Report("SegmentLoading failed",__FILE__,__LINE__, Segment,RpMessage,(int)(Segment->length*100),0); JobEndReason = JOB_OTHER_ALARM; if (dryerbufferlength <= 0.1) EndState(CurrentJob, "Job Ended"); else DistanceToSpoolState(CurrentJob); } - SSegment.length = Segment->length; - SSegment.has_length = Segment->has_length; - SSegment.n_brushstops = Segment->brushstopscount; - PreSegmentState(&SSegment,SegmentId,SegmentIdPointer); + else + { + SSegment.length = Segment->length; + SSegment.has_length = Segment->has_length; + SSegment.n_brushstops = Segment->brushstopscount; + + PreSegmentState(&SSegment,SegmentId,SegmentIdPointer); + } } else { -- cgit v1.3.1 From 26b6af221609c7126a73351e415d7017613c31ae Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 6 Jan 2020 12:34:55 +0200 Subject: some fixes from 1.4.5.110 (Beta +) --- .../Embedded_SW/Embedded/Common/report/filter.c | 5 +++ .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded/Communication/Connection.c | 4 +++ .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 12 ++++--- .../Embedded/Drivers/Motors/MotorActions.c | 15 ++++---- .../Embedded/Modules/IDS/IDS_dispenser.c | 4 +-- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 4 +-- Software/Embedded_SW/Embedded/Modules/IFS/ifs.h | 1 + .../Embedded/Modules/Thread/ThreadLoad.c | 42 +++++++++++++--------- .../Embedded/Modules/Thread/Thread_Winder.c | 10 ++++-- .../Embedded/Modules/Thread/Thread_ex.h | 2 ++ 11 files changed, 66 insertions(+), 35 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/report/filter.c b/Software/Embedded_SW/Embedded/Common/report/filter.c index febc1ea8c..f0eb5a140 100644 --- a/Software/Embedded_SW/Embedded/Common/report/filter.c +++ b/Software/Embedded_SW/Embedded/Common/report/filter.c @@ -360,6 +360,11 @@ STATUS Report(const char *message, int parameter2) { + if ((FileName == 0)&&(errorCode==0)&&(LineNumber==0)&&(parameter1 == 0)) + { + LOG_ERROR(55,"Error report"); + } + /* if message passes the filter send it to distributor */ if (filterTest(severity) || (GET_PRIVATE_SEVERITY(severity) > 0)) return reportDistribute(REPORT_FORMAT, diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index 99debf806..56ceccd28 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -34,7 +34,7 @@ struct serialBuffer { size_t used; size_t size; } typedef SerialBuffer; -#define SHORT_BUFFER_SIZE 200 +#define SHORT_BUFFER_SIZE 100 char CommShortRxBuffer[10][SHORT_BUFFER_SIZE]; char CommRxBuffer[2][COMM_MAX_BUFFER_SIZE]; SerialBuffer inBuffer[12]; diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 18f176e64..9f355fa59 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -64,6 +64,10 @@ void ConnectionRequest(MessageContainer* requestContainer) if (request->has_unixtime) utilsUpdateDateTime(request->unixtime);//(request->seconds); + ReportStopReporting(); + DiagnosticsStop(); + JobStopReporting(); + AlarmHandlingStop(); /* extern TangoVersion_t _gTangoVersion; extern char Dat[50]; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index d1a3ee958..42e4d673b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -371,37 +371,41 @@ uint32_t SetMotHome(TimerMotors_t _motorId) uint32_t MotorSetMaxSpeed(TimerMotors_t _motorId, uint32_t MaxSpeed) { + if(MotorsCfg[_motorId].maxfrequency != MaxSpeed) + ReportWithPackageFilter(GeneralFilter,"MotorSetMaxSpeed",__FILE__,__LINE__,_motorId,RpMessage,MaxSpeed,0); MotorsCfg[_motorId].maxfrequency = MaxSpeed; FPGA_SetMotMaxSpeed(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetMaxSpeed",__FILE__,__LINE__,_motorId,RpMessage,MaxSpeed,0); return OK; } uint32_t MotorSetMicroStep(TimerMotors_t _motorId, uint32_t microstep) { + if (MotorDriverRequest[_motorId].microstep != microstep) + ReportWithPackageFilter(GeneralFilter,"MotorSetMicroStep",__FILE__,__LINE__,_motorId,RpMessage,microstep,0); MotorDriverRequest[_motorId].microstep = microstep; FPGA_SetMotMicroStep(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetMicroStep",__FILE__,__LINE__,_motorId,RpMessage,microstep,0); return OK; } uint32_t MotorSetKvalHold(TimerMotors_t _motorId, uint8_t Value) { + if(MotorsCfg[_motorId].kvalhold != Value) + ReportWithPackageFilter(GeneralFilter,"MotorSetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,Value,0); MotorsCfg[_motorId].kvalhold = Value; MotorsCfg[_motorId].tvalhold = Value; FPGA_SetMotKvalHold(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,Value,0); return OK; } uint32_t MotorSetKvalRun(TimerMotors_t _motorId, uint8_t Value) { + if(MotorsCfg[_motorId].kvalrun != Value) + ReportWithPackageFilter(GeneralFilter,"MotorSetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,Value,0); MotorsCfg[_motorId].kvalrun = Value; MotorsCfg[_motorId].tvalrun = Value; FPGA_SetMotKvalRun(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,Value,0); return OK; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index b58bba677..ddd0d293c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -260,7 +260,7 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / //REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction stopped"); Report("Motor to stopper stopped",__FILE__,avreageSampleValue,StoredavreageSampleValue,RpWarning,avreageSampleSum,0); Report("Move_To_Stopper_Callback 1",__FILE__,cycles,MotorPosition,RpMessage,Initialcurrentposition,0); - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorVerifiedCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz ); @@ -360,7 +360,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea { Report("MotorMoveToDrierPosition end",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveToDrierPositionCallBackFunction); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction @@ -402,7 +402,6 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb callback(MotorId,0); return OK; } - //Report("MotorMovetoEncoderPosition direction",__FILE__,__LINE__,direction,RpWarning,15,0); //MotorSetDirection( MotorId, direction); @@ -441,7 +440,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } if (CallbackCalls%200 == 1) { - MotorId = Control_Read_Dryer_Position(0,0); + MotorId = Read_Dryer_ENC_Position(0,0); Report("MotorMoveCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,MotorId,0); } MotorId = IfIndex&0xFF; @@ -455,7 +454,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO Report("MotorControlGetnBusyState stop",__FILE__,__LINE__,MotorDriverResponse[MotorId].Busy,RpMessage,0,0); }*/ //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -488,7 +487,7 @@ uint32_t MotorSetSpeedCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TO if (BusyFlag == 1) { //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorSetSpeedCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -523,7 +522,7 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit if ((LimitSwitch == LIMIT) ||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveToLimitSwitchCallBackFunction); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; if ((MotorId == HARDWARE_MOTOR_TYPE__MOTO_RDANCER)&&(HoldRightDancer == true)) @@ -768,7 +767,7 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re //stop this control loop DancerValueDirection = false; DancerId = 0xFF; - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId],MotorMoveToDancerPositionCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 3d1ba6e78..e2c2b3b1c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -159,8 +159,8 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re DispenserControlId[DispenserId] = AddControlCallback(NULL, IDS_Dispenser_StopMotorCallback, CloseValveTimeout, TemplateDataReadCBFunction,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - else - Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + //else + // Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 00d740c7e..d8db2c4a5 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -1299,7 +1299,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) //Task_sleep(5); PreSegmentWCFStarted = false; PreSegmentPrepareStarted = false; - REPORT_MSG(PreSegmentWCFStarted,"START IDSPresegmentPrepareStart"); + //REPORT_MSG(PreSegmentWCFStarted,"START IDSPresegmentPrepareStart"); // IDSPresegmentPrepareStart(); return OK; @@ -1458,7 +1458,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) #else Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); #endif - IDS_Cleaning_Stop_Cleaning_Solution(NULL); + //IDS_Cleaning_Stop_Cleaning_Solution(NULL); SegmentNumOfBrushStops = Segment->n_brushstops; BrushStopTime = Segment->length*1000/(double)SegmentNumOfBrushStops; //brushstop in meters //brushstop in millisecond BrushStopTime = ((BrushStopTime*100)/dyeingspeed);//brushstop in seconds diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h index 11ae5b008..36542a1a9 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h @@ -52,6 +52,7 @@ bool MidTankValvesAction(bool action); //Cartridge_MidTank_ON of Cartridge_MidTa bool ColorMatch(); bool IFS_TimeOutAlarm(bool status); void ResponseDemo(int MidtankId); +bool IFS_MidTankFilling(void); bool CartridgeValidationResponseFunc(MessageContainer* requestContainer); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 40000b8bb..25c36f3fd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -359,6 +359,7 @@ else { LoadStages++; + LoadStatus = OK; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -558,6 +559,8 @@ CallbackCounter--; if (CallbackCounter == 0) { + LoadStatus = OK; + LoadStages++; if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call { @@ -681,7 +684,8 @@ //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); TotalLoadedLen = 0; - SpeedTControlId = AddControlCallback(NULL,ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + DrierPrevLocation = 200; //initial safe value + SpeedTControlId = AddControlCallback(ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -709,12 +713,13 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(NULL,Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) { REPORT_MSG(LoadStages,"Loading Ended"); + ThreadLoadingReport(); if(LoadingControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); @@ -752,6 +757,7 @@ usnprintf(LoadErrorMsg, 100, "Load sequence stopped by user on stage %d",LoadStages); LoadStatus = ERROR; } + LoadStages = THREAD_LOAD_INIT; load.color = colorON; return OK; @@ -766,21 +772,19 @@ return OK; } Screw_Dir = 1-Screw_Dir; - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000); + status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,13000); 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); - Report("Thread_Load_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); - if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) + uint32_t temp = Read_Dryer_ENC_Position(); + Report("Thread_Load_Dryer_UnLoading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); + //Report("Thread_Load_Dryer_UnLoading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); + if ((abs (temp -DrierPrevLocation)>1000 )&&(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; @@ -801,7 +805,7 @@ { 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); + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-(numberOfCycles-2));//it takes two cycles to identify a stop of the arm TimeoutsCounter = 0; CallbackCounter = 0; if(PullerControlId != 0xFF) @@ -826,12 +830,14 @@ load.color = fastBILNK; usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); LoadStatus = ERROR; + TryAgain = true; ThreadLoadingReport(); } return OK; } uint32_t Thread_Load_Dryer_UnLoading(void) { + uint32_t temp; REPORT_MSG(LoadStages, "Thread UnLoad State Machine step"); //LoadArmInfo.LoadArmRounds = 0; //uint32_t numberOfSteps = 0; @@ -899,9 +905,10 @@ 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, LoadArmInfo.LoadArmRounds,0); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&temp); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + DrierPrevLocation = temp; + Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,DrierPrevLocation,RpMessage, LoadArmInfo.LoadArmRounds,0); 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); @@ -1002,7 +1009,6 @@ ThreadLoadingReport(); break; case THREAD_LOAD_END: - MessageState = 0; LoadStages = THREAD_LOAD_END; Thread_Load_End(); break; @@ -1025,23 +1031,27 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) return ERROR; } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); + Report("ThreadLoadButton params",__FILE__,LoadStatus,TryAgain,RpMessage,SecondTry,0); if (LoadStatus == ERROR) { if ((SecondTry == false)&&(TryAgain == true)) { LoadStatus = OK; SecondTry = true; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages); } else { SecondTry = false; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages+1); } } else { - ThreadLoadStateMachine(ReadValue); + Report("Calling State machine status OK",__FILE__,ReadValue,LoadStatus,RpMessage,SecondTry,0); + ThreadLoadStateMachine(LoadStages); } return OK; } @@ -1145,7 +1155,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index f0b709ff2..78092ae2b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -61,6 +61,7 @@ static bool KeepWindingCone = false; static uint32_t WindingConeLocation; static uint32_t WinderBackToBaseTime = 800; +float NumberOfRotationPerPassage = 0.0; InternalWinderConfigStruc InternalWinderCfg = {0}; //#define READ_SCREW_ENCODER #ifdef READ_SCREW_ENCODER @@ -106,12 +107,17 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) InternalWinderCfg.spoolbackingrate = request->backingrate; InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*2;//request->rotationsperpassage; + InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*3;//request->rotationsperpassage; if (request->rotationsperpassage > 6.1) InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; + if (NumberOfRotationPerPassage > 1) + { + InternalWinderCfg.NumberOfRotationPerPassage = NumberOfRotationPerPassage; + Report("Rotation per passage set from stub",__FILE__,__LINE__,(int)(request->rotationsperpassage*1000),RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); + } InternalWinderCfg.diameter = request->diameter; usnprintf(ScrewStr, 150, "WindingConfig start,offset,head,tail {, %d, %d, %d, %d, %d}",InternalWinderCfg.startoffsetpulses,(int)InternalWinderCfg.segmentoffsetpulses, - (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate); + (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000)); Report(ScrewStr,__FILE__,__LINE__,(int)InternalWinderCfg.diameter,RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); return status; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index dd9395248..420b782b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -42,6 +42,8 @@ uint32_t StoreDancerConfigMessage(void); uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); +extern float NumberOfRotationPerPassage; //debug for rotation per passage trials + uint32_t Winder_Init(void); uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); -- cgit v1.3.1 From f070724e30040ae7cc3fada4c4492ed9e80f8106 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 6 Jan 2020 14:32:44 +0200 Subject: fixes, add dryer control support --- Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 2 +- .../Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c | 2 +- Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 6 +++--- Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 10 +++++++--- .../Embedded/StateMachines/Initialization/PowerOffSequence.c | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index 15117e616..78ae257ac 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -402,7 +402,7 @@ uint32_t MidTankReading(void) MidTankCounter = 0; if (IFS_info.Ink.time_out > 0) return ERROR; - MidTankReadControlId = AddControlCallback( MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + MidTankReadControlId = AddControlCallback("MidTankReading", MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c index a058d54f9..5dcabc576 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c @@ -97,7 +97,7 @@ void Stub_FpgaWriteRegRequest(MessageContainer* requestContainer) ptr = (volatile short *) (request->address); if (request->address == (FPGA3_BASE | 0x3D0)) { - ctlId = AddControlCallback( ResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,ptr,ptr, 0 ); + ctlId = AddControlCallback("Reset", ResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,ptr,ptr, 0 ); } else *ptr = (request->value & 0xFFFF); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 25c36f3fd..0aff26320 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -685,7 +685,7 @@ LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); TotalLoadedLen = 0; DrierPrevLocation = 200; //initial safe value - SpeedTControlId = AddControlCallback(ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + SpeedTControlId = AddControlCallback("Thread length",ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -713,7 +713,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback("Load jog",Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) @@ -1155,7 +1155,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 0a3a9e149..45ab2cb19 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -41,7 +41,11 @@ double CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; +#ifndef DRIER_CONTROL_TEST +TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#else TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#endif HardwareDancerType ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM] = {FEEDER_DANCER,NUM_OF_DANCERS,POOLER_DANCER,WINDER_DANCER,NUM_OF_DANCERS}; uint32_t ControlIdtoMotorId [MAX_THREAD_MOTORS_NUM] = {0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t SpeedControlId=0xFF; @@ -848,7 +852,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) } // if (HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled // AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],0); - if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled + if (Motor_i == ThreadMotorIdToMotorId[DRYER_MOTOR]) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled continue; } #ifdef TEST_PID_THREAD @@ -897,7 +901,7 @@ uint32_t ThreadDryerRampUp(uint32_t IfIndex, uint32_t BusyFlag) ControlIdtoMotorId[DRYER_MOTOR] = 0xFF; } - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); //ReportWithPackageFilter(ThreadFilter,"ThreadDryerRampUp",__FILE__,ControlIdtoMotorId[DRYER_MOTOR],(int)InitialDryerSpeed,RpWarning,(int)OriginalMotorSpd_2PPS[DRYER_MOTOR],0); @@ -927,7 +931,7 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) DrierDivider = dyeingspeed/5; //ramp up drier in 5 cm/sec steps ReportWithPackageFilter(ThreadFilter,"Drier ramp up",__FILE__,__LINE__,(int)dyeingspeed,RpWarning,(int)DrierDivider,0); InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/DrierDivider; - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback("DryerRampUp",ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); #endif #ifdef HUNDRED_MICROSECONDS_DANCER_READ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 1fb77a540..e1866a6d9 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -653,7 +653,7 @@ uint32_t AbortPowerDownFunc(MessageContainer* requestContainer) SendChars((char*)container_buffer, container_size); PowerDownUpdate(POWER_OFF_CANCELLED); - ctlId = AddControlCallback( AbortPowerDownResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + ctlId = AddControlCallback("Abort", AbortPowerDownResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); Report("HWSystemResetRequest", __FILE__,__LINE__,0, RpMessage, 2, 0); -- cgit v1.3.1