Ladder Diagram Import, Modeling, Simulation, and Code Generation

Ladder diagram blocks and functions

Ladder Diagram is a graphical programming language used to develop software for programmable logic controllers (PLCs). It is one of the languages that the IEC 61131 Standard specifies for use with PLCs. A program in Ladder Diagram notation is a circuit diagram that emulates circuits of relay logic hardware. The underlying program uses Boolean expressions that translate readily to switches and relays.

The ladder import feature of Simulink® PLC Coder™ allows you to import Ladder Diagram created with Rockwell Automation® IDEs such as RSLogix™ 5000 and Studio 5000 into the Simulink environment as a model. The ladder modelling feature of Simulink PLC Coder allows you to create Ladder Diagrams in the Simulink environment as a model.

After importing or creating the Ladder Diagram models, you can do the following from Simulink.

  • You can edit the imported Ladder Diagram model from within Simulink by using the plcladderlib library.

  • You can simulate the Ladder Diagram after importing the Ladder diagram into Simulink

  • You can generate C code from the imported Ladder Diagram and integrate the code into your existing C language-based simulation environments.

  • You can generate Ladder Diagram code from the imported Ladder Diagram and integrate the code into your Rockwell Automation IDE.


    You cannot generate Structured Text code from the Ladder Diagram blocks. The Ladder feature supports only ladder code generation.

  • You can generate PLC testbench code for the imported Ladder Diagram and verify the code in your Rockwell Automation IDE.


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


plcimportladderImport ladder diagram into a Simulink subsystem
plcgeneraterunnertbGenerate L5X test bench code for specified AOI Runner block and AOI name
plcgeneratecodeGenerate Structured Text or Ladder Diagram (L5X) for the atomic subsystem
plcladderlibOpen the Simulink PLC Coder Ladder Library
plcladderoptionGet or set parameter values associated with Ladder Diagram models
plcloadtypesLoad the data types for Simulink PLC Coder ladder models
plccleartypesClear the data types associated with the Simulink PLC Coder ladder models from the workspace
plcladderinstructionsLists ladder instructions identified by Simulink PLC Coder


expand all

XICExamine If Closed
XIOExamine If Open
OTEOutput Energize
OTLOutput Latch
OTUOutput Unlatch
TONTimer On Delay
TOFTimer Off Delay
RTORetentive Timer On
CTUCount Up
CTDCount Down
TNDTemporary End
AFIAlways False
NOPNo Operation
MCRMaster Control Reset
ADDAdd inputs
SUBSubtract inputs
MULMultiply inputs
DIVDivide one input by another
CPTEvaluate expression
ANDBitwise AND
ORBitwise OR
NOTBitwise NOT
ONSOne Shot
OSROne Shot Rising
OSFOne Shot Falling
NEQNot Equal To
EQUEqual To
LEQLess Than or Equal To
GEQGreater Than or Equal To
LESLess Than
GRTGreater than
AOI RunnerAOI Runner
PLC Controller SuitePLC Controller
PLC ControllerPLC Controller
Ladder Diagram ProgramLadder Diagram Program
Ladder Diagram SubroutineLadder Diagram Subroutine
Ladder Diagram Function Block (AOI)Ladder Diagram Function Block (AOI)
Variable ReadVariable Read
Variable WriteVariable Write
COPCopy File
FLLFile Fill
Power Rail StartPower Rail Start
Power Rail TerminalPower Rail Terminal
Rung TerminalRung Terminal
Custom InstructionCreate custom ladder instruction


Supported Features in Ladder Diagram

Ladder features and elements that are supported by Simulink PLC Coder.

Import L5X Ladder Files into Simulink

Importing ladder files into Simulink.

Modeling and Simulation of Ladder Diagrams in Simulink

Create Ladder Diagrams in Simulink and perform simulation.

Generating Ladder Diagram Code from Simulink

Generate Ladder Diagram code (L5X) from Simulink.

Generating C Code from Simulink Ladder

Generate C code from a Simulink Ladder Diagram Model.

Verify Generated Ladder Diagram Code

Verify generated code against the original Simulink model in your IDE using a generated test bench.

Create Custom Instruction in PLC Ladder Diagram Models

Create user-defined instruction in PLC Ladder Diagram models.

Featured Examples