Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 10 of 29

1772 Mini PLC-2/05 Processor (Cat. No. 1772-LS, LSP) Programming and Operations Manual, pages 91 to 100

Pages 91 to 100 of 289

The original document is the PDF (1.4 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 1772-LSP

Page 91

Chapter 10 Math Instructions

Multiplication Reports the product of two values stored in the Get instruction words immediately preceding the multiply instruction. Programmed in the output position of the ladder diagram. The product is stored in two multiplication instruction words. The first word contains the most significant digit and the second word contains the least significant digit. If the product is less than six digits, leading zeros appear in the product. 130 G 123

131 G 061

051 X 007

052 X 503

Important: Use consecutive word addresses for the two addresses of the multiply instruction. Division Reports the quotient of two values stored in the two Get instructions immediately preceding division instruction. Programmed in the output position of the ladder diagram rung. The quotient is stored in two divide instruction words. The first word contains the most significant word and the second word contains the least significant digit. 140 G 050

141 G 025

066

067

002

000

Important: Use consecutive word addresses for the two addresses of the divide instruction. Quotient is expressed as a decimal, accurate to 3 decimal places. Any remaining data is rounded. Division by zero (including 0 : 0) gives the result of 999.999. This result differs from the PLC-2/20 and PLC -2/30 controllers where 0.0 = 1.000. 140 G 000

141 G 000

066

067

999

999

Keystrokes: You enter a three-digit math operation by performing the following keystrokes. 1.

Start the rung. Press -[G]-.

2.

Enter <address>.

3.

Enter <data> if appropriate.

4.

Press -[G]-.

5.

Enter <address>. 10-3

Page 92

Chapter 10 Math Instructions

6.

Enter <data> if appropriate.

7.

Close the rung by pressing the appropriate math instruction key (Table 10.B). Table 10.B Three Digit Math Functions

8.

Addition

-( + )-

Subtraction

-( - )-

Multiplication

-( x )-

Division

-( ÷ )-

Enter <address(es)>.

Editing a Completed Rung You edit a three digit math operation to change an address or the instruction type by performing the following steps.

Expanded Math

1.

See chapter 9 and follow the editing procedure for a Get instruction.

2.

Position the cursor over the math function.

3.

Press the appropriate instruction type key.

4.

Enter <address(es)>.

The processor can perform four math operations involving two operands: Addition Subtraction Multiplication Division

A+B=C A-B=C AxB=C A÷B=C

The processor can perform three additional operations that involve only one operand, the equations are: Square Root

A=C

Conversion (BCD to Binary)

E (BCD) = F (Binary)

Conversion (Binary to BCD)

F (Binary) = E (BCD)

You solve these equations with expanded math operations using the EAF function of your processor. Figure 10.1 shows operand and result locations in a ladder diagram rung. 10-4

Page 93

Chapter 10 Math Instructions

Figure 10.1 Primary Ladder Diagram for EAF Addition 050 G 000

051 G 000

052 G 000

053 G 000

Operand B

Start Executive Aux Function Function Number: Data Addr: Result Addr:

01 040 060

Operand A Result (Term C)

Data Address The data address (operand A) is the starting address of four consecutive data table words that contain the: augend minuend multiplicand dividend root conversion word The data table can also contain a default value when performing square roots and conversions. The default value directs the processor to get its data from the rung. The operand has a format like that shown in Figure 10.2. Enter the instructions for operand A from the keyboard of the 1770-T3 industrial terminal or through ladder diagram instructions. Once you select the data address(s), the EAF automatically reserves the next three addresses (four total) for the remaining words.

10-5

Page 94

Chapter 10 Math Instructions

Figure 10.2 Data Address Format Operand A is stored in the data table like this: 17 16 15 14 13

10 7

4

3

0

X

S

X

X

M

L

K

Integer High Word

X

X

X

X

J

H

G

Integer Low Word

X

X

X

X

F

E

D

Decimal High Word

X

X

X

X

C

B

A

Decimal Low Word

Operand A is displayed in the 1770-T3 industrial terminal like this: M

L

K

J

H

G

F

E

D

C

B

A

• implied and not displayed. S = Sign Bit X = Additional Storage Bits

Important: Valid data addresses include the I/O image table and the data table (except word 027). Specifically, valid addresses are from 010 to 026, from 030 to 077, and from 110 to the end of the data table. Data addresses and result addresses must not reside in the input image table. The most significant four bits of the integer high word of the data address (Figure 10.2) are reserved for status bits. bit 17 - not used bit 16 - sign (+/-) bit 15 - not used bit 14 - not used There is an implied decimal point between the integer low word and the decimal high word. The decimal point is implied but not displayed (Figure 10.2).

10-6

Page 95

Chapter 10 Math Instructions

Conditioning Instructions The conditioning instructions (operand B) may require up to four data table words (Figure 10.2). We use Get instructions to enter data for operand B that can contain an: addend subtrahend multiplier divisor root conversion word Operand B has the format xxx xxx.xxx xxx. Enter it from the keyboard of the 1770-T3 industrial terminal or through ladder diagram instructions. The number you enter has a fixed decimal point. To include the range of numbers between 999 999.999 999 to 000 000.000 000 requires 12 bits from each of the four data words. To enter the number MLK takes only one get or one data table word. G +\ - MLK

XXX MLK . XXX XXX

To enter the number MLK JHG takes two gets or two data words. G G +\ - MLK JHG

MLK JHG . XXX XXX

To enter the number MLK JHG.FED takes three gets or three data table words. G G G +\ - MLK JHG FED

MLK JHG . FED XXX

To enter the number MLK JHG.FED CBA takes four gets or data table words. G G G G +\ - MLK JHG FED CBA

MLK JHG . FED CBA

Access an expanded math function by pressing [SHIFT][EAF] or [SHIFT][SCT]. The EAF instruction is an output instruction and must be preceded by the gets of operand B. This operand may be preconditioned but nothing can be programmed between the gets and the EAF instruction. Should you program five gets, the last four gets are the only ones to be processed. The four gets need not have consecutive addresses. They can have any address except 000-007 and 100-107 in the processor work area. 10-7

Page 96

Chapter 10 Math Instructions

Figure 10.3 Result Address Format Result Address 17 16 15 14 13 o X S Z u

10 7

4

3

0

M

L

K

N

X

X

X

X

J

H

G

N + 1

X

X

X

X

F

E

D

N + 2

X

X

X

X

C

B

A

N + 3

Operand A is displayed i the 1770-T3 industrial terminal like this: M

L

K

J

H

G

F

E

D

C

B

A

S = Sign Bit Z = Zero Indicator o = Overflow/Underflow u X = Additional Storage Bits

Result Address The result address (term C) is the starting address of four consecutive data table words that contain the: sum difference product quotient root converted word The result word has the format shown in Figure 10.3. The format is similar to the data address except that there are three status bits. Once you select the result address, the EAF instruction automatically reserves the next three addresses for the remaining words of the result (Figure 10.3). Be careful not to select data and result addresses so close together that the addresses of the operands following the data address overlap the result address. bit 17 - not used bit 16 - sign bit: 0 = positive (+), 1 = negative (-) bit 15 - zero indicator: 0 = non-zero; 1 = zero result 10-8

Page 97

Chapter 10 Math Instructions bit 14 - overflow/underflow/illegal bit; significance depends on the arithmetic operation being performed at the time overflow (addition) - set indicates result exceeds displayable result overflow (subtraction) - set indicates result exceeds displayable result overflow or underflow (multiplication) - set indicates result exceeds displayable result illegal (division) - set indicates division by zero or result exceeds result word range In this section, unused status bits are shown blank for the following reasons: Whether the content of an unused status bit in an input word is 0 or 1 is irrelevant as such bits are ignored in EAF instruction execution. The EAF instruction reset unused status bits in result words. For simplicity the bits are left blank. The processor can “chain” the results of the last executed EAF instruction with the current EAF instruction. You can use the last result as either the augend, minuend, multiplicand or dividend. Or, you can also use the last result as either the addend, subtrahend, multiplier or divisor.

Branch Instructions The least amount of instructions required to make the processor execute an EAF instruction is shown in Figure 10.1. The instructions composing the three terms A, B, and C are probably in different locations of your ladder diagram. Chances are that you would never see them. You can monitor the values in these instructions using the ladder diagram shown in Figure 10.4. The ladder diagram serves two purposes. It contains both the least amount of instructions required to execute an EAF instruction and display branches. Therefore, you have a choice of using either one of two ladder diagrams to execute an EAF instruction. These two ladder diagrams are named: primary optional

10-9

Page 98

Chapter 10 Math Instructions

Figure 10.4 Optional Ladder Diagram for EAF Addition

Result

Operand A

Operand B

060 G 000 040 G 000 050 G 000

061 G 000 041 G 000 051 G 000

062 G 000 042 G 000 052 G 000

063 G 000 043 G 000 053 G 000

Start Executive Aux Function Function Number: Data Addr: Result Addr:

01 040 060

In the optional ladder diagram (Figure 10.4), the first branch contains the result (term C). The second branch contains the data address or operand A (term A). The third branch contains operand B (term B).

Function Numbers To program a specific operation, enter the appropriate function number (Table 10.C). This entry identifies a specific EAF math operation. Table 10.C EAF Function Numbers Function Number 01 02 03 04 05 13 14

Mathematical Operation Add Subtract Multiply Divide Square Root BCD to Binary Binary to BCD

Error Handling Two types of run-time errors can occur when you use EAF instructions. They are illegal opcode and illegal address errors. An illegal opcode occurs if you enter a function number other than 1, 2, 3, 4, 5, 13, or 14. An illegal address error occurs if the operand pointed to by the data address or if the result pointed by the result address is located in the processor’s work areas or in the program areas.

10-10

Page 99

Chapter 10 Math Instructions

Expanded Math Operations Your processor executes the following expanded math operations and maintains the proper sign of the result: addition subtraction multiplication division BCD to binary conversion Binary to BCD conversion square root (not a signed function)

Addition, Subtraction, Multiplication, and Division Addition Reports the sum (result address) of the augend (operand A, the data address) and the addend (operand B, the conditioning gets). The addition function uses up to 12 digits for each operand. When the sum exceeds 999 999.999 999, the overflow bit (bit 14) in the result address word is set. 060 G 000 040 G 000 050 G 000

061 G 000 041 G 000 051 G 000

062 G 000 042 G 000 052 G 000

063 G 000 043 G 000 053 G 000

Start Executive Aux Function Function Number: Data Addr: Result Addr:

01 040 060

Important: If an overflow value is used for subsequent comparisons or other arithmetic operations, inaccurate results could occur. Subtraction Reports the difference (result address) between two operands, a minuend (data address) and subtrahend (conditioning gets). The operands can use up to 12 digits. 060 G 000 040 G 000 050 G 000

061 G 000 041 G 000 051 G 000

062 G 000 042 G 000 052 G 000

063 G 000 043 G 000 053 G 000

Start Executive Aux Function Function Number: Data Addr: Result Addr:

02 040 060

10-11

Page 100

Chapter 10 Math Instructions

Multiplication Reports the product (result address) of a multiplicand (data address) and a multiplier (conditioning gets). Operands can only be six digits. 060 G 000 040 G 000 050 G 000

061 G 000 041 G 000 051 G 000

062 G 000 042 G 000 052 G 000

063 G 000 043 G 000 053 G 000

Start Executive Aux Function Function Number: Data Addr: Result Addr:

03 040 060

Division Reports the quotient (result address) of a dividend (data address) and a divisor (conditioning instructions). 060 G 000 040 G 000 050 G 000

061 G 000 041 G 000 051 G 000

062 G 000 042 G 000 052 G 000

063 G 000 043 G 000 053 G 000

Start Executive Aux Function Function Number: Data Addr: Result Addr:

04 040 060

Important: The quotient has at least six decimal digits. Any remaining data is rounded. Division of a number by zero (including 0 : 0) gives the result of 999.999 and the illegal bit is set. Primary Ladder Diagram Keystrokes: You enter the instructions for a primary ladder diagram to execute an addition, subtraction, multiplication, or division operation by performing the following steps.

10-12

1.

Open the rung. Press -[G]-.

2.

Enter <address>.

3.

Enter <data> if appropriate.

4.

Press -[G]-.

5.

Enter <address>.

6.

Enter <data> if appropriate.

7.

Press -[G]-.

8.

Enter <address>.