diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-02-06 13:33:13 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-02-06 13:33:13 +0200 |
| commit | 67f576c95d1eed3846611a008253bdba35b5767c (patch) | |
| tree | 6a22cae752a282acd82ffd8b723436c603c86754 /Software/Embedded_SW/Embedded/Modules/Control | |
| parent | 917d08c0c4cfd95b6bf545a857361bcf0da5ea8a (diff) | |
| parent | 063724aa818cc243b10a5c202e28b3cb49e6503f (diff) | |
| download | Tango-67f576c95d1eed3846611a008253bdba35b5767c.tar.gz Tango-67f576c95d1eed3846611a008253bdba35b5767c.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c | 58 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Control/control.c | 60 |
2 files changed, 68 insertions, 50 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 6d92e06c9..a9b539690 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -56,10 +56,8 @@ #include "Modules/General/buttons.h" #include "Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.h" -#ifdef Use_WHS_Card #include <Drivers/I2C_Communication/WHS_Card/D_ADS122_PT100/WHS_PT100_ADC.h> #include <Drivers/I2C_Communication/I2C_Task.h> -#endif Task_Handle Millisecond_Task_Handle; /******************** Definitions ********************************************/ @@ -606,9 +604,10 @@ uint32_t MillisecLowLoop(uint32_t tick) OneHourTick = (tick%eOneHour == 0) ?true:false; //gather Motor data from FPGA //ROM_IntMasterDisable(); - + int StartPT100 = 0; //Screw_ENC_Velocity_to_DAC(); - for testing the screw enc - + if (Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD) + StartPT100 = TEMP_SENSE_ANALOG_DRYER_TEMP1; if (Ten_msTick) { //Speed_Data = Calculate_Speed_Sensor_Velocity(); @@ -619,39 +618,18 @@ uint32_t MillisecLowLoop(uint32_t tick) Trigger_HeaterWriting(); } -#ifdef Use_Head_Card if(Fifty_msTick) { Trigger_PT100_Read();//call every 50mSec (minimum delay 30mSec) //Set_HeadCard_PT100();//call every 50mSec (minimum delay 30mSec) } -#endif -/*#ifdef Use_Head_Card - if (m20msecTick) //read odd PT1000 - { - for (Sensor_i = HEAD_PT100_ZONE_1_0X80_0;Sensor_i < HEAD_PT100_ZONE_2_0X80_1;Sensor_i++) - { - //MillisecReadFromI2CTempSensor(Sensor_i, NULL); - } - //Set_HeadCard_PT100(); -#warning call chip select replace in I2C - } - if (m70msecTick) //read odd PT1000 + if(m70msecTick) { - for (Sensor_i = HEAD_PT100_ZONE_2_0X80_1;Sensor_i < HEAD_PT100_RESERVE_0X8E_1;Sensor_i++) - { - //MillisecReadFromI2CTempSensor(Sensor_i, NULL); - } - //Set_HeadCard_PT100(); + AlarmHandling_ControlTrigger(0,0); } -#endif */ if (m90msecTick) { -#ifdef Use_Head_Card - for (Sensor_i = TEMP_SENSE_ANALOG_DRYER_TEMP1;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) -#else - for (Sensor_i = 0;Sensor_i < MAX_MAIN_CARD_TEMP_SENS_ID;Sensor_i++) -#endif + for (Sensor_i = StartPT100;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) { MillisecReadFromTempSensor(Sensor_i, NULL); } @@ -664,11 +642,7 @@ uint32_t MillisecLowLoop(uint32_t tick) /////////////////////////////////////////////////////////////////// -#ifdef Use_Head_Card - for (Sensor_i = TEMP_SENSE_ANALOG_DRYER_TEMP1;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) -#else - for (Sensor_i = 0;Sensor_i < MAX_MAIN_CARD_TEMP_SENS_ID;Sensor_i++) -#endif + for (Sensor_i = StartPT100;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) { MillisecUpdateTemperatures (Sensor_i,TemperatureSensorRead(Sensor_i)); } @@ -689,10 +663,7 @@ uint32_t MillisecLowLoop(uint32_t tick) ADC_TriggerCollection(); } -#ifdef Use_Head_Card - //Head_Read_IO_Reg(0x46, HIGH);//READ HEAD CARD LS -#endif - + Trigger_InputsReading(); } if (Gradient_Tick) DispensersCollectionCall(); @@ -737,14 +708,10 @@ uint32_t MillisecLowLoop(uint32_t tick) static int Counter = 0; MachineUpdateResponseFunc(); KeepAliveOneSecondCall(); -#ifdef Use_Head_Card + TemperatureListString(Lenstr); ReportWithPackageFilter(ThreadFilter,Lenstr,__FILE__,__LINE__,(int)Counter++,RpWarning,(int) msec_millisecondCounter,0); -//#ifdef Use_Head_Card - for (Sensor_i = TEMP_SENSE_ANALOG_DRYER_TEMP1;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) -#else - for (Sensor_i = 0;Sensor_i < MAX_MAIN_CARD_TEMP_SENS_ID;Sensor_i++) -#endif + for (Sensor_i = StartPT100;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) { TemperatureCalc[Sensor_i] = MillisecCalculateTemperatures ( Sensor_i); } @@ -755,10 +722,8 @@ uint32_t MillisecLowLoop(uint32_t tick) PressureCalc[Disp_i] = MillisecCalculatePressures(Disp_i); } } -#ifdef Use_WHS_Card Trigger_WHS_PT100_Read_All(); Trigger_WHS_MAX11614_Read_allADC(); -#endif } if (OneMinute_Tick) @@ -778,7 +743,8 @@ uint32_t MillisecLowLoop(uint32_t tick) }*/ midtankDisplay = 1-midtankDisplay; Gas_PPM_Info = Calculate_Gas_Power_Consumption(); - Trigger_WHS_MAX11614_Read_allADC(); + //Trigger_WHS_MAX11614_Read_allADC(); + ResetControlTime(); } if (OneHourTick) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index e093815a9..02a216ba6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -65,9 +65,10 @@ #include "MillisecTask.h" - +//#define CONTROL_DEBUG +#define DURATION_LIMIT 5 /******************** Definitions ********************************************/ -#define MAX_TANGO_CONTROL_DEVICES 120 +#define MAX_TANGO_CONTROL_DEVICES 100 /******************** STRUCTURES AND ENUMs ********************************************/ @@ -108,6 +109,7 @@ ControlDeviceStruc ControlArray[MAX_TANGO_CONTROL_DEVICES]; uint32_t ControlDatalog[MAX_TANGO_CONTROL_DEVICES]; #define MAX_BACKLOG_SIZE 100 uint16_t ControlBacklog[MAX_BACKLOG_SIZE]={0}; +uint32_t ControlTime[MAX_TANGO_CONTROL_DEVICES]={0}; uint16_t backlogindex = 0; uint32_t Control_timerBase = TIMER0_BASE; //Timer handle uint32_t MaxHighDevices = 0xFF; @@ -382,6 +384,7 @@ uint32_t AddControlCallback(char* Name, ControlCBFunction Callback, uint32_t Ct if (deviceId == 0xFF) { LOG_ERROR(deviceId, "Add Callback failed"); + AlarmHandlingSetAlarm(EVENT_TYPE__FPGA_WATCHDOG_ACTIVATED,true); return 0xFF; } key = GateMutex_enter(gateControlDB); @@ -556,8 +559,26 @@ uint32_t ControlLoop(uint32_t tick) return OK; } +uint32_t prevtick = 0; +void ResetControlTime(void) +{ + memset(ControlTime,0,sizeof(ControlTime)); +} uint32_t ControlLowLoop(uint32_t tick) { + uint32_t skipped_ticks = 0; +#ifdef CONTROL_DEBUG + uint32_t tempp,tempq,delta; + uint32_t sys_ticks_start = msec_millisecondCounter,sys_ticks_end,max = 0,dev = 0; +#endif + if (tick-prevtick>1) + { + skipped_ticks = tick-prevtick-1; + if (tick-prevtick>10) + Report("ControlLowLoop skipped",__FILE__,tick,(int)prevtick,RpWarning,(int)skipped_ticks,0); + } + prevtick = tick; + for (ControlLowDevice_i = 0; ControlLowDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlLowDevice_i++) { if (ControlArray[ControlLowDevice_i].ControlActive) @@ -566,12 +587,14 @@ uint32_t ControlLowLoop(uint32_t tick) continue; if (ControlArray[ControlLowDevice_i].ControlTiming == eOneMillisecond) continue; - if (((tick - ControlArray[ControlLowDevice_i].StartTick)%ControlArray[ControlLowDevice_i].ControlTiming)==0) // run the control on exact intervals + if (((tick - ControlArray[ControlLowDevice_i].StartTick)%ControlArray[ControlLowDevice_i].ControlTiming)<=skipped_ticks) // run the control on exact intervals { ControlBacklog[backlogindex]=ControlLowDevice_i; if ( ++backlogindex >= MAX_BACKLOG_SIZE) backlogindex = 0; - +#ifdef CONTROL_DEBUG + tempp = HibernateRTCSSGet(); +#endif if(ControlArray[ControlLowDevice_i].ControlDataReadPtr) ControlDatalog[ControlLowDevice_i] = ControlArray[ControlLowDevice_i].ControlDataReadPtr( ControlArray[ControlLowDevice_i].Parameter1); else @@ -580,9 +603,38 @@ uint32_t ControlLowLoop(uint32_t tick) ControlArray[ControlLowDevice_i].ControlCallbackPtr(ControlArray[ControlLowDevice_i].IfIndex, ControlDatalog[ControlLowDevice_i]); else LOG_ERROR (ControlLowDevice_i, "Invalid callback ptr"); +#ifdef CONTROL_DEBUG + tempq = HibernateRTCSSGet(); + if (tempq < tempp) + { + delta = (32768 - tempp) + tempq + 1; + } + else + delta = tempq - tempp; + if (ControlTime[ControlLowDevice_i]<delta) + { + ControlTime[ControlLowDevice_i] = delta; + } +#endif } } //if control active } //for +#ifdef CONTROL_DEBUG + sys_ticks_end= msec_millisecondCounter; + if (sys_ticks_end-sys_ticks_start > DURATION_LIMIT) + { + Report("ControlLowLoop long",__FILE__,sys_ticks_end-sys_ticks_start,(int)sys_ticks_end,RpWarning,(int)sys_ticks_start,0); + for (ControlLowDevice_i = 0; ControlLowDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlLowDevice_i++) + { + if (ControlTime[ControlLowDevice_i]>max) + { + max = ControlTime[ControlLowDevice_i]; + dev = ControlLowDevice_i; + } + } + Report(ControlArray[dev].Name,__FILE__,__LINE__,dev,RpWarning,max,0); + } +#endif //ROM_IntMasterEnable(); return OK; |
