The text of a manual · part 24 of 40
DL05 Micro PLC User Manual, Volume 1 of 2: Chapter 5: Standard RLL and Intelligent Box Instructions, pages 214 to 223
Pages 214 to 223 of 379, from DL05 Micro PLC User Manual, Volume 1 of 2
The original document is the PDF (5.8 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 D0-05AA
Page 214
Chapter 5: Standard RLL - Number Conversion Instructions DirectSOFT 5 Direct SOFT32
1 2 3 4 5 6 7 HEX to ASCII (HTA) 8 The HEX to ASCII instruction converts a table of HEX values to a specified table of ASCII values. 9 HEX values are one digit and their ASCII equivalents are two digits. This means a HEX table of two V-memory locations would require four V-memory locations 10 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 11 to program a HEX to ASCII table function. The example on the following page shows a program for the HEX to ASCII table function. 12 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 13 parameter must be a HEX value. 14 Step 3:, Specify the starting V-memory location (Vaaa) for the ASCII table in the HTA instruction. A 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. B C D 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 location in the ASCII table
LD
V1400
33 34
Convert octal 1400 to HEX 300 and load the value into the accumulator
LDA
O 1400
V1401
31 32
V1402
37 38
V1403
35 36
1234
V1600
5678
V1601
V1600 is the starting location for the HEX table
ATH
V1600
Handheld Programmer Keystrokes B
$
STR
DS5 HPP
Used Used
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
A
T MLR
0
ENT
PREV
3
4
B
A
3
E
B
H
7
ENT
E
1
0
A
4
G
1
A
0
A
6
0
A
0
0
ENT ENT
HTA
V aaa
DL05 Micro PLC User Manual, 6th Edition, Rev. A
5–91
Page 215
Chapter 5: Standard RLL - Number Conversion Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–92
Operand Data Type
DL05 Range aaa
V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V
See memory map
Discrete Bit Flags
Description
SP53
On when the value of the operand is larger than the accumulator can work with.
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 Direct SOFT32 5 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 SHFT
3 A 3
K JMP
E
B
F
0 A
4
1 B
0
5 E
1
ENT A
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
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page 216
Chapter 5: Standard RLL - Number Conversion Instructions
Gray Code (GRAY) DS5
Used
HPP
Used
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 GRAY (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. 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 V2010. Discrete Bit Flags
Description
SP63 SP70
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.
DirectSOFT Direct SOFT325 X1
LDF
K16
X27 X26 X25
X12 X11 X10
OFF OFF OFF
ON OFF ON
X10 Load the value represented by X10–X27 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
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
GRAY
Convert the 16 bit grey code value in the accumulator to a BCD value Acc.
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
OUT V2010 Copy the value in the lower 16 bits of the accumulator to V2010 Handheld Programmer Keystrokes $
B STR
SHFT SHFT GX OUT
1
ENT
L ANDST
D
G
R ORN
A
SHFT
V AND
6
F 3
B 5 0
1 Y MLS
ENT
C
A 2
B
A 0
B 0
1
A 1
G
0
ENT
6
ENT
Gray Code
BCD
0000000000
0000
0000000001
0001
0000000011
0002
0000000010
0003
0000000110
0004
0000000111
0005
0000000101
0006
0000000100
0007
1000000001
1022
1000000000
1023
V2010
DL05 Micro PLC User Manual, 6th Edition, Rev. A
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–93
Page 217
Chapter 5: Standard RLL - Number Conversion Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Shuffle Digits (SFLDGT) DS5
Used
HPP
Used
5–94
SFLDGT 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. Step 1: - Load the value (digits) to be shuffled into the first level of the accumulator stack. Step 2: - Load the order that the digits will be shuffled to into the accumulator. Step 3: - Insert the SFLDGT instruction.
NOTE: If the number used to specify the order contains a 0 or 9–F, the corresponding position will be set to 0.
Discrete Bit Flags
Description
SP63 SP70
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.
Shuffle Digits Block Diagram
Digits to be shuffled (first stack location)
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.
9
A
B
C
D
E
F
0
1
2
8
7
3
6
5
4
Specified order (accumulator)
Bit Positions
8
7
6
5
4
3
2
1
B
C
E
F
0
D A
9
Result (accumulator)
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page 218
Chapter 5: Standard RLL - Number Conversion Instructions In the following example when X1 is on, The value in the first level of the accumulator stack will be reorganized in the order specified by the value in the accumulator. Example A shows how the shuffle digits works when 0 or 9 –F is not used when specifying the order the digits are to be shuffled. Also, there are no duplicate numbers in the specified order. Example B shows how the shuffle digits works when a 0 or 9–F is used when specifying the order the digits are to be shuffled. Notice when the Shuffle Digits instruction is executed, the bit positions in the first stack location that had a corresponding 0 or 9–F in the accumulator (order specified) are set to “0”. Example C shows how the shuffle digits works when duplicate numbers are used specifying the order the digits are to be shuffled. Notice when the Shuffle Digits instruction is executed, the most significant duplicate number in the order specified is used in the result. DirectSOFT Direct SOFT32 5
A
X1
B
V2001
LDD 9
V2000 Load the value in V2000 and V2001 into the accumulator
Original bit Positions
A
B
V2000 C
D
E
8
7
6
5
4
3
2
1
A
B
C
D
E
F
0
1
2
7
3
6
V2007
Load the value in V2006 and V2007 into the accumulator
Specified order
New bit Positions
SFLDGT
0
9
LDD V2006
F
8
0
Acc.
F
E
V2000 C
B
A
9
8 7 6 5 0 F E D
4 C
3 B
2 A
1 9
3
0
0
2
1
V2007 4
8
7
6
5
4
3
2
1
1
2
8
7
3
6
5
4
8
7
6
5
4
3
2
1
B
C
E
F
0
D A
9
B
C
E
F
0
D A
9
V2001
D
V2006 5
C
V2001
0
0
4
9
Acc.
A
B
V2000 C
D
E
F
0
8
7
6
5
4
3
2
1
9
A
B
C
D
E
F
0
4
3
1
4
3
2
1
V2006
V2007 2
V2006
8
7
6
5
4
3
2
1
8
7
6
5
4
3
2
1
Acc.
0
0
4
3
0
0
2
1
Acc.
4
3
2
1
4
3
2
1
8 7 6 5 0 0 0 0
4 E
3 D
2 A
1 9
8
7
6
5
4
3
2
1
Acc.
Acc.
0
0
0
0
9
A
B
C
0
E
D
A
9
0
0
0
0
9
A
B
C
Shuf fle the digits in the first level of the accumulator stack based on the pattern in the accumulator. The result is in the accumulator . OUTD
0
0
0
V2010 V2011
V2011
V2010
V2010
V2011
Copy the value in the accumulator to V2010 and V2011
Handheld Programmer Keystrokes $
B STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
S
GX OUT
SHFT
RST
ENT D
3
C 3
D 3
SHFT D 3
A 2
C 3
F 5
A 2
L ANDST
D
C
A 2
A 0 A 0
6
6
T MLR
ENT
A
ENT
B 0
0 G
0 G
3
A 0
1
0
Acc.
ENT ENT
DL05 Micro PLC User Manual, 6th Edition, Rev. A
V2010
Acc.
Acc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–95
Page 219
Chapter 5: Standard RLL - Table Instructions
1 Table Instructions Move (MOV) 2 The Move instruction moves the values from a V-memory table to another V-memory table the same length (a table is a consecutive group of V-memory locations). The function 3 parameters are loaded into the first level of the accumulator stack and the accumulator by two additional instructions. The MOV instruction can be used to write data to non-volatile V4 memory (see Appendix F). Listed below are the steps necessary to program the MOV function. 5 • Step 1: - Load the number of V-memory locations to be moved into the first level of the accumulator stack. This parameter is a HEX value (K40 max, 100 octal). • Step 2: - Load the starting V-memory location for the locations to be moved into the accumulator. 6 This parameter is a HEX value. • Step 3: - Insert the MOVE instruction which specifies starting V-memory location (Vaaa) for the 7 destination table. Helpful Hint:, For parameters that require HEX values when referencing memory 8 locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. 9 Operand Data Type DL05 Range aaa 10 11 Discrete Bit Flags Description In the following example, when X1 is on, the constant value (K6) is loaded into the 12 accumulator using the Load instruction. This value specifies the length of the table and is placed in the first stack location after the Load Address instruction is executed. The octal 13 address 2000 (V2000), the starting location for the source table is loaded into the accumulator. The destination table location (V2030) is specified in the Move instruction. 14 A B C D MOV
DS5
Used
HPP
Used
V aaa
....................................A V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P
SP53
See memory map See memory map
On when the value of the operand is larger than the accumulator can work with.
DirectSOFT Direct SOFT325 X1
K6
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
O 2000
Convert octal 2000 to HEX 400 and load the value into the accumulator
V2030
Copy the specified table locations to a table beginning at location V2030
LD
LDA
MOV
Handheld Programmer Keystrokes $
B
STR
5–96
1
ENT
SHFT
L ANDST
D
SHFT
L ANDST
D 3
0
SHFT
M ORST
O INST#
V AND
SHFT
3
A
K JMP
G
C
A
6
2 C
A
2
A 0
D 0
0 A
3
0
X
X
X V2026
X
X
X
X V2027
0
1
2
3 V2000
0
1
2
3 V2030
0
5
0
0 V2001
0
5
0
0 V2031
9
9
9
9 V2002
9
9
9
9 V2032
3
0
7
4 V2003
3
0
7
4 V2033
8
9
8
9 V2004
8
9
8
9 V2034
1
0
1
0 V2005
1
0
1
0 V2035
X
X
X
X V2006
X
X
X
X V2036
X
X
X
X V2007
X
X
X
X V2037
ENT
0 A
X
ENT ENT
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page 220
Chapter 5: Standard RLL - Table Instructions
Move Memory Cartridge (MOVMC) and Load Label (LDLBL) DS5
Used
HPP
Used
1 2 The Move Memory Cartridge and the Load Label instructions are used to copy data from program ladder memory to V-memory. The 3 Load Label instruction is used with the MOVMC instruction when copying data from program ladder memory to V-memory. 4 To copy data from the program ladder memory to V-memory, the function parameters are loaded into the first two levels of the 5 accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program the Move Memory Cartridge and Load Label functions. 6 • Step 1: - Load the number of words to be copied into the second level of the accumulator stack. • Step 2: - Load the offset for the data label area in ladder memory and the beginning of the 7 V-memory block into the first level of the stack. • Step 3: - Load the source data label (LDLBL Kaaa) into the accumulator when copying data from 8 ladder memory to V-memory. This is the source location of the value. • Step 4: - Insert the MOVMC instruction which specifies destination in V-memory (Vaaa). This is the copy destination. 9 Operand Data Type DL05 Range 10 aaa 11 12 13 14 A B C D MOVMC V aaa
LDLBL K aaa
....................................A V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V
See memory map
DL05 Micro PLC User Manual, 6th Edition, Rev. A
5–97
Page 221
Chapter 5: Standard RLL - Table Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–98
Copy Data From a Data Label Area to V-memory In the example to the right, data is copied from a Data Label Area to V-memory. When X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the table and is placed in the second stack location after the next Load and Load Label (LDLBL) instructions are executed. The constant value (K0) is loaded into the accumulator, specifying the offset for the source and destination data. It is placed in the first stack location after the LDLBL instruction is executed. The source address where data is being copied from is loaded into the accumulator using the LDLBL instruction. The MOVMC instruction specifies the destination starting location and executes the copying of data from the Data Label Area to V-memory.
DirectSOFT 5 Direct SOFT32 X1
Data label area programmed after the END instruction
DLBL C
O
N
K
1
2
3
N
C
O
N
K
4
5
3
N
C
O
N
K
6
1
5
N
C
O
N
K 8
8
4
K4
. .
K1
N
LD
Load the value 4 into the accumulator specifying the number of locations to be copied.
1
2
3
4
V2000
4
5
3
2
V2001
LD
6
1
5
1
V2002
8
8
4
5
V2003
Load the value 0 into the accumulator specifying the offset for source and destination locations
X
X
X
X
V2004
4
K0
2
1
5
LDLBL
. .
K1 Load the value 1 into the accumulator specifying the Data Label Area K1 as the starting address of the data to be copied.
Handheld Programmer Keystrokes $
MOVMC
B STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
M ORST
ENT
V2000 SHFT
K JMP
E
SHFT
K JMP
A
B
L ANDST
B
3
L ANDST
O INST#
V AND
M ORST
C
C
3 3
1
2
4 0
V2000 is the destination starting address for the data to be copied.
ENT ENT
1
ENT A
2
A 0
DL05 Micro PLC User Manual, 6th Edition, Rev. A
A 0
0
ENT
Page 222
Chapter 5: Standard RLL - CPU Control Instructions
CPU Control Instructions No Operation (NOP) DS5
Used
HPP
N/A
NOP
The No Operation is an empty (not programmed) memory location. DirectSOFT 5 Direct SOFT32
Handheld Programmer Keystrokes SHFT
NOP
N TMR
O INST#
P
CV
ENT
End (END) DS5
Used
HPP
N/A
The End instruction marks the termination point of the normal program scan. An End instruction is required at the end of the main program body. If the End instruction is omitted an error will occur and the CPU will not enter the Run Mode. Data labels, subroutines and interrupt routines are placed after the End instruction. The End instruction is not conditional; therefore, no input contact is allowed. DirectSOFT 5 Direct SOFT32
END
Handheld Programmer Keystrokes SHFT
END
E
4
N TMR
D
ENT
3
Stop (STOP) DS5
Used
HPP
N/A
The Stop instruction changes the operational mode of the CPU from Run to Program (Stop) mode. This instruction is typically used to stop PLC operation in an error condition. In the following example, when C0 turns on, the CPU will stop operation and switch to the program mode. DirectSOFT32 5 Direct
STOP
Handheld Programmer Keystrokes $
C0 STOP
Discrete Bit Flags SP16 SP53
STR
SHFT
S RST
SHFT
C
SHFT
T MLR
2
A
0
O INST#
ENT P
CV
ENT
Description On when the DL05 goes into the TERM_PRG mode. On when the DL05 goes into the PRG mode.
DL05 Micro PLC User Manual, 6th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–99
Page 223
Chapter 5: Standard RLL - CPU Control Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Reset Watch Dog Timer (RSTWT) DS5
Used
HPP
N/A
5–100
The Reset Watch Dog Timer instruction resets the CPU scan timer. The default setting for the watch dog timer is 200ms. RSTWT Scan times very seldom exceed 200ms, but it is possible. For/next loops, subroutines, interrupt routines, and table instructions can be programmed such that the scan becomes longer than 200ms. When instructions are used in a manner that could exceed the watch dog timer setting, this instruction can be used to reset the timer. A software timeout error (E003) will occur and the CPU will enter the program mode if the scan time exceeds the watch dog timer setting. Placement of the RSTWT instruction in the program is very important. The instruction has to be executed before the scan time exceeds the watch dog timer’s setting. If the scan time is consistently longer than the watch dog timer’s setting, the timeout value may be permanently increased from the default value of 200ms by AUX 55 on the HPP or the appropriate auxiliary function in your programming package. This eliminates the need for the RSTWT instruction. In the following example the CPU scan timer will be reset to 0 when the RSTWT instruction is executed. See the For/Next instruction for a detailed example. SOFT 32 DirectSOFT 5
Handheld Programmer Keystrokes SHFT
R ORN
S
RSTWT
DL05 Micro PLC User Manual, 6th Edition, Rev. A
RST
T MLR
W ANDN
T MLR
ENT