The following example demonstrates how to import a simple ladder diagram from an L5X file (simpleXIC.L5X
) into the Simulink environment and generate test bench code for it. The ladder L5X file was created using RSLogix™ 5000 IDE and contains an AOI named simpleXIC
with contact and coil representing a switch and a light. The following is a snapshot of the ladder structure.

Use the plcladderimport
function to import the ladder into Simulink.
The imported model contains an AOI Runner block named simpleXIC_runner
, followed by a Ladder Diagram Function (AOI) block named simpleXIC
.
Add Signal Builder input block, Scope and output ports as shown.

Modify the Signal Builder input to mimic a switch operation as shown.
Generate test-bench for the Ladder Diagram model.
Tbcode =
1×1 cell array
{'C:\runnerTB\simpleXIC_runner.L5X'}
If the test-bench code generation is successful, a test-bench file simpleXIC_runner.L5X
is created. The generated AOI test bench file can be verified on Rockwell Automation® IDE.
Note
Test-bench generation for ladder diagram models containing timer blocks such as TON
, TOF
and RTO
fails. To generate test-bench code for these models, modify the ladder diagram structure while maintaining the logic.