The text of a manual · part 14 of 37
Sharp Programmable Controller New Satellite JW10 User's Manual: Chapter 9 Description of Instructions, pages 96 to 105
Pages 96 to 105 of 307, from Sharp Programmable Controller New Satellite JW10 User's Manual
The original document is the PDF (5.0 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.
Filed in the catalog under the Sharp jW-10CM
Page 96
[3] Indirect address assignment • F-70 and F-70w can assign indirect address for their source and destination. • If source or destination is assigned with indirect address, the assigned register itself does not execute operation. Registers of file address assigned by contents of three bytes headed by its register executes operation. (For file address, see page 7・8 "File address") • To assign indirect address, put @ (at mark) at the top of register. n
S
D
Ex. F-70 FILE
001
Transfer register contents assigned by 09000, 09001, and 09002 to 09400.
@09000 09400
In the example above, file address 005002 is register 19002. As a result, @09000 indicates 19002. 09002 09001 09000 000000000000101000000010 Always 0 File No. 0 (0 for JW10)
0
5
0
0
19002 00011101
09400 00011101
2
Indicate file address (0004002)
Note 1: For assigning indirect address, make sure to set even number address. One will be deducted if odd address number is set and changed to even address. (If @09003 is set, it is treated as @09002.) Note 2: Timer/counter setting area (001600 to 001677) of file address cannot be assigned as indirect address. Further, addresses 001700 to 001777, 003000 to 003777, and 010000 and after are used inside the CPU. These areas cannot be used by users. Therefore they cannot be set as indirect address. Reference: Examples of using indirect address • Each time input signal changes from OFF to ON, the program stores data of register 09400 to 512 bytes from 19000 to 19777 in order. 00000 Initial setting
F-08w 005000 09000 OCT 09002 09001 09000 000000000000101000000000 F-08 OCT
000
09002
File 0
0
5
0
0
0
(File address 005000 = 19000) 00001 Input signal
00001 F-70 FILE
07357 Zero flag
09400 @09000
09400 19000 19001
F-63w FILE
00001
001
19002
09000 • • •
• • •
19777 Fc12w 09000 006000 CMP If file address is more than 006000, it is returned to 005000. F-08w 005000 09000 OCT
9-21
512 bytes
9
Page 97
[4] Accumulator and stack register Use accumulator (ACC) and stack register with basic instructions such as STR and STR NOT. (See “Operation of basic instruction” in page 9・8.) However, application instructions execute operations using these as operation conditions. 1) Single input instruction • Execute only the contents of the accumulator (ACC) as operation condition. • The contents of ACC and stack register are stored after operation.
00001 00002 F-12w コ0001 09001 CMP 00000
9
STR 00001 OR 00000 AND NOT 00002 F-12 コ0001 09001
00001 00002 ACC
Contents of 00000
2) Multiple input instruction • F-62 and F-62w use the accumulator (ACC) and stack register S1 and S2 as they are three input instructions. • F-60 and F-60w use the accumulator (ACC) and stack register S1, S2 and S3 as they are four input instructions. • After operation, contents of ACC and stack register are latched. 00000 Shift direction ① 00001 Data input ② 00002 Shift input ③
STR NOT 00000 STR 00001 STR 00002 F-60 00003 F/B 09000 STR F-60 SFR 09000
00003 Reset input ④
ACC
Contents of
S1
Contents of
S2
Contents of
S3
Contents of
00003 00002 00001 00000
Reset input ④ Shift input ③ Data input ② Shift direction ①
3) Instruction without input • Instructions F-31, F-40, F-42, F-47, F-48, F-90, F-140, F-143, and F-145 do not have input condition so that they do not use the accumulator (ACC) and stack register. • After operation, contents of ACC and stack register are latched. 4) Instructions with which status of the accumulator (ACC) changes • F-43 reverses ACC condition just before (OFF to ON, ON to OFF). • F-44 turns ON the ACC for only one scan time just before the ACC changes from OFF to ON. The ACC turns OFF cases other than switching from OFF to ON. • F-45 turns ON the ACC for only one scan time just before the ACC changes from ON to OFF. The ACC turns OFF cases other than switching from OFF to ON. • After operation, contents of ACC and stack register are latched.
9-22
Page 98
[5] Operational condition • Operational condition of an application instruction can be a complicated serial/parallel circuit, not limited to a single contact ON/OFF condition. • If the operational condition is same, it may be programmed in succession, as shown in Example 2). Example 1) 00001 00002
Example 2) 04000
F-00 09011 09200 XFER
00003
Operational condition
Instruction
STR OR OR AND F-00
00001 00002 00003 04000
00010
00100
00011
09011 09200
Instruction
F-00 コ005009030 XFER F-13 0910109030 AND
Operational condition
F-00 コ0410コ1000 XFER
STR OR AND F-00
00010 00011 00100 コ0050 09030
F-13 09101 09030 F-00 コ0410 コ1000
Note 1: In case where operational condition is the same, and some instructions vary operation results between programming continually and programming by separated circuits. See page 9・26, "Double-length operation." • There are following two kinds of execution modes for application instruction to be executed when the operational condition is met. ① Those which operation takes place only at the 1 scan cycle that the operational condition is met. F-00, F-10 etc. ② Those which operation takes place at each scan cycle, so long as the operational condition is met. F-12, F-80 etc. • For the instruction of the group ① above, the ON/OFF state of the operational condition of the preceding scan cycle is compared with the ON/OFF state of the operational condition at the current scan cycle. If the preceding state is OFF and the current state is ON, the operation takes place as if the operational condition changed from OFF to ON.
• To execute at every scan cycle for the group of ① , use the F-47(ON level set) or F-48(ON level reset).
00001
F-47 ONLS F-63 I N C 09000 F-48 ONLR
• In case the operation is to be executed only at an OFF to ON transition of the operational condition of the group of ② , the F-44 instruction (rise edge differential instruction) must be used.
00200
00100 F-44
F-12 コ0100 09200 CMP
00011
• If the operational condition is not met, no operation takes place and the register on the destination side remains unaffected. In case of the instruction that affects the flag, the flag is cleared (See the next page for the flag.)
9-23
9
Page 99
[6] Operation flag 1) Kind of flags • Flag is used to reflect the operational result. There are 4 kinds of flags for the JW10 ; non-carry, error, carry, and zero flag. These are assigned to four bits of data memory, 07354 to 07357.
Non-carry flag Error flag Carry flag Zero flag
07354 07355 07356 07357
2) Instruction that affects flag Instruction such as F-03, F-12, F-63 etc. will set flag according to the result. 3) Transition of flag during scan cycle • Prior to processing of the user program at each scan cycle, flags are cleared. (Refer to page 8・1 "Operation cycle".) • When going into processing of a flag affecting instruction a.The flag is set according to the result of the instruction, if the operational condition is met for the instruction. b.Flag is cleared if the operational condition is not met for the instruction.
9
• As to the execution of no flag affecting instruction, the state of flag is not changed, whether the operation took place or not.
(If there is no flag affecting instructions in preceding steps.) 00100 ① 07356 ②
(Carry) 00110
③ 00200 ④
F-63 09100 INC F-63 09101 INC F-00 09300 コ0040 XFER F-03 コ0100 09200 BIN
(If there is no flag affecting instructions in steps to follow.)
Address 01000 01001 01002 01003 01004 01005 01006 01007 01010 01011 01012 01013 01014 01015
Instruction STR F-63 STR F-63 STR F-00
STR F-03
00100 ① 09100 07356 ② 09101 00110 09300 コ0040 00200 コ0100 09200
③
④
1 scan time
I/O
User program execution program I/O User execution
I/O
User program execution
I/O
Data memory 00100 Data memory 00110 Data memory 00200
State of flag
Depends on the result of ① Clear
Depends on the result of ① Depends on the result of ② Clear
Clear
Clear
Clear
Clear
Clear Step ④ (not executed) Step ③ (executed)
Depends on the result of ④
Clear clear not affected
Clear Step ④ (executed) Step ③ (executed) Step ② (not executed)
Step ② (executed)
Step ① (executed)
Step ① (executed)
9-24
Clear
Page 100
4) How to retain flag • Flag thus set according to the result may be changed or cleared after the operation of a flag affecting instruction in that scan cycle. When it goes into a next scan cycle, the flag is cleared before operation of the user program. • In case the flag has to be retained of its current state, you must write the state of the flag into the coil (such as auxiliary relay) immediately following the respective instruction. This retains the state of the flag until the operation of the respective instruction in the next scan cycle. Example: Program that sets 04050 ON when 19000 ≧ 19010 or 19001 ≧ 19010. 00010
F-12 19000 19010 CMP
07354
A
04000
04000 is set ON when 19000≧19010 after the operation of A.
(Non-carry)
00010
F-12 19001 19010 CMP
07354
The non-carry flag set in A changes according to result of B.
B
04050
The result of A (04000) is ORed with the result of B.
(Non-carry)
04000
I/O User program execution I/O User program execution I/O User program execution I/O
9 00010 07354 Operation of B (19001<19010)
Operation of B (19001≧19010)
Operation of B (19001<19010)
Operation of A (19000≧19010)
Operation of A (19000<19010)
Operation of A (19000<19010)
04000 04050
• To monitor the state of flag by the support tool such as hand-held programmer JW-13PG etc. or to display it externally, it is not possible to visually check the state of the flag because the state of the flag can only be retained for a single scan cycle by simply writing the state of the flag in the coil as in example above. • In such a case, it will be necessary to make the flag self-retained.
00100
07356
I/O
F-63 09000 INC 00200
User program execution
Data memory 00100
07000
(Carry) 07000
09000 Carry flag 07356 07000 Data memory 00200
The state of the carry flag (07356) after the operation of A can be self-retained until 00200 is set ON.
9-25
377 (8) 000
I/O
I/O User program execution
Page 101
[7] Double-length operation 1) Instructions that are capable of double-length operation • The following 12 instructions have the double-length operation function to permit operation of more than 2 bytes (or 4 bytes for a word execution instruction). ① F-10, F-10w : add register and register ② Fc10, Fc10w : add register and BCD constant ③ F-11, F-11w : subtract register from register ④ Fc11, Fc11w : subtract BCD constant from register ⑤ F-12, F-12w : compare register with register ⑥ Fc12, Fc12w : compare register with constant 2) Programming double-length operation • Double-length operation is utilized to reflect a carry over or a carry down in a next digit to follow. It should be programmed from a low order digit following to the operational condition. Example 1)
+ 00001
09001
09000
F-10 ADD
09000
F-10 ADD
9 In case of
00001
1
5
09001
09101 09100
09101
09100
09201
Instruction
09200
STR F-10
09200
00001 09000 09100 09200
09201
F-10 4
3
09001
09000
F-10 ADD
09000
+ 3
2
09101
5
09001 09101 09201
8
09100
Non-carry Error
09100
09200
4
3
+ 5
0
8
0
Non-carry Error
F-10 ADD
09001
09101
09201
1
5
+ 3
09001
Carry
Zero
1
0
Carry
Zero
0
0
0
09200
09100
09000
1
+
2
4
1
09101
8
09201
1
0
07354 07355 07356 07357
The carry flag in a lower digit is added to a next higher digit during the operation.
Reference: Programming in the following way would not perform the double-length operation. 00001
Non-carry Error
F-10 ADD
09000
09100
09200
4
3
+
09000 00001
5
0
8
1
09100
09200
3
4
0
0
09001
09101
09201
1
5
+
09001
2
09101
7
09201
Zero
1
0
07354 07355 07356 07357 Non-carry Error
F-10 ADD
Carry
0
0
Carry
Zero
1
0
07354 07355 07356 07357
Example 2) Double-length operation about 3 bytes is also possible in the same manner. 00001
00200
F-11w SUB
09040
09050 コ0004
F-12w コ0000 09100 CMP
F-11 SUB
09042
09052 コ0006
F-12w コ0002 09102 CMP
(Subtraction of BCD 6 digits)
F-12 CMP
9-26
コ0004 09104
(Comparison of 6 words data)
Page 102
3) Internal processing during the double-length operation • For operation of double-length operational instruction that appears first after the operational condition, the operation takes place without including the state of the flag before that. • If there is double-length operational instruction encountered during execution of the common operational condition, the following operation takes place. a. Execution takes place including the state of the carry flag immediately before. b. For the zero flag, the state of the zero flag immediately before is ANDed with the state ofthe zero flag after the operation of the respective instruction. If both are 1, the zero flag is then set.
F-10, F-10w Fc10, Fc10w
The state of the carry flag immediately before is added
F-11, F-11w Fc11, Fc11w
The state of the carry flag
F-12, F-12w Fc12, Fc12w
The state of the carry flag immediately before is subtracted immediately before is subtracted
Note 1: For the F-12, F-12w, Fc12 and Fc12w instructions, operation of S1-S2 or S1-n is carried out and its result is stored in the flag. 4) Cautions concerning the double-length operation ① Operation that includes the flag takes place for a different instruction, if double-length operational instruction has been programmed in a form of common operational condition. 00020
Non-carry Error
F-11 SUB
09000
09001
09002
2
−
0
3
09000
9
0
0
09002
09001
0
09010
09011
8
09012
+
4
1
09010
5
+
1
0
09011
0
0
09012
Zero
1
0
07354 07355 07356 07357 Non-carry Error
F-10 ADD
Carry
0
Carry
Zero
1
0
0
07354 07355 07356 07357
② The double-length operation takes place even if there is no flag affecting instruction between the double-length operational instructions. 00011
Non-carry Error
F-12 CMP
F-00 XFER
コ0000 09000
1
−
5
1
コ0000
0
8
09000
Carry
Zero
1
0
0
07354 07355 07356 07357
09100 コ0040
Instruction that does not affect the flag F-13 AND
09011
09020
F-11 SUB
09012
09013
Non-carry Error
2
09110
−
7
1
09012
7
− 1
09013
0
1
9
09110
Carry
Zero
0
0
0
07354 07355 07356 07357
③ If there is a flag affecting instruction between the double-length operational instructions, operation takes place including the flag caused by the operation of that instruction. 00050
Non-carry Error
F-12 CMP
コ0000 09000
1
4
−
コ0000 F-63 INC
1
1
3
0
Non-carry Error
377
(8)
09100
000 09100
0
0
コ0010 09010
2
4
−
コ0010
2
4
09010
0
− 1
Carry
Zero
1
1
07354 07355 07356 07357 Non-carry Error
F-12 CMP
Zero
0
07354 07355 07356 07357
09000
09100
Carry
0
0
Carry
Zero
1
0
07354 07355 07356 07357
④ If other than BCD code is specified for the F-10, F-10w, Fc10, Fc10w, F-11, F-11w, Fc11, or Fc11w instruction, an error flag is evoked so that double-length operation will no more be executed thereafter. 9-27
9
Page 103
[8] Description of each application instructions F-00 XFE R Symbol
F-00 XFER
S
D
The contents of the register (1 byte) are transferred to the register D.
Operation
S→D
Range of D
Instruction 04004
04004
F-00 09000 コ0041 XFER
09000 コ0041
When the input condition 04004 changes from OFF to ON, the contents of the register 09000 are transferred to the register コ0041.
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
Condition
Rising edge of input signal (OFF to ON)
After operation
Contents Unchanged of S Contents Contents of register S of D
Flag
〔Example for use〕
STR F-00
Function
Range of S
9
Transfer 1 byte data
09000
コ0041
01110101
01110101
Unchanged
Similarity instructions: F-00w, F-70, F-70w, F-74, F-74w
F - 00w XFER Symbol
Transfer 1 word data F-00w XFER
S
D
Function
The contents of the registers S, S+1 (1 word) are transferred to the register D, D+1.
Operation
S, S+1→D, D+1
Range of S
Range of D
Condition
After operation
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
〔Example for use〕
Instruction 04000
STR F-00w 04000
F-00w 09000 コ0040 XFER
09000 コ0040
When the input condition 04000 changes from OFF to ON, the contents of the registers 09000 and 09001 (1 word) are transferred to the registers コ0040 and コ0041. 09001
09000
0110101010101100
コ0041
コ0040
0110101010101100
Rising edge of input signal (OFF to ON) Contents Unchanged of S, S+1 Contents Contents of register S of D Contents Contents of register S+1 of D+1
Flag
Unchanged
Note 1: Be sure to use even addresses for registers S and D. Similarity instructions: F-00, F-70, F-70w, F-74, F-74w
9-28
Page 104
F-01 BCD Symbol
Transfer BCD (2 digits) constant F-01 BCD n
〔Example for use〕
D
Function
A 2 digits BCD constant "n" is transferred to the register D.
Operation n→D
Condition After operation
04004
F-01 BCD
15
15 09100
09100
When the input condition 04004 changes from OFF to ON, the BCD constant "15" is transferred to the register 09100.
Range of "n" 00 to 99
Range of D
Instruction 04004
S TR F-01
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
The following value is contained in the register 09100 after the transfer. 09100 00010101
Rising edge of input signal (OFF to ON)
1
5
Contents n (00 to 99) of D
Flag
Unchanged
Similarity instructions: F-01w
9
F-01w BCD Symbol
Transfer BCD (4 digits) constant F-01w BCD n
〔Example for use〕
D
Function
A 4 digits BCD constant "n" is transferred to the registers D, D+1.
Operation n→D, D+1
Condition After operation
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
F-01w 1984 BCD
1984 19100
19100
The following value is contained in the registers 19100 and 19101 after the transfer. 19101
19100
0001100110000100
Rising edge of input signal (OFF to ON)
1
Contents n of D, D+1
Flag
04001
When the input condition 04001 changes from OFF to ON, the BCD constant "1984" is transferred to the registers 19100 and 19101.
Range of "n" 0000 to 9999
Range of D
Instruction 04001
STR F-01w
Unchanged
Note 1: Be sure to use even addresses for registers D. Similarity instructions: F-01
9-29
9
8
4
Page 105
F-02 XCHG Symbol
Exchange 1 byte data between registers (eXCHanGe) F-02 XCHG
D1
The contents of the register D1 are exchanged with the contents of the register D2.
Operation
D1←→D2
Range of D2
04001
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
Before operation
Rising edge of input signal (OFF to ON)
After operation
Contents Contents of register D2 of D1 Contents Contents of register D1 of D2
Flag
F-02 09000 09001 XCHG
09000 09001
When the input condition 04001 changes from OFF to ON, the contents of the register 09000 are exchanged with the contents of the register 09001.
Condition
9
Instruction 04001
STR F-02
Function
Range of D1
〔Example for use〕
D2
After operation
09000 0 0 0 0 0 0 1 0
10000000
09001 1 0 0 0 0 0 0 0
00000010
Unchanged
Similarity instrucions: F-02w
F-02w XCHG Symbol
Exchange 1 word data between registers (eXCHanGe) F-02w XCHG
D1
D2
Function
The contents of the registers D1, D1+1 (1 word) are exchanged with the contents of the registers D2, D2+1 (1 word).
Operation
D, D1+1←→D2, D2+1
Range of D1
Range of D2
Condition
After operation
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
〔Example for use〕
04000
Instruction 04000 STR F-02w
F-02w 09000 19000 XCHG
09000 19000
When the input condition 04000 changes from OFF to ON, the contents of the registers 09000 and 09001 (1 word) are exchanged with the contents of the registers 19000 and 19001 (1 word). Before operation
After operation
09000 0 0 0 1 0 1 0 0
11001101
09001 1 0 0 1 1 0 1 0
01010011
19000 1 1 0 0 1 1 0 1
00010100
19001 0 1 0 1 0 0 1 1
10011010
Rising edge of input signal (OFF to ON) Contents of D1 Contents of D1+1 Contents of D2 Contents of D2+1
Flag
Contents of the register D2 Contents of register D2+1 Contents of the register D1 Contents of register D1+1 Unchanged
Note 1: Be sure to use even addresses for registers D1 and D2. Similarity instructions: F-02
9-30