Follow the instructions below to simulate FORCES Pro controllers in Simulink® models, and deploy FORCES Pro solvers on a Speedgoat real-time target machine. Please be aware that Simulink Real-Time® is only available on Windows 32-bit and 64-bit. It is NOT supported by OS X or Linux.
Generate a controller using either the MATLAB® or Simulink® interfaces for a chosen target. In the following we assume an x86 based 32-bit target platform. Read the appropriate documentation for instructions here for MATLAB® Interface and here for Simulink® Interface. On the Simulink® interface you can change the target platform on the 'Solver Settings' tab. In the MATLAB® interface just add the following line to your FORCES Pro script:
codeoptions.platform = 'x86'
If necessary, copy the generated FORCES Pro Simulink® block into your Simulink® model. You can find this block in the folder ~/interface of your generated files under the name
Provided that the generated S-function MEX file '<YourSolverName>_simulinkBlock.mex<PlatformID>' is on your MATLAB® path you can directly simulate the behaviour of your controller with the other components in your Simulink® model.
To build your application for deployment on the Simulink Real-Time®-compatible hardware you first need to move the MEX file '<YourSolverName>_simulinkBlock.mex<PlatformID>' to your ~/interface folder. The Simulink Real-Time® toolchain uses the MEX file to determine the interfaces to the controller. Make sure that this folder in on the MATLAB® path.
Setup your Simulink Real-Time® (until MATLAB® 2014a formerly known as xPC target) host-target system. Set simulation type in the Simulink® scheme to 'External'.
- Set system target file to 'slrt.tlc' (via the Simulink® model menu Simulation -> Model Configuration Parameters -> Code generation -> System target file -> slrt.tlc).
Integrate the ~/include directory and all 'x86' solver files into the Simulink® scheme definition so that the Simulink Real-Time® toolchain can link them with the other blocks of your Simulink® model. Add the following files in the settings Simulation -> Model Configuration Parameters -> Code generation > Custom code
The system is now able to build the application for the Simulink Real-Time® target. It is not necessary to add the paths of the header files in the Configuration Parameters pane of your Simulink® model since these paths can be resolved from the S-function.
Compile your project. If you encounter troubles when re-compiling your project, try to first delete directories produced by the Simulink Real-Time® at the previous compilation cycle, namely slprj and <projectName>_slrt_rtw.
Run the compiled project on your Speedgoat real-time target machine.
- ... -> Include directories -> '~/include/'
- ... -> Source files -> '~/src_target/<YourSolverName>.c' (if available)
- ... -> Libraries -> '~/lib_target/<YourSolverName>.lib' (if available)