Conference Contribution

TrueTime: Real-time Control System Simulation with MATLAB/Simulink

Dan Henriksson, Anton Cervin, Karl-Erik Årzén


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. The TrueTime network block is event driven and distributes messages between computer nodes according to a chosen network model. Currently five of the most common medium access control protocols are supported (CSMA/CD (Ethernet), CSMA/CA (CAN), token-ring, FDMA, and TDMA). It is also possible to specify network parameters such as transmission rate, pre- and post-processing delays, frame overhead, and loss probability. TrueTime is currently used as an experimental platform for research on flexible approaches to real-time implementation and scheduling of controller tasks. One example is feedback scheduling where feedback is used in the real-time system to dynamically distribute resources according to the current situation in the system.


The TrueTime homepage is found here.

In Proceedings of the Nordic MATLAB Conference, Copenhagen, Denmark, October 2003.

Download full document