## Binary code in Ladder Logic Programming

The Binary Code in Ladder Logic refers to the principle that things can be thought of in one of two states. The states can be defined as:

**1**or**0****On**or**Off****High**or**Low****Yes**or**No**

In a PLC, binary events are expressed symbolically using ladder logic in the form of a normally open contact (NO) and normally closed contact (NC). The normally open contact (NO) is TRUE when the event is active and FALSE when the event is NOT active. While the normally closed contact (NC) is FALSE when the event is active and TRUE when the event is NOT active.

### – **Normally Open Contact (NO) in Ladder Logic**

The event associated with a normally open contact (NO) can be TRUE or FALSE. When the event is TRUE then it is highlighted green and the logic flow can move past it to the next logic expression. Just like the current flow in an electric circuit when a switch is turned on.

### – **Normally Closed Contact (NC) in Ladder Logic**

The event associated with a normally closed contact (NC) can be TRUE or FALSE. The result of the normally closed contact (NC) is basically the opposite state of an event that occurs. So, if PLC input A is FALSE the result will be TRUE. And vise versa when PLC input A is TRUE the result will be FALSE.The normally closed contact (NC) is considered to be a ladder logic NOT function. It is sometimes referred to as reverse logic

If we translate a **NOT function** into a ladder logic diagram we express it symbolically in the form of a **normally closed contact** **(NC)** as seen in ladder logic truth table shown below….

**OR Function**

The OR function examines multiple PLC inputs and has one resulting output. If we translate an OR function into a ladder diagram we can express it symbolically in the form of two PLC inputs A and B using normally open contacts (NO) and a PLC output Y using relay coil.

The inputs are placed in the rung in what is known as a branch. This is the equivalent of a parallel connection in an electric circuit. The output is then connected in line with the rung. This time we have also highlighted the hidden OR function when we create a branch (parallel connection) with PLC input B across PLC input A.

We can write out the logic expression above as **IF** A **OR** B **THEN** Y.

The OR function examines if any of the PLC inputs are TRUE, then the corresponding result is also TRUE. However, all the PLC inputs must be FALSE in order for the corresponding result is also be FALSE.

Because PLC input A and B follows the binary concept and are part of the OR function there are four possible logic iterations.

For basic ladder logic programming we express binary events using normally open contacts (NC) and normally closed contacts (NC).

The five basic, yet essential, logic functions in ladder logic are:

**AND****OR****XOR****NAND****NOR**

The symbols may look a little different than those found on electrical diagrams, but they have almost the same functions. As we can see the example of IECuino