Main Content

PLC Code Generation Basics

Overview of how to generate structured text code

The basic steps for code generation are:

  • Create a model or open an existing model.

  • Configure the model for code generation by selecting the solver.

  • Configure PLC Coder code generation options.

The PLC Coder configuration parameters provide several options for the code generation.


Simulink PLC CoderGenerate structured text and ladder diagram code from Simulink models, Stateflow charts, and MATLAB functions (Since R2019b)


plccoderdemosProduct examples
plccoderprefManage user preferences
plcgeneratecodeGenerate structured text or ladder diagram (L5X) for the atomic subsystem
plcopenconfigsetOpen Configuration Parameters dialog box for subsystem
plcsetupSet up model parameters for PLC code generation (Since R2023b)


Getting Started

Code Generation Files and Folders

Code Generation for Simulink Models

Code Generation for Stateflow charts

Code Generation for MATLAB Function Block