generating ladder diagram code from simulink
this example shows how to import a simple ladder diagram from an
.l5x
file (simplecontroller.l5x
) into the simulink® environment, and then generate ladder diagram (l5x) from the imported model. the
ladder diagram .l5x
file was created using rslogix™ 5000 ide and contains contacts and coils representing switches and motor. this
figure shows the ladder structure.
use the
plcladderimport
function to import the ladder into simulink.[mdlname,mdllib,busscript] = plcimportladder('simplecontroller.l5x','openmodel','on')
the imported model contains a plc controller block named
simplecontroller
, followed by a task block namedmaintask
, and finally a ladder diagram program block namedmainprogram
. the model imported into simulink has blocks that implement the functionality of the contacts and coils.generate code for the subsystem
simplecontroller/simplecontroller
.generatedfiles = plcgeneratecode('simplecontroller/simplecontroller');
plc code generation successful for 'simplecontroller/simplecontroller'. generated ladder files: plcsrc\simplecontroller_gen.l5x
note
you cannot generate structured text code from the ladder diagram blocks. the ladder feature supports only ladder code generation.
see also
| | | | | |