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:- SCALE-RT Insight - a easy to use drag-and-drop GUI for creating a control and measurement surface for your models
- C API (Windows DLL) - for writing customized software which likes to access real-time models
- LabVIEW library
Workflow Outline
In order to get a model running in real-time the following steps are necessary- Create a model (e.g. simulating your target hardware) on the development system (Microsoft Windows) with one of the previously mentioned simulation tools
- 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)
- Load the compiled model onto the target and start the model
- 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:- shared memory for data exchange between different cores on a multi-core CPU, and
- distributed shared memory for data exchange between different models across CPU and computer boundaries.