The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No p art of this manual may be photocopied or
reproduced in any form without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through th e federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
March 2008Online onlyNew for Version 3.1 (Release 2008a)
October 2008Online onlyRevised for Version 3.2 (Release 2008b)
March 2009Online onlyRevised for Version 3.3 (Release 2009a)
September 2009 Online onlyRevised for Version 3.4 (Release 2009b)
March 2010Online onlyRevised for Version 3.5 (Release 2010a)
The model to which to attach the default Real-Time Windows
Target configuration set.
'ERT'
The default Real-Time Windows Target configuration set for
Real-Time Workshop
to
model.
Returnsconfigset
The default Real-Time Windows Target configuration set, which
later can be attached to a model.
®
Embedded Coder™ software to be attached
DescriptionThe rtwinconfigset function, when called with argument model,
attaches the default Real-Time Windows Target configuration set
RTWin to the model, then activates the configuration set. This default
configuration set specifies various simulation and code-generation
parameter values that are useful when working with a Real-Time
Windows Target model. In most cases, using
all the configuration parameter values that the model needs.
When called with no argument,
Real-Time Windows Target configuration set object. Later, you can
attach this configuration set to a model. See “Configuring a Model” in
the Real-Time Windows Target User’s Guide for more information.
The
rtwinconfigset('model', 'ERT') function attaches the default
Real-Time Windows Target configuration set for Real-Time Workshop
Embedded Coder software to the model, then activates the configuration
set. This default configuration set specifies various simulation and
rtwinconfigset returns the default
rtwinconfigset provides
1-3
rtwinconfigset
code-generation parameter values that are useful when working with
a Real-Time Windows Target model in the Real-Time Workshop
Embedded Coder environment.
The
rtwinconfigset('', 'ERT') function returns the default
Real-Time Windows Target configuration set object for the Real-Time
Workshop Embedded Coder software. Later, you can attach this
configuration set to a model.
See AlsoConfiguration Sets
Referencing Configuration Sets
Specifying the Default Configuration Set
1-4
rtwintgt
PurposeInstall and remove Real-Time Windows Target kernel
Descriptionrtwintgt -setup installs the Real-Time Windows Target kernel on
your system. It performs the same operation as
rtwintgt -install installs the Real-Time Windows Target kernel on
your system. It performs the same operation as
rtwintgt -uninstall removes the Real-Time Windows Target kernel
from your system.
rtwintgt -forceuninstall forcibly removes the Real-Tim e Windows
Target kernel from your system. Use this command if
-uninstall
only when all other attempts to uninstall the kernel fail. The command
leaves the computer in an inconsistent state that cannot be relied on
and does not post relevant error messages.
cannot successfully remove the kernel. Use this command
rtwintgt -install.
rtwintgt -setup.
rtwintgt
Note Never execute rtwintgt -forceuninstall without immediately
rebooting, after which you can reinstall the Real-Time Windows Target
kernel as described in “Installing the Kernel” in the Real-Time WindowsTarget User’s Guide.
rtwintgt -version displays the Real-Time Windows Target currently
installed on your system.
1-5
rtwintgt
1-6
Block Reference
2
Input (p. 2-2)
Output (p. 2-3)Output data f rom a Real-Time
Input data to a Real-Time Windows
Target application
Windows Target application
2 Block Reference
Input
Analog InputSelect and connect analog input
channels
Counter InputSelect and connect counter input
channels
Digital Input
Encoder Input
Other InputConnect with input sources that
Packet Input
Stream InputReceive formatted ASCII data
Select and connect digital input lines
or channels
Select and connect encoder input
channels
other input blocks cannot
Receive unformatted binary data
2-2
Output
Output
Analog OutputSelect and connect analog output
channels
Digital OutputSelect and connect digital output
lines or channels
Frequency OutputGenerate and output a
pulse-width-modulated square
wave
Other OutputConnect with output sources that
other output blocks cannot
Packet OutputTransmit unformatted binary data
Stream OutputTransmit formatted ASCII data
2-3
2 Block Reference
2-4
3
Blocks — Alphabetical List
Analog Input
PurposeSelect and connect analog input channels
LibraryReal-Time Windows Target
DescriptionThe Analog Input block allows you to select and connect specific analog
input channels to your Simulink
Input block to your model, you can enter the parameters for its I/O
driver. The following procedure uses the Humus oft
as an example:
1 Double-click the Analog Input block.
The Block Parameters: Analog Input dialog box opens:
®
model. After you add an Analog
®
AD512 I/O board
3-2
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
Analog Input
3 In the Input channels box, enter a channel vector that selects the
analog input channels you are using on this board. The vector can
be any valid MATLAB
analog input channels on the AD512 board, enter
[1,2,3,4,5,6,7,8] or [1:8]
If you want to use the first three analog input channels, enter
[1,2,3]
4 From the Input ra nge list, choose the input range for all of the
analog input channels you entered in the Input channels box. For
example, with the AD512 board, choose
Ifyouwanttheinputrangetobedifferentfordifferentanalog
channels, you need to add an I/O block for each different input range.
5 From the Block output signal list, choose from the following
options:
®
vector fo rm. For example, to select all eight
-5 to 5 V.
•
Volts — Returns a value equal to the analog voltage.
Normalized bipolar — Returns a full range value of -1 to +1
•
regardless of the input voltage r an ge.
•
Normalized unipolar — Re t urn s a full range value of 0 to +1
regardless of the input voltage range. For example, an analog
inputrangeof0to+5voltsand-5to+5voltswouldbothbe
converted to 0 to +1.
•
Raw — Returns a value of 0 to 2
converter would return values of 0 to 2
n
-1. For example, a 12-bit A/D
12
-1 (0 to 4095). The
advantage of this method is the returned value is always an
integer with no roundoff errors.
6 Set Output data type to specify the type of data that the block will
output to the model.
7 Click OK or Apply.
3-3
Analog Output
PurposeSelect and connect analog output channels
LibraryReal-Time Windows Target
DescriptionThe Analog Output block allows you to select and connect specific
analog output channels to your Simulink model. After you add an
Analog Output block to your model, you can enter the parameters for
its I/O driver. The block outputs The following procedure uses the
Humusoft AD512 I/O board as an example.
1 Double-click the Analog Output block.
The Block Parameters: Analog Output dialog box opens:
3-4
Analog Output
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
0.001
3 In the Output channels box, enter a channel vector that selects
the analog output channels you are using on this board. The vector
can be any valid MATLAB vector form. For example, to select both
analog output channels on the AD512 board, enter
[1,2] or [1:2]
4 From the Output range list, choose the input range for all of the
analog input channels you entered in the Input channels box. For
example, with the AD512 board, choose
Ifyouwanttheinputrangetobedifferentfordifferentanalog
channels, you need to add an I/O block for each different input range.
-5 to 5 V.
5 From the Block input signal list, choose from the following
options:
•
Volts — Expects a value equal to the analog output voltage.
is converted to the full range of the output voltage regardless of
the output voltage range.
•
Normalized unipolar — Expects a value between 0 and +1 that
is converted to the full range of the output voltage regardless of
the output voltage range. For example, an analog output range
of 0 to +5 volts and -5 to +5 volts would both be converted from
values between 0 and +1.
•
Raw — Expects a value of 0 to 2
converter would expect a value between 0 and 2
n
-1. For example, a 12-bit A/D
12
-1 (0 to 4095).
The advantage of this method is the expected value is always an
integer with no roundoff errors.
3-5
Analog Output
6 Enter the initial value for each analog output channel you entered
in the Output channels box. For exa m p le , if you entered
[1,2]
in the Output channels box, and you want an initial value of 0
volts, enter
7 Enter a final value for each analog channel you entered in the
Output channels box. For example, if you entered
[0,0].
[1,2] in the
Output channels box, and you want final values of 0 volts, enter
[0,0].
8 Click OK or Apply.
3-6
Counter Input
PurposeSelect and connect counter input channels
LibraryReal-Time Windows Target
DescriptionThe Counter Input b lo ck allows you to select and connect specific
counter input channels to your Simulink model. After you have added
a Counter Input block to your model, you can enter the parameters
for its I/O driver. The following procedure uses the Humusoft MF604
I/O board as an example.
1 Double-click the Counter Input block.
The Block Parameters: Counter Input dialog box opens:
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
3-7
Counter Input
3 In the Input channels box, enter a channel vector that selects the
counter input channels you are using on this board. The vector can
be any valid MATLAB vector form. For example, to select all four
counter input channels on the MF604 board, enter
[1,2,3,4] or [1:4]
4 From Reset after read, which determines if the counter should be
reset to zero after its value has been read, choose one of the following
options:
•
never — Do not reset after reading.
always — Always reset after reading.
•
level — Reset after reading if block input is nonzero. This will
•
add an input to the Counter Input block.
•
rising edge — Reset after reading if block input changes from
zero to nonzero between the last two successive readings. This will
add an input to the Counter Input block.
3-8
•
falling edge — Reset after reading if the block input changes
from nonzero to zero between last two successive readings. This
will add an input to the Counter Input block.
•
either edge — Reset after reading if the block input changes
either from zero to nonzero or from nonzero to zero between the
last two successive readings. This will add an input to the Counter
Input block.
5 From Clock input source, which determines the clock input source
to increment the counter, select
•
input pin rising edge — Clock edge low to high transitions
input pin falling edge — Clock edge high to low transitions
•
internal clock — Internal timebase
•
If you set the Gate input functionality parameter to
when high, latch & reset on edge
or enable when low,
enable
Counter Input
latch & reset on edge, you can measure positive or negative
pulse lengths in units of the internal timebase. You can use
this combination with the National Instruments
and National Instruments PCI/PXI-62xx drivers for pulse width
measurement.
Not all counter chips support s electing the input edge. In this case,
only supported options appear in the pull-down menu.
6 From Gate input functionality, which defines the action of the
counter’s gate pin, select
•
none — Gate is disabled.
enable when high — Counting is disabled when the gate is low
•
and enabled when the gate is high.
•
enable when low — Counting is disabled when the gate is high
and enabled when the gate is low.
•
start on rising edge — Counting is disabled until low to high
transition of the gate occurs.
®
PCI/PXI-60xx
•
start on falling edge — Counting is disabled until high to
low transition of the gate occurs.
•
reset on rising edge — Counter is reset when low to high
transition of the gate occurs.
•
reset on falling edge — Counter is reset when high to low
transition of the gate occurs.
•
latch on rising edge — The count of the counter is remembered
when low to high transition of the gate occurs.
•
latch on falling edge — The count of the counter is
remembered when high to low transition of the gate occurs.
•
latch & reset on rising edge — The count of the counter
is remembered and then the counter is reset when low to high
transition of the gate occurs.
3-9
Counter Input
• latch & reset on falling edge — The count of the counter
is remembered and then the counter is reset when high to low
transition of the gate occurs.
•
enable when high, latch & reset on edge —Enablespulse
counting when the gate input goes high, counts the clock while it
is high, and remembers (latches) the pulse count. Then resets the
counter to prepare it for the next pulse in the gate input.
If you set the Clock input source parameter to
, you can measure positive pulse lengths in units of the
clock
internal
internal timebase. You can use this combination with the
National Instruments PCI/PXI-60xx and National Instruments
PCI/PXI-62xx drivers for pulse width measurement.
•
enable when low, latch & reset on edge —Enablespulse
counting when the gate input goes high, counts the clock while it
is lo w, and remembers (latches) the pulse count. Then resets the
counter to prepare it for the next pulse in the gate input.
If you set the Clock input source parameter to
, you can measure negative pulse lengths in units of
clock
internal
the internal timebase. You can use this combination with the
National Instruments PCI/PXI-60xx and National Instruments
PCI/PXI-62xx drivers for pulse width measurement.
Not all counter chips support all gate modes. Only supported g ate
modes appear in the pull-down menu.
7 Set Output data type to specify the type of data that the block will
output to the model.
8 Click OK or Apply.
Counter Input Block Demo
3-10
The Real-Time Windows Target software includes a demo that shows
the operation of the Counter Input block. To see this demo, type
rtcounter in the MATLAB Command Window, or start MATLAB Help
Counter Input
and choose Real-Time Windows Target > Demos > Frequency
Measurement.
3-11
Digital Input
PurposeSelect and connect digital input lines or channels
LibraryReal-Time Windows Target
DescriptionThe Digital Input block allows you to select and connect specific digital
lines or channels to your Simulink model. After you have added a
Digital Input block to your model, you can enter the parameters for
its I/O driver. The following procedure uses the Humusoft AD512 I/O
board as an example.
1 Double-click the Digital Input block.
The Block Parameters: Digital Input dialog box opens:
3-12
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
Digital Input
3 In the Input channels box, enter a channel vector that selects the
digital input channels you are using on this board. The vector can
be any valid MATLAB vector form. For example, to select all eight
digital input channels on the AD512 board, enter
[1,2,3,4,5,6,7,8] or [1:8]
If you want to use the first four digital input lines, enter
[1,2,3,4]
If you have one 8-bit d igital channel, enter [1].Ifyouhavetwo
8-bit digital channels, enter
choose
4 From the Channel mode list, choose one of the following options:
•
•
Byte.
Bit — Returns a value of 0 or 1.
Byte — Groups eight digital lines into one digital channel a nd
returns a value of 0 to 255.
[1 9],andfromtheChannel mode list,
5 Set Output data type to specify the type of data that the block will
output to the model.
6 Click OK or Apply.
3-13
Digital Output
PurposeSelect and connect digital output lines or channels
LibraryReal-Time Windows Target
DescriptionThe Digital Output block allows you to select and connect specific
digital lines or channels to your Simulink model. After you have added
a Digital Output block to your model, you can enter the p arameters
for its I/O driver. The following procedure uses the Humusoft AD512
I/O board as an example.
1 Double-click th e Digital Output block.
The Block Parameters: Digital Output dialog box opens:
3-14
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
Digital Output
3 In the Output channels box, enter a channel vector that selects the
digital output channels you are using on this board. The vector can
be any valid MATLAB vector form. For example, to select all eight
digital output channels on the AD512 board, enter
[1,2,3,4,5,6,7,8] or [1:8]
If you want to use the first four digital output lines, enter
[1,2,3,4]
If you have one 8-bit d igital channel, enter [1].Ifyouhavetwo
8-bit digital channels, enter
choose
4 From the Channel mode list,choosefromoneofthefollowing:
•
•
Byte.
Bit —Expectsavalueof0or1.
Byte — Expects a value of 0 to 255 that is converted to one digital
channel of eight digital lines.
[1 9],andfromtheChannel mode list,
5 Enter the initial values for each digital output line or channel you
entered in the Output channels box. For example, if you entered
[1,2,3,4] in the Output channels box, and you want initial values
of 0 and 1, enter
[0,0,1,1]
If you choose Byte from the Channel mode list, enter a value between
0 and 255 for each digital output channel. For example, for one byte
(8 dig ita l lines) with an initial value of 25, enter
(16 digital lines) with initial values of 25 and 50, enter
6 Enter a final value for each digital output channel you entered in the
Output chan nels box. For example, if you entered
[25].Fortwobytes
[25 50].
[1,2,3,4] in the
Output channels box, and you want final values of 0, enter
[0,0,0,0]
3-15
Digital Output
If you choose Byte from the Channel mode list, enter a value between
0 and 255 for each digital output channel.
7 Click OK or Apply.
3-16
Encoder Input
PurposeSelect and connect encoder input channels
LibraryReal-Time Windows Target
DescriptionThe Encoder Input block allows you to select and connect s pecific
encoder input channels to your Simulink model. After you have added
an Encoder Input block to your model, you can enter the parameters
for its I/O driver. The following procedure uses the Humusoft MF604
I/O board as an example.
1 Double-click the Encoder Input block.
The Block Parameters: Encoder Input dialog box opens:
3-17
Encoder Input
2 In the Sample time box, enter the same value you entered in the
Fixed step size box from the Configuration Parameters dialog box,
or an integer multiple of that value.
3 In the Input channels box, enter a channel vector that selects the
encoder input channels you are using on this board. The vector can
be any valid MATLAB vector form. For example, to select all four
encoder input channels on the MF604 board, enter
[1,2,3,4] or [1:4]
4 Encoders typically use two sets of stripes, shifted in phase, to
optically detect the amplitude and direction of movement. The
Quadrature mode parameter specifies which encoder stripe edges
should be counted.
•
double — Counts the rising edges from both stripe sets
single — Counts the rising edges from one stripe set
•
quadruple — Counts rising and falling edges from both stripe sets
•
3-18
Quadruple mode yields four times more pulses per revolution than
the single mode. Therefore, quadruple is more precise and is
recommended unless other parameters dictate otherwise.
5 The encoder interface chip has a reset pin in addition to encoder
inputs. This pin is usually connected to the index output of the
encoder. However, it can be connected to any signal or not be used at
all. The Reset input function specifies the function of this pin.
•
gate — Enables encoder counting
reset — Level reset of the encoder count
•
rising edge index — Resets the encoder count on the rising edge
•
falling edge index — Resets the encoder count on the falling
•
edge
Encoder Input
6 The encoder interface chip has a built-in lowpass filter that attempts
to filter out any high frequencies, which are interpreted as noise. The
Input filter clock frequency is the cutoff frequency (Hz) of this
filter. The cutoff frequency you specify is rounded to the nearest
frequency supported by the chip.
If the encoder is moving slowly and high-frequency noise is present,
employ the filter to eliminate the noise. This keeps the noise from
being counted as encoder pulses. If the encoder is moving quickly , the
filter can filter out all of the high-frequency pulses, including those
you want to count. In this case, consider leaving the filter disabled by
setting the cutoff frequency to
7 Set Output data type to specify the type of data that the block will
output to the model.
8 Click OK or Apply.
Inf.
3-19
Frequency Output
PurposeGenerate and output a pulse-width-modulated square wave
LibraryReal-Time Windows Target
DescriptionThe Frequency Output block generates a pulse-width-modulated square
wave that alte rnates between low (0) and high (1) with a specified
frequency and duty cycle. The frequency is specified in Hertz. The duty
cycle is specified as a decimal fraction between 0 and 1 inclusive. This
fraction specifies the amount of time that the output signal value is
high (1). For example, a duty cycle of .7specifiesthattheoutputishigh
70% of the time, and low 30% of the time.
After you have added a Frequency Output block to your model,
double-click the Frequency Output block to open the Block Parameters:
Frequency Output dialog box. The default appearance of the dialog
box is:
3-20
Frequency Output
y parameter values as needed, then click OK or Apply.Ifyou
Specif
y a non-default value for Output signal frequency source or
specif
Output
as sho
Sampl
Outp
signal duty source, the appearance of the dialog box changes
wn below. The parameters are:
etime
r the same value you entered in the Fixed step size box
Ente
the Configuration Parameters dialog box, or an integer
from
iple of that v al u e.
mult
ut channels
ctor that selects the output channels you are using on this
Ave
rd. The vector can be any valid MATLAB vector form.
boa
3-21
Frequency Output
Output signal frequency source
The source that specifies the frequency to output. The frequency
is specified in Hertz. The Output signal frequency source
can be either of the following:
external (Default)
The frequency is specified by an input signal. An input port
appears on the block to accept the signal. A Frequencyinitial value and a Frequency final value may be needed.
internal
The frequency is specified by a tunable parameter named
Frequency. If you specify
Frequency initial value,andFrequency final value is
disabled:
internal, Frequency replaces
3-22
Frequen
This tu
source
Freque
This p
is
speci
and p
the f
to sp
no va
fre
cy
nable parameter appears when Output signal frequency
is
internal. Specify the desired frequency in Hertz.
ncy initial value
arameter appears when Output signal frequency source
ernal
ext
fied frequency takes effect when you connect to the target,
requency signal takes effect. You can use this parameter
ecify initial conditions and give them time to stabilize. If
lue a ppears, connecting to the target has no effect on the
quency.
. Optionally specify a frequency in Hertz. The
ersists until simulation starts, at which time the value of
Frequency Output
Frequency final value
This parameter appears when Output signal frequency source
is
external. Optionally specify a frequency in Hertz. The
specified frequency ta k e s effect when s i m ulation completes and
persists indefinitely. Dis connect ing from the target does not affect
the frequency. You can use this parameter to put a connected
device into a safe or neutral state after simulation. If no value
appears, the frequency in effect at the end of simulation persists
afterwards.
Output signal duty source
The source that specifies the duty cycle. The specification is a
decimal fraction between 0 and 1 inclusive that determines the
amount of time that the output signal value is high (1). For
example, a duty cycle of .7 specifies that the output is high 70%
of the time, and low 30% of the time. Two duty cycle values have
special significance:
0
The output signal is continuously low (0) regardless of any
frequency specification currently in effect.
1
The output signal is continuously high (1) regardless of any
frequency specification currently in effect.
The Output signal duty source can be either of the following:
internal (Default)
The duty cycle is specified by a tunable parameter named
Duty.
external
The duty cycle is specified b y an input signal. An input port
appears on the block to accept the signal. If you specify
external, Duty initial value replaces Duty,andDuty
final value is enabled:
3-23
Frequency Output
Duty
Duty initial value
This tunable parameter appears when Output signal duty
source is
fraction between 0 and 1. Specifying 0 or 1 overrides the currently
specified frequency and enforces a continuously low or high output
signal for the duration of the specification.
This parameter appears when Output signal duty source is
external. Optionally specify a duty cycle. The specified duty
cycle takes effect when you connect to the target, and persists
until simulation starts. If no value appears, connecting to the
target has no effect o n the duty cycle. You can specify any
duty cycle. Often the Duty initial value is 0 or 1, enforcing a
continuously low or high initial output signal. Specifying 0 or 1
overrides any Frequency initial value.
internal. Specify the desired duty cycle as a decimal
3-24
Duty final value
This parameter appears when Output signal duty source is
external. Optionally specify a duty cycle. The specified duty cycle
takes effect when simulation completes and persists indefinitely.
Disconnecting from the target does not change the duty cycle. If
no value appears, the duty cycle in effect at the end of simulation
persists indefinitely afterwards. You can specify any duty cycle.
Often the Duty final value is 0 or 1, enforcing a continuously
low or high initial output signal. Specifying 0 or 1 overrides any
Frequency final value.
Other Input
PurposeConnect with input sources thatotherinputblockscannot
LibraryReal-Time Windows Target
DescriptionThe Real-Time Windows Target Other Input block can be used for
interfacing input signals that other Real-Time Windows Target input
blocks do not accommodate. The Other Input block is rarely used, and
for only a few drivers. For details, see the documentation for the driver
that you intend to use.
If none of the available blocks, including Other Input, provide what
youneed,youcancreateyourownI/OblockstoworkwithReal-Time
Windows Target applications. See “Custom I/O Driver Blocks” for
details.
3-25
Other Output
PurposeConnect with output sources that other output blocks cannot
LibraryReal-Time Windows Target
DescriptionThe Real-Time Windows Target Other O utput block can be used for
interfacing input signals that other Real-Time Windows Target output
blocks do not accommodate. The Other Output block is rarely used,
and for only a few drivers. For details, see the documentation for the
driver that you intend to use.
If none of the available blocks, including Other Output, provide what
youneed,youcancreateyourownI/OblockstoworkwithReal-Time
Windows Target applications. See “Custom I/O Driver Blocks” for
details.
3-26
Packet Input
PurposeReceive unformatted binary data
LibraryReal-Time Windows Target
DescriptionThe P acket Input block receives unformatted binary data. A fter you
have added a Packet Input block to your model, double-click the Packet
Input block to open the Block Parameters: Packet Input dialog box.
The driver must be Standard Devices > Serial Port, Standard
Devices > UDP Protocol, Standard Devices > File,orVector >
CAN Device. Specify parameter valuesasneeded,thenclickOK or
Apply. When you install a UDP device, enter port addresses in decimal
format in the Standard Devices UDP Protocol dialog box.
The parameters are:
3-27
Packet Input
Sample time
Enter the same value you entered in the Fixed step size box
from the Configuration Parameters dialog box, or an integer
multiple of that value.
Packet identifier
Enter the ID of the packet to receive. If your protocol does not
have packet IDs, this parameter is disabled.
Input packet size
The number of bytes expected in each input packet. This number
must be the same as the number of bytes needed to s atisfy the
type specifications in Block output data types.
Block output data types
A string, or a cell array of strings, that specify how the data in
each packet obtained from the device is to be typed and grouped
for input to the application. The Packet Input block has an
output port corresponding to each string in Block output datatypes. Changing the number of strings automatically changes the
number of output ports.
3-28
Each string has the format [
by the string has the type specified by
specified by
means one double value , and '4*int8' means a vector of four
int8 values.
By providing an appropriate cell array of strings, you can
convert an input packet into any needed types, packaged
into vectors in any needed way. For example, specifying
{'int16','int16','double'} creates three ports. The first
and second each output an
double.Specifying{'2*int16','double'} creates two ports: a
vector of two
Show “Data Ready” port
If enabled, the block has an output port that signals 1 if the block
has new data available, and 0 otherwise.
n;or1ifn is not specified. For example, 'double'
int16 values, and a scalar double.
n*]datatype. The data described
datatype and the width
int16 value, and the th ird outputs a
Packet Input
Show “Data Error” port
If enabled, the block has an output port that signals 1 if a data
error has occurred, and 0 otherwise.
Show packet timestamp port
Select this check box to show the timestamp for the CAN message
packets. If your protocol doe s not have packet timestamps, the
block ignores this value.
3-29
Packet Output
PurposeTransmit unformatted binary data
LibraryReal-Time Windows Target
DescriptionThe Packet Output block sends unformatted binary data. After you have
added a Packet Output block to your model, double-click the Digital
Output block to open the Block Parameters: Digital Output dialog box.
3-30
The driver must be Standard Devices > Serial Port, Standard
Devices > UDP Protocol, Standard Devices > File,orVector >
CAN Device. Specify parameter valuesasneeded,thenclickOK or
Apply. When you install a UDP device, enter port addresses in decimal
format in the Standard Devices UDP Protocol dialog box.
Packet Output
The parameters are:
Sample time
Enter the same value you entered in the Fixed step size box
from the Configuration Parameters dialog box, or an integer
multiple of that value.
Packet identifier
Enter the ID of the packet to receive. If your protocol does not
have packet IDs, this parameter is disabled.
Output packet size
The number of bytes to be transmitted in the output packet. This
number must be the same as the number of bytes needed to satisfy
the type specifications in Output packet field data types.
Output packet field data typ es
A string, or a cell array of strings, that specify how data p rovided
by the application will be formatted into a packet for output to the
device. The Packet Output block hasaninputportcorresponding
to each string in Output packet field data types. Changing the
number of strings automatically changes the number of ports.
Each string has the format [
by the string has the type specified by
specified by
means one double value , and '4*int8' means a vector of four
int8 values.
The signal input to each port of the Packet Output block can be
a scalar or vector of any Simulink data type. The string for each
port specifies the type to be used when its signal is output to the
device. If the format string for a port matches the type of the
signal input to that port, the signal value appears verbatim in
the output packet.
Youcanalsoperformtypeconversiononoutput. Forexample,
if an input signal is a four-element
n;or1ifn is not specified. For example, 'double'
n*]datatype. The data described
datatype and the width
int16 vector, but the
3-31
Packet Output
corresponding string is '4*int8', each of the four integers is
converted to an
resulting data occupies four bytes in the output packet.
Show “Data Ready” port
If enabled, the block has an output port that signals 1 if the block
is ready to accept new data, and 0 otherwise.
Show “Data Error” port
If enabled, the block has an output port that signals 1 if a data
error has occurred, and 0 otherwise.
Initial value
If specified, a vector that has the same number of e lements as
the sum of the widths of the input signals across all ports. The
specified data is sent when simulation begins, before any other
data that is output during simulation.
Final value
If specified, a vector that has the same number of e lements as
the sum of the widths of the input signals across all ports. The
specified data is sent when simulation ends, after any other data
that is output during simulation.
int8 before being written to the packet. The
3-32
Stream Input
PurposeReceive formatted ASCII data
LibraryReal-Time Windows Target
DescriptionThe Stream Input block receives formatted ASCII data. After you have
added a Stream Input block to your model, double-click the Stream
Input block to open the Block Parameters: Stream Input dialog box.
The driver must be Standard Devices > Serial Port, StandardDevices > File,orStandard Devices > UDP Protocol.Specify
parameter values as needed, then click OK or Apply.Whenyouinstall
a UD P device, enter port addresses in decimal format in the Standard
Devices UDP Protocol dialog box.
The parameters are:
3-33
Stream Input
Sample time
Enter the same value you entered in the Fixed step size box
from the Configuration Parameters dialog box, or an integer
multiple of that value.
Block output data types
A string or a cell array of strings. The block has as many output
ports as the number of strings. Each string specifies a data type
by name, and optionally a number of elements. For example,
'double' means one double value, and '4*int8' means four
int8 values.
The values made available on output ports are grouped and typed
according to the Block output data types strings. For example,
if Block output data types is
block outputs an
and a
double vector of width 3 on the second output port.
int8 vector of width 2 on the first output port,
{'2*int8','3*double'},the
Format string
A specification in the same formatusedbyClibraryI/Oroutines
like
scanf. The format string describes the data to be received.
The number of elements in the string must equal the number of
data items specified in Block output data types.
3-34
For example, if Block output data types is
{'2*int8','3*double'},andFormat string is '%d %d
%f %f %f'
, the block reads an ASCII representation of two
integers and three doubles. The block makes the resulting values
available to the application in an
firstoutputport,anda
double vector of width 3 on the second
int8 vector of width 2 on the
output port.
IfthedatatypespecifiedforavalueinBlock output data types
differs from the type of the corresponding element in Formatstring, type conversion occurs automatically. The block reads
data as specified by Format string, converts the data to match
the Block output data types, and provides the d ata to the
application on the block output ports.
Stream Input
Message termination
A string, cell array of strings, or a number. If the value is a string,
receiving this s equence of characters terminates data input. If the
value is a cell array, any of the strings in the cell array terminates
data input. If the value is a number, data input terminates after
reading the specified number of characters.
Show “Data Ready” port
If enabled, the block has an output port that signals 1 if the block
has new data available, and 0 otherwise.
Show “Data Error” port
If enabled, the block has an output port that signals 1 if a data
error has occurred, and 0 otherwise.
3-35
Stream Output
PurposeTransmit formatted ASCII data
LibraryReal-Time Windows Target
DescriptionThe Stream Output block sends formatted ASCII data. After you have
added a Stream Output block to your model, double-click the Stream
Output block to open the Block Parameters: Stream Output dialog box.
3-36
The driver must be Standard Devices > Serial Port, Standard
Devices > File,orStandard Devices > UDP Protocol.Specify
parameter values as needed, then click OK or Apply.Whenyouinstall
a UD P device, enter port addresses in decimal format in the Standard
Devices UDP Protocol dialog box.
The parameters are:
Stream Output
Sample time
Enter the same value you entered in the Fixed step size box
from the Configuration Parameters dialog box, or an integer
multiple of that value.
Inputportsizes
A port width, or vector of port widths. The number of elements
determines the number of input ports. Each port has the width
specified by the corresponding element. For example, specifying
3,1,2 indicates that the block has three input ports. The first is a
vector of width
of width
specified; any Simulink data type can be input.
Format string
A specification in the same formatusedbyClibraryI/Oroutines
like
format string must have the same number of specifiers as the sum
of the elements of Inputportsizes.
2, f or a total of six elements. Only the widths need to be
printf. The format string describes the data to be sent. The
3, the second is a scalar, and the third is a vector
For example, assume that Inputportsizesis
Format string of
representing: three integers from the vector on the first input
port; a double from the scalar on the input second port; and two
integers from the vector on the third input port.
If the data type specified in the Format string for a value
differs from the type of the actual value, type conversion occurs
automatically, and converted data that conforms to the Format
string is output as ASCII to the device.
Show “Data Ready” port
If enabled, the block has an output port that signals 1 if the block
is ready to accept new data, and 0 otherwise.
Show “Data Error” port
If enabled, the block has an output port that signals 1 if a data
error has occurred, and 0 otherwise.
'%d%d%d%f%d%d'would output ASCII
3,1,2.Thena
3-37
Stream Output
Initial string
If specified, a string that is sent when simulation begins, before
any other data that is output during simulation. The string can
contain anything; it could be used to initialize a device. It is
sent literally as specified, without translation using the Format
string.
Final string
If specified, a string that is sent when simulation ends, after
any other data that is output during simulation. The string can
contain anything; it could be used to shut down a device. It is
sent literally as specified, without translation using the Format
string
3-38
Configuration Parameters
4
4 Configuration Parameters
Real-Time Workshop Pane: Real-Time Windows Target
4-2
In this section...
“Real-Time W indows Target Tab Overview” on page 4-3
“Target function library” on page 4-4
“Utility function generation” on page 4-6
“Compiler optimizations” on page 4-7
“Generate assembly listings” on page 4-8
“Rebuild all” on page 4-9
“External mode” on page 4-10
“Transport layer” on page 4-12
“MEX-file arguments” on page 4-14
“Static memory allocation” on page 4-16
“Static memory buffer size” on page 4-18
Real-Time Workshop®Pane: Real-Time Windows Target™
Real-Time Windo
Control the code
for a Real-Time W
created by Real-Time W orkshop
ws Target Tab Overview
indows Target application.
Configuration
This tab appea
rs only if you spe cify
rtwin.tlc as the System target file.
See Also
• Real-Time Windows Target User’s Guide
• Real-Time Windows Target Reference Manual
• Real-Time Windows Target Release Notes
®
code generation software
4-3
4 Configuration Parameters
Target function library
Specify a floating-point math library extension.
Settings
Default: C89/C90 (ANSI)
C89/C90 (ANSI)
Generates calls to the ISO/IEC 9899:1990 C standard math library for
floating-point functions.
C99 (ISO)
Generates calls to the ISO/IEC 9899:1999 C standard math library.
GNU99 (GNU)
Generates calls to the GNU gcc math library, which provides C99
extensions as defined by compiler option
C++ (ISO)
Generates calls to the ISO/IEC 14882:2003 C++ standard math library.
This setting is visible only if you selected
parameter on the Real-Time Workshop pane of the Configuration
Parameters dialog box.
-std=gnu99.
C++ for the Language
4-4
Tips
• Before setting this parameter, verify that your compiler supports the
library you want to use. If you select a parameter value that your compiler
does not support, compiler errors can occur.
• Restriction — Stateflow
Selecting a different parameter has no effect on code generate d for
Stateflow components.
Real-Time Workshop®Pane: Real-Time Windows Target™
Application
Efficiency
Safety precaution
Setting
No impact
No impact
See Also
• Creating an External Mode Communication Channel
• Target Interfacing
4-13
4 Configuration Parameters
MEX-file arguments
Specify external mode MEX arguments.
Settings
Default: ''
For a shared memory transport, rtwinext allows two optional arguments.
The arguments are positional, so the first argument m ust appear if the second
appears.
• An argument that is currently unused. Specify
necessary.
• An argument that specifies verbosity. Specify 0 for Nonverbose, or 1 for
Verbose.
The default is Nonverbose mode (
arguments to:
'' 1
where '' is the empty string and 1 specifies Verbose mode.
0). To specify Verbose mode, set MEX-file
'' for this argument if
Dependency
This parameter is enabled by checking External Mode.
Command-Line Information
Parameter: ExtModeMexArgs
Type: string followed by integer
Value:
Default: ''
'' | '' 0 | '' 1
4-14
Recommended Settings
Real-Time Workshop®Pane: Real-Time Windows Target™