The text of a manual · part 38 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 353 to 362
Pages 353 to 362 of 592, from DL205 PLC User Manual, Volume 1 of 2
The original document is the PDF (13 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 PLC Direct D2-08ND3 and Koyo D2-08ND3
Page 353
Chapter 5: Standard RLL Instructions - Number Conversion
Binary Coded Decimal (BCD)
1 2 3 accumulator is converted to the BCD equivalent value using the BCD instruction. The BCD value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. 4 5 6 7 8 9 10 11 12 13 14 A B C D
Binary Coded Decimal instruction converts a binary value BCD 230 The in the accumulator to the equivalent BCD value. The result 240 resides in the accumulator. 250-1 In the following example, when X1 is on, the binary (HEX) value in V2000 and V2001 is 260 loaded into the accumulator using the Load Double instruction. The binary value in the DS Used HPP Used DirectSOFT X1
V2001
0
LDD
0
0
V2000
0
6
F
7
1
Binary Value
V2000
Load the value in V2000 and V2001 into 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
0
0
0 0
0
0
0
0 0
0
0
0
0 0
0
0
1
1
0 1
1
1
1
0 1
1
1
0
0 0
1
2 1 4 7 4 4 8 3 6 4 8
1 0 7 3 7 4 1 8 2 4
5 3 6 8 7 0 9 1 2
2 6 8 4 3 5 4 5 6
6 7 1 0 8 8 6 4
3 3 5 5 4 4 3 2
1 6 7 7 7 2 1 6
8 3 8 8 6 0 8
2 0 9 7 1 5 2
1 0 4 8 5 7 6
5 2 4 2 8 8
2 6 2 1 4 4
6 5 5 3 6
3 2 7 6 8
1 6 3 8 4
8 1 9 2
4 0 9 6
1 0 2 4
5 1 2
2 5 6
1 6 2 4 8
3 2
1 6
8
4
2 1
1 3 4 2 1 7 7 2 8
BCD
4 1 9 4 3 0 4
1 3 1 0 7 2
2 0 4 8
16384 + 8192 + 2048 + 1024 + 512 + 256 + 64 + 32 + 16 + 1 = 28529
Convert the binary value in the accumulator to the BCD equivalent value
BCD Equivalent Value
Acc.
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
0
0
0 0
0
0
0 0
0
0
0 1
0
1
0
0
0 0
1
0
0 0
1
0
0 0
1
0
2
8
5
2
9
The BCD value copied to V2010 and V2011
0
0
0
1
1
OUTD
V2010
Copy the BCD value in the accumulator to V2010 and V2011
0
0
V2011
V2010
Handheld Programmer Keystrokes $
B
STR
1
L ANDST
D
SHFT
B
C
GX OUT
SHFT
SHFT
ENT
D
3
D
2
1
C
3
D
3
A
0
A
0
0
ENT
ENT
C
3
A
2
A
2
B
0
A
1
0
ENT
DL205 User Manual, 4th Edition, Rev. A
5–131
Page 354
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Invert (INV) Invert instruction inverts or takes the one’s complement of INV 230 The the 32-bit value in the accumulator. The result resides in the 240 accumulator. 250-1 260 In the following example, when X1 is on, the value in V2000 and V2001 will be loaded into DS Used HPP Used the accumulator using the Load Double instruction. The value in the accumulator is inverted using the Invert instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction.
DirectSOFT X1
5–132
V2001 0
LDD
4
0
V2000 5
00 22 55 00
V2000 Load the value in V2000 and V2001 into the accumulator
Acc.
INV 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
0
0
1
1
0
0
0
0
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
1 1
1 1
0
0
1
1
1
0
0
0
1 1
0
1
1
0
0
1
0
0
1
1
0
0
1
1
0
1
0
1
1
0
1
0
0
0
0
0
1
0
1 1
1 1 1
B
F
A
F
A
Invert the binary bit pattern in the accumulator
F
OUTD V2010
V2011
D
V2010
Copy the value in the accumulator to V2010 and V2011
Handheld Programmer Keystrokes $
B 1
STR
ENT
SHFT
L ANDST
D 3
3
SHFT
I
N TMR
V AND
GX OUT
SHFT
8
D
D
C
A 0
A 0
0
ENT C
3
A 2
A 2
DL205 User Manual, 4th Edition, Rev. A
B 0
A 1
0
0
ENT
ENT
F
0
1
0
0
1
1
Page 355
Chapter 5: Standard RLL Instructions - Number Conversion
Ten’s Complement (BCDCPL)
1 2, accumulator value 3 10’s compliment value 4 In the following example when X1 is on, the value in V2000 and V2001 is loaded into the accumulator. The 10’s complement is taken for the 8-digit accumulator using the Ten’s 5 Complement instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. 6 7 8 9 10 11 12 13 14 A B C D
Ten’s Complement instruction takes the 10’s complement 230 The (BCD) of the 8-digit accumulator. The result resides in the 240 accumulator. The calculation for this instruction is : 250-1 100000000 260 DS Used HPP Used
DirectSOFT
BCDCPL
V2000
V2001
X1
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
LDD
V2000
Load the value in V2000 and V2001 into the accumulator
BCDCPL
Takes a 10’s complement of the value in the accumulator OUTD
V2010
V2011
V2010
Copy the value in the accumulator to V2010 and V2011
Handheld Programmer Keystrokes $
B
STR
1
SHFT
L ANDST
D
SHFT
B
C
GX OUT
SHFT
ENT
D
3
1
C
3
D
2
C
3
3
A
0
CV
L ANDST
ENT
B
A
A
2
A
0
P
2
C
D
A
2
0
1
0
0
ENT
ENT
DL205 User Manual, 4th Edition, Rev. A
5–133
Page 356
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Binary to Real Conversion (BTOR) Binary-to-Real instruction converts a binary value in the 230 The accumulator to its equivalent real number (floating point) 240 format. The result resides in the accumulator. Both the binary 250-1 and the real number may use all 32 bits of the accumulator. 260
BTOR
NOTE: This instruction only works with unsigned binary, or decimal values. It will not work with signed decimal values.
Discrete Bit Flags SP63 SP70
DS Used HPP Used
5–134
Description On when the result of the instruction causes the value in the accumulator to be zero. 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 X1
V1401 LDD
V1400
0
0
0
5
7
2
4
1
V1400 Load the value in V1400 and V1401 into the accumulator
Acc.
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
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 1
Sign Bit
0
0
1
0 0
0
1
0
1 0
1
1
1
0
0 0
Exponent (8 bits)
Mantissa (23 bits)
Real Number Format
OUTD V1500 4
Copy the real value in the accumulator to V1500 and V1501
8
A
E
4
8
V1501
2
0
The real number (HEX) value copied to V1500
V1500
Handheld Programmer Keystrokes $
B STR
1
ENT
SHFT
L ANDST
D 3
3
SHFT
B
T MLR
O INST#
GX OUT
SHFT
1
D
D
B
E 1
R ORN
ENT
B
F
3
DL205 User Manual, 4th Edition, Rev. A
1
A 4
A 5
A 0
A 0
0
0
ENT
ENT
Page 357
Chapter 5: Standard RLL Instructions - Number Conversion
Real to Binary Conversion (RTOB)
1 2 3 NOTE : The decimal portion of the result will be rounded down (14.1 14 or - 14.1 -15). NOTE : If the real number is negative, it becomes a signed decimal value. 4 Discrete Bit Flags Description 5 6 7 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 8 value in the accumulator 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. 9 10 11 12 13 14 A B C D
Real-to-Binary instruction converts the real number in 230 The the accumulator to a binary value. The result resides in the 240 accumulator. Both the binary and the real number may use all 250-1 32 bits of the accumulator. 260
RTOB
1 2
SP63 SP70 SP72 SP73 SP75
On when the result of the instruction causes the value in the accumulator to be zero. On anytime the value in the accumulator is negative. On anytime the value in the accumulator is a valid floating point number. On when a signed addition or subtraction results in an incorrect sign bit. On when a number cannot be converted to binary.
DS Used HPP Used
DirectSOFT X1
4 8 A E 4 8 2 0
LDD
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
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
OUTD
V1500
Copy the real value in the accumulator to V1500 and V1501
V1501
V1500
0 0 0 5 7 2 4 1
The binary number copied to V1400
Handheld Programmer Keystrokes $
B
STR
1
SHFT
L ANDST
D
SHFT
R ORN
T MLR
GX OUT
SHFT
D
3
3
ENT
D
B
3
O INST#
B B
1 1
1
E
4
A
0
A
0
ENT
ENT F
5
A
0
A
0
ENT
DL205 User Manual, 4th Edition, Rev. A
5–135
Page 358
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Radian Real Conversion (RADR)
230 The Radian Real Conversion instruction converts the real value stored in the accumulator to the equivalent real 240 degree number in radians. The result resides in the accumulator. 250-1 260
RADR
Degree Real Conversion (DEGR)
Degree Real instruction converts the degree real radian 230 The value stored in the accumulator to the equivalent real number 240 in degrees. The result resides in the accumulator. 250-1 The two instructions described above convert real numbers in 260 the accumulator from degree format to radian format, and DS Used HPP N/A visa-versa. In degree format, a circle contains 360 degrees. In radian format, a circle contains 2 ⌸. 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 SP63 SP70 SP71 SP72 SP74 SP75
Description On when the result of the instruction causes the value in the accumulator to be zero. On anytime the value in the accumulator is negative. On anytime the V-memory specified by a pointer (P) is not valid. On anytime the value in the accumulator is a valid floating point number. On anytime a floating point math operation results in an underflow error. 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 R45
Load the real number 45 into the accumulator.
45.000000
RADR
Convert the degrees into radians, leaving the result in the accumulator.
0.7853982
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
5–136
DEGR
DL205 User Manual, 4th Edition, Rev. A
Page 359
Chapter 5: Standard RLL Instructions - Number Conversion
ASCII to HEX (ATH)
1 V aaa 2 This means an ASCII table of four V-memory locations would only require two V-memory 3 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 4 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 5 accumulator stack. Step 2: Load the starting V-memory location for the ASCII table into the accumulator. This 6 parameter must be a HEX value. Step 3: Specify the starting V-memory location (Vaaa) for the HEX table in the ATH instruction. 7 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 8 the value into the accumulator. Operand Data Type DL250-1 Range DL260 Range 9 aaa aaa 10 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 11 (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 12 below lists valid ASCII values for ATH conversion. 13 ASCII Values Valid for ATH Conversion ASCII Hex Value ASCII Value Hex Value 14 A B C D
ASCII TO HEX instruction converts a table of ASCII 230 The values to a specified table of HEX values. ASCII values are 240 two digits and their HEX equivalents are one digit. 250-1 260 DS Used HPP N/A
V-memory
30 31 32 33 34 35 36 37
V
All (See page 3 - 55)
0 1 2 3 4 5 6 7
38 39 41 42 43 44 45 46
ATH
All (See page 3 - 56)
8 9 A B C D E F
DL205 User Manual, 4th Edition, Rev. A
5–137
Page 360
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
DirectSOFT X1
K4
Hexadecimal Equivalents
ASCII TABLE
Load the constant value into the lower 16 bits of the accumulator. This value defines the number of V memory locations in the ASCII table
LD
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
1234
V1600
5678
V1601
V1600 is the starting location for the HEX table
ATH V1600
Handheld Programmer Keystrokes $
B STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
A
T MLR
0
ENT PREV
3
4 B
A 3
E
B 7
A 4
1
0 H
ENT E G
1
A 0
0
A 6
A 0
0
ENT
35 36
V1403
ENT
HEX to ASCII (HTA) The HEX to ASCII instruction converts a table of HEX
HTA
230 values to a specified table of ASCII values. HEX values are V aaa 240 one digit and their ASCII equivalents are two digits. 250-1 This means a HEX table of two V-memory locations would require four V-memory locations 260 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.
DS Used HPP N/A
5–138
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. 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
V
DL250-1 Range
DL260 Range aaa aaa
All (See page 3 - 55)
All (See page 3 - 56)
DL205 User Manual, 4th Edition, Rev. A
Page 361
Chapter 5: Standard RLL Instructions - Number Conversion 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 B
$ STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
H
T MLR
7
ENT PREV
3
2 B
A 3
C
1
0 A
B 0
ENT F
A 5
E 1
A 0
A 4
0 A
0
0
ENT ENT
The table below lists valid ASCII values for HTA conversion. ASCII Values Valid for HTA Conversion Hex Value
ASCII Value
Hex Value
ASCII Value
0 1 2 3 4 5 6 7
30 31 32 33 34 35 36 37
8 9 A B C D E F
38 39 41 42 43 44 45 46
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–139
Page 362
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Segment (SEG) BCD / Segment instruction converts a four digit HEX 230 The value in the accumulator to seven segment display format. 240
The result resides in the accumulator. 250-1 260 DS Used HPP Used
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
5–140
SEG
6
LD
F
7
1
V1400 Load the value in V1400 nto 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
1
0
1 1
1
0
0
0
0
0 0
0
0
0
0 0
0
0
0
0 0
0
1
1
0
1 1
1
0
0
0 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.
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
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
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 a f b
Segment Labels g e
Y57 Y56 Y55 Y54 Y53
Y24 Y23 Y22 Y21 Y20
OFF ON ON
OFF OFF ON ON OFF
ON ON c d
Handheld Programmer Keystrokes $
B STR
L ANDST
1 D
ENT B
3
SHFT
S RST
GX OUT
SHFT
E
SHFT F
A 4
1 G
E
6
4 C
5
A 0
ENT
D
A 2
0
ENT
0
C 3
DL205 User Manual, 4th Edition, Rev. A
2
ENT
Segment Labels