You can use the target
Package to provide PIL connectivity between Simulink® and the target hardware. In this example, your development computer is the
target hardware.
To support code generation, associate the board with a
target.Processor object that contains a language
implementation. For this example, create a
target.Processor object and reuse an existing
target.LanguageImplementation object. For information
about setting up a custom target.LanguageImplementation
object, see Register New Hardware Devices.
Create an object that contains details about executing the target
application. The object describes the tool that is required to run the
target application on the target hardware. To capture system commands for
starting and stopping the target application, you can use the
HostProcessExecutionTool or
SystemCommandExecutionTool class .
Create a Command object for downloading and running the
target application. Assign the string variable '$(EXE)'
to the String property as a place holder for the target
application name, which is not known until execution.
Create a CommunicationInterface object that provides
the target hardware with details of the communication channel and the rtiostream API
implementation.
Use:
The shipped TCP/IP rtiostream
implementation source file.
A BuildDependencies object to specify, for
the rtiostream API, the source files that are
compiled with the target application.
A MainFunction object to pass arguments to
the target application
This step is optional. A PIL simulation uses a communication protocol for
the transfer of data between Simulink and the target hardware. The target.PILProtocol class describes the parameters of the
protocol. For this example, you can improve target run-time performance by
increasing the I/O buffer size that the protocol uses.
Create a target.PILProtocol object and specify I/O
buffer size.
You can configure a PIL simulation to produce execution-time profiles for
the generated code. To support code execution profiling, you must create a
timer object that describes the retrieval of current time from generated
code running on the target hardware. The timer object description must
include a description of the function that retrieves time and its
implementation.
This example uses a C function, timestamp_x86, which
returns the current time as a uint64 data type.
The previous steps created target hardware support for communications and
running the target application. Now, set up a connection between your
development computer and the target hardware by creating a
TargetConnection object. Specify:
The communication channel, which is the same channel specified
in the target hardware communication interface –– see step
4.
The connection properties.
The target, which is the board description specified in
previous steps.
To register the connectivity in MATLAB, use the target.add function to add the target hardware and
connection information to MATLAB memory. By default, the information is only available for the
current MATLAB session. To make the registration persist across MATLAB sessions, specify the name-value pair 'UserInstall',
true.
You can now specify your development computer as the target hardware for
PIL simulations. Before you run a PIL simulation, in the Configuration
Parameters dialog box, set Hardware board to
Example Intel Board.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.