| Contents | Index |
| On this page… |
|---|
Real-Time Windows Target software uses a small real-time kernel to run the application in real time. The real-time kernel runs at CPU ring zero (privileged or kernel mode) and uses the built-in PC clock as its primary source of time:
Timer interrupt — The kernel intercepts the interrupt from the PC clock before the Windows® operating system receives it. The kernel then uses the interrupt to trigger the execution of the compiled model. As a result, the kernel is able to give the real-time application the highest priority available.
Note This behavior intercepts any calls to the Windows operating system. Consequently, you cannot use Win32 calls in your C-code S-function. For more information, see Incompatibility with Win32 API Calls. |
The kernel is provided as a kernel-mode driver. To achieve precise sampling, the kernel reprograms the PC clock to a higher frequency. Because the PC clock is also the primary source of time for the Windows operating system, the kernel sends a timer interrupt to the operating system at the original interrupt rate.
Scheduler — The timer interrupt clocks a simple scheduler that runs the executable. The number of tasks is equal to the number of sampling periods in the model with multitasking mode. With single-tasking mode, there is only one task. The maximum number of tasks is 32, and faster tasks have higher priorities than slower tasks. For example, a faster task can interrupt a slower task.
During execution, the executable stores data in buffers. Later, the data in these buffers is retrieved by the Scope block. The scheduling, data storing, data transferring, and running the executable all run at CPU ring zero.
Communication with hardware — The kernel interfaces and communicates with I/O hardware using I/O driver blocks, and it checks for proper installation of the I/O board. If the board has been properly installed, the drivers allow your real-time application to run.
You can choose to have a driver block use values equal to voltage, normalize values from 0 to +1, normalize values from -1 to +1, or use the raw integer values from the A/D or D/A conversion press. Drivers also run at CPU ring zero.
Simulink external mode — Communication between Simulink software and the real-time application is through the Simulink external mode interface module. This module talks directly to the real-time kernel, and is used to start the real-time application, change parameters, and retrieve scope data.
The real-time application runs in real time on your PC computer and has the following characteristics:
Compiled code — Created from the generated C-code using the Open Watcom C/C++ compiler. For your convenience, this compiler is shipped with the Real-Time Windows Target software. No other third-party compiler is needed or can be used.
Note The Real-Time Windows Target software always uses the Open Watcom C/C++ compiler, even if you have specified some other compiler using the mex -setup command. Real-Time Windows Target software cannot be configured to use a compiler other than Open Watcom C/C++. |
The Open Watcom source code is available under the terms of the Open Watcom License. For more information, visit http://www.openwatcom.org.
Relation to your Simulink model — The executable contains a binary form of all Simulink model components, connections between blocks, time dependencies, and variables in the Simulink blocks.
Relation to the kernel — The executable must be loaded and executed directly by the Real-Time Windows Target kernel. It cannot be executed without the kernel.
The kernel runs as a kernel-mode driver, intercepts timer interrupts from the PC clock, maintains clock signals for the Windows operating system, and runs the application in real-time. As a result, both the kernel and the real-time application run at CPU ring zero.
Checksum — The Simulink model and the executable contain a checksum value. The kernel uses this checksum value to determine if the Simulink model structure, at the time of code generation, is consistent with the real-time application structure during execution. This verifies that when you change parameters during an execution, the mapping of Simulink model parameters to the memory locations in the real-time application is correct.
If you make structural changes to your Simulink model, the Simulink checksum value will not match the executable checksum value. You will have to rebuild your executable before you can connect it to your Simulink model.
You can acquire, display, and save signals by using Simulink Scope blocks and Simulink external mode. This lets you observe the behavior of your model during a simulation or your application while it runs in real time.
You can acquire signal data while running your real-time applications using
Signal Tracing — Process of acquiring and visualizing signals during a real-time run. It allows you to acquire signal data and visualize it on your computer while the executable is running.
Signal Logging — Process for acquiring signal data during a real-time run. After the run reaches its final time or you manually stop the run, you can plot and analyze the data.
You can save (log) data to variables in the MATLAB workspace or save data to your disk drive with MAT-files.
Signal logging differs from signal tracing. With signal logging you can only look at a signal after a run is finished.
For more information, see Logging Signals to the Base Workspace and Logging Signals to a Disk Drive.
Change the parameters in your Simulink model and observe the effect of those changes during a simulation or while running an application in real time.
Simulink external mode — You use Simulink external mode to connect your Simulink block diagram to your real-time application. The block diagram becomes a graphical user interface (GUI) to that executable.
Simulink external mode allows you to change parameters by editing the block diagram while running a simulation in external mode. New parameter values are automatically transferred to the real-time application while it is running.
There are different types of model parameters that you can change while running your real-time application. For example, parameters include the amplitude of a gain and the frequency of a sine wave. After you connect your real-time application to your Simulink model, you can change parameters. You can change these parameters before or while your real-time application is running by using one of the following methods:
Block parameters — Change values in the dialog boxes associated with the Simulink blocks.
Block parameters for masked subsystems — Change values in user-created dialog boxes associated with a subsystem.
MATLAB variables — Create MATLAB variables that represent Simulink block parameters, and then change parameter values by entering the changes through the MATLAB command line.
For more information about parameter tuning, see Tuning Parameters.
![]() | Using This Guide | Hardware Environment | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |