This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Import L5X Ladder Files into Simulink

This example shows how to import a Ladder Diagram from an L5X file created using Rockwell Automation® IDEs such as RSLogix™9 5000 and Studio 5000 into the Simulink® environment. The import operation is performed using the plcimportladder function.

Description of the Ladder Diagram

The figure shows a Ladder Diagram with a simple timer. The Ladder Diagram consists of four rungs with contacts (Switch_A, Light1, Motor_timer.DN), coils (Light1, Light2, EN, DN, Motor), and TON timer function.

The simple_timer.L5X file was created using the RSLogix 5000 IDE. A snippet of the L5X file is shown.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="30.00" TargetName="simple_timer" TargetType="Controller" ContainsContext="false" Owner="Arun Mathew Iype, MathWorks" ExportDate="Mon Nov 12 16:35:28 2018" ExportOptions="NoRawData L5KData DecoratedData ForceProtectedEncoding AllProjDocTrans">
<Controller Use="Target" Name="simple_timer" ProcessorType="Emulate 5570" MajorRev="30" MinorRev="11" TimeSlice="20" ShareUnusedTimeSlice="1" ProjectCreationDate="Mon Nov 12 16:33:36 2018" LastModifiedDate="Mon Nov 12 16:33:43 2018" SFCExecutionControl="CurrentActive" SFCRestartPosition="MostRecent"
 SFCLastScan="DontScan" ProjectSN="16#0000_0000" MatchProjectToController="false" CanUseRPIFromProducer="false" InhibitAutomaticFirmwareUpdate="0" PassThroughConfiguration="EnabledWithAppend" DownloadProjectDocumentationAndExtendedProperties="true" DownloadProjectCustomProperties="true" ReportMinorOverflow="false">
<RedundancyInfo Enabled="false" KeepTestEditsOnSwitchOver="false" IOMemoryPadPercentage="90" DataTablePadPercentage="50"/>
<Security Code="0" ChangesToDetect="16#ffff_ffff_ffff_ffff"/>
<Module Name="Local" CatalogNumber="Emulate 5570" Vendor="1" ProductType="14" ProductCode="53" Major="30" Minor="11" ParentModule="Local" ParentModPortId="1" Inhibited="false" MajorFault="true"
<EKey State="ExactMatch"/>
<Port Id="1" Address="0" Type="ICP" Upstream="false">
<Bus Size="10"/>
<Program Name="MainProgram" TestEdits="false" MainRoutineName="MainRoutine" Disabled="false" UseAsFolder="false">

Import Ladder Diagram

Before importing the L5X file into Simulink :

  • Verify the Ladder file is a valid L5X file. The file can be verified by compiling it in Rockwell Automation IDE.


    There are strict requirements for the AOI arguments in the L5X file being imported. The AOI argument list must satisfy the following conditions:

    • The output arguments should be at the last. For example, both Inputs InOuts,Outputs and InOuts,Inputs,Outputs are supported but Inputs,Outputs,InOuts is not.

    • All Inputs, InOuts, and Outputs arguments must be defined consecutively. For example, In1,In2,InOut1,InOut2,Out1,Out2. Mixed order like In1,InOut1,In2 is not supported.

  • If the file is valid, copy the L5X file into a directory with read and write permissions. You can also create a separate folder to store all the imported files along with the original Ladder L5X file.

Use the plcimportladder function to import the ladder into Simulink. For this example, the program Name of the ladder is MainProgram and the MainRoutineName is MainRoutine.

>> plcimportladder('simple_timer.L5X')

The Ladder Diagram is imported into the pwd\simple_timer.slx Simulink model. The state information of the ladder elements is stored in the data store memory and updated by the model during simulation. The plcout\simple_timer_value.m file gets called during the pre-load stage of the Simulink model. This file sets the timer initial values in Motor_timer data store memory.

The simple_timer.slx Simulink model consists of a Ladder Diagram Controller as the top unit.

This controller has a Main Task and Controller Tags. The Main Task consists of a Main Program.

The Main Program contains the Simulink implementation of the simple_timer.L5X Ladder Diagram. The ladder rung executes from top to bottom and left to right.

You can use the Signal Builder block to create test inputs for Switch_A and verify the operation of the imported ladder. You can also generate a PLC ladder code or a C code for the top-level subsystem. If you want to edit the imported ladder, the Simulink blocks are in the template Ladder Diagram Library. To open the library, enter:


See Also

| | | | | |

Related Topics