fbpx
.st0{fill:#FFFFFF;}

Basic PLC course, examples

Logical functions of a PLC

 October 25, 2009

By  Jose Carlos Villajulca

Programming a PLC requires the use of a specific language, which is generally only understood by the PLC itself. The programming language for each PLC varies depending on the manufacturer, and although the same symbols are used across different languages, the way these symbols are created and stored differs from manufacturer to manufacturer. Therefore, the way a PLC interprets instructions varies depending on the brand.

There are three commercially available languages that most PLC manufacturers make available to users; these languages are:

  • Ladder Diagram also known as Ladder Logic.
  • List of Instructions
  • Function Diagrams

First, a description of Ladder Logic will be given. This language is a graphical representation that, through software, implements both the physical contacts of a relay (Input Variables) and the coils (Output Variables) that constitute it. The activities performed by these representations are materialized through the input and output lines of the PLC.

In Ladder Logic the symbols used are very crude, but as an introduction we will first explain the symbols that relate the inputs to the outputs.

The basic elements corresponding to the inputs are shown below:

  • Normally open contact  
  • Normally closed contact 

Normally Open (NO) Contact: This has the same function as a real button, which, when not pressed, automatically returns to its natural state of being open or disconnected, see figure 6.1. In other words, when the user presses the switch, it creates a connection between the two internal contacts of the button, changing its logical state from open (disconnected) to closed (connected), see figure 6.2.

Figure 6.1 Switch with normally open contact at rest.

Figure 6.2 Switch with normally open contact activated.

Normally closed (NC) contact. It also functions like a real button, but in the opposite way to a normally open contact; that is, when it is not pressed, it automatically returns to its natural state, which is to be closed or connected, see figure 6.3.

When the user presses the switch, it opens the connection between the two internal contacts of the button, changing its logical state from closed (connected) to open (disconnected), see figure 6.4.

Figure 6.3 Switch with normally closed contact at rest.

Figure 6.4 Switch with normally open contact activated.

According to the convention established by PLC manufacturers, the correspondence between the closed and open logic states and the binary digits "0" and "1" is as follows:

  • Open is equivalent to logical "0".
  • Closed is equivalent to logical "1"

Now that we know the basic symbols for inputs in Ladder Logic, we need to find a way to obtain an output based on our inputs. The solution lies within Ladder Logic itself, since the symbol used to represent an output has a function similar to that of a coil in a relay. Once energized, this coil causes a change of state in the switch(s) under its influence.

To program a PLC, you must first consider the total inputs and outputs that will be interacting in the system to be automated. Subsequently, it is necessary to plan the procedure by which the inputs will be related to the outputs according to the expected responses of the system.

Truth tables are a tool frequently used for PLC programming, as they show the PLC's expected response based on combinations of input logic states. The combinations generated by how the input variables are connected give rise to standardized logic functions such as AND, OR, INVERTER, etc.

Both the logic functions mentioned in the previous paragraph and all those that are missing have an associated symbol by which they are identified in the area of electronics. It should be clarified that in this area these functions are called by their English name, therefore we will refer to them as such.

When using Ladder Logic to program a PLC, the symbols of the logic functions are not used; therefore, we must be able to implement them using input and output variables that, according to a certain arrangement, will behave like the logic functions: AND, OR, INVERTER, NOR, etc.

There are three logical functions from which all these are derived: AND, OR, and INVERTER. The following will explain how they are implemented using Ladder Logic, as well as their behavior.

AND LOGICAL FUNCTION

The AND logic function will have its output activated (energized) only if both contacts (normally open) have a logic level of 1; in all other cases, the output will be deactivated (de-energized). See Figures 6.5, 6.6, 6.7, and 6.8.

Figure 6.5 AND Logic Function with inputs A and B at «0».

Figure 6.6 AND Logic Function with input A at "0" and B at "1".

Figure 6.7 AND Logic Function with input A at "1" and B at "0".

Figure 6.8 AND Logic Function with inputs A and B at "1".

Note: The illuminated symbols are active.

Figures 6.5, 6.6, 6.7 and 6.8 generate the following truth table:

Table 6.1 Logical AND function

ABEXITFIGURE
0005.5
0105.6
1005.7
1115.8

OR LOGICAL FUNCTION

With an OR logic function, the output is activated (energized) if one or all of its normally open contacts are in a logic "1" state. Conversely, the output is deactivated (de-energized) when all switches are in a logic "0" state. See Figures 6.9, 6.10, 6.11, and 6.12.

Figure 6.9 OR Logic Function (O) with inputs A and B at «0».

Figure 6.10 AND Logic Function with input A at "0" and B at "1".

Figure 6.11 AND Logic Function with input A at "1" and B at "0".

Figure 6.12 AND Logic Function with inputs A and B at "1".

The truth table derived from Figures 6.9, 6.10, 6.11 and 6.12 is as follows:

Table 6.2 Logical OR (OR) function

ABEXITFIGURE
0005.9
0115.10
1015.11
1115.12

INVERSE LOGIC FUNCTION (NOT)

The NOT logic function, unlike the AND and OR functions, only requires one input contact, which must be normally closed. The output is activated (energized) if the contact is in the logic 0 state, see Figure 6.13. Conversely, the output is deactivated (de-energized) when the switch is in the logic 1 state, see Figure 6.14.

According to what was explained in the previous paragraph, it can be seen that the purpose of this logic function is to present the logical state of the contact in an inverted manner at the output.

Figure 6.13 Inverting Logic Function (NOT) with input A at "0".

Figure 6.14 Inverting Logic Function (NOT) with input A at "1".

Figures 6.13 and 6.14 are summarized in Table 6.3.

Table 6.3 Inverting Logic Function (NOT)

AEXITFIGURE
005.13
115.14

NON-INVERTING LOGIC FUNCTION

The non-inverting logic function requires only one contact, which must be normally open. The output reflects the logic state of the contact, see Figures 6.15 and 6.16.

Figure 6.15 Inverting NOT Logic Function with input A at "0".

Figure 6.16 Inverting NOT Logic Function with input A at "1".

The truth table for the NON-INVERTING logic function is shown below:

Table 6.4 Non-Inverting Logic Function.

Help us grow

Finally, if you are determined to learn Industrial Automation and advance your professional career, you may be interested in our Premium courses:

– Click to see all our courses at MyAutomationClass.com
- Course: «"Become a PLC expert in 60 days, from basic to pro"»
- Course: «"PID Controllers Master Class – 100% practical"»
- Course: «"How to create SCADA/HMI projects from scratch with InTouch"»
- Course: «"PID Tuning Ultimate: The Definitive Course for Tuning"»
- Course: «"Practical Process Modeling: Definitive Steps to Becoming an Expert"»
- Program: «"The Ultimate Process Control Formula" (All-inclusive: PID Control, Tuning, and Modeling)

If you have any questions, contact us via Facebook Messenger

Until next time. COMMENT AND SHARE! I'll be happy to answer your questions.


Tags: 


Image CTA - Comment

Jose Carlos Villajulca


I am a passionate Electronics Engineer specializing in Automation, Control, and Industrial Instrumentation. I love learning every day, and above all, sharing my knowledge with the world. If you have any suggestions for improving our website, please write to me at jvillajulca@instrumentacionycontrol.net

You might also be interested in...

  • Thank you so much for this invaluable information; it's truly very informative.
    Could you recommend a digital book that explains the meaning of each of the logical functions as you describe them in this document?

    It would be very useful for me to better understand the DCS we use in the plant.

    Fraternal greetings, my friend, thank you for all the information.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Sign up for our newsletter!

    >