The text of a manual · part 35 of 68
DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 303 to 312
Pages 303 to 312 of 608, from DL405 User Manual
The original document is the PDF (8.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 AutomationDirect D4-08B-1, AutomationDirect D4-08ND3S, AutomationDirect D4-16TA, PLC Direct D4-16TD2, AutomationDirect D4-32ND3-1, Konnect-It D4-08B-1, Koyo D4-08B-1, Konnect-It D4-08ND3S, and 6 more models
Page 303
Standard RLL Instructions Number Conversion Instructions
Ten’s Complement The Ten’s Complement instruction takes the 10’s complement (BCD) of the 8 digit (BCDCPL) accumulator. The result resides in the accumulator. The calculation for this 430 440 450 instruction is :
100000000 HPP DS -- accumulator value 10’s complement value
5--131
BCDCPL
In the following example when X1 is on, the value in V1400 and V1401 is loaded into the accumulator. The 10’s complement is taken for the 8 digit accumulator using the Ten’s Complement instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1400
V1401
X1
LDD
0
0
0
0
0
0
8
7
Acc. 0
0
0
0
0
0
8
7
Acc. 9
9
9
9
9
9
1
3
9
9
9
9
9
9
1
3
V1400 Load the value in V1400 and V1401 into the accumulator
BCDCPL
Takes a 10’s complement of the value in the accumulator OUTD V1500
V1501
Copy the value in the accumulator to V1500 and V1501
V1500
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
D
BCD
SHFT
C
P
L
OUT
SHFT
D
SHFT
V
SHFT
V
1
4
0
0
1
5
0
0
NOTE: If your program has a subtraction calculation which results in a borrowed digit (noted by the status flag), the BCDCPL instruction can be used to find the absolute difference between the two values in the subtraction.
Standard RLL Instructions DL405 User Manual, 4th Edition
Page 304
5--132
Standard RLL Instructions Number Conversion Instructions
Binary to Real Conversion (BTOR)
The Binary-to-Real instruction converts a binary value in the accumulator to its equivalent real number (floating point) format. The result resides in the accumulator. Both the binary and the real number may use all 32 bits of the accumulator
430 440 450
DS
HPP
BTOR
NOTE: This instruction will not work for a signed decimal. Discrete Bit Flags
Description
SP63
On when the result of the instruction causes the value in the accumulator to be zero.
SP70
On anytime the value in the accumulator is negative.
In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The BTOR instruction converts the binary value in the accumulator the equivalent real number format. The binary weight of the MSB is converted to the real number exponent by adding it to 127 (decimal). Then the remaining bits are copied to the mantissa as shown. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. The handheld programmer would display the binary value in V1500 and V1501 as a HEX value. DirectSOFT
V1401
X1
LDD
V1400
0
0
0
5
7
2
4
1
V1400 Load the value in V1400 and V1401 into the accumulator 8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
Acc. 0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
0
0
1
0
0
0
1
0
0
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
Binary Value
2 (exp 18) 127 + 18 = 145 145 = 128 + 16 + 1 BTOR
Convert the binary value in the accumulator to the real number equivalent format
Acc. 0
Sign Bit
1
0
0
1
0
0
0
1
0
1
0
1
1
1
0
0
Exponent (8 bits)
0
Mantissa (23 bits)
Real Number Format
OUTD
Standard RLL Instructions
V1500 4
Copy the real value in the accumulator to V1500 and V1501
A
V1501
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
D
SHFT
V
1
SHFT
B
T
O
R
SHFT
OUT
SHFT
D
SHFT
V
1
DL405 User Manual, 4th Edition
8
4
0
0
5
0
0
E
4
8
2
V1500
0
The real number (HEX) value copied to V1500
Page 305
5--133
Standard RLL Instructions Number Conversion Instructions
The Real-to-Binary instruction converts the real number in the accumulator to a binary value. If the real number is negative, it will become a signed decimal. The result resides in the accumulator. Both the binary and the real number may use all 32 bits of the accumulator. Any decimal portion will be truncated.
Real to Binary Conversion (RTOB)
430 440 450
DS
HPP
RTOB
Discrete Bit Flags
Description
SP63
On when the result of the instruction causes the value in the accumulator to be zero.
SP70
On anytime the value in the accumulator is negative.
SP72
On anytime the value in the accumulator is a valid floating point number.
SP73 on when a signed addition or subtraction results in a incorrect sign bit.
SP75
On when a BCD instruction is executed and a NON--BCD number was encountered.
In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The RTOB instruction converts the real value in the accumulator to the equivalent binary number format. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. The handheld programmer would display the binary value in V1500 and V1501 as a HEX value. DirectSOFT X1
4
LDD
8
A
E
4
V1401
V1400 Load the value in V1400 and V1401 into the accumulator
Sign Bit
Exponent (8 bits)
Acc. 0
1
0
0
1
0
0
0
1
8
2
0
Real Number Format
V1400
Mantissa (23 bits)
0
1
0
1
1
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
RTOB
Convert the real number in the accumulator to binary format.
128 + 16 + 1 = 145 127 + 18 = 145 Binary Value
2 (exp 18) 8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
Acc. 0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
0
0
1
0
0
0
1
0
0
0
0
1
5
7
OUTD V1500 Copy the real value in the accumulator to V1500 and V1501
V1501 0
0
V1500 2
4
1
The binary number copied to V1400.
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
D
SHFT
V
1
SHFT
R
T
O
B
SHFT
OUT
SHFT
D
SHFT
V
1
4
0
0
5
0
0
DL405 User Manual, 4th Edition
Standard RLL Instructions
0
Page 306
5--134
Standard RLL Instructions Number Conversion Instructions
Radian Real Conversion (RADR)
430 440 450
DS
HPP
Degree Real Conversion (DEGR)
430 440 450
DS
HPP
The Radian Real Conversion instruction converts the real degree value stored in the accumulator to the equivalent real number in radians. The result resides in the accumulator.
RADR
The Degree Real instruction converts the degree real radian value stored inthe accumulator to the equivalent real number in degrees. The result resides in the accumulator.
DEGR
The two instructions described above convert real numbers into the accumulator from degree format to radian format, and visa-versa. In degree format, a circle contains 360 degrees. In radian format, a circle contains 2 Π radians. These convert between both positive and negative real numbers, and for angles greater than a full circle. These functions are very useful when combined with the transcendantal trigonometric functions (see the section on math instructions). Discrete Bit Flags
Description
SP63
On when the result of the instruction causes the value in the accumulator to be zero.
SP70
On anytime the value in the accumulator is negative.
SP71
On anytime the V-memory specified by a pointer (P) is not valid.
SP72
On anytime the value in the accumulator is a valid floating point number.
SP74
On anytime a floating point math operation results in an underflow error.
SP75
On when a BCD instruction is executed and a NON--BCD number was encountered.
NOTE: The current HPP does not support real number entry with automatic conversion to the 32-bit IEEE format. You must use DirectSOFT for entering real numbers, using the LDR (Load Real) instruction. The following example takes the sine of 45 degrees. Since transcendental functions operate only on real numbers, we do a LDR (load real) 45. The trig functions operate only in radians, so we must convert the degrees to radians by using the RADR command. After using the SINR (Sine Real) instruction, we use an OUTD (Out Double) instruction to move the result from the accumulator to V-memory. The result is 32-bits wide, requiring the Out Double to move it. Accumulator contents (viewed as real number)
DirectSOFT X1
LDR
Standard RLL Instructions
R45
45.000000
RADR
Convert the degrees into radians, leaving the result in the accumulator.
0.7358981
SINR
Take the sine of the number in the accumulator, which is in radians.
0.7071067
Copy the value in the accumulator to V2000 and V2001.
0.7071067
OUTD V2000
DL405 User Manual, 4th Edition
Load the real number 45 into the accumulator.
Page 307
Standard RLL Instructions Number Conversion Instructions
ASCII to HEX (ATH)
430 440 450
DS
HPP
5--135
The ASCII TO HEX instruction converts a ATH table of ASCII values to a specified table of V aaa HEX values. ASCII values are two digits and their HEX equivalents are one digit. This means an ASCII table of four V--memory locations would only require two V-memory locations for the equivalent HEX table. The function parameters are loaded into the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program an ASCII to HEX table function. The example on the following page shows a program for the ASCII to HEX table function. Step 1:, Load the number of V--memory locations for the ASCII table into the first level of the accumulator stack. Step 2:, Load the starting V--memory location for the ASCII table into the accumulator. This parameter must be a HEX value. Step 3:, Specify the starting V--memory location (Vaaa) for the HEX table in the ATH instruction. Helpful Hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. Operand Data Type
V--memory
V
DL440 Range
DL450 Range aaa aaa
All (See p. 3--41)
All (See p. 3--42)
In the example on the following page, when X1 is ON the constant (K4) is loaded into the accumulator using the Load instruction and will be placed in the first level of the accumulator stack when the next Load instruction is executed. The starting location for the ASCII table (V1400) is loaded into the accumulator using the Load Address instruction. The starting location for the HEX table (V1600) is specified in the ASCII to HEX instruction. The table below lists valid ASCII values for ATH conversion. ASCII Values Valid for ATH Conversion Hex Value
ASCII Value
Hex Value
30
0
38
8
31
1
39
9
32
2
41
A
33
3
42
B
34
4
43
C
35
5
44
D
36
6
45
E
37
7
46
F
DL405 User Manual, 4th Edition
Standard RLL Instructions
ASCII Value
Page 308
5--136
Standard RLL Instructions Number Conversion Instructions
DirectSOFT X1
LD K4
33 34
V1400
Convert octal 1400 to HEX 300 and load the value into the accumulator
LDA O 1400
V1401
31 32
V1402
37 38
V1600
Handheld Programmer Keystrokes X(IN)
1
LD
K(CON)
4
LD
SHFT
A
OCT
1
4
0
0
SHFT
A
T
H
SHFT
V
1
6
DS
HPP
V1600
5678
V1601
35 36
V1403
STR
430 440 450
1234
V1600 is the starting location for the HEX table
ATH
HEX to ASCII (HTA)
Hexadecimal Equivalents
ASCII TABLE
Load the constant value into the lower 16 bits of the accumulator. This value defines the number of V memory location in the ASCII table
0
0
The HEX to ASCII instruction converts a table of HEX values to a specified table of ASCII values. HEX values are one digit and their ASCII equivalents are two digits.
HTA V aaa
This means a HEX table of two V--memory locations would require four V--memory locations for the equivalent ASCII table. The function parameters are loaded into the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program a HEX to ASCII table function. The example on the following page shows a program for the HEX to ASCII table function. Step 1:, Load the number of V--memory locations in the HEX table into the first level of the accumulator stack. Step 2:, Load the starting V--memory location for the HEX table into the accumulator. This parameter must be a HEX value.
Standard RLL Instructions
Step 3:, Specify the starting V--memory location (Vaaa) for the ASCII table in the HTA instruction. Helpful Hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. Operand Data Type
V--memory
DL405 User Manual, 4th Edition
DL440 Range
V
DL440 Range aaa aaa
All (See p. 3--41)
All (See p. 3--42)
Page 309
Standard RLL Instructions Number Conversion Instructions
5--137
In the following example, when X1 is ON the constant (K2) is loaded into the accumulator using the Load instruction. The starting location for the HEX table (V1500) is loaded into the accumulator using the Load Address instruction. The starting location for the ASCII table (V1400) is specified in the HEX to ASCII instruction. DirectSOFT X1
Hexadecimal Equivalents
LD
ASCII TABLE
K2 Load the constant value into the lower 16 bits of the accumulator. This value defines the number of V locations in the HEX table.
33 34
V1400
31 32
V1401
37 38
V1402
35 36
V1403
1234
V1500 LDA O 1500 Convert octal 1500 to HEX 340 and load the value into the accumulator
HTA V1400
5678
V1501
V1400 is the starting location for the ASCII table. The conversion is executed by this instruction. Handheld Programmer Keystrokes STR
X(IN)
1
LD
K(CON)
2
LD
SHFT
A
OCT
1
5
0
0
SHFT
H
T
A
SHFT
V
1
4
0
0
The table below lists valid ASCII values for HTA conversion. ASCII Values Valid for HTA Conversion ASCII Value
Hex Value
ASCII Value
0
30
8
38
1
31
9
39
2
32
A
41
3
33
B
42
4
34
C
43
5
35
D
44
6
36
E
45
7
37
F
46
DL405 User Manual, 4th Edition
Standard RLL Instructions
Hex Value
Page 310
5--138
Standard RLL Instructions Number Conversion Instructions
The BCD/Segment instruction converts a four digit HEX value in the accumulator to seven segment display format. The result resides in the accumulator.
Segment (SEG)
430 440 450
DS
HPP
SEG
In the following example, when X1 is on, the value in V1400 is loaded into the lower 16 bits of the accumulator using the Load instruction. The binary (HEX) value in the accumulator is converted to seven segment format using the Segment instruction. The bit pattern in the accumulator is copied to Y20--Y57 using the Out Formatted instruction. DirectSOFT
V1400
X1
6
LD
F
7
1
V1400 Load the value in V1400 into the lower 16 bits of the accumulator Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
1
0
1
1
0
0
0
1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
1
1
1
1
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
1
1
0
-- g f e d c b a
-- g f e d c b a
-- g f e d c b a
-- g f e d c b a Segment Labels
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
SEG
Convert the binary (HEX) value in the accumulator to seven segment display format
OUTF
Y20 K32
Copy the value in the accumulator to Y20--Y57
Acc.
a f b
Segment Labels
Y57 Y56 Y55 Y54 Y53 g e
OFF ON ON ON ON
S S
S S
S S c d
Standard RLL Instructions
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
V
SHFT
S
E
G
OUT
SHFT
F
SHFT
1
4
0
0
Y(OUT)
2
0
DL405 User Manual, 4th Edition
K(CON)
3
2
S S
Y24 Y23 Y22 Y21 Y20 OFF OFF ON ON OFF
Page 311
5--139
Standard RLL Instructions Number Conversion Instructions
The Gray code instruction converts a 16 bit gray code value to a BCD value. The BCD conversion requires 10 bits of the accumulator. The upper 22 bits are set to “0”. This instruction is designed for use with devices (typically encoders) that use the grey code numbering scheme. The Gray Code instruction will directly convert a gray code number to a BCD number for devices having a resolution of 512 or 1024 counts per revolution. If a device having a resolution of 360 counts per revolution is to be used you must subtract a BCD value of 76 from the converted value to obtain the proper result. For a device having a resolution of 720 counts per revolution you must subtract a BCD value of 152.
Gray Code (GRAY)
430 440 450
DS
HPP
GRAY
In the following example, when X1 is ON the binary value represented by X10--X27 is loaded into the accumulator using the Load Formatted instruction. The gray code value in the accumulator is converted to BCD using the Gray Code instruction. The value in the lower 16 bits of the accumulator is copied to V1500. DirectSOFT
X27 X26 X25
X1
LDF
S S
OFF OFF OFF
X10
X12 X11 X10
S S
ON OFF ON
K16 Load the value represented by X10--X27 into the lower 16 bits of the accumulator Acc.
GRAY Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
1
0
1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
1
1
0
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Convert the 16 bit grey code value in the accumulator to a BCD value OUT V1500
V1500
Copy the value in the lower 16 bits of the accumulator to V1500
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
F
SHFT
X(IN)
1
G
R
A
Y
SHFT
OUT
V
1
5
0
0
K(CON)
1
6
BCD
0000000000
0000
0000000001
0001
0000000011
0002
0000000010
0003
0000000110
0004
0000000111
0005
0000000101
0006
0000000100
0007
S S
S S
S
S
1000000001
1022
1000000000
1023
DL405 User Manual, 4th Edition
Standard RLL Instructions
SHFT
0
Gray Code
Page 312
5--140
Standard RLL Instructions Number Conversion Instructions
Shuffle Digits (SFLDGT)
430 440 450
DS
HPP
The Shuffle Digits instruction shuffles a maximum of 8 digits rearranging them in a specified order. This function requires parameters to be loaded into the first level of the accumulator stack and the accumulator with two additional instructions. Listed below are the steps necessary to use the shuffle digit function. The example on the following page shows a program for the Shuffle Digits function.
SFLDGT
Step 1: - Load the value (digits) to be shuffled into the first level of the accumulator stack. Step 2: - Load the order the digits will be shuffled to into the accumulator, numbered 1 through 8 (“1” being the least significant digit, and “8” being the most significant digit. Note: - If the number used to specify the order contains a 0 or 9--F, the corresponding position will be set to 0. See example Note: - If the number used to specify the order contains duplicate numbers, the most significant duplicate number is valid. The result resides in the accumulator. See example Step 3: - Insert the SFLDGT instruction. Shuffle Digits Block Diagram
There are a maximum of 8 digits that can be shuffled. The bit positions in the first level of the accumulator stack defines the digits to be shuffled. They correspond to the bit positions in the accumulator that define the order the digits will be shuffled. The digits are shuffled and the result resides in the accumulator.
Digits to be shuffled (first stack location) 9
A
B
C D
E
F
0
1
2
8
7
6
5
4
3
Specified order (accumulator) Bit Positions
8
7
6
5
4
3
2
1
B
C
E
F
0
D
A
9
Standard RLL Instructions
Result (accumulator)
DL405 User Manual, 4th Edition