Desktop version

Home arrow Computer Science arrow Real-Time and Distributed Real-Time Systems: Theory and Applications

Developing Distributed Real-Time System Applications—the MATLAB Way

MATLAB is an effective tool for simulation of dynamic systems. Though mostly used for simulation using a simulation timeline, MATLAB can also be used for simulation of dynamic systems on a real-time basis, that is, using a real clock as the timeline for simulation. Simulations can be run within the MATLAB environment as SIMULINK® models or as stand-alone systems, which can be used to develop distributed real-time system (DRTS) applications. MATLAB can also be used to for simulation of DRTS applications within the MATLAB environment. These methodologies are discussed in this chapter.

Developing MATLAB Real-Time Targets

The Real-Time Workshop (RTWS) is the basic module of MATLAB, which is used for generating real-time code from the model designed with the help of modules like the Simulink, Stateflow and xPC, for running either as a standalone application or within the MATLAB environment. It provides options for generating more efficient code with the help of the RTWS Embedded Coder (ERT) to produce more compact and faster code than RTWS. It also provides built-in support for software standards such as AUTOSAR (standard used in automotive software). For building an executable from a model a make file is required, which provides various configurations for controlling the compilation and target specification. A Target Language Compiler (TLC) is used for generating code for the target system.

Figure 5.1 shows the general schematic of code development using the RTWS.

Using the RTWS assumes that a C++ compiler is installed in the system and the most used one is a Microsoft Visual C++. For running a model in real-time within the MATLAB environment using Simulink, the Real-Time Windows Target must be installed using the rtwintgt-setup command at the MATLAB command prompt, details of which are available in the MATLAB documentation.

Figure 5.2 shows a Simulink model of a real-time task that generates a square wave of amplitude 2 volt with a time period of 1 s and a duty-cycle of

0.5 using an analog output card PCI-1711U [1] and the corresponding output

FIGURE 5.1

Building an RTWS application.

FIGURE 5.2

Simulink model of a real-time task for execution in a MATLAB environment.

captured on an oscilloscope as shown in Figure 5.3. The trigger is chosen as external and the corresponding target language compiler is rtwin.tlc.

The square-wave source is chosen as a sample-based one and the time-step of simulation chosen is 100 ms. The Target needs to be connected first using the button next to the simulation time on the model pane and then run in the usual way.

 
Source
< Prev   CONTENTS   Source   Next >

Related topics