The invention relates to a method for converting a ladder diagram into a PLC (
Programmable Logic Controller) program command, which comprises the following steps of: 1, presenting a topological structure of a ladder diagram by using a
directed graph; 2, traversing a transposed graph GL <T> by using a depth-first search method, storing a
topological sorting relation of parallel-connection peaks and coil peaks in a
queue Q; 3, carrying out breadth-first search on the parallel-connection peaks according to a connection relation of the
directed graph GL, carrying out depth-first search on serial-connection peaks adjacently connected with the parallel-connection peaks, generating an AND expression of the
directed graph GL on the whole serial-connection path and an OR expression of the serial-connection peaks; 4, generating a final expression of the maximum combining item of the parallel-connection peaks; 5, carrying out breadth-first search on a connection
relation graph Gp by using the Q,figuring out an OR expression of the corresponding parallel-connection peaks and verifying, finally, constructing the maximum combining item into the AND expression to form a final result; 6, judgingwhether a
queue Q' is empty; and 7,
processing a starting peak. The invention can be widely applied to the process of converting the ladder diagram into the PLC program command.