generating ladder diagram code from simulink -凯发k8网页登录

main content

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.

  1. use the plcladderimport function to import the ladder into simulink.

    [mdlname,mdllib,busscript] = plcimportladder('simplecontroller.l5x','openmodel','on')
  2. the imported model contains a plc controller block named simplecontroller, followed by a task block named maintask, and finally a ladder diagram program block named mainprogram. the model imported into simulink has blocks that implement the functionality of the contacts and coils.

  3. 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

| | | | | |

related topics

网站地图