From fc23da7f3510cce58308841eefb96d59868317ff Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 17 Dec 2018 09:41:17 +0200 Subject: Version 1.3.0.2 Reset Cause in log, remove some logs, improve memory on alarm handling. stop heaters and dispensers on alarm without job. split microsecond and control tasks to high and low priorities. Heaters PID with multiplications - use with new CFG. --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 76c0fbfd8..0e0a9f987 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -670,7 +670,7 @@ uint32_t ThreadPreSegmentState(void *JobDetails) LOG_ERROR (dyeingspeed," job speed zero"); return ERROR; } - LOG_ERROR (dyeingspeed," ThreadPreSegmentState"); + REPORT_MSG (dyeingspeed," ThreadPreSegmentState"); SetOriginMotorSpeed(process_speed); ThreadControlActive = true; @@ -718,17 +718,17 @@ uint32_t ThreadPreSegmentState(void *JobDetails) int REPSegmentId = 0; void ThreadInterSegmentEnded(void) { - LOG_ERROR (REPSegmentId,"ThreadInterSegmentEnded"); + REPORT_MSG (REPSegmentId,"ThreadInterSegmentEnded"); PreSegmentReady(Module_Thread,ModuleDone); } void ThreadSegmentEnded(void) { - LOG_ERROR (REPSegmentId," ThreadSegmentState"); + REPORT_MSG (REPSegmentId," ThreadSegmentState"); SegmentReady(Module_Thread,ModuleDone); } void ThreadDistanceToSpoolEnded(void) { - LOG_ERROR (REPSegmentId," ThreadDistanceToSpoolEnded"); + REPORT_MSG (REPSegmentId," ThreadDistanceToSpoolEnded"); DistanceToSpoolReady(Module_Thread,ModuleDone); } double seglength = 0.0; @@ -739,7 +739,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) REPSegmentId = SegmentId; seglength = JobTicket->segments[SegmentId]->length; CurrentSegmentId = SegmentId; - LOG_ERROR (seglength," ThreadSegmentState"); + REPORT_MSG (seglength," ThreadSegmentState"); ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded); return OK; } @@ -748,7 +748,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) uint32_t ThreadDistanceToSpoolState(void ) { seglength = dryerbufferlength; - LOG_ERROR (seglength,"ThreadDistanceToSpoolState"); + REPORT_MSG (seglength,"ThreadDistanceToSpoolState"); ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); return OK; } -- cgit v1.3.1 From 4554080793bd46fcb8f55578d2f67917584dc332 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 20 Dec 2018 15:07:17 +0200 Subject: Version 1.3.0.5: break sensor debounce (10 msec default). temperature spikes ignored in heating control. thread winding improved. --- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded_SW/Embedded/Modules/Heaters/Heaters.h | 1 - .../Embedded/Modules/Heaters/Heaters_print.c | 31 +++++++-- .../Embedded/Modules/Thread/Thread_Winder.c | 9 ++- .../Embedded/Modules/Thread/Thread_ex.h | 2 +- .../Embedded/Modules/Thread/Thread_init.c | 9 ++- .../Embedded/Modules/Thread/Thread_print.c | 80 ++++++++++++---------- .../Embedded/StateMachines/Printing/PrintingSTM.c | 2 +- 8 files changed, 86 insertions(+), 50 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c') diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index e416f25d5..2e588a5e1 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {001,003,000,004}; +TangoVersion_t _gTangoVersion = {001,003,000,005}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h index 7d0a94cbb..601f5ce31 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h @@ -54,7 +54,6 @@ extern HeaterCommand HeaterCmd[MAX_HEATERS_NUM]; extern uint32_t Heater_timerBase; uint32_t HeaterRecalculateSharedHeatersParams(uint32_t deviceId, uint32_t new_outputproportionalpowerlimit); -void HeatingTestSendResonse(uint32_t status, bool last,bool heater1Active,bool heater2Active, int temperature1, int temperature2,int Heater1Percentage,int Heater2Percentage, char* Message); uint32_t HeaterRecalculateHeaterParams(uint32_t deviceId, uint32_t new_outputproportionalpowerlimit); uint32_t HeatersSingleHeaterEnd(HardwarePidControlType HeaterId); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index e036af974..205e3fcce 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -85,6 +85,7 @@ Mailbox_Handle HeatersControlMsgQ = NULL; bool InitialHeating = true; bool DCInitialHeating[MAX_HEATERS_NUM] = {true}; bool HeaterReady[MAX_HEATERS_NUM] = {true}; +uint32_t HeaterPreviousRead[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0}; //A/C Heaters Cycle time in milliseconds - one for all heaters /******************** FUNCTIONS ********************************************/ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue); @@ -93,6 +94,7 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue); uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue); void HeatersStartControlTimer (void); + //********************************************************************** //******************** CODE *******************************************/ //********************************************************************** @@ -155,6 +157,7 @@ void LoadHeaterState(HeaterType HeaterType,HeaterState *HeaterState) int HeaterId = HeaterType; double temp = TemperatureSensorRead(HeaterId2PT100Id[HeaterId]); + HeaterState->has_heatertype = true; HeaterState->heatertype = HeaterType; HeaterState->has_setpoint = true; @@ -373,6 +376,7 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) HeaterPIDConfig[HeaterId].m_params.dt *=10; DCInitialHeating[HeaterId] = true; HeaterReady[HeaterId] = false; + HeaterPreviousRead[HeaterId] = TemperatureSensorRead(HeaterId2PT100Id[HeaterId]); } else if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature) //AC Heaters { @@ -380,6 +384,9 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) { ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, Frequency/*eOneSecond/*eHundredMillisecond*/,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); HeaterPIDConfig[HeaterId].m_params.dt *=10; + HeaterPreviousRead[HeaterId] = TemperatureSensorRead(DryerInternalPT100Id); + HeaterPreviousRead[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain] = TemperatureSensorRead(HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]); + HeaterPreviousRead[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary] = TemperatureSensorRead(HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary]); } if (MainDryerHeaterMaxTempControl == 0xFF) MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain],0); @@ -462,6 +469,12 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) LOG_ERROR (IfIndex, "Wrong Interface "); return 0xFFFFFFFF; } + if (abs(readValue - HeaterPreviousRead[index])>2000) + { + Report("Temperature Spike",__FILE__,__LINE__,HeaterPreviousRead[index],RpWarning,readValue, index); + return ERROR; + } + HeaterPreviousRead[index] = readValue; if (index == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) { MainPT100Read = readValue; @@ -524,6 +537,13 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) //LOG_ERROR (0, "unconfigured"); return ERROR; } + if (abs(readValue - HeaterPreviousRead[index])>2000) + { + Report("Temperature Spike",__FILE__,__LINE__,HeaterPreviousRead[index],RpWarning,readValue, index); + return ERROR; + } + HeaterPreviousRead[index] = readValue; + // check if the read value is within the proportional band if (InitialHeating) { @@ -638,11 +658,12 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) //LOG_ERROR (index, "unconfigured"); return ERROR; } -/* - HeatingTestSendResonse(0, false,GetHeaterState(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),GetHeaterState(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary), - Temperature[0],Temperature[1], - HeaterPIDConfig[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].m_calculatedError, HeaterPIDConfig[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].m_calculatedError,"Standard"); -*/ + if (abs(readValue - HeaterPreviousRead[index])>2000) + { + Report("Temperature Spike",__FILE__,__LINE__,HeaterPreviousRead[index],RpWarning,readValue, index); + return ERROR; + } + HeaterPreviousRead[index] = readValue; // check if the read value is within the proportional band if (DCInitialHeating[index]==true) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 2b6d3aaea..6915cc657 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -180,7 +180,7 @@ double WinderReferenceSpeed=0; int32_t TotalWinderSpeed=0; uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { - uint32_t Steps,i; + uint32_t Steps; double temp; double screw_horizontal_speed = 0; double RotationsPerSecond; @@ -232,6 +232,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) } screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; + ROM_IntMasterDisable(); ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; temp = SYS_CLK_FREQ; @@ -239,6 +240,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) temp /= ScrewSpeed; if (ScrewRunningTime != temp) { + ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; + ROM_IntMasterEnable(); //usnprintf(TempScrewStr, 100, "Winder: Horizon,Rotation, PPR, RPP{ %d, %d ,%d, %d} ",(int)screw_horizontal_speed,(int)RotationsPerSecond,(int)InternalWinderCfg.NumberOfRotationPerPassage,(int)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround); usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed); // Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); @@ -248,9 +251,9 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) //REPORT_MSG(temp , "new winder speed"); //Report("new winder speed",__FILE__,__LINE__,temp,RpWarning,ScrewSpeed,0); } - ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; /********************************************************************************/ + ROM_IntMasterEnable(); return OK; } @@ -409,7 +412,7 @@ void ScrewTimerInterrupt(int ARG0) { TimerDisable(Screw_timerBase, TIMER_A); } - //Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0); + Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0); // // Enable all interrupts. // diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index c5e3edc85..34be77177 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -29,7 +29,7 @@ uint32_t ThreadConfigBreakSensor(void *request); uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId); double ThreadGetMotorCalculatedError(int DancerId); uint32_t ThreadPrepareState(void *JobDetails); -uint32_t ThreadPreSegmentState(void *JobDetails); +uint32_t ThreadPreSegmentState(void *JobDetails, uint32_t SegmentId); uint32_t ThreadSegmentState(void *JobDetails, int SegmentId); uint32_t ThreadDistanceToSpoolState(void); uint32_t ThreadEndState(void *JobDetails); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 41daa4002..f641737ee 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -21,8 +21,10 @@ double NormalizedErrorCoEfficient[MAX_THREAD_MOTORS_NUM] = {0}; int DancerStopActivityLimit[MAX_THREAD_MOTORS_NUM] = {0}; HardwareDancer DancersCfg[MAX_SYSTEM_DANCERS] = {0}; +#define BREAK_SENSOR_LIMIT 10 + bool BreakSensorenabled; -int32_t BreakSensordebouncetimemilli; +int32_t BreakSensordebouncetimemilli = BREAK_SENSOR_LIMIT; HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_PID_CONTROL_TYPE__MotorFeeder,HARDWARE_PID_CONTROL_TYPE__MotorDryer,HARDWARE_PID_CONTROL_TYPE__MotorPooler,HARDWARE_PID_CONTROL_TYPE__MotorWinder,0}; @@ -116,7 +118,10 @@ uint32_t ThreadConfigBreakSensor(void *request) if (SensorCfg) { BreakSensorenabled = SensorCfg->enabled; - BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli; + if (SensorCfg->debouncetimemilli) + { + BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli; + } return OK; } return ERROR; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 0e0a9f987..72391e3a9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -355,6 +355,8 @@ void testDancersControl() bool dancerinvalid = false; int MotorFailedSample[MAX_THREAD_MOTORS_NUM] = {0,0,0,0,0}; char Message[60]; +uint16_t BreakSensorCounter = 0; +uint16_t BreakSensorLatchCounter = 0; uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //#define MAX_CONTROL_SAMPLES 6 @@ -425,16 +427,29 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { if (ReadBreakSensor()==ERROR) { - //consider applying the debouce parameters later - //BreakSensordebouncetimemilli - JobEndReason = JOB_THREAD_BREAK; - ThreadControlActive = false; - SendJobProgress(0.0,0,false, "ReadBreakSensor Error"); - SegmentReady(Module_Thread,ModuleFail); - AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true); - //EndState(CurrentJob,"ReadBreakSensor Error" ); - LOG_ERROR(index, "ReadBreakSensor Error"); - return OK; + BreakSensorCounter++; + BreakSensorLatchCounter++; + if (BreakSensorCounter>=BreakSensordebouncetimemilli) + { + //consider applying the debouce parameters later + //BreakSensordebouncetimemilli + JobEndReason = JOB_THREAD_BREAK; + ThreadControlActive = false; + SendJobProgress(0.0,0,false, "ReadBreakSensor Error"); + SegmentReady(Module_Thread,ModuleFail); + AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true); + //EndState(CurrentJob,"ReadBreakSensor Error" ); + LOG_ERROR(index, "ReadBreakSensor Error"); + return OK; + } //passed limit + }//ReadBreakSensor()==ERROR + else //reset counter - we are looking for consequent calls + { + if (BreakSensorCounter) + { + LOG_ERROR(BreakSensorCounter, "ReadBreakSensor Spike"); + } + BreakSensorCounter = 0; } } } @@ -525,7 +540,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) //MotorsConfigMessage(request); ThreadPrepareState(request); - ThreadPreSegmentState(request); + ThreadPreSegmentState(request,0); return OK; } bool InitialProcess = false; @@ -659,7 +674,7 @@ void SetOriginMotorSpeed(float process_speed) } //******************************************************************************************************************** -uint32_t ThreadPreSegmentState(void *JobDetails) +uint32_t ThreadPreSegmentState(void *JobDetails, uint32_t SegmentId) { //set the speed only before the first segment, speed is constant across all job segments and intersegments JobTicket* JobTicket = JobDetails; @@ -671,32 +686,25 @@ uint32_t ThreadPreSegmentState(void *JobDetails) return ERROR; } REPORT_MSG (dyeingspeed," ThreadPreSegmentState"); - - SetOriginMotorSpeed(process_speed); - ThreadControlActive = true; - PrepareState = false; - // set the new speed in the dryer motor to the speed of the new segment - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]); - //only for testing - when control works, these motors will take their speed from the dryer - //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING, OriginalMotorSpd_2PPS[POOLER_MOTOR]); - //only for testing - when control works, these motors will take their speed from the dryer - //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING, OriginalMotorSpd_2PPS[FEEDER_MOTOR]); - -//#warning rocker disabled - if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0) + if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job) { - MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1); - } - if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0) - { - MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1); - } -// #warning rocker disabled - -// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO + SetOriginMotorSpeed(process_speed); + ThreadControlActive = true; + PrepareState = false; + // set the new speed in the dryer motor to the speed of the new segment + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]); + if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0) + { + MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize); + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1); + } + if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0) + { + MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize); + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1); + } + } // activate control fr all motors //set speed for both rocker motors //wait for all motors to get to the required speed (set the target speed for the control to check) diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 46ec6450c..6c76bab86 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -214,7 +214,7 @@ static uint32_t PreSegmentState(void *JobDetails, int SegmentId) } if (Configured[Module_Thread]) { - ThreadPreSegmentState(JobDetails); + ThreadPreSegmentState(JobDetails,SegmentId); } if (Configured[Module_Winder]) { -- cgit v1.3.1 From 2769e72857ebc543d8f40a3cbca218f2f010a77d Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 27 Dec 2018 12:09:52 +0200 Subject: Version 1.3.0.8 changes for connection resiliance: priorities, diagnostics and alarm handling --- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded_SW/Embedded/Communication/Container.c | 2 +- Software/Embedded_SW/Embedded/Embedded.cfg | 38 +++++++++++----------- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 8 ++--- .../Embedded/Modules/Thread/Thread_Winder.c | 22 ++++++------- .../Embedded/Modules/Thread/Thread_print.c | 2 +- .../Embedded/StateMachines/Printing/JobSTM.c | 6 ++-- .../Embedded/StateMachines/Printing/PrintingSTM.c | 6 ++-- 9 files changed, 46 insertions(+), 42 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c') diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index eadfdd1d0..1bbd5a8ad 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {001,003,000,006}; +TangoVersion_t _gTangoVersion = {1,3,0,8}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index 5afc618ff..eb4ebbaf1 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -126,7 +126,7 @@ uint32_t CommunicationTaskMessageReceived(uint32_t buffer,uint16_t msgSize) * this communication task is created statically in system initialization, in blocking mode * over one of the chosen ommunication methods (USB or Blutooth). ******************************************************************************/ -uint32_t cLength[50] = {0}; +uint32_t cLength[51] = {0}; byte cindex = 0; void communicationTask(UArg arg0, UArg arg1) { diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index 0c3ad2f8e..8543f0493 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -76,7 +76,7 @@ MessageContainer createContainer(MessageType type, char* token, protobuf_c_boole container.data.data = response_buffer; container.data.len = response_size; - if (SuspendLargeMessages == true) + // if (SuspendLargeMessages == true) { // Report("EndJobMessage",__FILE__,__LINE__,(int)type,RpWarning,(int)response_size,0); TxmsgId[Txindex] = type; diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 240a79a6f..f12df421c 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -122,16 +122,17 @@ ControlTaskParams.stackSize = 2048; ControlTaskParams.priority = 11; Program.global.control = Task.create("&controlTask", ControlTaskParams); -var CommRxTaskParams = new Task.Params(); -CommRxTaskParams.instance.name = "communication"; -CommRxTaskParams.priority = 10; -CommRxTaskParams.stackSize = 8192; -Program.global.communication = Task.create("&communicationTask", CommRxTaskParams); +var AlarmHandlingTaskParams = new Task.Params(); +AlarmHandlingTaskParams.instance.name = "AlarmHandling"; +AlarmHandlingTaskParams.stackSize = 1024; +AlarmHandlingTaskParams.priority = 10; +Program.global.AlarmHandling = Task.create("&AlarmHandlingTask", AlarmHandlingTaskParams); -var HeaterControlTaskParams = new Task.Params(); -HeaterControlTaskParams.instance.name = "HeatersControl"; -HeaterControlTaskParams.priority = 9; -Program.global.HeatersControl = Task.create("&HeatersControlTask", HeaterControlTaskParams); +var CommTxTaskParams = new Task.Params(); +CommTxTaskParams.instance.name = "communicationTx"; +CommTxTaskParams.priority = 9; +CommTxTaskParams.stackSize = 4096; +Program.global.communicationTx = Task.create("&communicationTxTask", CommTxTaskParams); var ProcessTaskParams = new Task.Params(); ProcessTaskParams.instance.name = "process"; @@ -139,17 +140,16 @@ ProcessTaskParams.stackSize = 2048; ProcessTaskParams.priority = 8; Program.global.process = Task.create("&jobTask", ProcessTaskParams); -var CommTxTaskParams = new Task.Params(); -CommTxTaskParams.instance.name = "communicationTx"; -CommTxTaskParams.priority = 7; -CommTxTaskParams.stackSize = 4096; -Program.global.communicationTx = Task.create("&communicationTxTask", CommTxTaskParams); +var HeaterControlTaskParams = new Task.Params(); +HeaterControlTaskParams.instance.name = "HeatersControl"; +HeaterControlTaskParams.priority = 7; +Program.global.HeatersControl = Task.create("&HeatersControlTask", HeaterControlTaskParams); -var AlarmHandlingTaskParams = new Task.Params(); -AlarmHandlingTaskParams.instance.name = "AlarmHandling"; -AlarmHandlingTaskParams.stackSize = 1024; -AlarmHandlingTaskParams.priority = 6; -Program.global.AlarmHandling = Task.create("&AlarmHandlingTask", AlarmHandlingTaskParams); +var CommRxTaskParams = new Task.Params(); +CommRxTaskParams.instance.name = "communicationRx"; +CommRxTaskParams.priority = 6; +CommRxTaskParams.stackSize = 8192; +Program.global.communication = Task.create("&communicationTask", CommRxTaskParams); var MillisecLowTaskParams = new Task.Params(); MillisecLowTaskParams.instance.name = "MilliSecondLow"; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index c54976195..8d5955636 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -498,8 +498,8 @@ uint32_t AlarmHandlingEmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t AlarmHandlingStart(void) { - if (EventsNotificationRequestAccepted == false) - return ERROR; + //if (EventsNotificationRequestAccepted == false) + // return ERROR; if ( AlarmHandlingActive == false) { AlarmHandlingActive = true; @@ -684,7 +684,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) //Motor Status //machine cover open - if (tick%eOneSecond == 0) + if ((tick%eOneSecond == 0)&&(EventsNotificationRequestAccepted==true)) SendEventNotifications(); return OK; } @@ -814,7 +814,7 @@ uint32_t StartEventsNotificationRequestFunc(MessageContainer* requestContainer) // ReportInitParams InitParams; //ControlStart(); EventsNotificationRequestAccepted = true; - AlarmHandlingStart(); + //AlarmHandlingStart(); StartEventsNotificationRequest* request = start_events_notification_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (AlarmHandlingToken, requestContainer->token,36); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 6915cc657..fed1311bd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -181,7 +181,7 @@ int32_t TotalWinderSpeed=0; uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { uint32_t Steps; - double temp; + double temp,tempScrewSpeed; double screw_horizontal_speed = 0; double RotationsPerSecond; int32_t Averagewinderspeed = 0; @@ -232,16 +232,17 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) } screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - ROM_IntMasterDisable(); - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; + tempScrewSpeed = screw_horizontal_speed*RotationsPerSecond; + //ROM_IntMasterDisable(); CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; temp = SYS_CLK_FREQ; temp *= ScrewNumberOfSteps; - temp /= ScrewSpeed; - if (ScrewRunningTime != temp) + temp /= tempScrewSpeed; + if ((ScrewRunningTime != temp)||(ScrewSpeed != tempScrewSpeed)) { + ScrewSpeed = tempScrewSpeed; ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; - ROM_IntMasterEnable(); + //ROM_IntMasterEnable(); //usnprintf(TempScrewStr, 100, "Winder: Horizon,Rotation, PPR, RPP{ %d, %d ,%d, %d} ",(int)screw_horizontal_speed,(int)RotationsPerSecond,(int)InternalWinderCfg.NumberOfRotationPerPassage,(int)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround); usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed); // Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); @@ -253,7 +254,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) } /********************************************************************************/ - ROM_IntMasterEnable(); + //ROM_IntMasterEnable(); return OK; } @@ -313,6 +314,7 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) REPORT_MSG(ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); // MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); //ScrewDirection = 1-ScrewDirection; + REPORT_MSG(SegmentId,"Winder pre segment - SegmentId"); REPORT_MSG(ScrewSpeed,"Winder pre segment - ScrewSpeed"); //MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); ScrewsStartControlTimer (); @@ -398,12 +400,10 @@ void ScrewTimerInterrupt(int ARG0) { ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt ROM_IntMasterDisable(); - //ScrewDirectionChange(0,NOTBUSY); if (SCREW_TimerActivated == true) { MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); -// ScrewCurrentDirection = 1-ScrewCurrentDirection; MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); ScrewDirectionChangeCounter++; @@ -412,11 +412,11 @@ void ScrewTimerInterrupt(int ARG0) { TimerDisable(Screw_timerBase, TIMER_A); } - Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0); + ROM_IntMasterEnable(); + //Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0); // // Enable all interrupts. // - ROM_IntMasterEnable(); return ; } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 72391e3a9..94858cae2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -462,7 +462,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) usnprintf(Message, 60, "Dancer %d limit %d value %d Zero %d",DancerId,DancerStopActivityLimit[index],avreageSampleValue,DancersCfg[DancerId].zeropoint); //JobAbortedByUser = true; ThreadControlActive = false; - MotorGetStatusFromFPGA(ThreadMotorIdToMotorId[index]); + //MotorGetStatusFromFPGA(ThreadMotorIdToMotorId[index]); JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId; SendJobProgress(0.0,0,false, Message); //EndState(CurrentJob,Message ); diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 34ac6a857..e044808ca 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -925,7 +925,8 @@ Void jobTask(UArg arg0, UArg arg1) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = NULL; SuspendLargeMessages = false; - DiagnosticsStart(); + LOG_ERROR(4,"ResumeLargeMessages PrintingResultsOk"); + //DiagnosticsStart(); //CleanState(CurrentJob); break; case PrintingResultsFail: @@ -935,7 +936,8 @@ Void jobTask(UArg arg0, UArg arg1) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = NULL; SuspendLargeMessages = false; - DiagnosticsStart(); + LOG_ERROR(3,"ResumeLargeMessages PrintingResultsFail"); + //DiagnosticsStart(); //send message data as a validation error message to host ExitState(Message.messageData); diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 12c925bd8..85421fae5 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -333,9 +333,10 @@ uint32_t DistanceToSpoolReady(int ModuleId, ModuleStateEnum result) else { SuspendLargeMessages = true; - DiagnosticsStop(); + //DiagnosticsStop(); PrtMessage->messageId = FinishResultsFail; SendJobProgress(0.0, 0, false, "DistanceToSpool Fail"); + LOG_ERROR(1,"SuspendLargeMessages DistanceToSpoolReady"); } //memcpy(Message.messageData,JobDetails,MAX_MSG_LEN); Message.msglen = 10; @@ -374,7 +375,8 @@ uint32_t EndState(void *JobDetails, char *Message) { //ROM_IntMasterDisable(); SuspendLargeMessages = true; - DiagnosticsStop(); + LOG_ERROR(2,"SuspendLargeMessages EndState"); + //DiagnosticsStop(); if (Configured[Module_Winder]) { PrepareWaiting[Module_Winder] = ModuleIdle; -- cgit v1.3.1