import l5x ladder diagram files into simulink -pg电子麻将胡了
simulate, test, and validate your .l5x ladder diagram files by importing your ladder diagram files into simulink®. use the plcimportladder function to import your ladder diagram files into simulink. simulink plc coder™ supports only import of ladder diagram files created by using rockwell automation® rslogix 5000® and studio 5000 ® integrated development environments (ides).
ladder diagram description
the ladder diagram in the simple_timer.l5x file controls a motor by using an input switch (switch_a) and a timer (motor_timer). this ladder diagram was created using the studio 5000 ide.

light1, light2, and motor are the outputs of this ladder diagram.
import ladder diagram
before using the plcimportladder function to import your ladder diagram files into simulink:
verify that your .
l5xladder diagramfile has no errors by compiling the file in the rockwell automation ide.verify that the
.l5xladder diagram file uses blocks that are supported by simulink plc coder. for a list of supported blocks at the matlab® command line, enter:
plcladderlib
if your ladder diagram contains custom instructions that are not supported use the
custom instructionblock to create your instructions in simulink. for more information, see . to create a custom instruction, see .
to import the simple_timer.l5x ladder diagram file into simulink, use the plcimportladder function.
plcimportladder('simple_timer.l5x');the ladder diagram is imported into simulink and a simple_timer.slx file is created. the current folder also contains a simple_timer_value.mat file that loads the initial values for motor_timer into the model data store memory. the data store memory also contains state information of elements of the ladder diagram. this state information is updated by the model during simulation.
during the ladder diagram import, simulink plc coder:
imports rung comments. for example, rung two of
simple_timer.l5xhas the commentmotor on delay timer.this comment also appears in the simulink model as well.imports add on instruction (aoi) with mixed-order arguments, while preserving the order of the arguments. this order argument is preserved during ladder diagram code generation as well.
imported ladder diagram structure
the simple_timer.l5x ladder diagram file is located in controller simple_timer > maintask > mainprogram > mainroutine.

the simple_timer.slx ladder diagram is located in simple_timer > maintask > mainprogram > _logic. this structure is similar to the structure in the rockwell automation ide.

verify imported ladder diagram
to verify the imported ladder diagram:
connect a
signal editorblock toswitch_a.connect a
scopeblock to themotorandswitch_asignals.open the
simple_timer_verify.slxmodel.open the
scopeblock and click therunbutton.
open_system("simple_timer_verify.slx")
this image shows the scope block output for the model simulation. the motor (simple_timer) output turns on three seconds after switch_a is turned on and turns off as soon as switch_a is turned off. this behavior is the expected behavior of the ladder diagram.

see also
| | | | | |