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

The text of a manual · part 49 of 60

DL205 PLC User Manual, Volume 1 of 2, pages 481 to 490

Pages 481 to 490 of 598

The original document is the PDF (12 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 AutomationDirect D2-04TD1, AutomationDirect D2-08TD2, AutomationDirect D2-16ND3-2, AutomationDirect D2-32ND3, Konnect-It D2-04TD1, Koyo D2-04TD1, Konnect-It D2-08TD2, Koyo D2-08TD2, and 5 more models

Page 481

Chapter 5: Standard RLL Instructions

Double BCD to Real with Implied Decimal Point (BCDTORD) (IB-562)

1

2

3

BCDTORD Parameters • (DWORD BCD): specifies the Dword 4 or constant that will be converted to a Real number 5

Number of Decimal Points: specifies the number of implied decimal points in the Result DWORD 6

Result (DWORD REAL): specifies the location where the Real number will be placed 7 Parameter DL205 Range 8 9 10 BCDTORD Example In the following example, the BCDTORD instruction is used to convert the 32-bit data in V2000 from an 8-digit BCD data format to a 32-bit REAL (floating point) data format and 11 store into V3000 and V3001 when C100 turns on. K2 in the Number of Decimal Points implies the data will have two digits to the right of the 12 decimal point. 13 14 A B C D 230 240

250-1

Double BCD to Real with Implied Decimal Point converts the given 8-digit DWORD BCD value to a Real number, given an implied number of decimal points (K0-K8). For example, BCDTORD K12345678 with an implied number of decimal points equal to K5, would yield R123.45678

260

DS5 Used HPP

N/A

Value (DWORD BCD) ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠V,P,K Number of Decimal Points ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ K Result (DWORD REAL)⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V

K0-99999999; See DL205 V-memory map - Data Words K0-8 See DL205 V-memory map - Data Words

DL205 User Manual, 4th Edition, Rev. D

5-257

Page 482

Chapter 5: Standard RLL Instructions

1

2

3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Math - BCD (MATHBCD) (IB-521) 230 240 250-1 260

DS5 Used

HPP

N/A

5-258

Math - BCD Format lets you enter complex mathematical expressions like you would in Visual Basic, Excel, or C++ to do complex calculations, nesting parentheses up to 4 levels deep. In addition to + - * /, you can do Modulo (% aka Remainder), Bit-wise And (&) Or (|) Xor (^), and some BCD functions - Convert to BCD (BCD), Convert to Binary (BIN), BCD Complement (BCDCPL), Convert from Gray Code (GRAY), Invert Bits (INV), and BCD/ HEX to Seven Segment Display (SEG). Example: ((V2000 + V2001) / (V2003 - K100)) * GRAY(V3000 & K001F) Every V-memory reference MUST be to a single-word BCD formatted value. Intermediate results can go up to 32-bit values, but as long as the final result fits in a 16-bit BCD word, the calculation is valid. Typical example of this is scaling using multiply then divide, (V2000 * K1000) / K4095. The multiply term most likely will exceed 9999 but fits within 32 bits. The divide operation will divide 4095 into the 32-bit accumulator, yielding a result that will always fit in 16 bits. You can reference binary V-memory values by using the BCD conversion function on a V-memory location but NOT an expression. That is BCD(V2000) is okay and will convert V2000 from Binary to BCD, but BCD(V2000 + V3000) will add V2000 as BCD, to V3000 as BCD, then interpret the result as Binary and convert it to BCD - NOT GOOD. Also, the final result is a 16-bit BCD number and so you could do BIN around the entire operation to store the result as Binary. MATHBCD Parameters • (WORD): specifies the location where the BCD result of the mathematical expression will be placed (result must fit into 16-bit single V-memory location). • specifies the mathematical expression to be executed and the result is stored in specified Result (WORD). Each V-memory location used in the expression must be in BCD format.

Parameter WORD Result ⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V Expression⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠

DL205 User Manual, 4th Edition, Rev. D

DL205 Range See DL205 V-memory map - Data Words Text

Page 483

Chapter 5: Standard RLL Instructions

MATHBCD Example In the following example, the MATHBCD instruction is used to calculate the math expression which multiplies the BCD value in V1200 by 1000, then divides by 4095 and loads the resulting value in V2000 when C100 turns on.

DL205 User Manual, 4th Edition, Rev. D

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5-259

Page 484

Chapter 5: Standard RLL Instructions

1

2

3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Math - Binary (MATHBIN) (IB-501) 230 240 250-1 260

DS5 Used

HPP

N/A

5-260

Math - Binary Format lets you enter complex mathematical expressions like you would in Visual Basic, Excel, or C++ to do complex calculations, nesting parentheses up to 4 levels deep. In addition to + - * /, you can do Modulo (% aka Remainder), Shift Right (>>) and Shift Left (<<), Bit-wise And (&) Or (|) Xor (^), and some binary functions Convert to BCD (BCD), Convert to Binary (BIN), Decode Bits (DECO), Encode Bits (ENCO), Invert Bits (INV), HEX to Seven Segment Display (SEG), and Sum Bits (SUM). Example: ((V2000 + V2001) / (V2003 - K10)) * SUM(V3000 & K001F) Every V-memory reference MUST be to a single-word binary formatted value. Intermediate results can go up to 32-bit values, but as long as the final result fits in a 16-bit binary word, the calculation is valid. Typical example of this is scaling using multiply then divide, (V2000 * K1000) / K4095. The multiply term most likely will exceed 65535 but fits within 32 bits. The divide operation will divide 4095 into the 32-bit accumulator, yielding a result that will always fit in 16 bits. You can reference BCD V-memory values by using the BIN conversion function on a V-memory location but NOT an expression. That is, BIN(V2000) is okay and will convert V2000 from BCD to Binary, but BIN(V2000 + V3000) will add V2000 as Binary, to V3000 as Binary, then interpret the result as BCD and convert it to Binary - NOT GOOD. Also, the final result is a 16-bit binary number and so you could do BCD around the entire operation to store the result as BCD. MATHBIN Parameters • (WORD): specifies the location where the binary result of the mathematical expression will be placed (result must fit into 16-bit single V-memory location). • specifies the mathematical expression to be executed and the result is stored in specified Result (WORD). Each V-memory location used in the expression must be in binary format.

Parameter WORD Result ⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V Expression⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠

DL205 User Manual, 4th Edition, Rev. D

DL205 Range See DL205 V-memory map - Data Words Text

Page 485

Chapter 5: Standard RLL Instructions

MATHBIN Example In the following example, the MATHBIN instruction is used to calculate the math expression which multiplies the Binary value in V1200 by 1000 then divides by 4095 and loads the resulting value in V2000 when C100 turns on.

DL205 User Manual, 4th Edition, Rev. D

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5-261

Page 486

Chapter 5: Standard RLL Instructions

Math - Real (MATHR) (IB-541)

Math - Real Format lets you enter complex 1 mathematical expressions like you would in Visual Basic, Excel, or C++ to do complex calculations, nesting parentheses up to 4 levels 2 deep. In addition to + - * /, you can do Bit-wise

And (&) Or (|) and Xor (^). The DL260 also 3 supports several Real functions - Arc Cosine (ACOSR), Arc Sine (ASINR), Arc Tangent 4 (ATANR), Cosine (COSR), Convert Radians to Degrees (DEGR), Invert Bits (INV), Convert Degrees to Radians (RADR), HEX to Seven 5 Segment Display (SEG), Sine (SINR), Square Root (SQRTR), and Tangent (TANR). 6 Example: ((V2000 + V2002) / (V2004 - R2.5)) * SINR(RADR(V3000 / R10.0)) Every V-memory reference MUST be able to fit into a double-word Real formatted value. 7 MATHR Parameters 8 • (DWORD): specifies the location where the Real result of the mathematical expression will be placed (result must fit into a double-word Real formatted location). 9 • specifies the mathematical expression to be executed and the result is stored in specified Result (DWORD) location. Each V-memory location used in the expression must be in Real format. 10 Parameter DL205 Range 11 12 MATHR Example 13 In the following example, the MATHR instruction is used to calculate the math expression which multiplies the REAL (floating point) value in V1200 by 10.5 then divides by 2.7 and 14 loads the resulting 32-bit value in V2000 and V2001 when C100 turns on. A B C D 230 240

250-1 260

DS5 Used

HPP

N/A

DWORD Result ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V Expression⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠

5-262

DL205 User Manual, 4th Edition, Rev. D

See DL205 V-memory map - Data Words Text

Page 487

Chapter 5: Standard RLL Instructions

Real to BCD with Implied Decimal Point and Rounding (RTOBCD) (IB-561)

1

2

3

4 RTOBCD Parameters 5

Value (DWORD Real): specifies the Real Dword location or number that will be converted and rounded to a BCD number 6 with decimal points

Number of Decimal Points: specifies the 7 number of implied decimal points in the Result WORD • (WORD BCD): specifies the location 8 where the rounded/implied decimal points BCD value will be placed 9 Parameter DL205 Range 10 11 12 RTOBCD Example In the following example, the RTOBCD instruction is used to convert the 32-bit REAL (floating point) data format in V3000 and V3001 to the 4-digit BCD data format and store in 13 V2000 when C100 turns on. K2 in the Number of Decimal Points implies the data will have two implied decimal points. 14 A B C D 230 240

250-1 260

Real to BCD with Implied Decimal Point and Rounding converts the absolute value of the given Real number to a 4-digit BCD number, compensating for an implied number of decimal points (K0-K4) and performs rounding. For example, RTOBCD R56.74 with an implied number of decimal points equal to K1, would yield 567 BCD. If the implied number of decimal points was 0, then the function would yield 57 BCD (note that it rounded up). If the Real number is negative, the Result will equal its positive, absolute value.

DS5 Used HPP

N/A

Value (DWORD Real) ⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V,P,R Number of Decimal Points ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ K Result (WORD BCD)⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V

R ; See DL205 V-memory map - Data Words K0-4 See DL205 V-memory map - Data Words

DL205 User Manual, 4th Edition, Rev. D

5-263

Page 488

Chapter 5: Standard RLL Instructions

Real to Double BCD with Implied Decimal Point and Rounding (RTOBCDD) (IB-563)

1 Real to Double BCD with Implied Decimal Point and Rounding converts the absolute value of the given Real number to an 8-digit DWORD BCD number, compensating for an implied 2 number of decimal points (K0-K8) and performs rounding.

For example, RTOBCDD R38156.74 with an implied number of decimal points equal to K1, 3 would yield 381567 BCD. If the implied number of decimal points was 0, then the function would yield 38157 BCD (note that it rounded up). 4 If the Real number is negative, the Result will equal its positive, absolute value. 5 RTOBCDD Parameters • (DWORD Real): specifies the Dword 6 Real number that will be converted and rounded to a BCD number with decimal points 7

Number of Decimal Points: specifies the number of implied decimal points in the 8 Result DWORD • (DWORD BCD): specifies the location 9 where the rounded/implied decimal points DWORD BCD value will be placed 10 Parameter DL205 Range 11 12 RTOBCDD Example 13 In the following example, the RTOBCDD instruction is used to convert the 32-bit REAL (floating point) data format in V3000 and V3001 to the 8-digit BCD data format and store in 14 V2000 and V2001 when C100 turns on. K2 in the Number of Decimal Points implies the data will have two implied decimal points. A B C D 230 240

250-1 260

DS5

Used

HPP

N/A

Value (DWORD Real) ⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V,P,R Number of Decimal Points ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ K Result (DWORD BCD)⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V

5-264

DL205 User Manual, 4th Edition, Rev. D

R ; See DL205 V-memory map - Data Words K0-8 See DL205 V-memory map - Data Words

Page 489

Chapter 5: Standard RLL Instructions

Square BCD (SQUARE) (IB-523)

1

2 SQUARE Parameters

Value (WORD BCD): specifies the BCD

3 Word or constant that will be squared • (DWORD BCD): specifies the location 4 where the squared DWORD BCD value will be placed 5 6 Parameter DL205 Range 7 8 SQUARE Example In the following example, the SQUARE instruction is used to square the 4-digit BCD value in 9 V2000 and store the 8-digit double word BCD result in V3000 and V3001 when C100 turns on. 10 11 12 13 14 A B C D 230

Square BCD squares the given 4-digit WORD BCD number and writes it as an 8-digit DWORD BCD result.

240

250-1 260

DS5

Used

HPP

N/A

Value (WORD BCD) ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠V,P,K Result (DWORD BCD)⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V

K0-9999 ; See DL205 V-memory map - Data Words See DL205 V-memory map - Data Words

DL205 User Manual, 4th Edition, Rev. D

5-265

Page 490

Chapter 5: Standard RLL Instructions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Square Binary (SQUAREB) (IB-503) Square Binary squares the given 16-bit WORD Binary number and writes it as a 32-bit DWORD Binary result.

230 240 250-1 SQUAREB Parameters • (WORD Binary): specifies the binary 260 Word or constant that will be squared DS5

Used

HPP

N/A

5-266

• (DWORD Binary): specifies the location where the squared DWORD binary value will be placed

Parameter Value (WORD Binary) ⸠ ⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠V,P,K Result (DWORD Binary)⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠⸠ V

DL205 Range K0-65535; See DL205 V-memory map - Data Words See DL205 V-memory map - Data Words

SQUAREB Example In the following example, the SQUAREB instruction is used to square the single-word Binary value in V2000 and store the 8-digit double-word Binary result in V3000 and V3001 when C100 turns on.

DL205 User Manual, 4th Edition, Rev. D