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

The text of a manual · part 34 of 55

Hand-Held Terminal (Catalog Number 1747-PT1) User Manual: 20 - Math Instructions, pages 293 to 300

Pages 293 to 300 of 486, from Hand-Held Terminal (Catalog Number 1747-PT1) User Manual

The original document is the PDF (1.5 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 1747-PT1

Page 293

Chapter 20 Math Instructions

Example 1 (SLC 5/02 Processors Only) The BCD value 9760 at source N7:3 is converted from BCD and stored in N10:0. The maximum source value is 9999, BCD. ZOOM on FRD –(FRD)– NAME: FROM BCD SOURCE: N7:3 DEST: N10:0

2.3.0.0.2 –26784 9760

Source is displayed as –26784, decimal (equivalent to 9760 BCD).

EDT_DAT F1

F2

F3

F4

F5

9 7 6 0 N7:3 4–digit BCD 1001 0111 0110 0000 9 7 6 0 9 7 6 0 N10:0 Decimal 0010 0110 0010 0000

Example 2 (Fixed, SLC 5/01, and SLC 5/02 Processors) The BCD value 32760 in the math register is converted and stored in N10:0. The maximum source value is 32767, BCD. ZOOM on FRD –(FRD)– NAME: FROM BCD DEST: N10:0 SOURCE: S:13

2.3.0.0.2

Source is displayed as 10080, decimal (equivalent to 32760 BCD).

32760 10080

EDT_DAT F1

F2

F3

0000 0000 0000 0011

15 0

F4

0010 0111 0110 0000

S:14

0

15

0

3

2

0

F5

S:13

0

7

0

6

5–digit BCD

3 2 7 6 0 N10:0 Decimal 0111 1111 1111 1000

You should convert BCD values to integer before you manipulate them in your ladder program. If you do not convert the values, the processor manipulates them as integer and their value is lost. Important: If the math register (S:13 and S:14) is used as the source for the FRD instruction and the BCD value does not exceed 4 digits, be sure to clear word S:14 before executing the FRD instruction. If S:14 is not cleared and a value is contained in this word from another math instruction located elsewhere in the program, an incorrect decimal value will be placed in the destination word. 20–17

Page 294

Chapter 20 Math Instructions

An example of clearing S:14 before executing the FRD instruction is shown below. I:1.0 ] [ 0

MOV MOVE Source Dest

N7:2 4660 S:13 4660

0001 0010 0011 0100

CLR CLEAR Dest

S:14 0

FRD FROM BCD Source Dest

S:13 00001234 N7:0 1234

APS displays S:13 and S:14 in BCD. 0000 0100 1101 0010

When the input condition is set (1), a BCD value (from a 4-digit thumbwheel switch for example) is moved from word N7:2 into the math register. Status word S:14 is then cleared to make certain that unwanted data is not present when the FRD instruction is executed.

20–18

Page 295

Chapter 20 Math Instructions

Decode 4 to 1 of 16 (DCD)

Decode 4 to 1 of 16

DCD

Output Instruction

HHT Ladder Display:

(DCD)

HHT Zoom Display: (online monitor mode)

ZOOM on DCD –(DCD)– 2.3.0.0.2 NAME: DECODE 4 TO 1 OF 16 SOURCE: N7:0 4519 (decimal) DEST: N7:1 128 (decimal)

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: DCD DECODE 4 to 1 of 16 Source N7:0 11A7 Dest N7:1 0000000010000000

Hex Binary

When the rung is true, this output instruction turns on one bit of the destination word. The particular bit that is turned on depends on the value of the first four bits of the source word. See the table below. This instruction can be used to multiplex data. It could be used for applications such as rotary switches, keypads, bank switching, etc. Source Bit

15–04 03 02 01 00 x x x x x x x x x x x x x x x x

0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Destination 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0

0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0

0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0

0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0

0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0

0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0

0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0

0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

20–19

Page 296

Chapter 20 Math Instructions

Entering Parameters • Source – the address that contains the bit decode information. Only the first four bits (0–3) are used by the DCD instruction. The remaining bits may be used for other application specific needs. Change the value of the first four bits of this word to select one bit of the destination word. • Destination – the address of the word to be decoded. Only one bit of this word is turned on at any one time, depending on the value of the source word.

Using Arithmetic Status Bits Unaffected.

Square Root (SQR)

SLC 5/02 Processors Only Square Root

SQR

Output Instruction

HHT Ladder Display:

(SQR)

HHT Zoom Display: (online monitor mode)

ZOOM on SQR –(SQR)– NAME: SQUARE ROOT SOURCE: N7:0 21583 DEST: N7:1 147

2.3.0.0.2

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: SQR SQUARE ROOT Source Dest

N7:0 21583 N7:1 147

When this instruction is evaluated as true, the square root of the absolute value of the source is calculated and the rounded result is placed in the destination. The instruction will calculate the square root of a negative number without overflow or faults. In applications where the source value may be negative, use a comparison instruction to evaluate the source value to determine if the destination may be invalid. 20–20

Page 297

Chapter 20 Math Instructions

Using Arithmetic Status Bits C reserved V always reset Z set when destination value is zero S always reset

Math Register Contents unchanged.

Scale Data (SCL)

SLC 5/02 Processors Only Scale Data

HHT Ladder Display:

HHT Zoom Display: (online monitor mode)

SCL

Output Instruction

(SCL)

ZOOM on SCL –(SCL)– NAME: SCALE SOURCE: N7:0 RATE: 25000 OFFSET: 127 DEST: N7:1

2.3.0.0.2 9760 25000 127 24527

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: SCL SCALE Source

N7:0 9760 Rate [/10000] 25000 Offset

127

Dest

N7:1 24527

20–21

Page 298

Chapter 20 Math Instructions

This instruction can be used to solve linear equations of the form Dest = (Rate/10000) x Source + Offset “Rate” is sometimes referred to as Slope. When the SCL instruction is true, the value at the source address is multiplied by the rate value. The rounded result is added to the offset value and placed in the destination. Example SCL SCALE Source Rate [/10000]

N7:0 100 25000

Offset

127

Dest

N7:1 377

The source 100 is multiplied by 25000/10000 and added to 127. The result 377 is placed in the destination.

Important: In some cases, a mathematical overflow can occur before the offset is added. The overflow sets minor error bit S:5/0. If this bit is not reset in your ladder program before the end of the scan, a major error will be declared.

Entering Parameters The range of values for the following parameters is –32,768 to 32,767.

• Source – This can be a program constant (decimal) or a word address. • Rate – This is the positive or negative value you enter divided by 10,000. It can be a program constant (decimal) or a word address. The rate parameter is limited to a range of –3.2768 to 3.2767. • Offset – This can be a program constant (decimal) or a word address. • Destination – This is a word address containing the linear calulation (Rate/10000) x Source + Offset.

Using Arithmetic Status Bits C reserved V presence of an overflow at the destination is checked before and after the offset value is applied. This bit is set if an overflow is detected; otherwise reset. On overflow, minor error bit S:5/0 is also set and the value –32,768 or 32,767 is placed in the destination. Z set when destination value is zero. S set if the destination value is negative; otherwise reset.

20–22

Page 299

Chapter 20 Math Instructions

Math Register Contents unchanged.

Typical Application – Converting Degrees Celsius to Degrees Fahrenheit Convert degrees Celsius to degrees Fahrenheit. The conversion equation is F = (9/5)C + 32, or F = (1.8)C + 32.

Example: 25 degrees C = 77 degrees F. F = (1.8)25 + 32 = 77. Graphically,

F 100 77

32

25

100

C

To implement the conversion equation F = (1.8)25 + 32 = 77 in the SCL instruction: 1. Place the degrees C value (25 in this case) in the source parameter. 2. The multiplier is 1.8, so place a program constant value of 18000 in the rate parameter. 3. 32 must be added. Place this program constant in the offset parameter. When the SCL instruction goes true, the result will appear in the word address entered in the destination parameter. SCL SCALE Source Rate [/10000]

N7:0 25 18000

Offset

32

Dest

N7:1 77

The source 25 is multiplied by 18000/10000 and added to 32. The result 77 is placed in the destination.

20–23

Page 300

This page is a scan with no text; see it in the PDF.