Mathworks REAL-TIME WINDOWS TARGET 3 user guide

Real-Time Windows
Reference
Target™ 3
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support
suggest@mathworks.com Product enhancement suggestions
bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes
info@mathwo
com
rks.com
rks.com
Web
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
Real-Time Windows Target™ Reference
© COPYRIGHT 1999–2010 by The MathWorks, Inc.
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 2008 Online only New for Version 3.1 (Release 2008a) October 2008 Online only Revised for Version 3.2 (Release 2008b) March 2009 Online only Revised for Version 3.3 (Release 2009a) September 2009 Online only Revised for Version 3.4 (Release 2009b) March 2010 Online only Revised for Version 3.5 (Release 2010a)
Function Reference
1
Block Reference
2
Input ............................................. 2-2
Contents
Output
............................................ 2-3
Blocks — Alphabetical List
3
Configuration Parameters
4
Real-Time Workshop Pane: Real-Time Windows
Target
Real-Time Windows Target Tab Overview Target function library Utility function generation Compiler optimizations Generate as sembly listings Rebuild all External mode Transport layer MEX-file arguments Static memory allocation Static memory buffer size
.......................................... 4-2
............................. 4-4
.......................... 4-6
............................. 4-7
.......................... 4-8
....................................... 4-9
.................................... 4-10
................................... 4-12
............................... 4-14
........................... 4-16
........................... 4-18
............. 4-3
iii
Index
iv Contents
Function Reference
1
rtwho
Purpose Display information about Real-Time Windows Target status
Syntax rtwho
Description rtwho display information about the Real-Time Windows Target™ PC
status. For example, it lists:
All hardware drivers
Timers
Kernel performance
Machine type
Real-T ime Windows Target version
Example This command displays PC information.
rtwho
1-2
Real-Time Windows Target version 3.2.0 (C) The MathWorks, Inc. 1994-2008
Running on Multiprocessor APIC computer.
MATLAB performance = 100.0%
Kernel timeslice period = 1 ms
rtwinconfigset
Purpose Attach and activate default Real-Time Windows Target configuration
set
Syntax rtwinconfigset('model')
rtwinconfigset('model', 'ERT') configset=rtwinconfigset() configset=rtwinconfigset('','ERT')
Arguments model
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.
Returns configset
The default Real-Time Windows Target configuration set, which later can be attached to a model.
®
Embedded Coder™ software to be attached
Description The 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 Also Configuration Sets
Referencing Configuration Sets Specifying the Default Configuration Set
1-4
rtwintgt
Purpose Install and remove Real-Time Windows Target kernel
Syntax rtwintgt -setup
rtwintgt -install rtwintgt -uninstall rtwintgt -forceuninstall rtwintgt -version
Description rtwintgt -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 Windows Target 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 Input Select and connect analog input
channels
Counter Input Select and connect counter input
channels
Digital Input
Encoder Input
Other Input Connect with input sources that
Packet Input
Stream Input Receive 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 Output Select and connect analog output
channels
Digital Output Select and connect digital output
lines or channels
Frequency Output Generate and output a
pulse-width-modulated square wave
Other Output Connect with output sources that
other output blocks cannot
Packet Output Transmit unformatted binary data
Stream Output Transmit formatted ASCII data
2-3
2 Block Reference
2-4
3
Blocks — Alphabetical List
Analog Input
Purpose Select and connect analog input channels
Library Real-Time Windows Target
Description The 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
Purpose Select and connect analog output channels
Library Real-Time Windows Target
Description The 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.
Normalized bipolar —Expectsavaluebetween-1and+1that
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
Purpose Select and connect counter input channels
Library Real-Time Windows Target
Description The 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
Purpose Select and connect digital input lines or channels
Library Real-Time Windows Target
Description The 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
Purpose Select and connect digital output lines or channels
Library Real-Time Windows Target
Description The 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
Purpose Select and connect encoder input channels
Library Real-Time Windows Target
Description The 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
Purpose Generate and output a pulse-width-modulated square wave
Library Real-Time Windows Target
Description The 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 Frequency initial 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
Purpose Connect with input sources thatotherinputblockscannot
Library Real-Time Windows Target
Description The 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
Purpose Connect with output sources that other output blocks cannot
Library Real-Time Windows Target
Description The 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
Purpose Receive unformatted binary data
Library Real-Time Windows Target
Description The 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 data types. 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
Purpose Transmit unformatted binary data
Library Real-Time Windows Target
Description The 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
Purpose Receive formatted ASCII data
Library Real-Time Windows Target
Description The 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, 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:
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 Format string, 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
Purpose Transmit formatted ASCII data
Library Real-Time Windows Target
Description The 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.
®
software supports only C89/C90 (ANSI).
Command-Line Information
Parameter: GenFloatMathFcnCalls Type: string Value: Default: 'ANSI_C'
'ANSI_C' | 'C99 (ISO)' | 'GNU99 (GNU)' | 'C++ (ISO)'
Recommended Settings
Real-Time Workshop®Pane: Real-Time Windows Target™
Application
Debugging No impact
Traceability No impact
Safety precaution
Setting
No impact
4-5
4 Configuration Parameters
Utility function gener ation
Specify location for generating utility functions
Settings
Default: Auto
Auto
Operates as follows:
When the model contains Model blocks, place utilities within the
slprj/target/_sharedutils directory.
When the model does not contain Model blocks, place utilities in the
build directory (generally, in
Shared location
Directs code for utilities to be placed within the slprj directory in your working directory.
model.c or model.cpp).
4-6
Command-Line Information
Parameter: UtilityFuncGeneration Type: string Value: Default: 'Auto'
'Auto' | 'Shared location'
Recommended Settings
Application
Debugging
Traceability
Efficiency
Safety precaution
Setting
Shared location
Shared location
Shared location
No impact
Real-Time Workshop®Pane: Real-Time Windows Target™
Compiler optimi
Instruct the C co
mpiler to generate real-time code fully optimized for speed.
zations
Settings
Default: on
On
Optimizes th
Off
Performs no
e code for speed.
optimizations.
Command-Line Information
:
Parameter Type: Boolean Value: Default:
CCOptimize
on | off
on
Recommended Settings
Application
Setting
Debugging
Traceability
Efficiency On
Safety precaution On
Off
Off
4-7
4 Configuration Parameters
Generate assemb
Instruct the C co
mpiler to generate assembly listings for the generated code.
ly listings
Settings
Default: off
On
Generates as
Off
Suppresses
sembly listings.
assembly listings.
Command-Line Information
:
Parameter Type: Boolean Value: Default:
CCListing
on | off
off
Recommended Settings
Application
Setting
4-8
Debugging No impact
ability
Trace
ciency
Effi
ety precaution
Saf
No imp
No impact
No impact
act
Rebuild all
Force all the obj
Settings
Default: off
On
Rebuilds all
Off
Rebuilds on
Command-Line Information
Parameter Type: Boolean Value: Default:
ect files to always be rebuilt regardless of their time stamps.
object files at every build.
ly object files whose time stamps show they are outdated.
:
RebuildAll
on | off
off
Real-Time Workshop®Pane: Real-Time Windows Target™
Recommended Settings
Application
Debugging
Traceability No impact
Efficiency No run-time impact. (Build may take
Safety precaution On
Setting
On
longer.)
4-9
4 Configuration Parameters
External mode
Enable client/s application.
Settings
Default: on
On
Enables exte
Off
Disables ex
Dependencies
Selecting
erver communication between Simulink software and a n
rnal mode.
ternal mode.
External mode enables:
Transpor
MEX-fil
Static m
tlayer
earguments
emory allocation
Command-Line Information
ter:
Parame Type: string Value: Defau
lt:
ExtMode
'on' | 'off'
'on'
Recommended Settings
ing
Application
Debugging No impact
aceability
Tr
fficiency
E
afety precaution
S
Sett
impact
No
No impact
No impact
4-10
See Also
External Mode
Real-Time Workshop®Pane: Real-Time Windows Target™
4-11
4 Configuration Parameters
Transport layer
Specify the tran
Settings
Default: shar
sharedmem
Uses a shared
rtwinext.
Tips
TheMEX-filenamedisplayednexttoTransport layer cannot be edited in
the Configuration Parameters dialog box.
For targets provided by The MathWorks, like Real-Time W indows Target,
theMEX-filenameisspecifiedin:
sport protocol for external mode communication.
edmem
memory transport mechanism. The M EX-file name is
4-12
matlabroot/toolbox/simulink/simulink/extmode_transports.m
Depende
This parameter is enabled by checking External Mode.
Comman
Parameter: ExtModeTransport Type: Value: Default: 0
Reco
Application
Deb
Traceability No impact
ncy
d-Line Information
integer
0
mmended Settings
ugging
Setting
mpact
No i
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™
Application
Debugging No impact
Traceability No impact
Efficiency
Safety precaution
Setting
No impact
No impact
See Also
Target Interfacing
Client/Server Implementations
4-15
4 Configuration Parameters
Static memory al
Control the memo
ry buffer for external mode communication.
location
Settings
Default: off
On
Enables the S memory.
Off
Uses a stati dynamic me
tatic memory buffer size parametertoallocatedynamic
c memory buffer for external mode instead of allocating
mory (calls to malloc).
Tip
To determ the targe
ine how much memory you need to allocate, enable verbose mode on
t to display the amount of memory it tries to allocate and is available.
Dependencies
This parameter is enabled by checking External Mode.
This parameter enables Static memory buffer size.
4-16
Command-Line Information
Parameter: ExtModeStaticAlloc Type: string
'on' | 'off'
e:
Valu Default: 'off'
Recommended Settings
lication
App
Debugging No impact
Traceability No impact
Setting
Real-Time Workshop®Pane: Real-Time Windows Target™
Application
Efficiency
Safety precaution
See Also
External Mode Interface Options
Setting
No impact
No impact
4-17
4 Configuration Parameters
Static memory buffer size
Specify the memory buffer size for external mode communication.
Settings
Default: 1000000
Enter the number of bytes to preallocate for external mode communications buffers in the target.
Tips
If you enter too small a value for your application, external mode issues an
out-of-memory error.
To determine how much memory you need to allocate, enable verbose mode
onthetargettodisplaytheamountofmemoryittriestoallocateandis available.
4-18
Dependency
This parameter is enabled by Static memory allocation.
Command-Line Information
Parameter: ExtModeStaticAllocSize Type: integer Value: Any valid size Default:
1000000
Recommended Settings
Application
Debugging No impact
Traceability No impact
Efficiency
Safety precaution
Setting
No impact
No impact
See Also
External Mode Interface Options
Real-Time Workshop®Pane: Real-Time Windows Target™
4-19
4 Configuration Parameters
4-20
Index
IndexA
Analog Input block
configuring 3-2
Analog Output block
configuring 3-4
C
configuration parameters
pane
Compiler optimizations 4-7 External mode 4-10 Generate assembly listings 4-8
Rebuild all 4-9 Real-Time Windows Target tab 4-3 real-time workshop (interface)
target floating-point math
environment 4-4
utility function 4-6 Real-Time Wo rkshop (interface)
mex-file arguments 4-14
static memory allocation 4-16
static memory buffer size 4-18
transport layer 4-12
configuration set
specifying default 1-3
configuring
Analog Input bock 3-2 Analog O utput block 3-4 Counter Input block 3-7 Digital Input block 3-12 Digital Output block 3-14 Encoder Input block 3-17 Frequency Output block 3-20 Packet Input block 3-27 Packet Output block 3-30 Stream Input block 3-33 Stream Output block 3-36
Counter Input block
configuring 3-7
D
Digital Input block
configuring 3-12
Digital Output block
configuring 3-14
E
Encoder Input block
configuring 3-17
F
Frequency Output block
configuring 3-20
I
I/O blocks
Analog Input block 3-2 Analog O utput block 3-4 Counter Input block 3-7 Digital Input block 3-12 Digital Output block 3-14 Encoder Input block 3-17 Frequency Output block 3-20 Packet Input block 3-27 Packet Output block 3-30 Stream Input block 3-33 Stream Output block 3-36
P
Packet Input block
configuring 3-27
Packet Output block
configuring 3-30
R
Real-Time Windows Target kernel
Index-1
Index
installing 1-5 removing 1-5
rtwho function 1-2 rtwinconfigset function 1-3 rtwintgt function 1-5
S
Stream Input block
configuring 3-33
Stream Output block
configuring 3-36
Index-2
Loading...