Simulink PLC Coder
Simulink PLC Coder generates test benches that help you verify the Structured Text using PLC and PAC IDEs and simulation tools.
In Simulink, you can generate Structured Text using Simulink PLC Coder by right-clicking on a Subsystem block and selecting the PLC Coder > Generate Code for Subsystem option in the resulting context menu. In MATLAB, you can invoke the plcgeneratecode command, which lets you create scripts to generate Structured Text using an automated, repeatable build process.
With support for more than 130 Simulink blocks, all Stateflow constructs, and many Embedded MATLAB functions, Simulink PLC Coder can fully implement your control system models comprising feedback loops, mode and state logic, and math-intensive algorithms. You can use Simulink PLC Coder to convert discrete-time plant models into Structured Text for hardware-in-the-loop (HIL) testing. Alternatively, you can use Simulink Coder™ to generate C/C++ code for HIL testing with discrete-time or continuous-time models.
Simulink PLC Coder provides optimizations that reduce the memory size and increase the execution speed of the generated Structured Text. These optimizations include:
Your optimization needs can change with your project’s development phase. For example, during rapid prototyping, you might place parameters in global memory for tuning or calibration; during a subsequent production build, you might generate parameters with their literal numeric values using the Inline parameters option to produce more optimized code.
Simulink PLC Coder can output Structured Text in a variety of file formats used by third-party IDEs. File formats supported by Simulink PLC Coder include:
To generate Structured Text, you select from the list of supported IDEs in the Simulink PLC Coder configuration parameters dialog box. The Structured Text can then be integrated and compiled using the selected IDE.
Simulink PLC Coder inserts comments and user-specified block descriptions in the Structured Text so that you can trace text back to the model. Built-in identifier naming control lets you create unique identifiers that preserve object names and signal names in the model. These capabilities help you conduct more efficient code reviews and document how the model was implemented.
Simulink PLC Coder can simulate the model prior to Structured Text generation and package the results into a test harness that is generated with the algorithm code. The test harness serves to verify that model simulation behavior and Structured Text execution results match within an acceptable tolerance. You can then execute the test and analyze the results using your IDE or PLC device.