Processor-in-the-Loop Execution with the MATLAB Coder App - MATLAB & Simulink (original) (raw)
Use processor-in-the-loop (PIL) execution to verify the numerical behavior of cross-compiled object code with reference to your original MATLAB® functions.
Before you run a PIL execution, you must define a target connectivity configuration. In Processor-in-the-Loop Execution from Command Line, steps 1 and 2 of the example PIL Execution of Code Generated for a Kalman Estimator show how you can set up and register a connectivity configuration for PIL execution on your development computer.
- To open the MATLAB Coder™ app, on the MATLAB Toolstrip Apps tab, under Code Generation, click the app icon. The app opens the Create MATLAB Coder Project dialog box.
- To open your project, click Open, navigate to the folder that contains your MATLAB Coder project file, and select the file. For example,
kalman_filter01.coderprj
. - In the Prepare section of the MATLAB Coder tab of the toolstrip:
- Specify Language.
- Set Output Type to Static Library (.lib) or Dynamic Library (.dll).
- From the Settings > Hardware list, selectNone - Select device below.
- Open Settings > View All Settings. In theHardware pane, specifyDevice vendor andDevice type. These settings must match the target hardware settings in the
rtwTargetInfo.m
file of your target connectivity configuration. For host-based PIL, select settings that match your host computer. For example:- For a Windows® 64-bit system, set Device vendor to
Intel
andDevice type tox86-64 (Windows64)
. In addition, set Enable long long toYes
. - For a Linux® 64-bit system, set Device vendor to
Intel
andDevice type tox86-64 (Linux 64)
. - For a Mac OS X system, set Device vendor to
Intel
andDevice type tox86-64 (Mac OS X)
.
- For a Windows® 64-bit system, set Device vendor to
- In the Generate section of the toolstrip, clickGenerate Code > Generate Code and Build.
- In the Verify section of the toolstrip, use theRun Using PIL > Run file option to specify the test file that calls the original MATLAB functions, for example,
test01_ui.m
. - Make sure Verification mode is set to Use generated code.
- If required, select the Enable source-level debugging for SIL or PIL check box.
- The MATLAB Coder app:
- Generates a standalone library, for example,
codegen\lib\kalman01
. - Generates SIL interface code, for example,
codegen\lib\kalman01\pil
. - Runs the test file, replacing calls to the MATLAB function with calls to the generated code in the library.
- Displays messages from the PIL execution in the Command Window.
- Generates a standalone library, for example,
- Verify that the results from the PIL execution match the results from the original MATLAB functions.
- To terminate the PIL execution process, in the Command Window, click the link that follows
To terminate execution
, for example,clear kalman01_pil
.
Note
On a Windows operating system, the Windows Firewall can potentially block a SIL or PIL execution. To allow the execution, use the Windows Security Alert dialog box. For example, in Windows 7, click Allow access.