Main Content


Generate L5X test bench code for specified AOI Runner block and AOI name



TbCode = plcgeneraterunnertb (runnerBlk) returns the generated test bench code for the AOI runner block of the ladder diagram model. Open or load the Simulink® Ladder Diagram model first.


collapse all

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.

[mdlName,mdlLib,busScript] = plcimportladder('simpleXIC.L5X',...

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 = plcgeneraterunnertb('simpleXIC_runner/simpleXIC_runner')
Tbcode =

  1×1 cell array


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.


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.

Input Arguments

collapse all

AOI runner block name specified as character vector.

Output Arguments

collapse all

Generated test-bench file name specified as character vector.

Introduced in R2019a