The text of a manual · part 39 of 68
DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 343 to 352
Pages 343 to 352 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 343
Standard RLL Instructions Table Instructions
AND Move (ANDMOV)
430 440 450
DS
HPP
OR Move (ORMOV)
430 440 450
DS
HPP
The AND Move instruction copies data from a table to the specified memory location, ANDing each word with the accumulator data as it is written.
5--171
ANDMOV A aaa
The Or Move instruction copies data from a table to the specified memory location, ORing each word with the accumulator contents as it is written.
LDR A aaa
Exclusive OR Move The Exclusive OR Move instruction copies XORMOV data from a table to the specified memory (XORMOV) A aaa location, XORing each word with the accumulator value as it is written. 430 440 450
The following description applies to the AND Move, OR Move, and Exclusive OR HPP DS Move instructions. A table is just a range of V-memory locations. These instructions copy the data of a table to another specified location, preforming a logical operation on each word with the accumulator contents as the new table is written. Step 1:, Load the length of the table (number of V--memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. Step 2:, Load the starting V--memory location for the table into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 3:, Load the BCD/hex bit pattern into the accumulator which will be logically combined with the table contents as they are copied. Step 4:, Insert the AND Move, OR Move, or XOR Move instruction. This specifies the starting location of the copy of the original table. This new table will automatically be the same length as the original table. Operand Data Type
DL450 Range aaa
V--memory
V
All (See p. 3--42)
V3000 3 3 3 3 F F F F
ANDMOV K6666
V3100 2 2 2 2 6 6 6 6
The program on the next page performs the ANDMOV operation example above. It assumes that the data in the table at V3000 -- V3001 already exists. First we load the table length (two words) into the accumulator. Next we load the starting address of the source table, using the LDA instruction. Then we load the data into the accumulator to be ANDed with the table. In the ANDMOV command, we specify the table destination, V3100.
DL405 User Manual, 4th Edition
Standard RLL Instructions
The example table to the right contains BCD data as shown (for demonstration purposes). Suppose we want to move a table of two words at V3000 and AND it with K6666. The copy of the table at V3100 shows the result of the AND operation for each word.
Page 344
5--172
Standard RLL Instructions Table Instructions
DirectSOFT
Handheld Programmer Keystrokes
X0
LD K2
LDA O 3000
Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator.
STR
X(IN)
0
LD
K(CON)
5
Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning.
LD
SHFT
A
OCT
3
AND
SHFT
M
O
V
OCT
3
1
0
0
K6666
O 3100
The example to the right shows a table of two words at V3000 and logically ORs it with K8888. The copy of the table at V3100 shows the result of the OR operation for each word. The program to the right performs the ORMOV example above. It assumes that the data in the table at V3000 -- V3001 already exists. First we load the table length (two words) into the accumulator. Next we load the starting address of the source table, using the LDA instruction. Then we load the data into the accumulator to be ORed with the table. In the ORMOV command, we specify the table destination, V3100.
V3000 1 1 1 1
V3100 9 9 9 9 9 9 9 9
DirectSOFT X0
LD K2 Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator. LDA O 3000 Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning. LD K8888 Load the constant value 8888 (Hex.) into the lower 16 bits of the accumulator.
STR
X(IN)
0
LD
K(CON)
5
LD
SHFT
A
OCT
3
OR
SHFT
M
O
V
1
ORMOV K8888
1 1 1 1
Handheld Programmer Keystrokes
Standard RLL Instructions
0
Copy the table to V3100, ANDing its contents with the accumulator as it is written.
ANDMOV
3
0
Load the constant value 6666 (Hex.) into the lower 16 bits of the accumulator.
LD
OCT
0
0
0
0
ORMOV
0
O 3100 Copy the table to V3100, ORing its contents with the accumulator as it is written.
0
The example to the right shows a table of two words at V3000 and logical XORs it with K3333. The copy of the table at V3100 shows the result of the XOR operation for each word.
V3000 1 1 1 1 1 1 1 1
XORMOV K3333
V3100 2 2 2 2 2 2 2 2
The ladder program example for the XORMOV is similar to the one above for the ORMOV. Just use the XORMOV instruction. On the handheld programmer, you must use the SHFT key and spell “XORMOV” explicitly.
DL405 User Manual, 4th Edition
Page 345
Standard RLL Instructions Table Instructions
Find Block (FINDB)
430 440 450
DS
HPP
The Find Block instruction searches for an occurrence of a specified block of values in a V--memory table. The function parameters are loaded into the first and second levels of the accumulator stack and the accumulator by three additional instructions. If the block is found, its starting address will be stored in the accumulator. If the block is not found, flag SP53 will be set. Operand Data Type
5--173
FINDB A aaa
DL450 Range aaa
V--memory
V
All (See p. 3--42)
V--memory
P
All (See p. 3--42)
Discrete Bit Flags
Description
SP53 on when the Find Block instruction was executed but did not find the block of data in table specified
The steps listed below are the steps necessary to program the Find Block function. Step 1:, Load the number of bytes in the block to be located. This parameter must be a HEX value, 0 to FF. Step 2:, Load the length of a table (number of words) to be searched. The Find Block will search multiple tables that are adjacent in V--memory. This parameter must be a HEX value, 0 to FF. Step 3:, Load the ending location for all the tables into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 4:, Load the table starting location for all the tables into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 5:, Insert the Find Block instruction. This specifies the starting location of the block of data you are trying to locate. Start Addr. Table 1 Table 2 Table 3
Number of words Start Addr. Block
Number of bytes
Standard RLL Instructions
Table n End Addr.
DL405 User Manual, 4th Edition
Page 346
5--174
Standard RLL Instructions Table Instructions
Swap (SWAP)
The Swap instruction exchanges the data in two tables of equal length.
SWAP A aaa
430 440 450
DS
HPP
The following description applies to both the Set Bit and Reset Bit table instructions. Step 1:, Load the length of the tables (number of V--memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. Remember that the tables must be of equal length. Step 2:, Load the starting V--memory location for the first table into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 3:, Insert the Swap instruction. This specifies the starting address of the second table. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Helpful hint:, The data swap occurs within a single scan. If the instruction executes on multiple consecutive scans, it will be difficult to know the actual contents of either table at any particular time. So, remember to swap just on a single scan. Operand Data Type
DL450 Range aaa
V--memory
V
All (See p. 3--42)
The example to the right shows a table of two words at V3000. We will swap its contents with another table of two words at 3100 by using the Swap instruction. The required ladder program is given below.
V3000
V3100
1 2 3 4
SWAP
5 6 7 8
A B C D 0 0 0 0
The example program below uses a PD contact (triggers for one scan for off-to-on transition). First, we load the length of the tables (two words) into the accumulator. Then we load the address of the first table (V3000) into the accumulator using the LDA instruction, converting the octal address to hex. Note that it does not matter which table we declare “first”, because the swap results will be the same. DirectSOFT X0
Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator.
LD K2
Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning.
LDA O 3000
Swap the contents of the table in the previous instruction with the one at V3100.
SWAP
Standard RLL Instructions
O 3100
Handheld Programmer Keystrokes STR
X(IN)
SHFT
LD
K(CON)
2
LD
SHFT
A
OCT
SHFT
S
W
A
DL405 User Manual, 4th Edition
P
D
SHFT
0
3
0
0
0
P
OCT
3
1
0
0
Page 347
Standard RLLInstructions Clock/Calendar Instructions
5--175
Clock/Calender Instructions Date (DATE)
430 440 450
DS
HPP
The Date instruction can be used to set the date in the CPU. The instruction requires two consecutive V--memory locations (Vaaa) to set the date. If the values in the specified locations are not valid, the date will not be set. The current date can be read from 4 consecutive V--memory locations (V7771--V7774).
DATE V aaa
Date
Range
V Memory Location (BCD) (READ Only)
Year
0--99
V7774
Month
1--12
V7773
Day
1--31
V7772
Day of Week
0--06
V7771
The values entered for the day of week are: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday Operand Data Type
V--memory
DL440 Range
DL450 Range
A aaa aaa
V
All (See p. 3--41)
All (See p. 3--42)
In the following example, when C0 is on, the constant value (K94010301) is loaded into the accumulator using the Load Double instruction (C0 should be a contact from a one shot (PD) instruction). The value in the accumulator is output to V2000 using the Out Double instruction. The Date instruction uses the value in V2000 to set the date in the CPU. DirectSOFT
Constant (K)
C0
9
4
0
1
0
3
0
1
Acc. 9
4
0
1
0
3
0
1
Acc. 9
4
0
1
0
3
0
1
9
4
0
1
0
3
0
1
LDD
In this example, the Date instruction uses the value set in V2000 and V2001 to set the date in the appropriate V--memory locations (V7771--V7774)
K94010301 Load the constant value (K94010301) into the accumulator OUTD V2000 Copy the value in the accumulator to V2000 and V2001
V2001
V2000
Format V2001
DATE V2000
9
Set the date in the CPU using the value in V2000 and V2001
4
0
V2000 1
0
3
0
1
STR
C(CR)
0
LD
SHFT
D
SHFT
Year
Month
K(CON)
9
4
0
1
0
3
0
1
OUT
SHFT
D
SHFT
V
2
0
0
0
SHFT
D
A
T
E
SHFT
V
2
0
Day
0
Day of Week
0
DL405 User Manual, 4th Edition
Standard RLL Instructions
Handheld Programmer Keystrokes
Page 348
5--176
Standard RLL Instructions Clock/Calendar Instructions
Time (TIME)
430 440 450
DS
HPP
The Time instruction can be used to set the time (24 hour clock) in the CPU. The instruction requires two consecutive V-memory locations (Vaaa) which are used to set the time. If the values in the specified locations are not valid, the time will not be set. The current time can be read from V--memory locations V7747 and V7766--V7770.
TIME V aaa
Date
Range
V Memory Location (BCD) (READ Only)
1/100 seconds (10ms)
0--99
V7747
Seconds
0--59
V7766
Minutes
0--59
V7767
Hour
0--23
V7770
Operand Data Type
V--memory
DL440 Range
DL440 Range
A aaa aaa
V
All (See p. 3--41)
All (See p. 3--41)
In the following example, when C0 is on, the constant value (K73000) is loaded into the accumulator using the Load Double instruction (C0 should be a contact from a one shot (PD) instruction). The value in the accumulator is output to V2000 using the Out Double instruction. The TIME instruction uses the value in V2000 to set the time in the CPU. DirectSOFT
Constant (K)
C0
0
0
0
7
3
0
0
0
Acc. 0
0
0
7
3
0
0
0
Acc. 0
0
0
7
3
0
0
0
0
0
0
7
3
0
0
0
LDD
The Time instruction uses the value set in V2000 and V2001 to set the time in the appropriate V--memory locations (V7766--V7770)
K73000 Load the constant value (K73000) into the accumulator OUTD V2000 Copy the value in the accumulator to V2000 and V2001
V2001
Format
V2000
V2001
TIME
0
V2000
0
0
V2000 7
3
0
0
0
Set the time in the CPU using the value in V2000 and V2001
Not Used
Standard RLL Instructions
Handheld Programmer Keystrokes STR
C(CR)
0
LD
SHFT
D
SHFT
K(CON)
OUT
SHFT
D
SHFT
V
SHFT
T
I
M
E
DL405 User Manual, 4th Edition
7
3
0
0
2
0
0
0
SHFT
V
2
0
Hour Minutes
0
0
0
Seconds
Page 349
Standard RLL Instructions CPU Control Instructions
5--177
CPU Control Instructions No Operation (NOP)
430 440 450
DS
HPP
The No Operation is an empty (not programmed) memory location. These instructions are just place-holders in the program. So, you will not need to program them, because they automatically appear after the end of the program.
NOP
DirectSOFT Handheld Programmer Keystrokes NOP
End (END)
430 440 450
DS
HPP
SHFT
N
O
P
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.
END
DirectSOFT Handheld Programmer Keystrokes END
END
Stop (STOP)
430 440 450
DS
HPP
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 a shutdown condition such as a I/O module failure.
STOP
In the following example, when SP45 comes on indicating a I/O module failure, the CPU will stop operation and switch to the program mode. DirectSOFT
Handheld Programmer Keystrokes
STOP
STR
SPCL
4
5
SHFT
S
T
O
P
SP45 will turn on if there is an I/O module falure
DL405 User Manual, 4th Edition
Standard RLL Instructions
SP45
Page 350
5--178
Standard RLL Instructions CPU Control Instructions
Break (BREAK)
430 440 450
DS
HPP
The Break instruction changes the operational mode of the CPU from Run to the Test Program mode. This instruction is typically used to aid in debugging an application program. The Break instruction allows V--memory and image register data to be retained where it would be normally cleared with the Stop instruction or a normal Run to Program transition.
BREAK
In the following example when C10 turns on, the CPU will stop operation and switch to the Test program mode. DirectSOFT
Handheld Programmer Keystrokes
C10 BREAK
Reset Watch Dog Timer (RSTWT)
430 440 450
DS
HPP
STR
C(CR)
1
0
SHFT
B
R
E
The Reset Watch Dog Timer instruction resets the CPU scan timer. The default setting for the watch dog timer is 200ms. 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
K
RSTWT
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.
Standard RLL Instructions
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. DirectSOFT
Handheld Programmer Keystrokes SHFT RSTWT
DL405 User Manual, 4th Edition
R
S
T
W
T
Page 351
Standard RLL Instructions Program Control Instructions
5--179
Program Control Instructions Goto/Label (GOTO/LBL)
430 440 450
DS
HPP
The Goto/Label skips all instructions between the Goto and the corresponding LBL instruction. The operand value for the Goto and the corresponding LBL instruction are the same. The logic between Goto and LBL instruction is not executed when the Goto instruction is enabled. Up to 128 Goto instructions and 64 LBL instructions can be used in the program.
K aaa GOTO
K aaa
LBL
Operand Data Type
Constant
DL440 Range
K
DL450 Range aaa aaa
1--FFFF
1--FFFF
In the following example, when C7 is on, all the program logic between the Goto and the corresponding LBL instruction (designated with the same constant Kaaa value) will be skipped. The instructions being skipped will not be executed by the CPU. DirectSOFT C7
K5 GOTO
X1
C2 OUT
S S S LBL
K5
X5
Y2 OUT
Handheld Programmer Keystrokes STR
7
SHFT
G
O
STR
X(IN)
1
OUT
C(CR)
2
SHFT
L
B
STR
X(IN)
5
OUT
Y(OUT)
2
T
O
SHFT
K(CON)
L
SHFT
K(CON)
5
5
S S
DL405 User Manual, 4th Edition
Standard RLL Instructions
C(CR)
Page 352
5--180
Standard RLL Instructions Program Control Instructions
The For and Next instructions are used to execute a section of ladder logic between the For and Next instructions a specified numbers of times. When the For instruction is enabled, the program will loop the specified number of times. If the For instruction is not energized the section of ladder logic between the For and Next instructions is not executed.
For/Next (FOR/NEXT)
430 440 450
DS
HPP
A aaa FOR
NEXT
For / Next instructions cannot be nested. Up to 64 For / Next loops may be used in a program. If the maximum number of For / Next loops is exceeded, error E413 will occur. The normal I/O update and CPU housekeeping is suspended while executing the For / Next loop. The program scan can increase significantly, depending on the amount of times the logic between the For and Next instruction is executed. With the exception of immediate I/O instructions, I/O will not be updated until the program execution is completed for that scan. Depending on the length of time required to complete the program execution, it may be necessary to reset the watch dog timer inside of the For / Next loop using the RSTWT instruction. Operand Data Type
DL440 Range
DL450 Range
A aaa aaa
V--memory
V
All (See p. 3--41)
All (See p. 3--42)
Constant
K
1--9999
1--9999
In the following example, when X1 is on, the application program inside the For / Next loop will be executed three times. If X1 is off the program inside the loop will not be executed. The immediate instructions may or may not be necessary depending on your application. Also, The RSTWT instruction is not necessary if the For / Next loop does not extend the scan time larger the Watch Dog Timer setting. For more information on the Watch Dog Timer, refer to the RSTWT instruction. DirectSOFT
X1
RSTWT
Standard RLL Instructions
Handheld Programmer Keystrokes
K3 FOR
1
2
3
STR
X(IN)
1
SHFT
F
O
R
SHFT
K(CON)
SHFT
R
S
T
W
T
STR
SHFT
I
SHFT
X(IN)
2
Y5
Y(OUT)
SHFT
I
SHFT
Y(OUT)
5
OUTI
SHFT
N
E
X
T
X20
NEXT
DL405 User Manual, 4th Edition
3
0