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

The text of a manual · part 33 of 55

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

Pages 285 to 292 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 285

Chapter 20 Math Instructions

Double Divide (DDV)

Double Divide

DDV

Output Instruction

HHT Ladder Display:

(DDV)

HHT Zoom Display: (online monitor mode)

ZOOM on DDV –(DDV)– NAME: DOUBLE DIVIDE SOURCE: N7:0 9 DEST: N7:1 5000

2.3.0.0.2

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: DDV DOUBLE DIVIDE Source N7:0 9 Dest N7:1 5000

The contents of the math register are divided by the source value. The rounded quotient is placed in the destination. If the remainder is 0.5 or greater, round up occurs in the destination. The unrounded quotient is placed in the most significant word of the math register. The remainder is placed in the least significant word of the math register.

Using Arithmetic Status Bits C always reset V set if division by zero or if the result is greater than 32,767 or less than –32,768; otherwise reset. On overflow, the minor error flag is also set. The value 32,767 is placed in the destination. Z set if the result is zero; otherwise reset S set if the result is negative; otherwise reset; undefined if overflow is set

Math Register Initially contains the dividend of the DDV operation. Upon instruction execution the unrounded quotient is placed in the most significant word of the math register. The remainder is placed in the least significant word of the math register.

20–9

Page 286

Chapter 20 Math Instructions

Negate (NEG)

Negate

NEG

Output Instruction

HHT Ladder Display:

(NEG)

HHT Zoom Display: (online monitor mode)

ZOOM on NEG –(NEG)– NAME: NEGATE SOURCE: N7:0 DEST: N7:1

2.3.0.0.2 98 –98

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: NEG NEGATE Source Dest

N7:0 98 N7:1 –98

The source value is subtracted from 0 and then stored in the destination. (The destination contains the 2’s complement of the source.)

Using Arithmetic Status Bits C cleared if 0 or overflow, otherwise set. V set if overflow, otherwise reset. On overflow, the minor error flag is also set. The value 32,767 is placed in the destination. Exception: If you are using a Series C or later SLC 5/02 processor and have the Math Overflow Selection Bit S:2/14 set, then the unsigned, truncated overflow remains in the destination. Z set if the result is zero; otherwise reset. S set if the result is negative; otherwise reset.

Math Register Unchanged.

20–10

Page 287

Chapter 20 Math Instructions

Clear (CLR)

Clear

CLR

HHT Ladder Display:

(CLR)

HHT Zoom Display: (online monitor mode)

ZOOM on CLR –(CLR)– NAME: CLEAR DEST: N7:1

Output Instruction

2.3.0.0.2 0

EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: CLR CLEAR Dest

N7:1 0

The destination value is cleared to zero.

Using Arithmetic Status Bits C always reset V always reset Z always set S always reset

Math Register Unchanged.

20–11

Page 288

Chapter 20 Math Instructions

Convert to BCD (TOD)

Convert to BCD

TOD

HHT Ladder Display:

(TOD)

HHT Zoom Display: (online monitor mode)

ZOOM on TOD –(TOD)– NAME: TO BCD SOURCE: N7:0 DEST: S:13

Output Instruction

2.3.0.0.2 557 1367 (decimal)

EDT_DAT F1

F2

F3

F4

F5

Fixed, SLC 5/01 Processors ZOOM on TOD –(TOD)– NAME: TO BCD SOURCE: N7:0 DEST: N7:1

2.3.0.0.2 557 1367 (decimal)

EDT_DAT F1

F2

F3

F4

F5

SLC 5/02 Processors Ladder Diagrams and APS Displays: TOD

TOD

TO BCD Source

TO BCD Source

Dest

N7:0 557 S:13 00000557

Fixed, SLC 5/01 Processors

Dest BCD

N7:0 557 N7:1 0557

BCD

SLC 5/02 Processors

Use this conversion instruction when you want to display or transfer BCD values external to the processor.

Entering Parameters • Source – the address of the value to be converted to BCD. If the integer value you enter is negative, the sign is ignored and the conversion occurs as if the number were positive. The absolute value of the number is used for conversion. • Destination – the address of the location to hold the result of the conversion. With SLC 5/02 processors, the destination parameter can be a word address in any data file, or it can be the math register, S:13 and S:14. With fixed and SLC 5/01 processors, the destination can only be the math register. If the math register is the destination, 32,767 is the maximum value. If a word address is used, 9999 is the maximum value. 20–12

Page 289

Chapter 20 Math Instructions

Using Arithmetic Status Bits C always reset V set if the BCD result is larger than 9999. Overflow results in a minor error. Z set if the destination value is zero S set if the source word is negative; otherwise reset

Math Register (When Used) Contains the 5–digit BCD result of the conversion. This result is valid at overflow. Example 1 (SLC 5/02 Processors Only) The integer value 9760 stored at N7:3 is converted to BCD and the BCD equivalent is stored in N10:0. The maximum BCD value possible is 9999. 9

7

6

0

N7:3 Decimal

9

7

6

0

N10:0 4–digit BCD

0010 0110 0010 0000

1001 0111 0110 0000 9

ZOOM on TOD –(TOD)– NAME: TO BCD SOURCE: N7:3 DEST: N10:0

7

6

0

2.3.0.0.2 9760 –26784

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

EDT_DAT F1

F2

F3

F4

F5

20–13

Page 290

Chapter 20 Math Instructions

Example 2 (Fixed, SLC 5/01, and SLC 5/02 Processors) In the following example, the integer value 32760 stored at N7:3 is converted to BCD. The 5-digit BCD value is stored in the math register. The lower 4 digits of the BCD value is moved to output word O:2 and the remaining digit is moved thru a mask to output word O:3. When using the math register as the destination parameter in the TOD instruction, the maximum BCD value possible is 32767. However, for BCD values above 9999, the overflow bit is set, resulting in minor error bit S:5/0 also being set. Your ladder program can unlatch S:5/0 before the end of the scan to avoid major error 0020, as done in this example. This example will output the absolute value (0–32767) contained in N7:3 as 5 BCD digits in output slots 2 and 3.

3 2 7 6 0

0

0

0

15 S:14

3

2

0

15

7

6

ZOOM on TOD –(TOD)– NAME: TO BCD SOURCE: N7:3 DEST: S:13

N7:3 Decimal

0

2.3.0.0.2 32760 10080

S:13 & S:14 5–digit BCD

0

EDT_DAT

S:13

F1

F2

F3

F4

F5

Destination is displayed as 10080, decimal (equivalent to 2760 BCD). TOD TO BCD Source

] [

Dest

N7:3 32760 S:13 00032760

APS displays S:13 and S:14 in BCD.

Overflow bit S:5 (U) 0

S:0 ] [ 1

Minor Error Bit

MOV MOVE Source Dest

S:13 10080 O:2.0 10080

0010 0111 0110 0000 2

7

6

0

MVM MASKED MOVE Source Mask Dest

S:14 3 000F O:3.0 3

0000 0000 0000 0011 3

20–14

Page 291

Chapter 20 Math Instructions

Convert from BCD (FRD)

Convert from BCD

FRD

Output Instruction

HHT Ladder Display:

(FRD)

HHT Zoom Display: (online monitor mode)

ZOOM on FRD –(FRD)– NAME: FROM BCD DEST: N7:1 SOURCE: S:13

2.3.0.0.2 557 1367 (decimal)

EDT_DAT F1

F2

F3

F4

F5

Fixed, SLC 5/01 Processors ZOOM on FRD –(FRD)– NAME: FROM BCD SOURCE: N7:0 DEST: N7:1

2.3.0.0.2 9760 (decimal) 2620

EDT_DAT F1

F2

F3

F4

F5

SLC 5/02 Processors Ladder Diagrams and APS Displays: FRD

FRD

FROM BCD Source

FROM BCD Source

Dest

S:13 00000557 N7:1 557

Fixed, SLC 5/01 Processors

BCD Dest

N7:0 2620 N7:1 2620

BCD

SLC 5/02 Processors

Use this instruction when you want to convert BCD values to integer or decimal values.

Entering Parameters • Source – word address of the value in BCD to be converted to integer/decimal. With SLC 5/02 processors, the source parameter can be a word address in any data file, or it can be the math register, S:13. With fixed and SLC 5/01 processors, the source can only be the math register. If the math register is the source, 32,767 is the maximum value. If a word address is used, 9999 is the maximum value.

• Destination – word address to contain the converted decimal/integer value.

20–15

Page 292

Chapter 20 Math Instructions

Using Arithmetic Status Bits C always reset V set if a non-BCD value is contained at the source or the value to be converted is greater than 32,767; otherwise reset. Overflow results in a minor error. Z set when destination value is zero S always reset

Math Register (When Used) Used as the source for converting the entire number range of a register.

Ladder Logic Filtering of BCD Input Devices We recommend that you always provide ladder logic filtering of all BCD input devices prior to executing the FRD instruction. The slightest difference in point–to–point input filter delay can cause the FRD instruction to fault due to conversion of a non–BCD digit. An example of filtering is shown below. S:1 ]/[ 15

EQU

FRD

EQUAL Source A

N7:1

FROM BCD Source

I:2

Source B

I:2

Dest

N7:2

MOV MOVE Source

I:2

Dest

N7:1

The above rungs cause the processor to verify that the value at slot 2 (I:2) remains the same for two consecutive scans before the FRD instruction is executed. This prevents the FRD instruction from converting a non–BCD value during an input value change.

20–16