The invention discloses a method and
system for converting a ladder diagram program into an
instruction list program and executing compiling and interpretation of the
instruction list program. According to the ladder diagram
conversion method, energy flow classes and auxiliary nodes are introduced according to the characteristics of edition and execution of a ladder diagram, the class is set on each diagram peak, and an auxiliary node is added; the serial and parallel connection relationship is judged according to the out-degree and in-degree of the class and the auxiliary node where an element is located. After the ladder diagram is converted into the
instruction list, a PLC immediate compiling method combined with compiling and interpretation and a divide-and-conquer method concept are adopted, a compiling front end and an interpretation rear end are designed independently, and in combination with a GCC rear-end structure, a PLC compiling
system specific to a special
machine model is generated. The method and
system for converting the ladder diagram program into the instruction
list program and compiling the instruction
list program have the advantages that the ladder diagram program with a complex
logic structure can be accurately and rapidly converted into the instruction
list program, and in the conversion process, grammar
error checking is carried out on the program, and the common errors like an open circuit, a
short circuit and a
bridge circuit are excluded, so that the
correctness of the generated instruction list program is guaranteed.