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

The text of a manual · part 11 of 70

SLC 500 Instruction Set Reference Manual, pages 101 to 110

Pages 101 to 110 of 694

The original document is the PDF (7.2 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-L514

Page 101

Data Handling Instructions

5-5

Use this instruction to convert BCD values to integer values. With Fixed and SLC 5/01 processors, the source can only be the math register. With SLC 5/02 and higher processors, the source parameter can be a word address in any data file, or it can be the math register, S:13.

Convert from BCD (FRD)

Updates to Arithmetic Status Bits FRD From BCD Source N7:58 0156h< Dest N7:59 0<

The arithmetic status bits are found in Word 0, bits 0 to 3 in the status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

Output Instruction

•

•

Table 5.3 Processor Function With this Bit

The Processor

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

sets if 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.

S:0/2

Zero (Z)

sets if destination value is zero.

S:0/3

Sign (S)

always resets.

TIP

S:1 ]/[ 15

We recommend that you always provide ladder logic filtering of all BCD input devices prior to performing the FRD instruction. The slightest difference in point–to–point input filter delay can cause the FRD instruction to overflow due to the conversion of a non-BCD digit.

EQU

FRD

EQUAL Source A

FROM BCD Source

Source B

N7:1 0 I:0.0 0

Dest

I:0.0 0 N7:2 0

MOV MOVE Source

Dest

I:0.0 0 N7:1 0

In the above example, the two rungs cause the processor to verify that the value at I:0.0 remains the same for two consecutive scans before it executes the FRD. This prevents the FRD from converting a non–BCD value during an input value change. Publication 1747-RM001G-EN-P - November 2008

Page 102

5-6

Data Handling Instructions

To convert numbers larger than 9999 BCD, the source must be the Math Register (S:13). You must reset the Minor Error bit (S:5/0) to prevent an error.

TIP

Changes to the Math Register, S:13 and S:14 Used as the source for converting the entire number range of a register.

Example 1 The BCD value 9760 at source N7:3 is converted and stored in N10:0. The maximum source value is 9999, BCD.

FRD FROM BCD Source Dest

Publication 1747-RM001G-EN-P - November 2008

The source value is displayed in BCD format.

N7:3 9760 N10:0 9760

9

7

6

0

N7:3

4-digit BCD

1001

0111

0110

0000

9

7

6

0

N10:0

Decimal

0010

0110

0010

0000

Page 103

Data Handling Instructions

5-7

Example 2 The BCD value 32760 in the math register is converted and stored in N7:0. The maximum source value is 32767, BCD.

FRD FROM BCD Source Dest

S:14 0000 15 0

0000 0000 0011 0 0 0 3

3

S:13 00032760 N7:0 32760

S:13 and S:14 are displayed in BCD format.

S:13 0010 0111 0110 0000 15 0 5-digit BCD 2 7 6 0

2

7

6

0

N7: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 integers and their value is lost.

TIP

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.

Publication 1747-RM001G-EN-P - November 2008

Page 104

5-8

Data Handling Instructions

Clearing S:14 before executing the FRD instruction is shown.

I:1 ] [ 0

MOV MOVE Source

N7:2 4660 S:13 4660

Dest

0001 0010 0011 0100

CLR CLEAR Dest

S:14 0

FRD FROM BCD Source Dest

S:13 00001234 N7:0 1234

S:13 and S:14 are displayed in BCD format. 0000 0100 1101 0010

When the input condition is set (1), a BCD value (transferred from a 4-digit thumb wheel 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.

Radian to Degrees (DEG)

Source * 180/Π where Π = 3.141592

DEG Radians to Degrees Source N7:60 0< Dest N7:61 0<

Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

Use this instruction to convert radians (source) to degrees and store the result in the destination. The following formula applies:

•

Example: Convert 3 radians to degrees. Using ratio where 180° = Π in radians, we have:

•

Output Instruction

180 -------Π

--x = 180 -------3 Π

180 x = 3 ⎛ --------⎞ ⎝ Π⎠ x = 171.89 degrees

Entering Parameters • Source is the integer and/or floating point values. • Destination is the address of the word where the data is to be stored.

Publication 1747-RM001G-EN-P - November 2008

Page 105

Data Handling Instructions

5-9

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the status file. After an instruction is executed, the arithmetic status bits in the status file are updated. Table 5.4 Processor Function

Degrees to Radians (RAD)

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

sets if overflow generated or an unsupported input is detected; otherwise resets

S:0/2

Zero (Z)

sets if the result is zero; otherwise resets

S:0/3

Sign (S)

sets if the result is negative; otherwise resets

Use this instruction to convert degrees (source) to radians and store the result in the destination. The following formula applies.

Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 Output Instruction

The Processor

Source * Π/ 180 where Π = 3.141592

RAD Degrees to Radians Source N7:61 0< Dest N7:60 0<

•

With this Bit

•

•

Example: Convert 135 degrees to radians.

Π -------180 x = -------Π -------135 180

Π x = 135 ⎛ --------⎞ ⎝ 180⎠ x = 2.356 Radians

Entering Parameters • Source is the integer and/or floating point values. • Destination is the address of the word where the data is to be stored.

Publication 1747-RM001G-EN-P - November 2008

Page 106

5-10

Data Handling Instructions

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the status file. After an instruction is executed, the arithmetic status bits in the status file are updated. Table 5.5 Processor Function With this Bit The Processor S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

sets if overflow generated or an unsupported input is detected; otherwise resets

S:0/2

Zero (Z)

sets if the result is zero; otherwise resets

S:0/3

Sign (S)

sets if the result is negative; otherwise resets

Decode 4 to 1 of 16 (DCD) When executed, this instruction sets 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.

DCD Decode 4 to 1 of 16 Source N7:62 0003h< Dest N7:63 0000000000000100<

Use this instruction to multiplex data in applications such as rotary switches, keypads, and bank switching.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

•

Output Instruction

Source Bit

Destination

15-04

03

02

01

00

15

14

13

12

11

10

09

08

07

06

05

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

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

Publication 1747-RM001G-EN-P - November 2008

Page 107

Data Handling Instructions

5-11

Entering Parameters • Source is the address that contains the bit decode information. Only the first four bits (0 to 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 is the address of the word where the data is to be stored.

Updates to Arithmetic Status Bits Unaffected.

Encode 1 of 16 to 4 (ENC) When the rung is true, this output instruction searches the source from the lowest to the highest bit, and looks for the first set bit. The corresponding bit position is written to the destination as an integer as shown in the table below.

ENC Encode 1 of 16 to 4 Source N7:64 0000000000000100< Dest N7:65 0003h<

Use this instruction to multiplex data in applications such as rotary switches, keypads, and bank switching.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

Output Instruction

Source Bit

Destination

15

14

13

12

11

10

09

08

07

06

05

04

03

02

01

00

15 to 04 03

02

01

00 x x x x x x x x x x x x x x x 1 x x x x x x x x x x x x x x 1 0 x x x x x x x x x x x x x 1 0 0 x x x x x x x x x x x x 1 0 0 0 x x x x x x x x x x x 1 0 0 0 0 x x x x x x x x x x 1 0 0 0 0 0 x x x x x x x x x 1 0 0 0 0 0 0 x x x x x x x x 1 0 0 0 0 0 0 0 x x x x x x x 1 0 0 0 0 0 0 0 0 x x x x x x 1 0 0 0 0 0 0 0 0 0 x x x x x 1 0 0 0 0 0 0 0 0 0 0 x x x x 1 0 0 0 0 0 0 0 0 0 0 0 x x x 1 0 0 0 0 0 0 0 0 0 0 0 0 x x 1 0 0 0 0 0 0 0 0 0 0 0 0 0 x 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 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

Publication 1747-RM001G-EN-P - November 2008

Page 108

5-12

Data Handling Instructions

Entering Parameters • Source is the address of the word to be encoded. Only one bit of this word should be on at any time. If more than one bit in the source is set, the destination bits are set based on the least significant bit that is set. If a source of zero is used, all of the destination bits are reset and the arithmetic status zero bit (S:0/2) is set. • Destination is the address that contains the bit encode information. Bits 4 to 15 of the destination are reset by the ENC instruction.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the status file. After an instruction is executed, the arithmetic status bits in the status file are updated. Table 5.6 Controller Function With this Bit

Publication 1747-RM001G-EN-P - November 2008

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

sets if more than one bit in the source is set; otherwise reset. The math overflow bit (s:5/0) is not set.

S:0/2

Zero (Z)

sets if destination value zero.

S:0/3

Sign (S)

always resets.

Page 109

Data Handling Instructions

Copy File (COP) and Fill File (FLL) Instructions

FLL Fill File Source 0 Dest #ST14:0 Length 3

Using COP

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

The destination file type determines the number of words that an instruction transfers. For example, if the destination file type is a counter and the source file type is an integer, three integer words are transferred for each element in the counter-type file. After a COP or FLL instruction is executed, index register S:24 is cleared to zero.

COP Copy File Source #ST14:0 Dest #ST14:10 Length 3

•

5-13

•

•

•

This instruction copies blocks of data from one location into another. It uses no status bits. If you need an enable bit, program an output instruction (OTE) in parallel using an internal bit as the output address. The following figure shows how file instruction data is manipulated.

Output Instruction

Source

Destination

File to File

Entering Parameters Enter the following parameters when programming this instruction. • Source is the address of the file you want to copy. You must use the file indicator (#) in the address. • Destination is the starting address where the instruction stores the copy. You must use the file indicator (#) in the address. • Length is the number of elements in the file you want to copy. – Maximum length is based on destination file type. If the destination file type is 3 words per element (Timer or Counter), you can specify a maximum length of 42. If the destination file type is 1 word per element, you can specify a maximum length of 128 words.

TIP

The maximum lengths are based on destination file type.

Publication 1747-RM001G-EN-P - November 2008

Page 110

5-14

Data Handling Instructions

All elements are copied from the source file into the destination file each time the instruction is executed. Elements are copied in ascending order. If your destination file type is a timer, counter, or control file, be sure that the source words corresponding to the status words of your destination file contains zeros. Be sure that you accurately specify the starting address and length of the data block you are copying. The instruction will not write over a file boundary (such as between files N16 and N17) at the destination. An error occurs if a write is attempted over a file boundary. You can perform file shifts by specifying a source element address one or more elements greater than the destination element address within the same file. This shifts data to lower element addresses.

Using FLL This instruction loads elements of a file with either a program constant or value from an element address. The instruction fills the words of a file with a source value. It uses no status bits. If you need an enable bit, program a parallel output that uses a storage address. The following figure shows how file instruction data is manipulated. Destination Source

Word to File

Publication 1747-RM001G-EN-P - November 2008