PLC Programming Examples

PLC Programming Examples

A signal lamp is required to be switched on if a pump is running and the pressure is satisfactory, or if the lamp test switch is closed. In this application, if there should be an output from the lamp inputs from both the pump and pressure sensors are required. Hence, AND logic gates are used.

OR logic is used for the test input condition, it is required to give an output of lamp on regardless of whether there is a signal from the AND system. By using END or RET instruction in the ladder diagram, we can tell PLC has reached the end of the program. The function block diagram and the ladder diagram are shown below in the figure.

PLC Program to Test Glowing of Lamp
PLC Program to Test Lamp Glowing

As another example, consider a valve that is to be operated to lift a load when a pump is running and either the lift switch is operated or a switch operated indicating that the load has not already been lifted and is at the bottom of its lift channel.

OR logic is used for two switches and an AND logic is used with two switches and the pump. The valve will be operated only if the pump is ON and two switches are operated.

PLC Program to Operate Valve
PLC Program to Operate Valve

Consider a drinks machine that allows the selection of tea or coffee, milk or no milk, sugar or no sugar, and will supply the required hot drink on the insertion of a coin. From the figure, it is seen that either tea or coffee is selected using the first OR logic gate.

The first AND gate gives an output when either Tea or coffee is selected and a coin is inserted into the machine. The output from this AND gate is given to the second AND gate. The second AND gate operates only when hot water combines with tea. Milk and sugar are optional additions that can occur after a coin has been inserted.

Functional Block Diagram of Drinking Machine
FBD for Drinking Machine
Ladder Logic for Drinking Machine
Ladder Logic for Drinking Machine Application

History of PLCs

Initially, early PLCs couldn’t graphically represent logic, so they used Boolean algebra to depict logical expressions.

As programming terminals evolved, ladder logic became more common because it was a familiar format used for electromechanical control panels. More modern formats, such as state logic and Function Block diagrams, exist, but they are still not as popular as ladder logic. A significant development in standardizing PLC programming languages was the introduction of IEC 1131-3, which provided a framework for using multiple languages, including ladder logic, within the same controller.

A possible reason for this is that programmers prefer the more visual appeal of ladder logic over structured text programming.

Until approximately the mid-1990s, PLCs were programmed using proprietary programming panels or special-purpose programming terminals, which often had dedicated function keys representing the various logical elements of PLC programs.

Some proprietary programming terminals displayed the elements of PLC programs as graphic symbols, but plain ASCII code representations of contacts, coils, and wires were common.