PLC Code Generation in the Development Process
Simulink® PLC Coder™ software lets you generate IEC 61131-3 compliant Structured Text code from Simulink models. This software brings the Model-Based Design approach into the domain of PLC and PAC development. Using the coder, system architects and designers can spend more time fine-tuning algorithms and models through rapid prototyping and experimentation, and less time on coding PLCs.
Typically, you use a Simulink model to simulate a design for realization in a PLC. Once satisfied that the model meets design requirements, run the Simulink PLC Coder compatibility checker utility. This utility verifies compliance of model semantics and blocks for PLC target IDE code generation compatibility. For more information on how to use the compatibility checker, see Check Your Model Using the Model Advisor. Next, invoke the Simulink PLC Coder tool, using either the command line or the user interface. The coder generates Structured Text code that implements the design embodied in the model.
Usually, you also generate a corresponding test bench. You can use the test bench with PLC emulator tools to drive the generated Structured Text code and evaluate its behavior.
The test bench feature increases confidence in the generated code and saves time spent on test bench implementation. The design and test process are fully iterative. At any point, you can return to the original model, modify it, and regenerate code.
At completion of the design and test phase of the project, you can easily export the generated Structure Text code to your PLC development environment. You can then deploy the code.
Using Simulink PLC Coder, you can also generate Ladder Diagram code for your applications from a Stateflow® chart. The benefits are:
You can design your application by using states and transitions in a Stateflow chart. Once you complete the design, you can generate Ladder Diagram code in XML or another format. You then import the generated code to an IDE such as CODESYS 3.5 or RSLogix™ AOI 5000 and view the ladder diagram.
When you test your Stateflow chart by using a set of inputs, you can reuse these inputs to create a test bench for the Ladder Diagram code. You import the test bench to your PLC IDE and compare the results of simulation with the results of running the ladder diagram. If the results match, the original Stateflow chart is equivalent to the generated Ladder Diagram code.
Expected Users
The Simulink PLC Coder product is a tool for control and algorithm design and test engineers in the following applications:
PLC manufacturing
Machine manufacturing
Systems integration
You must be familiar with:
MATLAB® and Simulink software and concepts
PLCs
Structured Text language
If you want to download generated code to a PLC IDE, you must also be familiar with your chosen PLC IDE platform. For a list of these platforms, see Supported IDE Platforms.
Glossary
Term | Definition |
---|---|
PAC | Programmable automation controller. |
PLC | Programmable logic controller. |
IEC 61131-3 | IEC standard that defines the Structured Text language for which the Simulink PLC Coder software generates code. |
PLCopen | Vendor- and product-independent organization that works with the IEC 61131-3
standard. The Simulink
PLC Coder product can generate Structured Text using the PLCopen XML standard
format. See https://www.plcopen.org for details. |
Structured Text | High-level textual language defined by IEC 61131-3 standard for the programming of PLCs. |
function block | Structured Text language programming concept that allows the encapsulation and reuse of algorithmic functionality. |
System Requirements
For a list of related products, see System Requirements at the MathWorks® website.
Issues with Anti-Virus Software
The Simulink PLC Coder software ships with IDE-specific executables that are used in the Import Structured Text Code Automatically workflows. Some anti-virus software identifies these files as malware. However, it has been determined that these cases are false positives and that the files are malware free. You can mark these files as malware free in your antivirus program.