aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Control/control.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-01-09 10:42:14 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-01-09 10:42:14 +0200
commitd50d729a2b7d45ca4b22df7ff0d8823825c479b6 (patch)
treeb6ac5a0813c4b76d43ad3af1d56ac8a44361dd7f /Software/Embedded_SW/Embedded/Modules/Control/control.c
parentaeebb8d47e1d78b50d9ae5afd9df6eaf9765ed87 (diff)
downloadTango-d50d729a2b7d45ca4b22df7ff0d8823825c479b6.tar.gz
Tango-d50d729a2b7d45ca4b22df7ff0d8823825c479b6.zip
Version 1.3.1.1 changes
Communication tx traces (reports, diagnostics, alarms, job reports) File system file download support – not tested! Communication tx with pre-allocated memory (improve and add areas) Winder Screw – send messages in regular mode Preparation for motor actions timeouts Preparations for control debug Heaters: bug fix, enlarge PID start region IDS: • Dispenser time out between motor operation and valve operation (start->open. Close->stop). • Dispenser homing backlash – to pressure above limit (currently 0.1 for machines without mixer) or timeout (10 seconds). State machine – Suspend Large Messages cancelled.
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control/control.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/control.c130
1 files changed, 33 insertions, 97 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c
index 001cafeb3..a35b804e4 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/control.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c
@@ -304,12 +304,22 @@ void OneMilliSecondControlInterrupt(UArg arg0)
return ;
}
+uint32_t ControlDevice_i;
+uint32_t ControlLowDevice_i;
+uint32_t GetControlDevice_i(void)
+{
+ return ControlDevice_i;
+}
+uint32_t GetControlLowDevice_i(void)
+{
+ return ControlLowDevice_i;
+}
uint32_t ControlLoop(uint32_t tick)
{
//call all modules control functions
//test dancers and speed encoders
//check all callback units (state machine waiting for completion of a change)
- uint32_t Device_i;
+ //uint32_t ControlDevice_i;
/*bool Ten_msTick, Hundred_msTick, Onesecond_Tick,Tick98,Tick998;
Ten_msTick = (tick%eTenMillisecond == 0) ?true:false;
Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false;
@@ -320,24 +330,24 @@ uint32_t ControlLoop(uint32_t tick)
Tick998 = (tick%eOneSecond == 996) ?true:false;
*/
//ROM_IntMasterDisable();
- for (Device_i = 0; Device_i < MAX_TANGO_CONTROL_DEVICES;Device_i++)
+ for (ControlDevice_i = 0; ControlDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlDevice_i++)
{
- if (ControlArray[Device_i].ControlActive)
+ if (ControlArray[ControlDevice_i].ControlActive)
{
- ControlBacklog[backlogindex]=Device_i;
+ ControlBacklog[backlogindex]=ControlDevice_i;
if ( ++backlogindex >= 999)
backlogindex = 0;
- switch (ControlArray[Device_i].ControlTiming)
+ switch (ControlArray[ControlDevice_i].ControlTiming)
{
case eOneMillisecond:
- if(ControlArray[Device_i].ControlDataReadPtr)
- ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1);
+ if(ControlArray[ControlDevice_i].ControlDataReadPtr)
+ ControlDatalog[ControlDevice_i] = ControlArray[ControlDevice_i].ControlDataReadPtr( ControlArray[ControlDevice_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]);
+ LOG_ERROR (ControlDevice_i, "Invalid callback ptr");
+ if(ControlArray[ControlDevice_i].ControlCallbackPtr)
+ ControlArray[ControlDevice_i].ControlCallbackPtr(ControlArray[ControlDevice_i].IfIndex, ControlDatalog[ControlDevice_i]);
else
- LOG_ERROR (Device_i, "Invalid callback ptr");
+ LOG_ERROR (ControlDevice_i, "Invalid callback ptr");
break;
default:
break;
@@ -353,7 +363,7 @@ uint32_t ControlLowLoop(uint32_t tick)
//call all modules control functions
//test dancers and speed encoders
//check all callback units (state machine waiting for completion of a change)
- uint32_t Device_i;
+ //uint32_t Device_i;
bool Ten_msTick, Hundred_msTick, Onesecond_Tick,Tick98,Tick998;
Ten_msTick = (tick%eTenMillisecond == 0) ?true:false;
Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false;
@@ -362,101 +372,27 @@ uint32_t ControlLowLoop(uint32_t tick)
Tick998 = (tick%eOneSecond == 996) ?true:false;
//ROM_IntMasterDisable();
- for (Device_i = 0; Device_i < MAX_TANGO_CONTROL_DEVICES;Device_i++)
+ for (ControlLowDevice_i = 0; ControlLowDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlLowDevice_i++)
{
- if (ControlArray[Device_i].ControlActive)
+ if (ControlArray[ControlLowDevice_i].ControlActive)
{
- if (tick == ControlArray[Device_i].StartTick)
+ if (tick == ControlArray[ControlLowDevice_i].StartTick)
continue;
- if (((tick - ControlArray[Device_i].StartTick)%ControlArray[Device_i].ControlTiming)==0) // run the control on exact intervals
+ if (((tick - ControlArray[ControlLowDevice_i].StartTick)%ControlArray[ControlLowDevice_i].ControlTiming)==0) // run the control on exact intervals
{
- ControlBacklog[backlogindex]=Device_i;
+ ControlBacklog[backlogindex]=ControlLowDevice_i;
if ( ++backlogindex >= 999)
backlogindex = 0;
- if(ControlArray[Device_i].ControlDataReadPtr)
- ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1);
+ if(ControlArray[ControlLowDevice_i].ControlDataReadPtr)
+ ControlDatalog[ControlLowDevice_i] = ControlArray[ControlLowDevice_i].ControlDataReadPtr( ControlArray[ControlLowDevice_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]);
+ LOG_ERROR (ControlLowDevice_i, "Invalid callback ptr");
+ if(ControlArray[ControlLowDevice_i].ControlCallbackPtr)
+ ControlArray[ControlLowDevice_i].ControlCallbackPtr(ControlArray[ControlLowDevice_i].IfIndex, ControlDatalog[ControlLowDevice_i]);
else
- LOG_ERROR (Device_i, "Invalid callback ptr");
+ LOG_ERROR (ControlLowDevice_i, "Invalid callback ptr");
}
- /*
- ControlBacklog[backlogindex]=Device_i;
- if ( ++backlogindex >= 999)
- backlogindex = 0;
- switch (ControlArray[Device_i].ControlTiming)
- {
- case eOneMillisecond:
- break;
- case eTenMillisecond:
- if (Ten_msTick)
- {
- 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;
- case eHundredMillisecond:
- if (Tick98)
- {
- //there is a need to trigger the data collection from FPGA, from I2C or from ADC 1.5 milliseconds to collect the data
- 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 (Hundred_msTick)
- {
- //there is a need to trigger the data collection from FPGA, from I2C or from ADC 1.5 milliseconds to collect the data
- 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;
- case eOneSecond:
- if (Tick998)
- {
- 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 (Onesecond_Tick)
- {
- 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;
- case eNoControl:
- 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
- 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
} //for
//ROM_IntMasterEnable();