Tuesday, June 3, 2008

Realtime Simulation on Linux

Motivation

The development process of electronic and mechanical devices often includes the simulation of parts or whole systems without actual hardware. On the one hand this is done in order to verify that the requirements are met and that the final system will in principal work. On the other hand control circuits in development can be interfaced with a simulated hardware for testing the control algorithms without destroying valuable hardware or for developing the control circuits without even having the actual hardware (the increasing time-to-market pressure requires the development of hardware and control devices in parallel). For these applications an off-line simulation is not sufficient as the most control devices must be tested in real-time - especially for time-critical applications (such as e.g. flight control units). For hardware-in-the-loop simulation and rapid control prototyping a simulation system must be able to compute mathematical models within a certain time-frame (e.g. a few hundred microseconds). In the following a real-time simulation framework solution is described which is based on Linux.

SCALE-RT is a Linux based realtime simulation framework supporting a variety of different IO hardware including National Instruments FPGA cards. SCALE-RT turns a standard personal computer into a hardware-in-the-loop (HiL) platform. Different simulation tools are supported such as Matlab/Simulink, ITI SimulationX and the open source software scilab/scicos (http://www.scilab.org).

Components

A hardware in the loop systems requires usually two or more computers: one developer machine (running Microsoft Windows) and one or more target machines (where the actual simulation is executed). In SCALE-RT 4.1 the target machine runs Linux (Kernel 2.6.xx) with Xenomai real-time extension. The models are compiled on the development machine into a kernel module which is then copied to the target machine and executed. The so-called model data interface server (MDI server) runs on the target machine and enables to load, start, stop, and control inputs and outputs of running models. It can be accessed over network via different interfaces:
  1. SCALE-RT Insight - a easy to use drag-and-drop GUI for creating a control and measurement surface for your models
  2. C API (Windows DLL) - for writing customized software which likes to access real-time models
  3. LabVIEW library

Workflow Outline

In order to get a model running in real-time the following steps are necessary
  1. Create a model (e.g. simulating your target hardware) on the development system (Microsoft Windows) with one of the previously mentioned simulation tools
  2. Generate code and cross-compile the model into a real-time executable with the tool-chain of the SCALE-RT developer kit (for Matlab the Realtime Workshop is required)
  3. Load the compiled model onto the target and start the model
  4. Control model parameters and measure model outputs e.g. SCALE-RT Insight

Hardware Support

Measurement hardware (National Instruments PCI cards) is supported via the open source COMEDI interface. Analog IO, digital IO as well as different types of bus systems (CAN) are supported. The modularity of the Linux kernel enables to dynamically extend the system with new hardware drivers.

Real-Time Computation Cluster

The HiL simulation of large systems (such as e.g. whole aircraft) often yield models of such a high complexity that they cannot be run on a single CPU in real-time. In such cases it is necessary to split a large model into smaller sub-models which are able to run on simulation targets. The SCALE-RT platform supports this step by different inter-model communication primitives:
  1. shared memory for data exchange between different cores on a multi-core CPU, and
  2. distributed shared memory for data exchange between different models across CPU and computer boundaries.
The latter option requires the use of external hardware (shared memory PCI cards: VMIC 5565) which supports low-latency (50 micro-seconds) and low-jitter model intercommunication.

Conclusion

SCALE-RT is a flexible Linux based real-time simulation environment which supports different measurement hardware. The scalability of the system is reflected in its real-time cluster support as well as in the extension via new hardware drivers.