Free Essay

Submitted By alwimatzan

Words 9164

Pages 37

Words 9164

Pages 37

138

Programmable Logic Controllers: Hardware and Programming

Chapter 7

7.1 Introduction

The majority of PLC manufacturers use the ladder logic diagram programming language to program their programmable logic controllers (PLCs). Some manufacturers prefer using logic gate circuits or Boolean expressions to program their PLCs. Therefore, it is beneficial to know how to convert one type of PLC programming language to the other. In this chapter, you will learn how to create logic gate circuits from ladder logic diagrams and vice versa. You will review the functions associated with the combinational logic gates. These gates are the NOT, AND, OR, NAND, NOR, XOR, and XNOR gates. You will learn how to create PLC ladder logic diagrams that emulate the functions of these gates.

Programming Logic Gate Functions in PLCs

Chapter Outline

7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.10 7.11 7.12 7.13 7.14 Introduction Combinational and Sequential Logic Gate Circuits Boolean Expressions, Truth Tables, and Logic Gate Circuits NOT Gates or Inverters AND Gates OR Gates NAND Gates NOR Gates XOR (Exclusive OR) Gates XNOR (Exclusive NOR) Gates Simplifying Boolean Expressions Creating PLC Ladder Logic Diagrams from Logic Gate Circuits Creating PLC Ladder Logic Diagrams from Boolean Expressions Creating Logic Gate Circuits from PLC Ladder Logic Diagrams

Technical Terms combinational logic gates sequential logic devices Boolean expression Boolean algebra true state logic high false state logic low truth table gate symbols NOT gate AND gate OR gate NAND gate NOR gate XOR gate XNOR gate Karnaugh map Quine-McCluskey routine

Combinational logic gates: Logic devices in which the output of the device is dependent only on the present inputs to the device. There is no dependency on past inputs. Combinational logic gates do not require clock pulses to operate. Sequential logic devices: Logic devices in which the output of the device is dependent on the present and past inputs to the device. Sequential logic devices require clock pulses to operate.

7.2 Combinational and Sequential Logic Gate Circuits

Combinational logic gates do not require clock pulses to operate. Their outputs depend only on their inputs. This means that the outputs of combinational logic gates are generated instantaneously. Generally, the combinational logic gates are simply called logic gates. Seven logic gates exist. Seven logic gates exist: NOT, AND, OR, NAND, NOR, XOR (exclusive OR), and XNOR (exclusive NOR). The gates in a circuit represent a simple Boolean expression. For example, two-input AND gates with inputs A and B and output Y graphically represent the expression Y = A · B. Figure 7-1 displays a logic gate circuit which shows the connection of logic gates for a Boolean expression. Sequential logic devices have outputs that depend on their inputs as well as time. They require clock pulses. Therefore, an inherent delay time is always present for the sequential logic circuits. Flipflop devices such as reset-set (RS), JK, delay (D), and toggle (T) are sequential logic devices. Figure 7-2 displays a sequential logic circuit.

Learning Objectives

After completing this chapter, you will be able to: • Describe combinational and sequential logic gate circuits. • Create PLC ladder logic programs for NOT, AND, OR, NAND, NOR, XOR, and XNOR logic gates. • Create Boolean expressions and logic gate circuits from truth tables. • Use the Logic Converter instrument in NI Multisim to create logic tables and Boolean expressions from logic gate circuits. • Convert Boolean expressions to PLC ladder logic diagrams. • Convert PLC ladder logic diagrams to logic gate circuits and Boolean expressions.

A

AB′ AB′+A′B+C A′B

B

C Figure 7-1. A three-input logic gate circuit.

137

Chapter 7

Programming Logic Gate Functions in PLCs

139

140

Programmable Logic Controllers: Hardware and Programming

1 kΩ/5 V +V 1 kΩ/5 V +V Clock pulses 0000 XXXX

J J 1 kΩ/5 V 1 kΩ/5 V +V J K Q +V Q JK flip-flop K Q′

Truth table: Table used to map Boolean expressions. Truth tables contain Boolean expression inputs and outputs. Gate symbols: Symbols used to display logic gate devices.

K Q′ JK flip-flop

Logic low is represented by the absence of a voltage potential. The logic high in a programmable logic controller is represented with five volts (+5 V), and the logic low is represented with zero volts (0 V). By applying conventional algebra, you can plot a function’s input and output points to create the characteristic of the function as a graph. This graph represents the function pictorially in an x–y coordinate system. The x-axis is for the input points and the y-axis is for the output points. In Boolean algebra, a table contains the digital input and output points. This table is called a truth table. Figure 7-3 displays a Boolean expression and its truth table. Note that a prime symbol (′) indicates the inverse value of the input. In Figure 7-3, the A with a prime represents the inverse of A. There are schematic symbols for every combinational and sequential logic device. The schematic symbols for logic gates are called gate symbols. Using logic gate symbols, one can create the logic gate circuits. Figure 7-4 displays the logic gate circuit for Boolean expression in Figure 7-3. In the following sections, you will learn what type of Boolean expressions, truth tables, and logic gate symbols are used for the seven logic gates introduced in Section 7.2.

Boolean expression: Y = AB + A′C Truth Table Figure 7-2. Sequential logic circuit. These circuits require clock pulses.

Boolean expression: Names for equations in Boolean algebra. Boolean algebra: Form of mathematics that uses two conditions or states: true and false. True state: State in digital electronics that is represented with a number 1. False state: State represented in digital electronics with a number zero. Logic high: State in digital electronics that is represented with 5 volts. Also called logic one. Logic low: State in digital electronics that is represented with zero volts. Also called logic zero.

In this textbook, you will study only combinational logic gate circuits. However, you first need to review the concepts of Boolean expressions, truth tables, and gate symbols.

7.3 Boolean Expressions, Truth Tables, and Logic Gate Circuits

In basic algebra, you learned that every function has its own equation. Similarly in the field of digital electronics, every gate logic function has its own equation called a Boolean expression. The nineteenth century British mathematician, George Boole, invented a type of algebra that uses only two conditions or states. The two states are true and false. This type of algebra using only two states is called Boolean algebra in honor of Boole. In Boolean algebra, the true state is represented by the number one, called logic high or logic one. The false state is represented by the number zero, called logic low or logic zero. In the field of digital electronics, logic high is represented by the presence of a voltage potential.

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C 0 1 0 1 0 1 0 1

Y 0 1 0 1 0 0 1 1

Figure 7-3. Boolean expression and its truth table.

A B AB Y A′C C Figure 7-4. Logic circuit for Boolean expression in Figure 7-3.

Chapter 7

Programming Logic Gate Functions in PLCs

141

142

Programmable Logic Controllers: Hardware and Programming

7.4 NOT Gates or Inverters

The output of a NOT gate is the inverse of the input. The NOT gate is sometimes called an inverter. The function of a NOT gate is simulated by the electric circuit displayed in Figure 7-5. When the switch is closed, the electric bulb is short circuited, and it turns off. When the switch is open, electric current flows through the lightbulb, and the lightbulb turns on. Like the NOT gate, the output is on when the input is off and vice versa. The input is inverted to generate an output. Figure 7-6 displays the NOT logic gate symbol, its Boolean expression, and its truth table. Figure 7-7 displays that there are two different types of PLC ladder logic diagrams that perform the NOT function. • In rung 0000, the XIO (examine if open) device is connected to the output. Therefore, the XIO device is normally closed and output zero is ON. When you press pushbutton #1 (I:0/0), the output zero (pilot light #1) is turned off. (Notice that address I:0/0 references the port 0 on module 0.) • In rung 0001, pushbutton #2 (I:0/1) is connected to internal coil bit B3:0/0. (Notice that address I:0/1 references the port 1 on module 0.) In rung 0002, the internal contact bit B3:0/0 is inverted and connected to output one (pilot light #2). When normally open input I:0/1 is open, output one (O:0/1) is ON. Press input 0/1 to close it, then output one will turn OFF.

NOT gate: Gate that generates a logic high output when all inputs are logic low. Pushbutton #1 I:0 0000 0 Pushbutton #2 I:0 0001 1 Control relay B3:0 0002 0 0003

NOT or INVERTER Logic Gate Pilot light #1 O:0 0 Control relay B3:0 0 Pilot light #2 O:0 1 End

Figure 7-7. Two ways to program a NOT function in a PLC.

7.5 AND Gates

AND gate: Gate that only generates a logic high output when all inputs are logic high.

1 kΩ + − 5V 1 LT Switch is opened (SW = 0), Lamp is on (LT = 1)

0 Switch (SW)

Switch is closed (SW = 1), Lamp is off (LT = 0)

The function of an AND gate is simulated in the electric circuit displayed in Figure 7-8. Notice that the lamp will be on only when both switches are closed. Figure 7-9 displays a two-input AND logic gate symbol, its Boolean expression, and its truth table. In the truth table, you can see that there is only one set of inputs that produces a logic high output. Figure 7-10 displays a ladder logic diagram that performs the function of a two-input AND gate. When normally open inputs I:0/0 and I:0/1 are closed, output O:0/0 is energized.

7.6 OR Gates

Figure 7-5. Electric circuit emulating the function of a NOT gate.

OR gate: Gate that generates a logic high output in all states except when all inputs are logic low.

Boolean expression: Y = A′ A Y A 0 1 Y 1 0

NOT gate symbol

Truth table

The function of an OR gate is simulated in the electric circuit displayed in Figure 7-11. Notice that the lamp will be ON when one or both of the switches are closed. Figure 7-12 displays a two-input OR logic gate symbol, its Boolean expression, and its truth table. The truth table shows a logic high output for all combinations of inputs except where both A and B are low. When either input A, B, or both are on, the output is on. Figure 7-13 displays a ladder logic diagram that performs the function of a two-input OR gate. When either normally open (NO) inputs I:0/0, I:0/1, or both are closed, output O:0/0 is energized.

Figure 7-6. Boolean expression, gate symbol, and truth table for NOT logic gate.

Chapter 7

Programming Logic Gate Functions in PLCs

143

144

Programmable Logic Controllers: Hardware and Programming

Switch A

0 1

0 1

Switch B

Switch A

0 1

Lamp on = 1 1 kΩ Lamp off = 0 1 kΩ Switch B

0 1 Lamp on = 1 Lamp off = 0

+

− 5V + 5V −

Figure 7-8. Electric circuit emulating an AND gate.

Figure 7-11. Electric circuit emulating an OR gate. Boolean expression: Y = A · B A B Y A 0 0 1 1 B 0 1 0 1 Truth table Two-input OR gate Y 0 0 0 1 Boolean expression: Y = A + B A B Y A 0 0 1 1 B 0 1 0 1 Truth table Y 0 1 1 1

Two-input AND gate

Figure 7-9. Boolean expression, gate symbol, and truth table for a two-input AND logic gate.

Figure 7-12. Boolean expression, gate symbol, and truth table for a two-input OR logic gate.

AND Logic Gate Pushbutton #1 Pushbutton #2 I:0 I:0 0000 0 1 0 0000 0 0001 End Pushbutton #2 I:0 1 0 Pilot light #1 O:0 Pushbutton #1 I:0 OR Logic Gate Pilot light #1 O:0

Figure 7-10. AND gate ladder logic diagram.

0001

End

Figure 7-13. Ladder logic diagram for an OR gate.

Chapter 7

Programming Logic Gate Functions in PLCs

145

146

Programmable Logic Controllers: Hardware and Programming

7.7 NAND Gates

The function of a NAND gate is simulated in the electric circuit displayed in Figure 7-14. Notice that the lamp will be off when both switches are closed. The NAND gate takes its name from NOT and AND. Its outputs are the inverse of the AND gate. Figure 7-15 displays a two-input NAND logic gate symbol, its Boolean expression, and its truth table. Notice that the NAND gate can be built by connecting an AND gate in series with a NOT gate. Using the De-Morgan theorem, sometimes also called the Bubble method, you can convert a NAND gate to an OR gate with inverted inputs where (A · B) ′ = A′ + B′. Figure 7-16 displays that there are two different types of ladder logic diagrams that perform the NAND function. • Both normally closed inputs I:0/0 and I:0/1 must be energized (opened) to turn off the output O:0/0.

NAND gate: Gate that does not generate a logic high output when all inputs are logic low. An inverted AND.

•

When both normally open inputs I:0/2 and I:0/3 are energized (closed), the relay coil B3:0/0 is energized. Then the normally closed contact B3:0/0 is opened to turn off output O:0/1.

7.8 NOR Gates

NOR gate: Gate that generates a logic high output when all inputs are logic low. An inverted OR.

The function of a NOR logic gate is simulated in the electric circuit displayed in Figure 7-17. Notice that the lamp will be ON when both switches are open. The NOR gate takes its name from NOT and OR. Its outputs are the inverse of the OR gate.

NAND Logic Gate

Pushbutton #1 I:0 0000 0 Pushbutton #2 I:0

Pilot light #1 O:0 0

1 Switch A 1 kΩ 1 Switch B

0 Lamp on = 1 0 Lamp off = 0

0001 2

1 Creating NAND logic gate using AND and NOT logic gates. Control relay Pushbutton #3 Pushbutton #4 I:0 I:0 B3:0 3 0 Pilot light #2 O:0 1 End

+ 5V

−

Control relay B3:0 0002 0

Figure 7-14. Electric circuit emulating a NAND gate.

0003

Boolean expression: Y = A · B = A + B A B

Figure 7-16. Ladder logic diagram for a NAND gate.

Y =A·B

A B A·B

Y=A·B

A 0 0 1 1

B 0 1 0 1 Truth table

Y 1 1 1 0

Switch B 1 1 kΩ 0 1

Switch A 0

Lamp on = 1 Lamp off = 0

NAND gate Figure 7-15. Boolean expression, gate symbol, and truth table for a NAND logic gate.

+ 5V

−

Figure 7-17. Electric circuit emulating a NOR gate.

Chapter 7

Programming Logic Gate Functions in PLCs

147

148

Programmable Logic Controllers: Hardware and Programming

Figure 7-18 displays a two-input NOR logic gate symbol, its Boolean expression, and its truth table. Notice the NOR gate can be built by connecting an OR gate in series with a NOT gate. Using the De-Morgan theorem, you can convert a NOR gate to an AND gate with inverted inputs where (A + B) ′ = A′ · B′. Figure 7-19 displays that there are two different types of ladder logic diagrams that perform the NOR gate function. • Both normally closed inputs I:0/0 and I:0/1 must be deenergized (remain closed) to turn on the output O:0/0.

Boolean expression: Y = A + B = A · B A B Y=A+B A 0 0 1 1 B 0 1 0 1 Truth table Y 1 0 0 0

•

When both normally open inputs I:0/2 and I:0/3 are de-energized, the relay coil B3:0/0 is de-energized. Then the normally closed contact B3:0/0 remains closed to turn on output O:0/1.

7.9 XOR (Exclusive OR) Gates

XOR gate: Gate that generates a logic high output when one input is logic high and the other input is logic low or vice versa.

A B A+B NOR gate

Y=A+B

The function of an XOR (exclusive OR) gate is simulated in the electric circuit displayed in Figure 7-20. Notice that the lamp will be on if one switch is open while the other switch is closed. Figure 7-21 displays an XOR logic gate symbol, its Boolean expression, and its truth table. Looking at the truth table, you can see that either inputs A or B (but not both) must be high to produce a high output. One input must be ON and the other one OFF in order to have the output ON. Figure 7-22 displays a ladder logic diagram that performs the function of an XOR gate. When I:0/0 is on, I:0/1 must be off and vice versa in order to turn on output O:0/0. When either Pushbutton #1 or Pushbutton #2 is pressed, the output is ON. When both pushbuttons are pressed, output is OFF.

Switch A Switch B

Figure 7-18. Boolean expression, gate symbol, and truth table for a NOR logic gate.

NOR Logic Gate Pushbutton #1 I:0 0000 0 1 0 Pushbutton #2 I:0 Pilot light #1 O:0

Lamp on = 1 1 kΩ Lamp off = 0

Creating NOR logic gate using OR and NOT logic gates. Control relay Pushbutton #3 I:0 B3:0

0001 2 Pushbutton #4 I:0 3 Control relay B3:0 0002 0 1 Pilot light #2 O:0 0

+ 5V

−

Figure 7-20. Electric circuit emulating an XOR gate. Boolean expression: Y = A + B = A · B + A · B A B Y A 0 0 1 1 B 0 1 0 1 Y 0 1 1 0

XOR gate

0003 End

Figure 7-19. Ladder logic diagram for a NOR gate.

Figure 7-21. Boolean expression, gate symbol, and truth table for an XOR logic gate.

Chapter 7

Programming Logic Gate Functions in PLCs

149

150

Programmable Logic Controllers: Hardware and Programming

XOR Logic Gate Pushbutton #1 I:0 0000 0 Pushbutton #1 I:0 0 1 Pushbutton #2 I:0 1 0 Pushbutton #2 I:0 Pilot light #1 O:0

Boolean expression: Y = A + B = A · B + A · B A B Y A 0 0 1 1 B 0 1 0 1 Y 1 0 0 1

A B XNOR gate

End

0001

Figure 7-24. Boolean expression, gate symbol, and truth table for an XNOR logic gate.

Figure 7-22. Ladder logic diagram for an XOR gate.

7.10 XNOR (Exclusive NOR) Gates

The function of an XNOR (exclusive NOR) gate is simulated in the electric circuit displayed in Figure 7-23. Notice that the lamp will be on when either both switches are open or closed. The lamp will not be on if only switch A is activated, or if only switch B is activated. Figure 7-24 displays an XNOR logic gate symbol, its Boolean expression, and its truth table. Notice the XNOR gate can be built by connecting an XOR gate in series with the NOT gate. When either or both pushbuttons are pressed or not pressed, the output is ON.

XNOR gate: Gate that generates a logic high output when either both inputs are logic high or both inputs are logic low.

Figure 7-25 displays that there are two different types of ladder logic diagrams that perform the XNOR function. • Both inputs I:0/0 and I:0/1 must be on or off to turn on the output O:0/0. • When I:0/2 is on and input I:0/3 is off or vice versa (i.e., XOR gate), the relay coil B3:0/0 is energized. Then the normally closed contact B3:0/0 opens to turn off output O:0/1.

7.11 Simplifying Boolean Expressions

In previous sections, the use of Boolean expressions, truth tables, and logic gate circuits were studied. You saw how logic gates were converted to PLC ladder logic diagrams. In this and the next two sections, you will study how to create PLC ladder logic diagrams from truth tables. To convert a truth table to a PLC ladder logic diagram, you must first find its simplified Boolean expression. The next step is to use the gate logic to PLC ladder diagram conversion routine to create the PLC ladder logic diagram. Three methods are used to simplify Boolean expressions. • Karnaugh maps. • Quine-McCluskey routine. • Electronic simulation software.

Switch A

Switch B

Lamp on = 1 1 kΩ Lamp off = 0

Karnaugh Maps

+ 5V −

Karnaugh map: A tool that can be used to simplify Boolean expressions. This is an older, difficult method for Boolean expression simplification.

Figure 7-23. Electric circuit emulating an XNOR gate.

Karnaugh maps (K-Map) are graphical representations of truth tables. They use columns and rows to represent each term in a truth table. For an n-variable input truth table, there are 2n boxes in a Karnaugh map. For example, for a two-input truth table, four boxes (22) are needed. A K-Map has a box for every line in the truth table. Binary numbers are placed above each column and to the left of each row. Figure 7-26 shows how binary numbers related to the input values are placed in a two-input, three-input, and four-input K-Map.

Chapter 7

Programming Logic Gate Functions in PLCs

151

152

Programmable Logic Controllers: Hardware and Programming

XNOR Logic Gate Pushbutton #1 I:0 0000 0 Pushbutton #1 I:0 0 1 Pushbutton #2 I:0 1 0 Pushbutton #2 I:0 Pilot light #1 O:0

Two-Input Karnaugh Map A 0 0 1 1 B 0 1 0 1 Y B 0 A 0 1

1

Creating XNOR logic gate using XOR and NOT logic gates. Control relay Pushbutton #1 Pushbutton #2 I:0 B3:0 I:0 0001 0 Pushbutton #1 I:0 0 Control relay B3:0 0002 0 1 1 Pushbutton #2 I:0 1 Pilot light #2 O:0 0

Three-Input Karnaugh Map A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 Y C 0 AB 00 01 11 10

1

Four-Input Karnaugh Map A 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 B 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 C 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 D 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 Y AB CD 00 00 01 11 10

0003

End

Figure 7-25. Ladder logic diagram for an XNOR gate.

01

Notice that the input values are placed so that the values for adjacent columns and rows change only a single bit. For example, for a threeinput K-Map, binary numbers related to inputs A and B are placed above the columns in the order 00, 01, 11, and 10. Binary numbers related to input C are placed to the left of the rows in the order 0 and 1. This ordering follows the Gray code system explained in Chapter 3. To use the K-Map, the expression must be in a sum of products (SOP) form, such as AB′ + BC. This means that the Boolean expression consists of groups that are created from ANDed inputs. Then, the groups are summed (ORed) to create the entire Boolean expression. Use the following steps and refer to Figure 7-27 to simplify the Boolean expressions using K-Maps. 1. Select an appropriate K-Map that has the correct number of input boxes, such as two-input and three-input. As stated, for an n-variable input truth table, there will be 2n boxes. Therefore, for a two-variable (A and B) input table, there will be 22 boxes, or 4 boxes.

11

10

Figure 7-26. Two-input, three-input, and four-input K-Maps.

Chapter 7

Programming Logic Gate Functions in PLCs

153

154

Programmable Logic Controllers: Hardware and Programming

A B 0 1 0 0 1 1 Correct A B 0 1 0 1 0 1 1 0 Correct A B 0 1 0 1 1 1 1 1 Correct A 0 0 1 0 1 Group of 4 C 0 1 AB 00 1 0 C Group of 2 0 1 AB 00 0 0 1 B

A 0 0 1 0 1 Incorrect 01 1 0 11 1 0 10 1 0 Group of 3 1

A

Incorrect 01 1 0 11 1 0 10 1 1 Group of 5

B

Incorrect A 1 1 1 Correct AB C 0 1 00 1 0 01 1 0 Correct AB C Leftmost cell 0 1 00 1 1 Top cell 01 1 11 1 1 10 1 1 Rightmost cell 11 1 1 10 1 1 AB C 0 1 00 1 0 B 0 1 0 0 1 1 1 1 B

2. Plot only the terms in which Y = 1. 3. Follow the rules below for grouping the 1s in the K-Map that lead to simplifying the expression. • Adjacent groups with binary number 1 in them must be combined in groups of 1, 2, 4, 8, 16, and so on. See Figure 7-27A. • Each group must contain an even number of binary 1s. See Figure 7-27B. • Every 1 in adjacent cells must be included in a group. See Figure 7-27C. • The same 1 can be used in two or more overlapping groups. See Figure 7-27C. • Each group should be as large as possible. See Figure 7-27D. • The map can be considered closed, so that the end boxes are grouped adjacently (top and bottom, or left and right). Figure 7-27E shows how groups wrap around the K-Map. 4. Write the Boolean expressions for each group, and then simplify the expression by retaining only the common variables. See Figure 7-28. 5. Then, sum the common variables from each group to create the simplified sum of product (SOP) Boolean expression. See Figure 7-28.

C

Incorrect 01 1 0 11 1 1 10 1 1

D

Incorrect

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C 0 1 0 1 0 1 0 1

Y 0 0 1 0 1 0 1 1

AB C 0 1

Group 1 00 01 1 11 1 1 Group 3 10 1 Group 2

Boolean expression for each group: Group 1 = A′ B C′ + A B C′ Common variables = BC′ Group 2 = A B C′ + A B′ C′ Common variables = AC′ Group 3 = A B C′ + A B C Common variables = AB Simplified SOP Boolean expression: Y = BC′ + AC′ + AB

E

Bottom cell

Figure 7-27. Simplifying Boolean expressions using K-Maps. A—Grouping pairs of binary 1s in adjacent cells. B—Grouping even number of 1s in adjacent cells. C—Grouping 1s in the adjacent cells. D—Groups must be as large as possible. E—Groups can wrap around the K-Map.

Figure 7-28. Simplified sum of product (SOP) Boolean Expression.

Chapter 7

Programming Logic Gate Functions in PLCs

155

156

Programmable Logic Controllers: Hardware and Programming

Example 7-1

The example displayed in Figure 7-29 illustrates how to use a Karnaugh map to find the simplified SOP Boolean expression. Examine the steps used to simplify. 1. There are three inputs: A, B, and C. Therefore, select a threeinput Karnaugh map. Note that the map will have 23 (8) boxes. 2. Plot only the terms in which Y = 1. 3. Group the adjacent logic highs (1s). Remember, each group should be as large as possible. For this Karnaugh map, there is only one group. 4. Then, write the expression for the group and then simplify the expression by retaining the common variable(s). The simplified SOP Boolean expression is Y = C.

Electronic Circuit Simulation

Using electronic circuit simulation software to find the simplified Boolean expression is the easiest method. This type of software allows you to enter the input and output data and solves and simplifies the expression for you. An example of this type of software is NI Multisim. In Example 7-2, you will learn how to use NI Multisim to find the simplified Boolean expression of a truth table. If you have access to this software, work through the following example.

Example 7-2

Open the NI Multisim program. From the Instruments toolbar, click the Logic Converter icon. Then, click a space in the work area to place the converter. Double-click the Logic Converter image to open the Logic Converter dialog box. Figure 7-30 displays the Logic Converter instrument and dialog box. Click the inputs A, B, C, and D since your example truth table has those four inputs. Next, click the output column and type the output bits for the truth table displayed in Figure 7-31 (column Y). Click the Simplify button to find the simplified Boolean expression: A′CD + B′CD + BC′D + ABCD′ The answer appears in the rectangle at the bottom of Figure 7-30. The simplified Boolean expression consists of the sum of four product

Quine-McCluskey Routine

For more than five inputs, the Karnaugh map method becomes very difficult. Therefore, for more than five input variables, the Quine-McCluskey routine is a better method for simplifying Boolean expressions. The Quine-McCluskey routine is a complicated method that uses the Boolean algebraic simplification rules to find the simplified Boolean expression. We will not study the theory of the QuineMcCluskey method in this textbook, but you should know that this method exists and might be used in an advanced course.

Quine-McCluskey routine: Tool used as an advanced Boolean expression simplification routine.

Truth Table: Example 7-1 A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 Y 0 1 0 1 0 1 0 1 AB C 0 Group 1 1 1 1 1 1

00

01

11

10

Boolean expression for each group: Group 1 = A′ B′ C + A′ B C + A B C + A B′ C Common variable(s) = C Simplified SOP Boolean expression: Y=C

Figure 7-29. Using a Karnaugh map to find a simplified Boolean expression for Example 7-1.

A 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

B 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

C 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

D 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Y 0 0 0 1 0 1 0 1 0 0 0 1 0 1 1 0

Figure 7-30. Truth table for Example 7-2.

Chapter 7

Programming Logic Gate Functions in PLCs

157

158

Programmable Logic Controllers: Hardware and Programming

expressions. Therefore, four rungs must be connected in parallel. Each rung has series input devices on it. Figure 7-32 displays the PLC ladder logic diagram created from the simplified Boolean expression.

7.12 Creating PLC Ladder Logic Diagrams from Logic Gate Circuits

In previous sections, you learned how to create PLC ladder logic diagrams for the logic gates. To create the ladder logic diagram from a logic gate circuit, you must convert each gate to its equivalent ladder logic diagram. Note that these simple conversions were discussed in sections 7.4 through 7.10. In this section, three examples are used to illustrate how to create PLC ladder logic diagrams for logic gate circuits. Study the procedures used in the following examples.

Logic converter instrument Select A-D Output column

Example 7-3

Create the PLC ladder logic diagram for the logic gate circuit displayed in Figure 7-33. Examine Figure 7-33. The pilot light red (PLTR) output section has three inputs: PBR, PBG, and SW. Pushbutton red (PBR) and pushbutton green (PBG) are inputs to an XOR logic gate. The output of the XOR logic gate and the inverted switch (SW) are inputs to a twoinput AND logic gate. These inputs generate the pilot light red (PLTR) output. The two-input AND logic gate output is also fed into a two-input NAND logic gate. The temperature switch (TSW) is another input to the NAND logic gate. The output generated from the NAND logic gate is labeled pilot light white (PLTW). Using the transformations described in Section 7.7 (on NAND gates) and Section 7.9 (on XOR gates), you can generate a PLC ladder logic diagram. Figure 7-34 displays the PLC ladder logic diagram for Example 7-3.

Simplify button

Simplified Boolean expression Figure 7-31. Using the Logic Converter instrument to find the simplified Boolean expression for Example 7-2.

Example 7-2 A’CD + B’CD + BC’D + ABC D’ = Y

A I:0 0000 0 B I:0 1 B I:0 1 A I:0 0 0001 2 C I:0 2 C I:0 2 B I:0 1 3 D I:0 3 D I:0 3 C I:0 2 D I:0 C I:0 D I:0

A’CD

O:0 0

PBR PBG PLTR

B’CD

SW BC’D

PLTW TSW Figure 7-33. Logic gate circuit for Example 7-3.

3

ABCD’

End

Figure 7-32. PLC ladder logic diagram for Example 7-2.

Chapter 7

Programming Logic Gate Functions in PLCs

159

160

Programmable Logic Controllers: Hardware and Programming

Example 7-3 PBR XOR PBG NOT AND PLTR (AND output)

Using the transformations from Section 7.5 (AND gates) and Section 7.6 (OR gates) you can create the PLC ladder logic diagram. Figure 7-36 displays the PLC ladder logic diagram for Example 7-4.

SW

PBR PBG

NAND TSW

PLTW (NAND output) SW

XOR output is ANDed with the inverted SW to generate PLTR output. PBR I:0 0000 0 PBR I:0 0 1 PBG I:0 2 0 PBG I:0 SW I:0 PLTR O:0

PLTR TSW Figure 7-35. Logic gate circuit for Example 7-4.

NOT

AND output Example 7-4 PBR

PLTW O:0 1

XOR AND

1

PLTR output is NANDed with TSW to generate PLTW output. PLTR O:0 0001 0 TSW I:0 3 0002

AND

PBG OR

NAND output

SW AND NOT TSW PLTR

NAND

End PBR I:0 0000 0 SW I:0 2 PBG I:0 1 TSW I:0 3 PLTR O:0 0

Figure 7-34. PLC ladder logic diagram for Example 7-3.

Example 7-4

Create the PLC ladder logic diagram for the logic gate circuit displayed in Figure 7-35. Pushbutton red (PBR) and pushbutton green (PBG) are inputs to a two-input AND gate. The output of the AND logic gate and the switch (SW) are inputs to a two-input OR logic gate. The output of the OR logic gate and an inverted temperature switch (TSW) are inputs to a second AND logic gate. This AND logic gate generates the output for pilot light red (PLTR).

AND

NOT

OR AND

End

0001

Figure 7-36. PLC ladder logic diagram for Example 7-4.

Chapter 7

Programming Logic Gate Functions in PLCs

161

162

Programmable Logic Controllers: Hardware and Programming

Example 7-5

Create the PLC ladder logic diagram for the logic gate circuit displayed in Figure 7-37. Inputs A and B are fed into an XNOR logic gate. Inputs D and E are fed into a NOR logic gate. Outputs of the XNOR and NOR logic gates plus input C are fed into a three-input OR logic gate. The threeinput OR logic gate generates output Y. Figure 7-38 displays the PLC ladder logic diagram for Example 7-5.

A I:0 0000 0 A I:0 0 1 B I:0 1 B I:0

Example 7-5

Y O:0 0

7.13 Creating PLC Ladder Logic Diagrams from Boolean Expressions

Some manufacturers use Boolean expressions to program their PLCs. In this section, you will learn how to use Boolean expressions to create PLC ladder logic diagrams. Work through the following three examples that illustrate how to create ladder logic diagrams for Boolean expressions.

0001 D I:0 3

C I:0 2 E I:0 4 End

Example 7-6

Create the PLC ladder logic diagram for the following Boolean expression. Y = A′ + B + CD + EB To create the diagram, each rung or each portion of a rung is created by replacing the Boolean letter with the inputs that match. Figure 7-39 summarizes the Boolean expressions and ladder diagrams for the logic gates covered in Sections 7-4 through 7-10.

Figure 7-38. PLC ladder logic diagram for Example 7-5.

Figure 7-40 displays the PLC ladder logic diagram. Notice that inverted A, B, CD, and EB inputs are in parallel (OR). Inputs C and D are in series (AND). Inputs E and B are also in series (AND).

Example 7-7

A B C D E Figure 7-37. Logic gate circuit for Example 7-5. Y

Create the PLC ladder logic diagram for the following Boolean expression. Y = (AB)′ + AC + BC Figure 7-41 displays the PLC ladder logic diagram. Notice that inverted A and B inputs are in series to generate output at the control relay. Then, the inverted output of AB is in parallel with AC and BC.

Chapter 7

Programming Logic Gate Functions in PLCs

163

164

Programmable Logic Controllers: Hardware and Programming

OR Gate: Y = A + B 000 I:1/0 A I:1/1 B NOR Gate: Y = A + B I:1/0 A I:1/1 B B3:0/0 002 A or B is Inverted AND Gate: Y = A · B I:1/1 I:1/0 A 004 B Y 4 O:2/2 Y 0001 1 O:2/1 O:2/0 Y 0000 0 B I:0 B3:0/0 1 A or B is Inverted C I:0 2 E I:0 D I:0 3 B I:0 A I:0

Example 7-6 A’ + B Y = A’ + B + C · D + E · B

Y O:0 0

001

C·D

E·B

003

End

Figure 7-40. PLC ladder logic diagram for Example 7-6.

NAND Gate: Y = A · B I:1/1 I:1/0 A B3:0/1 B

B3:0/1

Example 7-7

A and B are Inverted O:2/3 0000 A and B are Inverted XOR Gate: Y = A · B + A · B I:1/1 I:1/0 A I:1/0 A B I:1/1 B 0 O:2/5 Y 1 0002 A B 2 End B I:0 A I:1/0 B I:1/1 2 C I:0 Y 0 1 0 Y A I:0 B I:0 Control relay B3:0

005

006

O:2/4 0001 Y

Control relay B3:0 0 A I:0

(A · B)’

Y = (A · B)’ + (A · C) + (B · C)

O:0 0

C I:0

A·C

007

XNOR Gate: Y = A · B + A · B I:1/1 I:1/0

B·C

Figure 7-39. Boolean expression and ladder diagram summary.

Figure 7-41. PLC ladder logic diagram for Example 7-7.

Chapter 7

Programming Logic Gate Functions in PLCs

165

166

Programmable Logic Controllers: Hardware and Programming

Example 7-8

Create the PLC ladder logic diagram for the following Boolean expression. Y = (A + B) · (C + D) Figure 7-42 displays the PLC ladder logic diagram. Notice that A is in parallel with B and C is in parallel with D. Then, (A + B) and (C + D) are in series.

A I:0 0000 0 1 C I:0 2 B I:0

Example 7-9

C I:0 2 D I:0 3 Y O:0 0 Control relay B3:0 0

B’ + C · D C·D

A · (B’ + C · D) · C’

7.14 Creating Logic Gate Circuits from PLC Ladder Logic Diagrams

In Sections 7.11, 7.12, and 7.13, you learned how to create PLC ladder logic diagrams from truth tables, logic gate circuits, and Boolean expressions. In this section, you will see the reverse process. You will use examples to study how to convert PLC ladder logic diagrams to logic gate circuits. The first step in this process is to find the Boolean expression that represents the ladder logic diagram. You can then draw the logic gate circuit using the Boolean expression similar. You can also use the logic converter instrument in the NI Multisim program to find truth tables and Boolean expressions from the logic gate circuits. Three examples are used to illustrate how to convert PLC ladder logic diagrams to logic gate circuits.

0001

A I:0 0 0002

Control relay B3:0 0

Y = A · [A · (B’ + C · D) · C’]’

End

Figure 7-43. PLC ladder logic diagram for Example 7-9.

Example 7-9

Create the logic gate circuit for the PLC ladder logic diagram displayed in Figure 7-43. First, turn the PLC ladder logic diagram shown in Figure 7-43 into a Boolean expression as shown in the ladder

Example 7-8

A I:0 0000 0 B I:0 1 2 D I:0 3 0

A+B

C I:0

C+D

Y O:0

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

0001

End

Figure 7-42. PLC ladder logic diagram for Example 7-8.

diagram. Notice that in rung 0000, inverted input B is in parallel (ORed) with serial (ANDed) inputs C and D. This is represented by the following expression: B′ + C · D This combination (B′ + C · D) is in serial (ANDed) with input A and inverted input C′ in rung 0000. Therefore, the control relay output for this rung is the following: A · (B′ + C · D) · C′ In rung 0001, input A is in serial (ANDed) with the inverted output of the control relay from rung 0000 to generate the Boolean expression for output Y: Y = A · [A · (B′ + C · D) · C′] ′ Next, create the logic gate circuit using the Boolean expression from Figure 7-43. Figure 7-44 displays the logic gate circuit for this example. Notice that ANDed inputs C and D and inverted input B are ORed for the following Boolean expression: B′ + C·D Then, this is ANDed with input A and inverted input C for the following Boolean expression: A · (B′ + C · D) · C′ Finally, this output is inverted and ANDed with input A for the output of Y: Y = A · [A · (B′ + C·D) · C′] ′

Chapter 7

Programming Logic Gate Functions in PLCs

167

168

Programmable Logic Controllers: Hardware and Programming

C

C C · D’ + C’ · D CD D B’ + CD B’ B A C’ A · (B’ + CD) · C’ A [A · (B’ + CD) · C’] A Y = A · [A · (B’ + CD) · C’)’ Figure 7-46. Logic gate circuit for Example 7-10. B Y = A · [B + (C · D’ + C’ · D)] D B + (C · D’ + C’ · D)

Figure 7-44. Logic gate circuit for Example 7-9.

Example 7-10

Create the logic gate circuit for the PLC ladder logic diagram displayed in Figure 7-45. First, turn the PLC ladder logic diagram shown in Figure 7-45 into a Boolean expression as shown in the ladder diagram. Notice that in rung 0000, inputs C and D in the bottom parallel branches create an XOR logic gate (CD′ + C′D). This is in parallel (ORed) with input B, forming the following Boolean expression: B + (C · D′ + C′ · D)

Example 7-10

A I:0 0000 0 1 C I:0 2 C I:0 2 0001 D I:0 3 D I:0 3 End 0 B I:0 Y O:0

Finally, this combination is in serial (ANDed) with input A to generate output Y: Y = A · [B + (C · D′ + C′ · D)] Next, create the logic gate circuit using the Boolean expression from Figure 7-45. Figure 7-46 displays the logic gate circuit for this example. Notice that inputs C and D are XORed and then ORed with input B. This combination is then ANDed with input A for the output of Y: Y = A · [B + (C · D′ + C′ · D)]

Example 7-11

Create the logic gate circuit for the PLC ladder logic diagram displayed in Figure 7-47. First, turn the PLC ladder logic diagram shown in Figure 7-47 into a Boolean expression as shown in the ladder diagram. Notice that in rung 0000, parallel (ORed) inputs A, B, and inverted C are in parallel (ORed) with the output from the control relay which is in series (ANDed) with inverted input D, forming the following Boolean expression: (A + B + C′) + [D′ · (A + B + C′ + D′)] Finally, inverted input E′ in rung 0001 is in serial (ANDed) with the output of the control relay. This is equal to the output of Y: Y = E′ {(A + B + C′) + [D′ · (A + B + C′ + D′)]} Next, create the logic gate circuit using the Boolean expression from Figure 7-47. Figure 7-48 displays the logic gate circuit for this example.

Y = A · [B + (C · D’ + C’ · D)] B + (C · D’ + C’ · D) C · D’ + C’ · D

Figure 7-45. PLC ladder logic diagram for Example 7-10.

Chapter 7

Programming Logic Gate Functions in PLCs

169

170

Programmable Logic Controllers: Hardware and Programming

Example 7-11

A I:0 0000 0 B I:0 1 C I:0 2 D I:0 3 Control relay B3:0 0 0 Control relay B3:0

Summary

• • Combinational logic gates do not require clock pulses to operate. Combinational logic gates are called logic gates. There are seven logic gates: NOT, AND, OR, NAND, NOR, XOR (exclusive OR), and XNOR (exclusive NOR). Sequential logic devices require clock pulses and have outputs that depend on their inputs as well as time. Flip-flop devices such as reset-set (RS), JK, delay (D), and toggle (T) are sequential logic devices. Every gate logic function has its own equation called a Boolean expression. A type of algebra using only two states is called Boolean algebra in honor of Boole. In Boolean algebra, the true state is represented by the number one, called logic high or logic one. The false state is represented by the number zero, called logic low or logic zero. In Boolean algebra, a table, called a truth table, contains the digital input and output points. A prime symbol (′) indicates the inverse value of the input. The output of a NOT gate is the inverse of the input. The NOT gate is sometimes called an inverter. Karnaugh maps (K-Maps) are graphical representations of truth tables that use columns and rows to represent each term in a truth table.

• • • • •

A + B + C’

(A + B + C’) + [D’ · (A + B + C’ + D’)]

[D’ · (A + B + C’ + D’)]

•

Y = E’ {(A + B + C’) + [D’ · (A + B + C’ + D’)]}

Y O:0 0

E I:0 0001 4

Control relay B3:0 0

• • •

0002

End

Figure 7-47. PLC ladder logic diagram for Example 7-11.

Review Questions

Complete each of the following sentences with the correct word(s). 1. When the input to a NOT gate is a logic high, the output is a logic ______. 2. You can create a NOT gate ladder logic diagram using either one rung or ______ rungs. 3. In an one-rung NOT gate ladder logic diagram, the input instruction must be normally ______. 4. In a two-rung NOT gate ladder logic diagram, the input instruction must be normally ______. 5. In a two-rung NOT gate ladder logic diagram, you must use a(n) ______ contact. 6. In an AND gate ladder logic diagram, when both inputs are closed, the output is ______. 7. In an AND gate ladder logic diagram, when both inputs are open the output is ______.

A (A + B + C’) B C D D’ C’ (A + B + C’) + [D’ · (A + B + C’ + D’)] Y = E’ {(A + B + C’) + [D’ · (A + B + C’ + D’)]} E’

(A + B + C’ + D’) E

Figure 7-48. Logic gate circuit for Example 7-11.

Chapter 7

Programming Logic Gate Functions in PLCs

171

172

Programmable Logic Controllers: Hardware and Programming

8. In an AND gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 9. An AND gate ladder logic diagram requires ______ rung(s). 10. In a NAND gate ladder logic diagram, when both inputs are open, the output is ______. 11. In a NAND gate ladder logic diagram, when both inputs are closed, the output is ______. 12. In a NAND gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 13. You can create a NAND gate logic diagram using either one rung or ______. 14. In an one-rung NAND gate ladder logic diagram, the inputs must be in ______. 15. In an OR gate ladder logic diagram, when both inputs are closed, the output is ______. 16. In an OR gate ladder logic diagram, when both inputs are open, the output is ______. 17. In an OR gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 18. An OR gate ladder logic diagram requires ______ rung(s). 19. The input for an OR gate ladder logic diagram must be normally ______. 20. In a NOR gate ladder logic diagram, when both inputs are open, the output is ______. 21. In a NOR gate ladder logic diagram, when both inputs are closed, the output is ______. 22. In a NOR gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 23. In a one-rung NOR gate ladder logic diagram, both inputs must be normally ______. 24. In a two-rung NOR gate ladder logic diagram, inputs are connected in ______. 25. In an XOR gate ladder logic diagram, when both inputs are open, the output is ______. 26. In an XOR gate ladder logic diagram, when both inputs are closed, the output is ______. 27. In an XOR gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 28. The inputs in an XOR gate ladder logic diagram are connected in ______ and ______. 29. The inputs in an XOR gate ladder logic diagram are normally ______ and ______.

30. In an XNOR gate ladder logic diagram, when both inputs are open, the output is ______. 31. In an XNOR gate ladder logic diagram, when both inputs are closed, the output is ______. 32. In an XNOR gate ladder logic diagram, when one input is closed and the other one is open, the output is ______. 33. In a one-rung XNOR gate ladder logic diagram, the normally closed inputs are connected in ______. Specify if the following statements are true or false. 34. Both inputs to an AND gate must be high to produce a high output. 35. Both inputs to a NAND gate must be high to produce a high output. 36. Inverting a NAND gate will result in creating an AND gate. 37. Only one input to an OR gate must be high to produce a high output. 38. Both inputs to a NOR gate must be high to produce a high output. 39. Inverting an OR gate will result in creating a NOR gate. 40. Both inputs to an XOR gate must be high to produce a high output. 41. Both inputs to an XNOR gate must be high to produce a high output. 42. All three inputs to a three-input AND gate must be high to produce a high output. Create a PLC ladder diagram for the truth tables in the following problems. 43. A

0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 I I I I I I I I I Y 0 0 0 1 0 1 0 1

Chapter 7

Programming Logic Gate Functions in PLCs

173

174

Programmable Logic Controllers: Hardware and Programming

44. A

0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C 0 1 0 1 0 1 0 1

I I I I I I I I I

Y 0 0 0 1 0 1 1 0

Create a relay logic diagram for the ladder diagrams in the following problems. 47. L1

A CR B C D E-1 CR E-2 L2

Create a PLC ladder diagram for the relay logic diagrams in the following problems. 45.

A B C D E F Y

M

48. L1

A B Y1

L2

A G H J C Y1-1 D

B E Y1-2 D Y2-1 Y2

46. A

B

C D E

Y

Create a PLC ladder diagram for the Boolean expressions in the following problems. 49. 50. 51. 52. Y = (A′ + B) + (A′ + B + C′)′ Y = A′B′C + AB′ + A′BC′ Y = B′(A + C) + C(A′ + B) + AC Y = (A′B + AB′) × (A′B′ + AB) + ABC…...

Free Essay

... 2. PROGRAMMABLE LOGIC CONTROLLERS Topics: • PLC History • Ladder Logic and Relays • PLC Programming • PLC Operation • An Example Objectives: • Know general PLC issues • To be able to write simple ladder logic programs • Understand the operation of a PLC 2.1 INTRODUCTION Control engineering has evolved over time. In the past humans were the main method for controlling a system. More recently electricity has been used for control and early electrical control was based on relays. These relays allow power to be switched on and off without a mechanical switch. It is common to use relays to make simple logical control decisions. The development of low cost computer has brought the most recent revolution, the Programmable Logic Controller (PLC). The advent of the PLC began in the 1970s, and has become the most common choice for manufacturing controls. PLCs have been gaining popularity on the factory floor and will probably remain predominant for some time to come. Most of this is because of the advantages they offer. • Cost effective for controlling complex systems. • Flexible and can be reapplied to control other systems quickly and easily. • Computational abilities allow more sophisticated control. • Trouble shooting aids make programming easier and reduce downtime. • Reliable components make these likely to operate for years before failure. 2.1.1 Ladder Logic Ladder logic is the main programming method used for PLCs. As mentioned before, ladder logic has been......

Words: 3478 - Pages: 14

Free Essay

...Programming Logic and Design, 6th Edition Chapter 2 Exercises 1. Explain why each of the following names does or does not seem like a good variable name to you. Answer: Answers will vary. A possible solution: a. | c | – | Valid, but probably too short to be descriptive | b. | cost | – | Good | c. | costAmount | – | Good, but redundant | d. | cost amount | – | Invalid, spaces aren’t allowed | e. | cstofdngbsns | – | Valid, but difficult to read | f. | costOfDoingBusinessThisFiscalYear | – | Valid, but long and awkward | g. | costYear2012 | – | Good | h. | 2012YearCost | – | Invalid, cannot start with a digit | 17 2. If myAge and yourRate are numeric variables, and departmentName is a string variable, which of the following statements are valid assignments? If a statement is not valid, explain why not. Answer: a. | myAge = 23 | – | Valid | b. | myAge = yourRate | – | Valid | c. | myAge = departmentName | – | Invalid, cannot assign string to numeric | d. | myAge = “departmentName” | – | Invalid, cannot assign string to numeric | e. | 42 = myAge | – | Invalid, cannot assign a value to a literal constant | f. | yourRate = 3.5 | – | Valid | g. | yourRate = myAge | – | Valid | h. | yourRate = departmentName | – | Invalid, cannot assign string to numeric | i. | 6.91 = yourRate | – | Invalid, cannot assign a value to a......

Words: 1719 - Pages: 7

Premium Essay

...Programming Logic and Design, 6th Edition Chapter 5 Exercises 1. What is output by each of the pseudocode segments in Figure 5-22? Answer: a. 5, 22, 5 b. 4, 6, 7 c. 5, 6 d. Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye e. Hello Hello Hello f. Adios Adios Adios Adios Adios Adios Adios Adios 2. Design the logic for a program that outputs every number from 1 through 10. Answer: A sample solution follows Flowchart: Pseudocode: start Declarations num number housekeeping() number = 1 while number 99999 output “Please enter a valid zip code” input custZip endwhile return validateCustAge() while custAge < 10 OR custAge > 110 output “Please enter a valid customer age” input custAge endwhile return validateNumItems() Declarations num attempts = 0 num LIMIT = 2 validNumItems = 1 while (numItems < 1 OR numItems > 12) AND attempts < LIMIT output “Please reenter the number of items” input numItems attempts = attempts + 1 endwhile if attempts = 2 AND numItems < 0 then output “An invalid number of items was entered” output “This order will not be counted” validNumItems = 0 endif return housekeeping() output ZIP_PROMPT input custZip return detailLoop() output AGE_PROMPT input custAge output ITEM_PROMPT input......

Words: 1493 - Pages: 6

Free Essay

...device with the help of PLC which can control automatically the devices connected with it, the PLC we are using is Siemens LOGO module, we control the street light, home appliances, Lamp Flasher, and star delta starter. The PLC helps us in automatic control of devices with its output signal; we can also provide the time delay using timers. 1 3. Purpose of the Project: An engineer discovers new ideas and identifies opportunities in various sectors of national economy. He explores the possibilities of starting adventures infield of agriculture, trade, industry, transport and communication etc. An engineering project is a combination of numerous activities on the part of entrepreneurs, organizers, designers, workers and etc. The engineer is the key element in any project work and it is not possible to attain success for every engineer. An engineer should possess certain qualities and characteristics to achieve success in project or task undertaken. The characteristics which contribute to engineer’s success in his Technical competence, better judgment, intelligence, leadership, self-confidence, attitude of creativeness, honesty and emotional Stability. The purpose of this project is to save the power and save electricity with automatic control of devices with Programmable Logic Controller. 3.1.Learning Objectives: Develop a basic understanding on the following concepts: 1. To know about the Programmable Logic Control. 2. To learn the interfacing of PLC with hardware. 3.......

Words: 5909 - Pages: 24

Premium Essay

...use it as a default structure in creating two deviating figures from having Boolean system incorporated as such “If” and “then” structures that will correlate into having a rhetorical questions answerable by “yes” and “no” structure. As the plain yes or no and true or false play into scene the chart and figure moves apart as desired answers have certain consequences built. The yes or no and true or false structure will outline two deviating answers to each other that separates each other apart. This create the uniqueness in the flow diagram. As this goes, we create a flow diagram, in such we are able to see where the program will lead us. The advantage of using Pseudocode is that it does not use any syntax or structures within its programming realm. It is easy to understand because it is readable in plain text with the written flow of what needed to be applied in the program that is later applied in the flow diagram. In so speaking, any layman with no experience in computer programs would be able to read the Pseudocode system....

Words: 412 - Pages: 2

Free Essay

...Personal Learning Management University of Phoenix Algorithms and Logic for Computer Programming PRG 211 Professor Sam March 07, 2013 Personal Learning Management Being able to develop a management tool that would allow a user or student to review course material would be very beneficial. With a course such as programming that has so much information, it is important to be able to recall information in order to properly understand how programming works. I for example, do not have any prior knowledge of so I would have to continuously refresh the information that I have learn in the reading as well as in the class room environment. I will be discussing some topics that are important to the development of such a program. In order to properly develop an application, we must first address and analyze the problem that has caused this need. In this situation, we want to design an application that will allow students to be able to review reading assignments as well as task or anything that would be beneficial to retain. Some subjects are a harder to remember than others such as programming. Modular programming would be the best fit because we would want everyone to read the material in the same order. We would set up the program so everyone’s view is the same. If we allow people to “jump around” in the programming, some learning material is going to be skipped over and that would defeat the purpose of the development of this application. Submodules would be......

Words: 480 - Pages: 2

Premium Essay

...7.a 8. b 9. c 10. a 11. b 12. c 13. a 14. d 15. b T/F Questions 1 – 12, p.115 (12 pts. total – 1 pt. ea.) 1. f 2. t 3. t 4. f 5. t 6. f 7. f 8. t 9. t 10.f 11. t 12. f Algorithm Workbench #1 - #7, pp.115-6 – Write pseudocode (not Java) (21 pts. total) 1. Module Main() Declare userNum as Integer Display "Enter a number" input userNum call TimesTen(userNum) Display userNum End Function TimesTen(integer userNum) userNum = (userNum * 10) return userNum End Function Algorithm Workbench #1 - #7, pp. 115-6 (continued) – Write pseudocode (not Java) 2. def main(): showvalue() def showvalue(): print '12' main() 3. The value stored in ‘a’ will be: 3 The value stored in ‘b’ will be: 2 The value stored in ‘c’ will be: 1 4. Declare Integer age Declare Real income Declare String name Call Module1 (agem Real_Income, Name) 5. 6. 7. Debugging Exercises, p.117 (3 pts. Ea. / 12 pts. Total ) 1. 2. 3. 4. Programming Exercises, (#1 - p.117) (10 points total) #1. Kilometer Converter Design a modular program that asks the user to enter a distance in kilometers, and the converts that distance to miles. The conversion formula is as follows: Miles = Kilometers * 0.6214 Additional Instructions: 1. Design using pseudocode. 2. Use the following module names: getKilometers – read kilometers from user keyboard input and store in......

Words: 645 - Pages: 3

Free Essay

...Constraint Logic Programming in Prolog: Hanjie Puzzle Solver Lu´ Cleto and Jo˜o Marinheiro ıs a FEUP-PLOG, Turma 3MIEIC05, Group 23 {ei11077,ei11129}@fe.up.pt http://www.fe.up.pt Abstract. The purpose of this project was to use constraint logic programming in Prolog to implement a solver for the 2D puzzle, Hanjie. For this purpose we used the clp(FD) library provided by SICStus Prolog 4.2.3, speciﬁcally the sum/3 and automaton/3 combinatorial constraints. The program we developed is able to solve puzzles with dimensions up to 88x88, with only one possible solution, in less than one second. When there are multiple solutions, the execution time for the obtaining the ﬁrst solution varies with the number of possible solutions. These results show that the execution time of the program is primarily aﬀected by the amount of possible results. While larger grid dimensions do increase the execution time, the increase is linear if the number of possible solutions is maintained. On the other hand, increasing the number of possible solutions will lead to an exponential growth in execution time. 1 Introduction The goal of this project is to use constraint logic programming in Prolog to develop a logic program capable of solving a decision problem in the form of the 2D puzzle, Hanjie. This puzzle consists of a rectangular grid with ’clues’ on top of every column and to the left of every row that indicate the number and length of gray blocks in that column/row. To achieve this goal, ﬁrst...

Words: 9959 - Pages: 40

Premium Essay

...ate Aptitude Test in Engineering GATE 2014 Brochure Table of Contents 1. Introduction .............................................................................................................1 2. About GATE 2014 ......................................................................................................1 2.1. Financial Assistance ............................................................................................................................ 1 2.2 Employment ............................................................................................................................................ 2 2.3 Administration ....................................................................................................................................... 2 3.1 Changes Introduced in GATE 2013 that will continue to remain in force for GATE 2014 .......................................................................................................................................................... 3 4.1 Eligibility for GATE 2014 ................................................................................................................... 4 4.2 GATE Papers ............................................................................................................................................ 5 4.3 Zone-Wise List of Cities in which GATE 2014 will be Held ................................................... 6 4.4 Zone-Wise List of Cities for 3rd...

Words: 32784 - Pages: 132

Free Essay

...1.2.1.AK Combinational Logic Design Introduction Combinational and sequential logic are the fundamental building blocks of digital electronics. Combinational logic, which is sometimes referred to as "combinatorial logic”, is characterized by its output being a function of the current input value. A variety of different logic gates can be used to implement combinational logic circuits. Many of these gates will be studied in future units of this course. In this introductory unit, we will limit our designs to AND, OR, and INVERTER gates for the sake of simplicity. In this activity you will use the Circuit Design Software (CDS) to build and test your first combinational logic circuits. Equipment * Circuit Design Software (CDS) Procedure Now it’s time for you to implement your first AOI combinational logic circuit. The circuit that we will use for this purpose is a Car Safety Buzzer design.The design specifications are as follows: The buzzer is on whenever the door is open or when the key is in the ignition and the seat belt is not buckled. 1. Create a table that describes these design specification in terms of “highs” (1) and “lows” (0). This is when the sensor or indicator is active or not active. Seat Belt | 0 = SEAT BELT NOT BUCKLED | | 1 = SEAT BELT BUCKLED | Key | 0 = KEY NOT IN THE IGNITION | | 1 = KEY IN THE IGNITION | Door | 0 = DOOR IS NOT OPEN | | 1 = DOOR IS OPEN | Buzzer | 0 = BUZZER is OFF | | 1 = BUZZER is ON | 2.......

Words: 690 - Pages: 3

Free Essay

...engineering as a method is not confined to any particular purpose, but is often an important part of the scientific method and technological development. The process of taking something apart and revealing the way in which it works is often an effective way to learn how to build a technology or make improvements to it. When reverse engineering software, researchers are able to examine the strength of systems and identify their weaknesses in terms of performance, security, and interoperability. The reverse engineering process allows researchers to understand both how a program works and also what aspects of the program contribute to its not working. • What are the advantages and disadvantages of using reverse engineering to discover the logics of a software program? Reverse engineering in software is reversing a program's machine code back into it's original source code. The advantages to using this technique is that one can repair certain bugs, see how a program operates, and improve the operation of the program. The disadvantage is that certain other bugs may be introduced during this process. • Find any one tool available to perform reverse engineering of software programs. What are at least five features of that tool? REC Studio 4 - Reverse Engineering Compiler Multihost: Rec Studio runs on Windows XP/Vista/7, Ubuntu Linux, Mac OS X. Symbolic information support using Dwarf 2 and partial recognition of Microsoft's PDB......

Words: 301 - Pages: 2

Premium Essay

...Purpose: Calculate the result of a number raised to the power of another number input by the user using iterative logic without overflow of 32-bit integers## //Program start// START //declare variables // declare unsigned int base, exp, answer, errorInput, errorOutput Declare var string exit Global var constant int multiply = 1, maxValue = 2147483647 Set answer = 1 Set base = 1 Set exp = 1 // determine if input fits in unsigned 32 bit int and set exit sentinel // //welcome message// Display “This program will determine the value of an integer (X) raised to the power of a second integer (N).” WHILE exit !=n //set repeat of input if error message is flagged and reset error flags// DO SET errorInput = 0 Set errorOutput = 0 //user input prompts// Display “Please Enter first integer: “ Input base Display “Please enter second integer: ” Input exp IF (base,exp) >= maxValue THEN //error message// Display “ Error! Value exceeds maximum available input. Please enter a value less than 2147483647” SET errorInput = 1 END IF WHILE errorInput = 1 //perform calculation with iterative multiplication// //check for error outputs & unneccessary execution of loop// IF exp != 0 THEN FOR (errorOutput ! =1 && multiply maxValue THEN SET errorOutput = 1 END IF END FOR //end calculation and check for maximum value......

Words: 266 - Pages: 2

Free Essay

...Programmable Logic Controllers: Programming Methods and Applications by John R. Hackworth and Frederick D. Hackworth, Jr. Table of Contents Chapter 1 - Ladder Diagram Fundamentals Chapter 2 - The Programmable Logic Controller Chapter 3 - Fundamental PLC Programming Chapter 4 - Advanced Programming Techniques Chapter 5 - Mnemonic Programming Code Chapter 6 - Wiring Techniques Chapter 7 - Analog I/O Chapter 8 - Discrete Position Sensors Chapter 9 - Encoders, Transducers, and Advanced Sensors Chapter 10 - Closed Loop and PID Control Chapter 11 - Motor Controls Chapter 12 - System Integrity and Safety Preface Most textbooks related to programmable controllers start with the basics of ladder logic, Boolean algebra, contacts, coils and all the other aspects of learning to program PLCs. However, once they get more deeply into the subject, they generally narrow the field of view to one particular manufacturer's unit (usually one of the more popular brands and models), and concentrate on programming that device with it's capabilities and peculiarities. This is worthwhile if the desire is to learn to program that unit. However, after finishing the PLC course, the student will most likely be employed in a position designing, programming, and maintaining systems using PLCs of another brand or model, or even more likely, many machines with many different brands and models of PLC. It seems to the authors that it would be more advantageous to approach......

Words: 73061 - Pages: 293

Premium Essay

...Introduction to Programming Logic Phillip M. Ragland June 20, 2016 Individual Projects Document Noura Abbas Individual Project 1 There are many steps and processes to consider when designing a website for a customer. Regardless if the customer is an individual or a large corporation, the steps and processes for designing a website are pretty much the same. Each website that is designed with similar specifications. However, when it comes to the design aspects of a website, it will differ greatly from customer to customer. Some of the cues that determine the design of the website are the intended purpose of the website, the intended audience of the website, and of course the desire of the customer it is being designed for. Here are some basic steps and processes for the design of a website: 1). Gathering information from the customer 2). Planning 3). Design 4). Development 5). Testing and delivery 6). Maintenance (iDesign Studios, 2016). The first step (phase) for designing a website is to gather information. When gathering information, you will need to ask a lot of questions. Question such as what id the purpose of the website? Who is the audience of the website? What is the intended accomplishment of the website? Many such questions as these will need to address. The next step (phase) is planning. During the planning step, you will use the information that was gathered during the 1st phase to begin to......

Words: 1820 - Pages: 8

Free Essay

...Programming Solution Part 3: Array Structure Proposal Wayne Murray Algorithms and Logic for Computer Programming (PRG 211) November 14, 2011 Professor Sprouse Array Structure Proposal In my proposal from week two I would want to find the total number of units per patient for each procedure code billed by the doctor. A parallel array consisting of a one-dimensional and a two-dimensional array in this case would be a good way to solve this problem in a simplified code format. An array would also allow all the data the user wants to input to be stored in the program for multiple queries to be run without having to re-input the data. So this module of the program will allow the user to input all the different procedure codes billed the provider and return a units-per-patient statistic for the searched procedure code. Assuming the data that the user will input is all for the same provider, the following variables will need to be declared: the procedure code, the number of patients, and the number of units billed. Two arrays will be declared as well, one for the procedure code and one for the number of patients and units. The procedure code variable and array must be setup with a string data type since there are some procedure codes that have alpha characters. The number of patients and the number of units variables, as well as their corresponding array will be setup as integer data types. Since both of those variables are of the same data type they can be combined......

Words: 728 - Pages: 3