The text of a manual · part 23 of 68
Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 194 to 203
Pages 194 to 203 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual
The original document is the PDF (3.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.
Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204
Page 194
Section 5-14
Timer and Counter Instructions Limitations
Each TC number can be used as the definer in only one TIMER or COUNTER instruction.
Description
The CNTR(012) is a reversible, up/down circular counter, i.e., it is used to count between zero and SV according to changes in two execution conditions, those in the increment input (II) and those in the decrement input (DI). The present value (PV) will be incremented by one whenever CNTR(012) is executed with an ON execution condition for II and the last execution condition for II was OFF. The present value (PV) will be decremented by one whenever CNTR(012) is executed with an ON execution condition for DI and the last execution condition for DI was OFF. If OFF to ON changes have occurred in both II and DI since the last execution, the PV will not be changed. If the execution conditions have not changed or have changed from ON to OFF for both II and DI, the PV of CNT will not be changed. When decremented from 0000, the present value is set to SV and the Completion Flag is turned ON until the PV is decremented again. When incremented past the SV, the PV is set to 0000 and the Completion Flag is turned ON until the PV is incremented again. CNTR(012) is reset with a reset input, R. When R goes from OFF to ON, the PV is reset to zero. The PV will not be incremented or decremented while R is ON. Counting will begin again when R goes OFF. The PV for CNTR(012) will not be reset in interlocked program sections or by the effects of power interruptions. Changes in II and DI execution conditions, the Completion Flag, and the PV are illustrated below starting from part way through CNTR(012) operation (i.e., when reset, counting begins from zero). PV line height is meant to indicate changes in the PV only. Execution condition on increment (II)
ON
Execution condition on decrement (DI)
ON
OFF
OFF ON
Completion Flag
OFF
SV
PV
SV SV – 1
SV – 1 0001
SV – 2 0000
SV – 2 0000
Precautions
Program execution will continue even if a non-BCD SV is used, but the SV will not be correct.
Flags
ER:
SV is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary had been exceeded.
182
Page 195
Section 5-15
Data Shifting
5-15 Data Shifting All of the instructions described in this section are used to shift data, but in differing amounts and directions. The first shift instruction, SFT(010), shifts an execution condition into a shift register; the rest of the instructions shift data that is already in memory.
5-15-1 SHIFT REGISTER – SFT(010) Ladder Symbol
Operand Data Areas St: Starting word
I SFT(010)
IR, SR, AR, HR, LR
P St R
E
E: End word IR, SR, AR, HR, LR
Limitations
St must be less than or equal to E, and St and E must be in the same data area. If a bit address in one of the words used in a shift register is also used in an instruction that controls individual bit status (e.g., OUT, KEEP(011)), an error (“COIL DUPL”) will be generated when program syntax is checked on the Programming Console or another Programming Device. The program, however, will be executed as written. See Example 2: Controlling Bits in Shift Registers for a programming example that does this.
Description
SFT(010) is controlled by three execution conditions, I, P, and R. If SFT(010) is executed and 1) execution condition P is ON and was OFF the last execution, and 2) R is OFF, then execution condition I is shifted into the rightmost bit of a shift register defined between St and E, i.e., if I is ON, a 1 is shifted into the register; if I is OFF, a 0 is shifted in. When I is shifted into the register, all bits previously in the register are shifted to the left and the leftmost bit of the register is lost. E
St+1, St+2, ...
Lost data
St
Execution condition I
The execution condition on P functions like a differentiated instruction, i.e., I will be shifted into the register only when P is ON and was OFF the last time SFT(010) was executed. If execution condition P has not changed or has gone from ON to OFF, the shift register will remain unaffected. St designates the rightmost word of the shift register; E designates the leftmost. The shift register includes both of these words and all words between them. The same word may be designated for St and E to create a 16-bit (i.e., 1-word) shift register. When execution condition R goes ON, all bits in the shift register will be turned OFF (i.e., set to 0) and the shift register will not operate until R goes OFF again. Flags
There are no flags affected by SFT(010).
183
Page 196
Section 5-15
Data Shifting Example 1: Basic Application
The following example uses the 1-second clock pulse bit (25502) so that the execution condition produced by 00005 is shifted into a 3-word register between IR 010 and IR 012 every second.
00005
I SFT(010)
25502
P 010
00006
R
012
Address
Instruction
00000 00001 00002 00003
LD LD LD SFT(010)
Operands 00005 25502 00006 010 012
Example 2: Controlling Bits in Shift Registers
00200 00201
The following program is used to control the status of the 17th bit of a shift register running from AR 00 through AR 01. When the 17th bit is to be set, 00004 is turned ON. This causes the jump for JMP(004) 00 not to be made for that one cycle, and AR 0100 (the 17th bit) will be turned ON. When 12800 is OFF (i.e., at all times except during the first cycle after 00004 has changed from OFF to ON), the jump is executed and the status of AR 0100 will not be changed.
I SFT(010)
00202
P AR 00
00203
AR 01 R
Address
Instruction
00000 00001 00002 00003 00004
LD AND LD LD SFT(010)
00004 DIFU(013) 12800 12800 JMP(004) 00 12800 AR 0100
00005 00006 00007 00008 00009 00010 00011
LD DIFU(013) LD JMP(004) LD OUT JME(005)
Operands 00200 00201 00202 00203 AR 00 AR 01 00004 12800 12800 00 12800 AR 0100 00
JME(005) 00
When a bit that is part of a shift register is used in OUT (or any other instruction that controls bit status), a syntax error will be generated during the program check, but the program will executed properly (i.e., as written). Example 3: Control Action
184
The following program controls the conveyor line shown below so that faulty products detected at the sensor are pushed down a shoot. To do this, the execution condition determined by inputs from the first sensor (00001) are stored in a shift register: ON for good products; OFF for faulty ones. Conveyor speed has been adjusted so that HR 0003 of the shift register can be used to activate a pusher (00500) when a faulty product reaches it, i.e., when HR 0003 turns ON, 00500 is turned ON to activate the pusher.
Page 197
Section 5-15
Data Shifting
18The program is set up so that a rotary encoder (00000) controls execution of SFT(010) through a DIFU(013), the rotary encoder is set up to turn ON and OFF each time a product passes the first sensor. Another sensor (00002) is used to detect faulty products in the shoot so that the pusher output and HR 0003 of the shift register can be reset as required. Sensor (00001) Pusher (00500)
Sensor (00002)
Rotary Encoder (00000)
00001
I SFT(010)
00000
P HR 00
00003
R
HR 01
Chute
Address
Instruction
00000 00001 00002 00003
LD LD LD SFT(010)
HR 0003 00500
00002 00500
00004 00005 00006 00007 00008
LD OUT LD OUT NOT OUT NOT
Operands 00001 00000 00003 HR 00 HR 01 HR 0003 00500 00002 00500 HR 0003
HR 0003
5-15-2 REVERSIBLE SHIFT REGISTER – SFTR(084) Operand Data Areas C: Control word
Ladder Symbols
IR, AR, DM, EM, HR, LR, SR SFTR(084)
@SFTR(084)
C
C
St
St
E
E
St: Starting word
Limitations
IR, SR, AR, DM, EM, HR, LR E: End word IR, SR, AR, DM, EM, HR LR
St and E must be in the same data area and St must be less than or equal to E.
185
Page 198
Section 5-15
Data Shifting Description
SFTR(084) is used to create a single- or multiple-word shift register that can shift data to either the right or the left. To create a single-word register, designate the same word for St and E. The control word provides the shift direction, the status to be put into the register, the shift pulse, and the reset input. The control word is allocated as follows:
15 14 13 12
Not used. Shift direction 1 (ON): Left (LSB to MSB) 0 (OFF): Right (MSB to LSB) Status to input into register Shift pulse bit Reset
The data in the shift register will be shifted one bit in the direction indicated by bit 12, shifting one bit out to CY and the status of bit 13 into the other end whenever SFTR(084) is executed with an ON execution condition as long as the reset bit is OFF and as long as bit 14 is ON. If SFTR(084) is executed with an OFF execution condition or if SFTR(084) is executed with bit 14 OFF, the shift register will remain unchanged. If SFTR(084) is executed with an ON execution condition and the reset bit (bit 15) is OFF, the entire shift register and CY will be set to zero. Flags
ER:
St and E are not in the same data area or ST is greater than E. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY:
Example
Receives the status of bit 00 of St or bit 15 of E, depending on the shift direction.
In the following example, IR 00005, IR 00006, IR 00007, and IR 00008 are used to control the bits of C used in @SHIFT(084). The shift register is between LR 20 and LR 21, and it is controlled through IR 00009.
00005 05012
Direction
05013
Status to input
05014
Shift pulse
05015
Reset
00006
00007
00008
00009 @SFTR(084) 050 LR 20 LR 21
186
Address
Instruction
00000 00001 00002 00003 00004 00005 00006 00007 00008 00009
LD OUT LD OUT LD OUT LD OUT LD @SFT(010)
Operands 00005 05012 00006 05013 00007 05014 00008 05015 00009 050 LR 20 LR 21
Page 199
Section 5-15
Data Shifting
5-15-3 ARITHMETIC SHIFT LEFT – ASL(025) Ladder Symbols
Description
Operand Data Areas
ASL(025)
@ASL(025)
Wd
Wd
Wd: Shift word IR, SR, AR, DM, EM, HR, LR
When the execution condition is OFF, ASL(025) is not executed. When the execution condition is ON, ASL(025) shifts a 0 into bit 00 of Wd, shifts the bits of Wd one bit to the left, and shifts the status of bit 15 into CY.
CY
Bit Bit 15 00 1 0 0 1 1 1 0 0 0 1 0 1 0 0 1 1 0
Flags
ER:
The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY:
Receives the status of bit 15.
EQ:
ON when the content of Wd is zero; otherwise OFF.
N:
ON when a 1 is shifted into bit 15 of Wd.
5-15-4 ARITHMETIC SHIFT RIGHT – ASR(026) Ladder Symbols
Description
Operand Data Areas
ASR(026)
@ASR(026)
Wd
Wd
Wd: Shift word IR, SR, AR, DM, EM, HR, LR
When the execution condition is OFF, ASR(025) is not executed. When the execution condition is ON, ASR(025) shifts a 0 into bit 15 of Wd, shifts the bits of Wd one bit to the right, and shifts the status of bit 00 into CY. Bit Bit 15 00 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0
CY
0
Flags
ER:
The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY:
Receives the data of bit 00.
EQ:
ON when the content of Wd is zero; otherwise OFF.
187
Page 200
Section 5-15
Data Shifting
5-15-5 ROTATE LEFT – ROL(027) Ladder Symbols
Description
Operand Data Areas
ROL(027)
@ROL(027)
Wd
Wd
Wd: Rotate word IR, SR, AR, DM, EM, HR, LR
When the execution condition is OFF, ROL(027) is not executed. When the execution condition is ON, ROL(027) shifts all Wd bits one bit to the left, shifting CY into bit 00 of Wd and shifting bit 15 of Wd into CY. CY
Bit 15
Bit 00
0
1 0 1 1 0 0 1 1 1 0 0 0 1 1 0 1
Precautions
Use STC(041) to set the status of CY or CLC(041) to clear the status of CY before doing a rotate operation to ensure that CY contains the proper status before execution ROL(027). The status of CY is cleared at the end of each cycle (when END(001) is executed).
Flags
ER:
The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY:
Receives the data of bit 15.
EQ:
ON when the content of Wd is zero; otherwise OFF.
N:
ON when a 1 is shifted into bit 15 of Wd.
5-15-6 ROTATE RIGHT – ROR(028) Ladder Symbols
Description
Precautions
188
Operand Data Areas
ROR(028)
@ROR(028)
Wd
Wd
Wd: Rotate word IR, SR, AR, DM, EM, HR, LR
When the execution condition is OFF, ROR(028) is not executed. When the execution condition is ON, ROR(028) shifts all Wd bits one bit to the right, shifting CY into bit 15 of Wd and shifting bit 00 of Wd into CY. CY
Bit 15
Bit 00
0
0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1
Use STC(041) to set the status of CY or CLC(041) to clear the status of CY before doing a rotate operation to ensure that CY contains the proper status before execution ROR(028). The status of CY is cleared at the end of each cycle (when END(001) is executed).
Page 201
Section 5-15
Data Shifting Flags
ER:
The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY:
ROR(028) receives the data of bit 00.
EQ:
ON when the content of Wd is zero; otherwise OFF.
N:
ON when a 1 is shifted into bit 15 of Wd.
5-15-7 ONE DIGIT SHIFT LEFT – SLD(074) Ladder Symbols
Operand Data Areas St: Starting word
SLD(074)
@SLD(074)
St
St
E
E
IR, SR, AR, DM, EM, HR, LR E: End word IR, SR, AR, DM, EM, HR, LR
Limitations
St and E must be in the same data area, and St must be less than or equal to E.
Description
When the execution condition is OFF, SLD(074) is not executed. When the execution condition is ON, SLD(074) shifts data between St and E (inclusive) by one digit (four bits) to the left. 0 is written into the rightmost digit of the St, and the content of the leftmost digit of E is lost. E
... St
8 F C 5
D 7 9 1
Lost data
0
Precautions
If a power failure occurs during a shift operation across more than 50 words, the shift operation might not be completed.
Flags
ER:
The St and E words are in different areas, or St is greater than E. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
5-15-8 ONE DIGIT SHIFT RIGHT – SRD(075) Ladder Symbols
Operand Data Areas E: End word
SRD(075)
@SRD(075)
E
E
St
St
IR, SR, AR, DM, EM, HR, LR St: Starting word IR, SR, AR, DM, EM, HR, LR
Limitations
St and E must be in the same data area, and St must be less than or equal to E.
Description
When the execution condition is OFF, SRD(075) is not executed. When the execution condition is ON, SRD(075) shifts data between St and E (inclusive) by one
189
Page 202
Section 5-15
Data Shifting digit (four bits) to the right. 0 is written into the leftmost digit of St and the rightmost digit of E is lost. St 3 4 5 2
... E
F 8 C 1
Lost data
0
Precautions
If a power failure occurs during a shift operation across more than 50 words, the shift operation might not be completed. Set the range between E and St to a maximum of 50 words.
Flags
ER:
The St and E words are in different areas, or St is less than E. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
5-15-9 WORD SHIFT – WSFT(016)
Ladder Symbols
Operand Data Areas St: Starting word
WSFT(016)
@WSFT(016)
St
St
E
E
IR, SR, AR, DM, EM, HR, LR E: End word IR, SR, AR, DM, EM, HR, LR
Limitations
St and E must be in the same data area, and St must be less than or equal to E.
Description
When the execution condition is OFF, WSFT(016) is not executed. When the execution condition is ON, WSFT(016) shifts data between St and E in word units. Zeros are written into St and the content of E is lost.
E F
0
St + 1 C
2
3
4
5
St 2
1
0
2
9
Lost 0000 E 3
Flags
ER:
4
St + 1 5
2
1
0
2
St 9
0
0
0
0
The St and E words are in different areas, or St is greater than E. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
190
Page 203
Section 5-15
Data Shifting
5-15-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(017) Operand Data Areas C: Control word
Ladder Symbols
IR, SR, AR, DM, EM, HR, LR, #
Limitations
ASFT(017)
ASFT(017)
St: Starting word
C
C
IR, SR, AR, DM, EM, HR, LR
St
St
E
E
E: End word IR, SR, AR, DM, EM, HR, LR
St and E must be in the same data area, and St must be less than or equal to E. ASFT(017) is an expansion instruction. A Programming Device can be used to reassign function code 017 to another expansion instruction.
Description
When the execution condition is OFF, ASFT(017) does nothing and the program moves to the next instruction. When the execution condition is ON, ASFT(017) is used to create and control a reversible asynchronous word shift register between St and E. This register only shifts words when the next word in the register is zero, e.g., if no words in the register contain zero, nothing is shifted. Also, only one word is shifted for each word in the register that contains zero. When the contents of a word are shifted to the next word, the original word’s contents are set to zero. In essence, when the register is shifted, each zero word in the register trades places with the next word. (See Example below.) The shift direction (i.e. whether the “next word” is the next higher or the next lower word) is designated in C. C is also used to reset the register. All of any portion of the register can be reset by designating the desired portion with St and E.
Control Word
Bits 00 through 12 of C are not used. Bit 13 is the shift direction: turn bit 13 ON to shift down (toward lower addressed words) and OFF to shift up (toward higher addressed words). Bit 14 is the Shift Enable Bit: turn bit 14 ON to enable shift register operation according to bit 13 and OFF to disable the register. Bit 15 is the Reset bit: the register will be reset (set to zero) between St and E when ASFT(017) is executed with bit 15 ON. Turn bit 15 OFF for normal operation. Control word value
Flags
Function
#4000
Shifts upward (towards higher addressed words).
#6000
Shifts downward (towards lower addressed words).
#8000
Clears the contents of St through E to #0000.
ER:
The St and E words are in different areas, or St is greater than E. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
Example
The following example shows instruction ASFT(017) used to shift words in an 11-word shift register created between DM 0100 and DM 0110 with a control
191