From 387c1ee40b7bce5edd92491dc8d9edeb30a02524 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 26 Sep 2019 12:32:54 +0300 Subject: fix bug where thread jogging caused next jobs to be without ink, and other small problems --- .../Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 4 ++-- .../Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | 17 ++++++++++------- .../Embedded_SW/Embedded/Modules/Thread/Thread_init.c | 5 +++++ 3 files changed, 17 insertions(+), 9 deletions(-) (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 9ad42d739..c68156e68 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -567,13 +567,13 @@ { REPORT_MSG(LoadStages, "Thread UnLoad State Machine step"); LoadArmInfo.LoadArmRounds = 0; - uint32_t numberOfSteps = 0; + //uint32_t numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 SetOriginMotorSpeed(19); // OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; // CurrentControlledSpeed[FEEDER_MOTOR] = 1000; - 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 = 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; MotorControlConfig[POOLER_MOTOR].m_params.MAX = 1; MotorControlConfig[POOLER_MOTOR].m_params.MIN = MotorsControl[POOLER_MOTOR].outputproportionalpowerlimit*-1; MotorControlConfig[POOLER_MOTOR].m_params.Kd = MotorsControl[POOLER_MOTOR].derivativetime; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 4cbe1f70f..60bf8123f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -322,16 +322,19 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) #ifdef READ_SCREW_ENCODER int WinderRun; WinderRun = abs(ScrewLocationRun[1] - ScrewLocationRun[0]); - if ((WinderRun < 50000)&&(Add100 == false)) + if ((WinderRun < 20000)&&(Add100 == false)) { - WinderRunSum+=WinderRun; WinderRunSamples++; - WinderRunAverage = WinderRunSum/WinderRunSamples; - if ((fabs(WinderRun-WinderRunAverage)>=30)||(WinderRunSamples%100 == 0)) + if (WinderRunSamples>10) { - usnprintf(ScrewStr, 150, "curr,sum,avg,samples {Winder Encoder:, %d, %d, %d, %d, %d}",WinderRun,(int)WinderRunSum,(int)WinderRunAverage,(int)WinderRunSamples, - (int)(100*WinderRun/ScrewNumberOfSteps)); - Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); + WinderRunSum+=WinderRun; + WinderRunAverage = WinderRunSum/(WinderRunSamples-10); + if ((fabs(WinderRun-WinderRunAverage)>=30)||(WinderRunSamples%100 == 0)) + { + usnprintf(ScrewStr, 150, "curr,sum,avg,samples {Winder Encoder:, %d, %d, %d, %d, %d}",WinderRun,(int)WinderRunSum,(int)WinderRunAverage,(int)WinderRunSamples, + (int)(100*WinderRun/ScrewNumberOfSteps)); + Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); + } } } else diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 5d84bb5d0..88d62a495 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -11,6 +11,9 @@ #include "PMR/Hardware/HardwareDancer.pb-c.h" #include "PMR/Hardware/HardwareWinder.pb-c.h" #include "PMR/Hardware/HardwareBreakSensor.pb-c.h" +#include + +#include "Modules/AlarmHandling/AlarmHandling.h" #include "PMR/Printing/JobSpool.pb-c.h" #include "PMR/common/MessageContainer.pb-c.h" @@ -49,6 +52,8 @@ uint32_t MotorsConfigMessage(HardwareConfiguration * HWrequest) HardwareMotor *request; if (HWrequest == NULL) return ERROR; + AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,OFF); + for (MotorId = 0; MotorId < HWrequest->n_motors ; MotorId++) { request = HWrequest->motors[MotorId]; -- cgit v1.3.1