Читать книгу Programmable Logic Controllers - Su Chen Jonathon Lin - Страница 12

Оглавление

CHAPTER 4

Logic Basics and Boolean Algebra

Objectives: Explain the concept of binary operations.

Identify binary elements.

List the three basic logic functions: AND, OR, NOT.

List the mathematical expressions for logic circuits.

Use Boolean algebra to express logic circuits.

Describe the order of Boolean algebra operations.

Convert logic gates to Boolean equations.

Convert Boolean equations to ladder logic diagrams.

Explain the procedure for converting Boolean equations to ladder logic diagrams.

Convert AND, OR, and NOT logic functions to contact instructions.

Describe the characteristics of a state table.

Explain the procedure for constructing a state table from Boolean equations.

Construct a state table from Boolean equations.

Overview

Binary concepts and three basic logic functions are the fundamentals of good logic design. The states of an element are represented in binary because an element exists in only two states. A switch that can be toggled to ON or OFF is an example of binary element. The three basic logic functions are AND, OR, and NOT. There are three commonly used methods for expressing logic circuits: Boolean algebraic expressions, logic gates, and ladder diagrams. This chapter covers essential concepts of binary operations, basic logic functions, Boolean algebraic equations, logic gates, and ladder diagrams. Also, all three forms of logic conversions are explained in detail. The chapter concludes with the construction of state tables that are often used to verify the control logic.

4.1 Binary Operations

Binary operations are those elements that can exist in only one of two predetermined states. This is also known as the binary principle. Two examples of binary devices are a motor, which can have a running or stopped state, and a light switch, which can be in the open or closed state. Because there are only two possible outcomes, this two-state binary concept can be used for making decisions.

Binary symbols are used to translate this two-state logic concept into mathematical expressions. A binary zero (0) is used to represent the absence of a signal or the non-occurrence of an event, such as the de-energized motor or the non-actuated switch. A binary one (1) is used to represent the presence of a signal or the occurrence of an event, such as the energized motor or the activated switch. We would use a “0” to represent an open contact and a “1” to represent a closed contact.

4.1.1Positive Logic Elements

Input switches or contacts can be configured or wired in two types: normally open (NO) and normally closed (NC). In elements of the type NO, they produce a binary logic “1” when they are actuated, and a binary logic “0” when non-actuated (Figure 4.1). These elements of type NO are referred to as positive logic elements because they produce a logic “1” when they are actuated. Table 4.1 lists some typical examples of positive logic elements.

4.1.2Negative Logic Elements

A second element type is labeled NC, normally closed. It produces a binary “0” logic when it is actuated, and a binary “1” logic when non-actuated (Figure 4.2). NC types of elements are called negative logic elements. Table 4.2 lists some example of negative logic elements.


Figure 4.1: Positive (normally open) logic elements

Table 4.1: Positive (NO) input logic elements

ElementBinary “0” logic (in normal state)Binary “1” logic (in actuated state)
Limit switch (NO)
Pressure switch (NO)
Temperature switch (NO)
Liquid level switch (NO)
Photodetector (NO)
Push button (NO)
Relay contact (NO)

4.1.3Output Devices

The actuation of output devices is normally controlled by whether the electrical power is present. After applying electrical power to an output device, the device is called energized. Removing power from it, it is de-energized. In binary logic, being energized is represented by a binary “1,” de-energized is binary “0.” Table 4.3 gives examples of binary logic for output devices.


Figure 4.2: Negative (normally closed) logic elements

Table 4.2: Negative (NC) input logic elements

ElementBinary “1” logic (in normal state)Binary “0” logic (in actuated state)
Limit switch (NC)
Pressure switch (NC)
Temperature switch (NC)
Liquid level switch (NC)
Photodetector (NC)
Push button (NC)
Relay contact (NC)

4.2 Three Basic Logic Operations

There are three basic logic operations used in digital logic design: AND, OR, and NOT. Each of these operations has established rules that determine the outcome of the event based on certain conditions. The outcome of a logic operation is normally referred to as the output and the given conditions are called inputs.

4.2.1The AND function

Logically, the AND function is true (“1”) if and only if all of the inputs are true (“1”). There can be any number of inputs, but the resulting output (“1”) still requires that all of the inputs have values equal to true (“1”). The graphical symbol of an AND function is shown in Figure 4.3. The graphic symbol is called an AND gate.

Table 4.3: Binary logics for output elements



Figure 4.3: AND gate

Tables listing all possible input and output values are called true tables. The number of outcomes (or input combinations) in a true table is determined by the number of inputs and can be calculated as 2n, where n is the number of inputs. A logic gate with two inputs has a total of 4 (or 22) input combinations. A three-input logic gate has 8 (or 23) input combinations. Figure 4.4 shows the true tables for 2-input and 3-input AND gate.


Figure 4.4: True tables for 2-input and 3-input AND gate

A 2-input AND gate can be used to represent a simple safety circuit for a hydraulic punch press (Figure 4.5). This simple circuit consists of two push buttons that are wired in series and one solenoid output. Both push buttons must be actuated simultaneously to energize the solenoid for dropping the punch ram. The AND logic representation of this 2-input safety circuit is displayed in Figure 4.6.


Figure 4.5: A safety circuit using AND function


Figure 4.6: AND gate for 2-input safety circuit

4.2.2The OR Function

Logically, the OR output will be true (“1”) if any one of the inputs has true (“1”) value. Again, there is no limitation on the number of inputs. The graphical symbol and true table for a 2-input OR gate is shown in Figure 4.7.


Figure 4.7: 2-input OR gate

The OR function can be regarded as the parallel function, as shown in Figure 4.8. A car horn on a steering wheel is an example of using the OR function in which two push buttons are wired in parallel to control the horn. The horn can be activated by pressing either one of two push buttons. The OR logic representation of this 2-input car horn circuit is listed in Figure 4.9.


Figure 4.8: A car-horn circuit using the OR function


Figure 4.9: True table to 2-input car horn circuit


Figure 4.10a: NOT gate


Figure 4.10b: NOT gate


Figure 4.11: A normally closed relay contact as an inverter


Figure 4.12: NOT function with AND and OR functions

4.2.3The Not Function

Logically, the NOT function causes the output state to be the opposite state of the input. Because of this, it is often called the inverter. The NOT output is False (“0”) if the input is True (“1”) and, inversely, the output becomes True (“1”) if the input is False (“0”). The NOT function has only one input. It is graphically shown in Figure 4.10a and it has two states in its true table, as in Figure 4.10b.

In relay logic applications, a normally closed switch or a normally closed contact has the function of NOT gate (Figure 4.11). The normally closed push button in the first rung serves as an inverter function, , to control the output of the relay coil CR. The second rung of this relay diagram uses a normally closed relay contact, , as an inverter to control the output.

The NOT function of A is called “NOT A” and is represented as an A with a bar on top, . Often a NOT function is used in conjunction with the AND and OR functions, as in Figure 4.12.

4.3 Boolean Algebra

4.3.1Three Logic Functions

Boolean algebra is the fundamental mathematical expression of logic circuits. The algebraic symbols indicate the logical relationships between groups of inputs and outputs. Often they are called Boolean expressions. Series and parallel combinations are built with AND, OR, and NOT logical operators. Use a dot (•) between inputs to represent the AND operator, a (+) between inputs to represent the OR operator, and a bar over the letter () to represent the NOT operator (inverse or negation function). The dots between two inputs connected by AND are often omitted in writing the AND expressions. For example, Y = AB is used to represent Y = A∙B. Table 4.4 shows the logic, ladder logic expression, and Boolean equation of the three basic logic functions.

Table 4.4: Logic operations using Boolean algebra


Boolean algebra can be used to express any complex logic relations by using a combination of the three basic logic functions. Two examples follow:


4.3.2Order of Boolean Algebra Operations

The order of Boolean algebra operations follows two rules:

1.Grouping signs have the highest precedence. When grouping items, the order is parentheses ( ) first, brackets [ ] second, and braces { } third.

2.Besides grouping signs, the order of priority is the NOT function first, the AND function second, and the OR function last.

Example 4.1: Priority of operations

The priority of operations in this Boolean equation

Y = (A + B)C + (B + C)D

means that equations are to be done in the demonstrated order.

1st precedence (parentheses):(A + B) and (B + C)
2nd precedence (AND function):(A + B)C and (B + C)D
3rd precedence (OR function):(A + B)C + (B + C)D

4.4 Converting Logic Gates to Boolean Equations

Many logic control circuits are given in the logic gate form. It is often desirable to convert logic gate circuits to their corresponding Boolean equations. The converting procedure follows the associated level from left to right. The output of the logic gate in the lower (left) level becomes one of input of the next (right) level. Two examples are given in this section to convert the logic circuits to their Boolean equations.

Example 4.2: Using Boolean equation to express a circuit

The logic circuit shown in Figure 4.13 consists of one OR and one AND function.

The Boolean equation can be derived as follows. From the OR function we can find,

X = A + B(1)

From the AND function we have,

Y = XC(2)

Substitute (1) into (2) to obtain,

Y = (A + B)C

Example 4.3: Convert a gate circuit to its Boolean equation

The gate logic circuit in Figure 4.14 has two AND functions, one NOT function, and one OR function.

The Boolean equations for the three basic logic functions can be derived as below:

(1)
(2)
(3)

Combine (1), (2), and (3) to yield the Boolean equation as:



Figure 4.13: Sample logic circuit


Figure 4.14: Gate logic circuit

4.5 Input Elements

Boolean equations are often converted to ladder diagrams in PLC applications. Understanding the connecting relationship between input elements for the three basic logic functions (AND, OR, and NOT) in the ladder diagrams is the key to constructing ladder diagrams from Boolean equations.

4.5.1The NOT Function

The NOT function of an element is translated into either a normally closed (NC) contact or switch. Inversely, a non-NOT function of an element is interpreted as either a normally open (NO) contact or switch. Some examples are given in Figure 4.15.

4.5.2The AND Function

The AND function has the input elements connected in a series manner. Three examples are shown in Figure 4.16. Next to each Boolean expression is a ladder rung representation of the expression.

4.5.3The OR Function

The OR function has the input elements connected in a parallel manner. Three examples are given in Figure 4.17.


Figure 4.15: NOT functions


Figure 4.16: AND functions


Figure 4.17: OR functions

4.6 Converting Boolean Equations to Ladder Diagrams

There are two types of elements — input and output — that constitute a relay ladder diagram. Input elements can be further divided into groups: relay contacts, and switches. The state of relay contacts is controlled by their associated relay. Because they are not the actual input devices, they are referred to as internal inputs. Table 4.5 shows the graphical symbol and logic expression of typical input elements.

4.6.1Procedure of Converting Boolean Equations to Ladder Diagrams

Most control circuits consist of multiple Boolean equations with combined logic functions. This means there are multiple rungs in the ladder diagram. In principle, each Boolean equation produces one rung in the ladder diagram.

The procedure for converting Boolean equations to ladder logic diagrams has three steps.

Step 1: Identify output elements.

Each Boolean equation has one and only one output element. Therefore, the number of Boolean equations determines the number of output elements. The element on the left side of the equal sign of the Boolean equation is normally the output element.

Step 2: Identify the internal input elements and switch input elements.

All elements appearing on the right side of Boolean equations are input elements. To distinguish an internal input element from a switch input element, determine if the element appears in both sides of the equation. If an element symbol appears in both sides of Boolean equations, it is the internal input element. This means that this element is a contact controlled by its relay coil and has the same label as an output in Boolean equations.

Step 3: Construct the ladder diagram.

In principle, one Boolean equation is constructed as one rung in the ladder diagram. The output element is the last element in the rung. The AND or OR functions between input elements are converted, as in Table 4.6.

Table 4.5: Input elements

Input ElementSymbolLogic Expression
Contact A (NO)A
Contact A (NC)
Limit switch LS (NO)LS
Limit switch LS (NC)
Push button PB (NO)PB
Push button PB (NC)
Pressure switch PS (NO)PS
Pressure switch PS (NC)
Temperature switch TS (NO)TS
Temperature switch TS (NC)
Photodetector PD (NC)PD
Photodetector PD (NO)
Liquid level switch LL (NO)LL
Liquid level switch LL (NC)

Table 4.6: Logic AND and OR functions


The NOT function is interpreted as a normally closed (NC) state. It can be either a normally closed (NC) switch or normally closed (NC) contact (Figure 4.18). An input element without the NOT function is the normally open type. It can be either a normally open (NO) switch or normally open (NO) contact (Figure 4.19).

4.6.2Converting Examples

The two examples presented in this section show how to convert Boolean equations to their equivalent ladder diagrams.

Example 4.4: Convert these two Boolean equations to a ladder diagram.


The two Xs appearing in the right side of two equations are the contact controlled by the output relay X. Therefore, they shall be represented by a contact symbol. The way to determine whether an input element is an internal input or an external input is to determine if an element symbol appears in both sides of the equations. Because it does, it becomes an internal (contact) input in the right side of both equations. The ladder diagram of these two equations appears as Figure 4.20.

Example 4.5: Convert these three Boolean equations to a ladder diagram.



Figure 4.18: NC switch and NC contact


Figure 4.19: NO switch and NO contact


Figure 4.20: Ladder diagram


Figure 4.21: Ladder diagram

The three outputs are X, Y, Z, which are in the left side of the equations. Therefore, all X, Y, and Z elements in the right hand side of the three Boolean equations must be considered as the contacts (internal inputs). The remaining four elements in the right hand side, A, B, C, and D are switching devices. We assume that A and B are push button switches, whereas C and D are limit switches. The ladder diagram of these three Boolean equations appears as Figure 4.21.

4.7 Constructing State Tables from Boolean Equations

A state table shows the output state for all possible input combinations of a circuit. It can be used to verify the control logic. The number of possible combinations is determined by the number of inputs and can be calculated as 2n, where n is the number of inputs. A state table looks like the truth table of a logic gate. The only difference is how the output state is determined. In the truth table of a logic gate, the output state of each input combination is already determined by the logic gate. The output state in a state table is determined by the Boolean equation. Figure 4.22 shows the blank state diagram for three inputs. A state table can have more than one output. Figure 4.23 shows the state table of 3-inputs and 2-outputs.


Figure 4.22: Three-input state table

4.7.1Procedure of Developing a State Table

A circuit may be expressed in the form of a ladder logic diagram or with Boolean equations. Both the ladder logic diagram and Boolean equations can be used in constructing the state table of a logic circuit.

The procedure steps to analyze the the ladder diagrams and develop a state table are as follows:


Figure 4.23: Three-inputs and two-outputs state table

Step 1: Convert the ladder logic diagram to Boolean equations if necessary.

Step 2: Identify all inputs and outputs.

Step 3: Construct a table that shows all possible combinations of inputs.

Note that the number of possible input combinations is 2n, where n is the number of input variables. A two-input system, for example, has 22 = 4 input combinations. Likewise, a three-input system has 23 input combinations.

Step 4: Determine the output state, 1 or 0, for each output in all input combinations.

Two examples are presented in this section. The first example constructs a state table from a ladder diagram that consists of three rungs. The second example constructs a state table from three Boolean equations that have a total of two outputs.

4.7.2Constructing State Table Examples

Example 4.6: Construct a state table for the ladder logic diagram in Figure 4.24.

Three Boolean equations can be derived from the three horizontal ladder rungs in the diagram. They are:

X = A(1)
Y = B(2)
(3)

Substitute (1) and (2) to (3) to yield


Originally, this is a two input, three output system. Output X and Y are directly controlled by push button A and B, respectively. Therefore, we can regard this is a single output system. The controlling Boolean equation is



Figure 4.24: A ladder logic diagram


Figure 4.25: State table

The state table shown in Figure 4.25 is constructed based on this Boolean equation.

For Row 1: Given A = 0 and B = 0, so = 1


For Row 2: Given A = 0 and B = 1, so = 1


For Row 3: Given A = 1 and B = 0, so = 0


For Row 4: Given A = 1 and B = 1, so = 0


Add the output state of the above four rows to the table to complete the state table, as shown in Figure 4.25.

Example 4.7: Construct a state table from these two Boolean equations:


This system has four inputs (A, B, C, and D) and two outputs (X and Y). The state table of the system is shown in Figure 4.26.

For Row 1: Given A = 0, B = 0, C = 0, and D = 0, so = 1, = 1, = 1, and = 1


For Row 2: Given A = 0, B = 0, C = 0, and D = 1, so = 1, = 1, = 1, and = 0



Figure 4.26: State table of four inputs

For Row 3: Given A = 0, B = 0, C = 1, and D = 0, so = 1, = 1, = 0, and = 1


For Row 4: Given A = 0, B = 0, C = 1, and D = 1, so = 1, = 1, = 0, and = 0


Continue the evaluation of each row to complete the state table as shown in Figure 4.26.

Review Questions

1.Describe the binary principle.

2. Explain how “1” and “0” are used to represent two binary states.

3. What are the two configurations to which a switch or a relay contact can be wired?

4. Describe positive logic elements.

5. Describe negative logic elements.

6. What are the three basic logic functions?

7. Explain the operation principle of the AND function.

8. What is a true table?

9. How many possible input combinations are there for the logic gate having 2, 3, and 4 inputs, respectively?

10. Describe the operation principle of the OR function.

11. Describe the operation principle of the NOT function.

12. What is Boolean algebra?

13. What symbol is used to represent the AND function between two inputs?

14. What symbol is used to represent the OR function between two inputs?

15. What symbol is used to represent the NOT function of an input?

16. Convert the circuit given in the logic gates (Figure 4.27) to its Boolean equations.


Figure 4.27: Review Question 16

17. Convert the logic gate circuit (Figure 4.28) to its Boolean equations.


Figure 4.28: Review Question 17

18. Convert the following Boolean equations into a ladder diagram.


19. Convert the following Boolean equations into a ladder diagram.


20. What is a state table?

21. Summarize the procedure for constructing a state table for a logic circuit.

22. Construct a state table for the following Boolean equations.


Programmable Logic Controllers

Подняться наверх