Ladder Logic Rungs

Rungs are the building blocks of code in Ladder Logic.

Think of a rung as a wire that is connected to opposing voltage sources. If a rung is placed between the left and right rails it would behave the same as connecting a wire to the negative and positive terminals of a battery. If you did that what would happen? The wire would probably burn up, the battery would overheat and the result would be a direct short. A load is necessary, a light, horn, motor or anything that would add resistance. Ladder Logic behaves the same way, only without the heat and possible fireworks. The light, horn, or motor would be an instruction like a timer, counter, or latch.
Rungs require an output instruction, however input instructions are optional. When dragging an instruction to a rung all rungs visible in the ladder editor will display a small grey square indicating possible landing locations for the instruction. As the instruction is moved around in the editor the grey squares turn to green circles indicating where the instruction would end up if the mouse button were released.

Rung Branches can be placed on rungs or existing branches.

To add another level to a branch right click on the branch and choose Add Branch Level from the selection menu. Grabbing the right side of a branch will enable you to move the branch left or right on the rung. Grabbing a branch on the left side will allow you to move a branch to another branch or change the branch level.

Branches do not require instructions, however verifying a rung with a branch that does not have an instruction will result in a warning indicating there is a shorted branch.

Tip: Sometimes shorting a branch can be a useful troubleshooting tool.

If a rung is in error four vertical e’s are displayed adjacent to the rung number.

Right clicking on the e’s will bring up a selection window where “verify rung” can be selected. Upon execution the error window will display the error. For instance when a new rung is placed between the rails the e’s are displayed. Upon verifying the rung the error display message will be as follows: “Error: Rung xx: Empty rung.” Clicking on the error message will place the pointer or caret on the rung in error.

If an instruction has a single question mark (?) this indicates a value needs to be entered, either a tag or constant.

For instance when an XIC instruction is placed on a rung a single question mark appears on the instruction indicating the instruction is not referenced to a tag. Upon referencing the instruction to a tag the question mark is replaced by the tag name. More than four vertical e’s are displayed adjacent to the rung number if an instruction is in error. For instance if an OTE instruction is placed on a rung and the instruction is referenced to a tag defined as a DINT rather than a BOOL the software will indicate the error with the multiple e’s adjacent to the rung number. OTE instructions require a tag defined as BOOL type. Upon verifying the rung the error display message will be as follows: “Invalid data type. Argument must match parameter data type.” Clicking on the error message will place the pointer or caret on the instructions tag.

Double question marks (??) indicate the system is unable to attain a value.

This is common while online with a processor and the data has yet to be retrieved. This is not indicative of an error per say; question marks are shown rather than a 0 or nothing as either would indicate data or the lack of data.