In an FX ladder diagram a series contact corresponds to a logical AND and a parallel contact to a logical OR, while combining several branches in series or parallel calls for the block instructions. Getting clear which drawing maps to which instruction is what lets you write the logic correctly and still be able to change it later.
Each rung of a ladder diagram, from the left busbar to the right busbar, is one logical path. Contacts placed one after another along the path make it conduct only when all of them are closed, which is a logical AND; contacts placed side by side between two points make it conduct when either one closes, which is a logical OR. This mapping is the foundation of the ladder diagram; the instructions merely translate the drawing into executable code.
A series connection shows up in the instruction list as an AND operation: take a starting contact first, then every normally-open or normally-closed contact added in series gets an instruction of its own, AND for normally open and ANI for normally closed. The more contacts in series, the more conditions the rung must satisfy. Order matters when writing series logic: the instruction list ANDs each statement with the rung in the order written, so writing them out of order changes the logic.
A parallel connection shows up as an OR operation: adding a normally-open contact in parallel with an existing branch uses OR, and adding a normally-closed one uses ORI. Parallel contacts typically appear where one contact offers an alternative path alongside others, and the more parallel contacts there are, the easier the rung conducts. A parallel instruction must follow immediately after the point it is parallel with; put it in the wrong place and it parallels a different piece of logic.
When what is being combined in series or parallel is not a single contact but a whole block of branch, the block instructions come in: ANB to connect the preceding two blocks in series, ORB to connect them in parallel. The key to using them is "work out each block first, then operate between blocks". Nesting depth is limited, and too deep a nest is not only error-prone to work out but poor to read, so breaking it into intermediate bits written in layers is advisable.
Keep the reading order left to right and top to bottom, place the condition least likely to be satisfied furthest to the right so wasted evaluation is reduced, and remember that output coils and set/reset instructions may only appear at the end of a rung. Avoid driving one output from several places, which harms readability and invites mistakes. With set/reset, watch the power-fail retention and initialisation so that a state does not survive a restart.
| Logic | Ladder pattern | Instruction | Note |
|---|---|---|---|
| AND (series) | Contacts one after another | AND / ANI | AND for normally open, ANI for normally closed |
| OR (parallel) | Contacts side by side | OR / ORI | OR for normally open, ORI for normally closed |
| OR then AND | Two parallel branches in series | OR then ANB | Evaluate the parallel block first |
| AND then OR | Two series branches in parallel | AND then ORB | Evaluate the series block first |
| Several blocks in parallel | Several branches side by side | ORB repeatedly | Merge block by block |
| Several blocks in series | Several sections in series | ANB repeatedly | Merge block by block |
| Starting condition | First contact of the rung | LD / LDI | LD for normally open, LDI for normally closed |
| Output drive | Coil at the end of the rung | OUT | Appears at the end of the rung |
| Retentive output | Set/reset at the end of the rung | SET / RST | Watch the power-up initial state |
Instruction sets differ slightly in the nesting depth and the exact way block instructions are written, so go by the programming manual for the software you use. What trips up newcomers is not single series or parallel contacts but the order of mixed block operations; with complex logic, working each block out into an intermediate relay and then combining the intermediate bits in series or parallel is safer than piling up nesting, and much easier to change later.
The syntax and semantics of ladder diagram and the other programming languages follow GB/T 15969.3 (identical to IEC 61131-3); the graphical and text symbols used on the program drawings follow the GB/T 4728 series, Graphic symbols for electrical diagrams; the electrical connection, protection and earthing of the equipment follow GB 5226.1 and the equivalent international standard IEC 60204-1. The exact instruction names and the nesting depth allowed are as stated in the manufacturer's programming manual.
Verify logic of this kind offline or in simulation before downloading. Contact logic on a safety circuit must never be modified by analogy with ordinary logic; safety functions must be implemented by a dedicated safety circuit or safety relay.