• No results found

3-2 L OGIC F UNCTIONS

V + (

1 0(0V) Example

g n i t a r e p o t o

N Operating Limitswitch g

n i g n i r t o

N Ringing Bell

f f

O On Lightbulb

t n e li

S Blowing Horn

d e p p o t

S Running Motor

d e g a g n e s i

D Engaged Clutch

n e p

O Closed Valve

3-2 L

OGIC

F

UNCTIONS

The binary concept shows how physical quantities (binary variables) that can exist in one of two states can be represented as 1 or 0. Now, you will see how statements that combine two or more of these binary variables can result in either a TRUE or FALSE condition, represented by 1 and 0, respectively.

Programmable controllers make decisions based on the results of these kinds of logical statements.

Operations performed by digital equipment, such as programmable control-lers, are based on three fundamental logic functions—AND, OR, and NOT.

These functions combine binary variables to form statements. Each function has a rule that determines the statement outcome (TRUE or FALSE) and a symbol that represents it. For the purpose of this discussion, the result of a statement is called an output (Y), and the conditions of the statement are called inputs (A and B). Both the inputs and outputs represent two-state variables, such as those discussed earlier in this section.

THE AND FUNCTION

Figure 3-1 shows a symbol called an AND gate, which is used to graphically represent the AND function. The AND output is TRUE (1) only if all inputs are TRUE (1).

Output Inputs

An AND function can have an unlimited number of inputs, but it can have only one output. Figure 3-2 shows a two-input AND gate and its resulting output Y, based on all possible input combinations. The letters A and B represent inputs to the controller. This mapping of outputs according to predefined inputs is called a truth table. Example 3-1 shows an application of the AND function.

Figure 3-2. Two-input AND gate and its truth table.

EXAMPLE 3-1

Show the logic gate, truth table, and circuit representations for an alarm horn that will sound if its two inputs, push buttons PB1 and PB2, are 1 (ON or depressed) at the same time.

SOLUTION

1 B

P PB2 AlarmHorn

) 0 ( d e h s u p t o

N Notpushed(0) Slient(0) )

0 ( d e h s u p t o

N Pushed(1) Slient(0) )

1 ( d e h s u

P Notpushed(0) Slient(0) )

1 ( d e h s u

P Pushed(1) Sounding(1)

Line Voltage L1

PB1 PB2

Line Voltage (Common) L2

Electrical Ladder Circuit A

B

Logic Representation Alarm Horn PB1

PB2

Y

h t u r T D N

A Table s

t u p n

I Output B

A Y

0

0 0

1

0 0

0

1 0

1

1 1

AND Truth Table

Figure 3-3. Symbol for the OR function.

THE OR FUNCTION

Figure 3-4. Two-input OR gate and its truth table.

As with the AND function, an OR gate function can have an unlimited number of inputs but only one output. Figure 3-4 shows an OR function truth table and the resulting output Y, based on all possible input combinations.

Example 3-2 shows an application of the OR function.

EXAMPLE 3-2

Show the logic gate, truth table, and circuit representations for an alarm horn that will sound if either of its inputs, push button PB1 or PB2, is 1 (ON or depressed).

Figure 3-3 shows the OR gate symbol used to graphically represent the OR function. The OR output is TRUE (1) if one or more inputs are TRUE (1).

Output Inputs

A B

Y

PB1 PB2

Electrical Circuit +

V

h t u r T R

O Table s

t u p n

I Output B

A Y

0

0 0

1

0 1

0

1 1

1

1 1

SOLUTION

Line Voltage L1

PB2

PB1

Line Voltage (Common) L2

Electrical Ladder Circuit

1 B

P PB2 AlarmHorn

) 0 ( d e h s u p t o

N Notpushed(0) Slient(0) )

0 ( d e h s u p t o

N Pushed(1) Sounding(1) )

1 ( d e h s u

P Notpushed(0) Sounding(1) )

1 ( d e h s u

P Pushed(1) Sounding(1)

Electronic Representation PB1

+ V

PB2

Alarm Horn

+

Alarm Horn PB1

PB2

Logic Representation

THE NOT FUNCTION

Figure 3-5 illustrates the NOT symbol, which is used to graphically represent the NOT function. The NOT output is TRUE (1) if the input is FALSE (0).

Conversely, if the output is FALSE (0), the input is TRUE (1). The result of the NOT operation is always the inverse of the input; therefore, it is sometimes called an inverter.

Electrical Circuit

The NOT function, unlike the AND and OR functions, can have only one input. It is seldom used alone, but rather in conjunction with an AND or an OR gate. Figure 3-6 shows the NOT operation and its truth table. Note that an A with a bar on top represents NOT A.

Figure 3-6. NOT gate and its truth table.

Figure 3-5. Symbol for the NOT function.

Input Output

At first glance, it is not as easy to visualize the application of the NOT function as it is the AND and OR functions. However, a closer examination of the NOT function shows it to be simple and quite useful. At this point, it is helpful to recall three points that we have discussed:

1. Assigning a 1 or 0 to a condition is arbitrary.

2. A 1 is normally associated with TRUE, HIGH, ON, etc.

3. A 0 is normally associated with FALSE, LOW, OFF, etc.

Examining statements 2 and 3 shows that logic 1 is normally expected to activate some device (e.g., if Y = 1, then motor runs), and logic 0 is normally expected to deactivate some device (e.g., if Y = 0, then motor stops). If these conventions were reversed, such that logic 0 was expected to activate some device (e.g., if Y = 0, then motor runs) and logic 1 was expected to deactivate some device (e.g., Y = 1, then motor stops), the NOT function would then have a useful application.

1. A NOT is used when a 0 (LOW condition) must activate some device.

2. A NOT is used when a 1 (HIGH condition) must deactivate some device.

The following two examples show applications of the NOT function.

Although the NOT function is normally used in conjunction with the AND and OR functions, the first example shows the NOT function used alone.

NOT Truth Table t

u p n

I Output

A A

0 1

1 0

A

NOT

A A

Note: In this example, the level switch L1 is normally open, but it closes when the liquid level reaches L1. The ladder circuit requires an auxiliary control relay (CR1) to implement the not normally open L1 signal. When L1 closes (ON), CR1 is energized, thus opening the normally closed CR1-1 contacts and deactivating V1. S1 is ON when the system operation is enabled.

EXAMPLE 3-3

Show the logic gate, truth table, and circuit representation for a solenoid valve (V1) that will be open (ON) if selector switch S1 is ON and if level switch L1 is NOT ON (liquid has not reached level).

SOLUTION

0 0 1 1

0 1 0 1

1 0 1 0

0 0 1 0 S1 L1(L1) V1

Truth Table S1

L1

V1

Logic Representation S1 Level Switch

L1 V1

L1 L2

CR1

CR1-1 L1

S1 V1

Electrical Ladder Circuit

EXAMPLE 3-4

Show the logic gate, truth table, and circuit representation for an alarm horn that will sound if push button PB1 is 1 (ON or depressed) and PB2 is NOT 0 (not depressed).

SOLUTION

Logic Representation

Alarm Horn PB1

PB2

PB1 PB2

+ V

Electrical Ladder Circuit Line Voltage

L1

PB1 PB2

Line Voltage (Common) L2 1

B

P PB2 AlarmHorn

) 0 ( d e h s u p t o

N Notpushed(0) Slient(0) )

0 ( d e h s u p t o

N Pushed(1) Slient(0) )

1 ( d e h s u

P Notpushed(0) Sounding(1) )

1 ( d e h s u

P Pushed(1) Slient(0)

Note: In this example, the physical representation of a field device element that signifies the NOT function is represented as a normally closed, or not normally open, switch (PB2). In the logical representation section of this example, the push button switch is represented as NOT open by the symbol.

Electrical Circuit

Figure 3-7. Two-input NAND gate and its truth table.