| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Windows Target |
| Contents | Index |
| Learn more about Real-Time Windows Target |
| On this page… |
|---|
The Real-Time Windows Target Library |
Real-Time Windows Target I/O driver blocks allow you to select and connect specific analog channels and digital lines to your Simulink model through I/O driver blocks. These blocks provide an interface to your physical I/O boards and your real-time application. They ensure that the C code created by Real-Time Workshop code generation software correctly maps block diagram signals to the appropriate I/O channels. All I/O blocks support all applicable Simulink datatypes.
You can have multiple I/O blocks associated with each type of I/O board. For example, you can have one Analog Input block for channels 1 to 4 and another block for channels 5 to 8. Each I/O block in a model specifies its own block configuration parameters, which apply only to that instance of that block. See Blocks — Alphabetical List for a description of the configuration parameters for each I/O block.
The Real-Time Windows Target Library provides blocks that you can use with supported I/O boards. You can also create your own I/O blocks to work with Real-Time Windows Target software. See Custom I/O Driver Blocks for details.
All Real-Time Windows Target I/O driver blocks are available in the Real-Time Windows Target Library. To view this library from the MATLAB Command Window, type:
rtwinlib
To view the Real-Time Windows Target Library from a model:
In the model window, choose View > Library Browser.
The Simulink Library Browser opens. The left pane shows a hierarchy of libraries and categories, with the Simulink library at the top. The right pane shows the blocks available in the category selected on the left. See Library Browser for more information.
The Real-Time Windows Target library opens.
You can add any I/O block in the library to your Simulink model by dragging it from the library to the model. After you add the block, connect it to your model as you would any other block, and provide block configuration parameter values as described for the block in Blocks — Alphabetical List.
I/O driver blocks output multiple signals as a vector instead of individual channels or lines. To connect the individual channels and lines to parts of your Simulink model, you need to separate the vector with a Demux block.
After you add and configure an I/O driver block in your Simulink model, you can separate and connect the output signals from the blocks:
In the Simulink window, choose View > Library Browser.
The Simulink Library Browser opens.
In the Simulink library, click Signal Routing. From the list in the right pane, click and drag Demux to your Simulink model.
Double-click the Demux block. The Block Parameters: Demux dialog box opens. Enter the number of lines leaving the Demux block. For example, if you entered three channels in the Analog Input driver block, enter 3 in the Number of outputs box.

Finish making connections and selecting display options.
Connect the Analog Input block to the Demux block input.
Connect each of the Demux block output lines to the input of other blocks.
In the Simulink window, and from the Format menu, click Port/Signal Displays > Wide Nonscalar Lines, and click Signal Dimensions.
In this simple example, inputs 1 and 2 are not connected, but they could be connected to other Simulink blocks.
For a better understanding of how to specify device settings when using both analog and digital signals, this section uses the Keithley® Metrabyte™ DAS-1601 I/O board as an example. The following is a specification summary of the DAS-1601 board:
Analog input (A/D) — 16 single-ended or 8 differential analog inputs (12-bit), polarity is switch configured as either unipolar (0 to 10 volts) or bipolar (+/- 10 volts). Gain is software configured to 1, 10, 100, and 500.
Digital input — Four unidirectional digital inputs
Analog output (D/A) — Two analog outputs (12-bit). Gain is switch configured as 0 to 5 volts, 0 to 10 volts, +/- 5 volts, or +/- 10 volts
Digital output — Four unidirectional digital outputs
Base address — Switch configured base address
This section explores different configurations for input signals.
Once an Analog Input block has been placed in the model and the I/O board selected and configured, you can set up the Analog Input block to handle input signals.
Single analog input — The most basic case is for a single analog input signal that will be physically connected to the first analog input channel on the board. In the Block Parameter: Analog Input dialog box, and the Input channels box, enter
1 or [1]
The use of brackets is optional for a single input.
Input vector with differential analog — Analog channels are numbered starting with channel 1 and continue until you reach a number corresponding to the maximum number of analog signals supported by the I/O board.
In the case of the DAS-1601, when configured as differential inputs, eight analog channels are supported. The analog input lines are numbered 1 through 8. The complete input vector is
[1 2 3 4 5 6 7 8] or [1:8]
If you want to use the first four differential analog channels, enter
[1 2 3 4]
Input vector with single-ended analog — Now, assume your DAS-1601 board is configured to be single-ended analog input. In this case, 16 analog input channels are supported. The complete input vector is
[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] or [1:16]
To use the first four single-ended analog input channels, enter
[1 2 3 4] or [1:4]
The next figure shows the resulting block diagram.

We do not recommend specifying more channels than you actually use in your block diagram. This results in additional overhead for the processor with A/D or D/A conversions. In this case, for example, even though some channels are not actually used in the block diagram, these channels are still converted.
You could attach terminator blocks to channels 4 and 5 inside your block diagram after passing the Analog Input block vector in to a Demux block. Adding terminator blocks provides you with graphical information in your block diagram to clearly indicate which channels you connected and which are available. The penalty is that even the terminated channels are converted, adding some computational overhead.
The next figure shows the block implementation.

Depending on the board and the number of channels used, I/O conversion time can affect the maximum sample rate that can be achieved on your system. Rather than converting unused channels, we recommend specifying only the set of channels that are actually needed for your model.
![]() | Using I/O Boards | Using Analog I/O Drivers | ![]() |

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