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. --- .../Embedded/Modules/Control/MillisecTask.c | 82 ++++++++++++++++--- .../Embedded_SW/Embedded/Modules/Control/control.c | 91 +++++++++++++++++++++- 2 files changed, 160 insertions(+), 13 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 68bd680a8..64b6ac4e0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -90,6 +90,7 @@ MillisecMotorDataStruc SpeedSetPending[NUM_OF_MOTORS] = {0}; MillisecMotorDataStruc PT100Data[MAX_TEMPERATURE_SENSOR_ID] = {0}; /******************** GLOBAL PARAMETERS ********************************************/ Mailbox_Handle MillisecMsgQ = NULL; +Mailbox_Handle TenMillisecMsgQ = NULL; Mailbox_Handle MotorsMsgQ[NUM_OF_MOTORS] = {NULL}; bool MillisecRestart; static GateMutex_Handle gateMillisecDB; @@ -114,6 +115,7 @@ void MillisecInit(void) Error_init(&eb); MillisecMsgQ = Mailbox_create(sizeof(MillisecMessageStruc), 2, NULL,&eb); + TenMillisecMsgQ = Mailbox_create(sizeof(MillisecMessageStruc), 2, NULL,&eb); for (i=0;i= 999) + backlogindex = 0; + switch (ControlArray[Device_i].ControlTiming) + { + case eOneMillisecond: + break; case eTenMillisecond: if (Ten_msTick) { @@ -374,7 +422,17 @@ uint32_t ControlLoop(uint32_t tick) memset (&ControlArray[Device_i],0,sizeof(ControlDeviceStruc) ); break; default: - LOG_ERROR (ControlArray[Device_i].ControlTiming, "Invalid control timing value"); + if (tick%ControlArray[Device_i].ControlTiming == 0) + { + if(ControlArray[Device_i].ControlDataReadPtr) + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1); + else + LOG_ERROR (Device_i, "Invalid callback ptr"); + if(ControlArray[Device_i].ControlCallbackPtr) + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); + else + LOG_ERROR (Device_i, "Invalid callback ptr"); + } break; } //switch } //if control active @@ -410,3 +468,30 @@ void controlTask(UArg arg0, UArg arg1) } } } +/****************************************************************************** + * ======== messageTsk ======== + * Task for this function is created statically. See the project's .cfg file. + * this message task is created statically in system initialization, + ******************************************************************************/ +void controlLowTask(UArg arg0, UArg arg1) +{ + ControlMessageStruc Message; + //char str[60]; + //uint16_t length; + //Clock_setTimeout(HostKAClock, 1000); + //Clock_start(HostKAClock); + Control_Task_Handle = Task_self(); + + while(1) + { + Mailbox_pend(TenControlMsgQ , &Message, BIOS_WAIT_FOREVER); + switch (Message.messageId) + { + case OneMillisec: + ControlLowLoop(Message.tick); + break; + default: + break; + } + } +} -- cgit v1.3.1 From 5cb32e4d23885b476f34547f2bc36e4b057ead0e Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 17 Dec 2018 14:54:33 +0200 Subject: Winder bugs. improved trace, improved control (callback invoked after time requested elabsed) --- .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 2 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 40 +++++++++-------- .../Embedded_SW/Embedded/Modules/Control/control.c | 34 ++++++++++++--- .../Embedded_SW/Embedded/Modules/Control/control.h | 3 +- .../Embedded/Modules/Thread/Thread_Winder.c | 50 +++++++++++++--------- 5 files changed, 83 insertions(+), 46 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control') diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index cfba461ff..8a54526a5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -392,7 +392,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t MotorStop(_motorId,Hard_Hiz ); MotorMove(_motorId,direction,Steps ); - MotorMoveControlId[_motorId] = AddControlCallback( MotorMoveCallBackFunction, eTenMillisecond, MotorControlGetnBusyState,(IfTypeMotors*0x100+_motorId), _motorId, 0 ); + MotorMoveControlId[_motorId] = AddControlCallback( MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+_motorId), _motorId, 0 ); return MotorMoveControlId[_motorId]; } diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 0e9ed5e8e..35f12dd50 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -372,38 +372,44 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) }//if dispensers }//for brush }//for segments - for (Dispenser_i=0;Dispenser_i= 999) + backlogindex = 0; + + if(ControlArray[Device_i].ControlDataReadPtr) + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1); + else + LOG_ERROR (Device_i, "Invalid callback ptr"); + if(ControlArray[Device_i].ControlCallbackPtr) + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); + else + LOG_ERROR (Device_i, "Invalid callback ptr"); + } + /* ControlBacklog[backlogindex]=Device_i; if ( ++backlogindex >= 999) backlogindex = 0; @@ -422,8 +442,10 @@ uint32_t ControlLowLoop(uint32_t tick) memset (&ControlArray[Device_i],0,sizeof(ControlDeviceStruc) ); break; default: + //LOG_ERROR(tick, "Default Timing checked"); if (tick%ControlArray[Device_i].ControlTiming == 0) { + Report("Default Timing checked",__FILE__,__LINE__,tick,RpWarning,ControlArray[Device_i].ControlTiming,0); if(ControlArray[Device_i].ControlDataReadPtr) ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1); else @@ -434,7 +456,7 @@ uint32_t ControlLowLoop(uint32_t tick) LOG_ERROR (Device_i, "Invalid callback ptr"); } break; - } //switch + } //switch*/ } //if control active } //for //ROM_IntMasterEnable(); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 0aba4b4ba..b3e574d2a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -37,10 +37,11 @@ typedef enum void ControlInit(void); void ControlStop(void); void ControlStart(void); -uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); +uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); uint32_t TemplateDataReadCBFunction (uint32_t deviceId, uint32_t Parameter1); extern Task_Handle Control_Task_Handle; +extern uint32_t millisecondCounter; #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index d92e6a330..2b6d3aaea 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -124,7 +124,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); - REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2"); + REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2"); status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback); //set motor location 0 here @@ -141,7 +141,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; - REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); + REPORT_MSG(millisecondCounter, "Winder_ScrewAtOffsetCallback"); MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands PrepareReady(Module_Winder, ModuleDone); return OK; @@ -175,15 +175,20 @@ InternalWinderCfg.segmentoffsetpulses numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; */ char ScrewStr[100]; +//char TempScrewStr[100]; +double WinderReferenceSpeed=0; +int32_t TotalWinderSpeed=0; uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { - uint32_t Steps,i,winderspeed=0; + uint32_t Steps,i; double temp; - uint32_t WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR]; - float screw_horizontal_speed = 0; - float RotationsPerSecond; + double screw_horizontal_speed = 0; + double RotationsPerSecond; + int32_t Averagewinderspeed = 0; + TotalWinderSpeed-=WinderMotorSpeed[WinderMotorSpeedCounter]; WinderMotorSpeed[WinderMotorSpeedCounter] = CurrentControlledSpeed[WINDER_MOTOR]; + TotalWinderSpeed+=WinderMotorSpeed[WinderMotorSpeedCounter]; if (WinderMotorSpeedCounter++>=MAX_WINDER_SPEED_CALCULATION) { WinderMotorSpeedCounter=0; @@ -215,18 +220,18 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) } if (WinderMotorSpeedRollOver) { - for (i=0;i