TrueTime: Real-time Control System Simulation with MATLAB/Simulink
Dan Henriksson, Anton Cervin, Karl-Erik Årzén · 2003
Abstract: Traditional control design using MATLAB/Simulink, often disregards the temporal effects arising from the actual implementation of the controllers. Nowadays, controllers are often implemented as tasks in a real-time kernel and communicate with other nodes over a network. Consequently, the constraints of the target system, e.g., limited CPU speed and network bandwidth, must be taken into account at design time. For this purpose we have developed TRUETIME, a toolbox for simulation of distributed real-time control systems. TRUETIME makes it possible to simulate the timely behavior of real-time kernels executing controller tasks. TRUETIME also makes it possible to simulate simple models of network protocols and their influence on networked control loops. TRUETIME consists of a kernel block and a network block, both variable-step S-functions written in C++. TRUETIME also provides a collection of MATLAB functions used to, e.g., do A/D and D/A conversion, send and receive network messages, set up timers, and change task attributes. The TRUETIME blocks are connected with ordinary continuous Simulink blocks to form a real-time control system. The TRUETIME kernel block simulates a computer with an event-driven real-time kernel, A/D and D/A converters, a network interface, and external interrupt channels. The kernel executes user-defined tasks and interrupt handlers, representing, e.g., I/O tasks, control algorithms, and communication tasks. Execution is defined by user-written code functions (C++ functions or m-files) or graphically using ordinary discrete Simulink blocks. The simulated execution time of the code may be modeled as constant, random or even data-dependent. Furthermore, the real-time scheduling policy of the kernel is arbitrary and decided by the user.