The text of a manual · part 27 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 239 to 248
Pages 239 to 248 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual
The original document is the PDF (2.1 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 Omron CQM1-CPU21
Page 239
Section 5-15
Timer and Counter Instructions PV Change
If C is 002, INI(61) changes the high-speed counter’s PV to the 8-digit value in P1 and P1+1. With high-speed counter 0, the PV can be F003 2767 to 0003 2767 in Up/Down Mode, or 0000 0000 to 0006 5535 in Incremental Mode. The hexadecimal value F in the most significant digit of PV indicates that PV is negative. Leftmost 4 digits
Rightmost 4 digits
P1+1
P1
Up/Down Mode
Incrementing Mode
F0032767 to 00032767
00000000 to 00065535
With high-speed counters 1 and 2 (CQM1 only), the PV can be F838 8607 to 0838 8607 in Linear Mode, or 0000 0000 to 0006 4999 in Ring Mode. The hexadecimal value F in the most significant digit of PV indicates that PV is negative. Leftmost 4 digits
Rightmost 4 digits
Linear Mode
Ring Mode
P1+1
P1
F8388607 to 08388607 (–8,388,607 to 8,388,607)
00000000 to 00064999
Note The PV of absolute high-speed counters 1 and 2 (CQM1-CPU44-E/-EV1 only) cannot be changed. Stop Pulse Output
If C is 003, INI(61) stops pulse output. Refer to 1-3 Pulse Output Functions (CQM1 Only) and 1-4 Pulse Output Function (CPM1A Only) for details on pulse output.
Flags
ER:
The specified port and function are not compatible. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) P1+1 exceeds the data area boundary. (C=002) There is an error in the operand settings. INI(61) is executed in an interrupt subroutine while a pulse I/O or highspeed counter instruction is being executed in the main program.
5-15-8 HIGH-SPEED COUNTER PV READ – PRV(62) Ladder Symbols
Operand Data Areas P: Port specifier
PRV(62)
@PRV(62)
P
P
C
C
D
D
000, 001, or 002 C: Control data 000, 001, or 002 D: First destination word IR, SR, AR, DM, HR, LR
This instruction is not available for SRM1 PCs. Limitations
In the CPM1/CPM1A PCs, P and C must be 000. In CQM1 PCs, P and C must be 000, 001, or 002. D and D+1 must be in the same data area. DM 6143 to DM 6655 cannot be used for D.
Description
When the execution condition is OFF, PRV(62) is not executed. When the execution condition is ON, PRV(62) reads data specified by P and C and writes it to D or D and D+1.
221
Page 240
Section 5-15
Timer and Counter Instructions
The port specifier (P) specifies the high-speed counter or pulse output. P
Function
000
Specifies high-speed counter 0 or a pulse output from a bit.
001
Specifies high-speed counter 1 or a pulse output from port 1.
002
Specifies high-speed counter 2 or a pulse output from port 2.
Note CPM1/CPM1A PCs are equipped with high-speed counter 0 only. The control data, C, determines which type of data will be accessed. C
High-speed Counter PV (C=000)
Data
Destination word(s)
000
High-speed counter PV
D and D+1
001
Status of high-speed counter or pulse output
D
002
Range comparison results
D
If C is 000, PRV(62) reads the specified high-speed counter’s PV and writes the 8-digit value in D and D+1. With high-speed counter 0, the PV can be F003 2767 to 0003 2767 in Up/Down Mode, or 0000 0000 to 0006 5535 in Incremental Mode. The hexadecimal value F in the most significant digit of PV indicates that the PV is negative. Leftmost 4 digits D+1
Rightmost 4 digits D
Up/Down Mode
Incrementing Mode
F0032767 to 00032767
00000000 to 00065535
With high-speed counters 1 and 2 (CQM1 only), the PV can be F838 8607 to 0838 8607 in Linear Mode, or 0000 0000 to 0006 4999 in Ring Mode. The hexadecimal value F in the most significant digit of PV indicates that the PV is negative. Leftmost 4 digits
Rightmost 4 digits
Linear Mode
Ring Mode
D+1
D
F8388607 to 08388607 (–8,388,607 to 8,388,607)
00000000 to 00064999
With absolute high-speed counters 1 and 2, the PV can be 0000 0000 to 0000 4095 in BCD Mode, or 0000 0000 to 0000 0359 in Mode.
High-speed Counter or Pulse Output Status (C=001)
Leftmost 4 digits
Rightmost 4 digits
BCD Mode
D+1
D
0000 0000 to 0000 4095
Mode 0000 0000 to 0000 0359
If C is 001 (CQM1 only), PRV(62) reads the operating status of the specified high-speed counter or pulse output and writes the data to D. Refer to 1-3-5 Determining the Status of Ports 1 and 2 for details on determining the status of pulse outputs. The following table shows the function of bits in D for high-speed counters 1 and 2, and pulse outputs from ports 1 and 2 (CQM1-CPU43-E/-EV1 only). Bits not listed in the table are not used and will always be 0. Bit
Function
00
High-speed counter comparison status. (0: Stopped; 1: Comparing)
01 04
High-speed counter underflow/overflow. (0: Normal; 1: Underflow/Overflow occurred.) Deceleration of pulse frequency. (0: Not specified; 1: Specified.)
05
Total number of pulses specified. (0: Not specified; 1: Specified.)
06
Pulse output completed. (0: Not completed; 1: Completed)
07
Pulse output status (0: Stopped; 1: Outputting)
For absolute high-speed counters 1 and 2 (CQM1-CPU44-E/-EV1 only), Bit 00 of D indicates the comparison status (0: Stopped; 1: Comparing). The other bits in D (01 through 15) are not used and will always be 0.
222
Page 241
Section 5-15
Timer and Counter Instructions
Note These flags are in AR 05 and AR 06, but those words are normally refreshed only once each cycle, so the data obtained with PRV(62) will be more up-to-date. Range Comparison Results (C=002)
If C is 002 (CQM1 only), PRV(62) reads the results of the comparison of the PV to the 8 ranges defined by CTBL(63) and writes this data to D. Bits 00 through 07 of D contain the Comparison Result flags for ranges 1 to 8. (0: Not in range; 1: In range)
Note These flags are in AR 05 and AR 06, but those words are normally refreshed only once each cycle, so the data obtained with PRV(62) will be more up-to-date. Flags
ER:
The specified port and function are not compatible. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) D+1 exceeds the data area boundary. (C=000) There is an error in the operand settings. PRV(62) is executed in an interrupt subroutine while a pulse I/O or highspeed counter instruction is being executed in the main program.
223
Page 242
Section 5-16
Shift Instructions
5-16 Shift Instructions 5-16-1 SHIFT REGISTER – SFT(10) Ladder Symbol
Operand Data Areas St: Starting word
I SFT(10)
IR, SR, AR, HR, LR
P St R
E
E: End word IR, SR, AR, HR, LR
E must be greater than or equal to St, and St and E must be in the same data area.
Limitations
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(11)), an error (“COIL/OUT 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. SFT(10) is controlled by three execution conditions, I, P, and R. If SFT(10) 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.
Description
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(10) 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
224
There are no flags affected by SFT(10).
Page 243
Section 5-16
Shift Instructions Example
The following example uses the 1-second clock pulse bit (25502) so that the execution condition produced by 00000 is shifted into IR 010 every second. Output 10000 is turned ON whenever a “1” is shifted into 01007. 00000
I SFT(10)
25502
P 010
00001
R
010
01007 10000
Address
Instruction
00000 00001 00002 00003
LD LD LD SFT(10)
00004 00005
LD OUT
Operands 00000 25502 00001 010 010 01007 10000
5-16-2 WORD SHIFT – WSFT(16) Ladder Symbols
Operand Data Areas St: Starting word
WSFT(16)
@WSFT(16)
St
St
E
E
IR, SR, AR, DM, HR, LR E: End word IR, SR, AR, DM, HR, LR
Limitations
St and E must be in the same data area, and E must be greater than or equal to St. DM 6144 to DM 6655 cannot be used for St or E.
Description
When the execution condition is OFF, WSFT(16) is not executed. When the execution condition is ON, WSFT(16) 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. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
5-16-3 ARITHMETIC SHIFT LEFT – ASL(25) Ladder Symbols
Limitations
Operand Data Areas
ASL(25)
@ASL(25)
Wd
Wd
Wd: Shift word IR, SR, AR, DM, HR, LR
DM 6144 to DM 6655 cannot be used for Wd.
225
Page 244
Section 5-16
Shift Instructions Description
When the execution condition is OFF, ASL(25) is not executed. When the execution condition is ON, ASL(25) 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
Precautions
A 0 will be shifted into bit 00 every cycle if the undifferentiated form of ASL(25) is used. Use the differentiated form (@ASL(25)) or combine ASL(25) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) Receives the status of bit 15. ON when the content of Wd is zero; otherwise OFF.
CY: EQ:
5-16-4 ARITHMETIC SHIFT RIGHT – ASR(26) Ladder Symbols
Operand Data Areas
ASR(26)
@ASR(26)
Wd
Wd
Wd: Shift word IR, SR, AR, DM, HR, LR
Limitations
DM 6144 to DM 6655 cannot be used for Wd.
Description
When the execution condition is OFF, ASR(25) is not executed. When the execution condition is ON, ASR(25) 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
Precautions
A 0 will be shifted into bit 15 every cycle if the undifferentiated form of ASR(26) is used. Use the differentiated form (@ASR(26)) or combine ASR(26) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) Receives the data of bit 00. ON when the content of Wd is zero; otherwise OFF.
CY: EQ:
5-16-5 ROTATE LEFT – ROL(27) Ladder Symbols
Limitations
226
Operand Data Areas
ROL(27)
@ROL(27)
Wd
Wd
DM 6144 to DM 6655 cannot be used for Wd.
Wd: Rotate word IR, SR, AR, DM, HR, LR
Page 245
Section 5-16
Shift Instructions Description
Precautions
When the execution condition is OFF, ROL(27) is not executed. When the execution condition is ON, ROL(27) 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
Use STC(41) to set the status of CY or CLC(41) to clear the status of CY before doing a rotate operation to ensure that CY contains the proper status before executing ROL(27). CY will be shifted into bit 00 every cycle if the undifferentiated form of ROL(27) is used. Use the differentiated form (@ROL(27)) or combine ROL(27) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
CY:
Receives the data of bit 15.
EQ:
ON when the content of Wd is zero; otherwise OFF.
5-16-6 ROTATE RIGHT – ROR(28) Ladder Symbols
Operand Data Areas
ROR(28)
@ROR(28)
Wd
Wd
Wd: Rotate word IR, SR, AR, DM, HR, LR
Limitations
DM 6144 to DM 6655 cannot be used for Wd.
Description
When the execution condition is OFF, ROR(28) is not executed. When the execution condition is ON, ROR(28) shifts all Wd bits one bit to the right, shifting CY into bit 15 of Wd and shifting bit 00 of Wd into CY.
Precautions
CY
Bit 15
Bit 00
0
0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1
Use STC(41) to set the status of CY or CLC(41) to clear the status of CY before doing a rotate operation to ensure that CY contains the proper status before execution ROR(28). CY will be shifted into bit 15 every cycle if the undifferentiated form of ROR(28) is used. Use the differentiated form (@ROR(28)) or combine ROR(28) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
CY:
Receives the data of bit 00.
EQ:
ON when the content of Wd is zero; otherwise OFF.
227
Page 246
Section 5-16
Shift Instructions
5-16-7 ONE DIGIT SHIFT LEFT – SLD(74) Ladder Symbols
Operand Data Areas St: Starting word
Limitations
SLD(74)
@SLD(74)
St
St
E
E
IR, SR, AR, DM, HR, LR E: End word IR, SR, AR, DM, HR, LR
St and E must be in the same data area, and E must be greater than or equal to St. DM 6144 to DM 6655 cannot be used for St or E.
Description
When the execution condition is OFF, SLD(74) is not executed. When the execution condition is ON, SLD(74) 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
Precautions
... St
8 F C 5
D 7 9 1
Lost data
0
If a power failure occurs during a shift operation across more than 50 words, the shift operation might not be completed. A 0 will be shifted into the least significant digit of St every cycle if the undifferentiated form of SLD(74) is used. Use the differentiated form (@SLD(74)) or combine SLD(74) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
The St and E words are in different areas, or St is greater than E. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
5-16-8 ONE DIGIT SHIFT RIGHT – SRD(75) Ladder Symbols
Operand Data Areas E: End word
Limitations
SRD(75)
@SRD(75)
E
E
St
St
IR, SR, AR, DM, HR, LR St: Starting word IR, SR, AR, DM, HR, LR
St and E must be in the same data area, and E must be less than or equal to St. DM 6144 to DM 6655 cannot be used for St or E.
228
Page 247
Section 5-16
Shift Instructions Description
When the execution condition is OFF, SRD(75) is not executed. When the execution condition is ON, SRD(75) shifts data between St and E (inclusive) by one 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
0
Precautions
... E
F 8 C 1
Lost data
If a power failure occurs during a shift operation across more than 50 words, the shift operation might not be completed. A 0 will be shifted into the most significant digit of St every cycle if the undifferentiated form of SRD(75) is used. Use the differentiated form (@SRD(75)) or combine SRD(75) with DIFU(13) or DIFD(14) to shift just one time.
Flags
ER:
The St and E words are in different areas, or St is less than E. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
5-16-9 REVERSIBLE SHIFT REGISTER – SFTR(84) Operand Data Areas C: Control word
Ladder Symbols
IR, SR, AR, DM, HR, LR SFTR(84)
@SFTR(84)
C
C
St
St
E
E
St: Starting word
Limitations
IR, SR, AR, DM, HR, LR E: End word IR, SR, AR, DM, HR, LR
St and E must be in the same data area and St must be less than or equal to E. DM 6144 to DM 6655 cannot be used for C, St, or E.
Description
SFTR(84) 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
229
Page 248
Section 5-16
Shift Instructions
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(84) 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(84) is executed with an OFF execution condition or if SFTR(84) is executed with bit 14 OFF, the shift register will remain unchanged. If SFTR(84) 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
Example
ER:
St and E are not in the same data area or ST is greater than E. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
CY:
Receives the status of bit 00 of St or bit 15 of E, depending on the shift direction.
In the following example, IR 00000, IR 00001, IR 00002, and IR 00003 are used to control the bits of C used in @SFTR(84). The shift register is in DM 0010, and it is controlled through IR 00004. 00000 03512
Direction
03513
Status to input
03514
Shift pulse
03515
Reset
00001
00002
00003
Address
Instruction
00000 00001 00002 00003 00004 00005 00006 00007 00008 00009
LD OUT LD OUT LD OUT LD OUT LD @SFT(10)
Operands 00000 03512 00001 03513 00002 03514 00003 03515 00004
DM DM
00004
035 0010 0010
@SFTR(84) 035 DM 0010 DM 0010
5-16-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(17) Operand Data Areas C: Control word
Ladder Symbols
IR, SR, AR, DM, HR, LR, # ASFT(17)
@ASFT(17)
St: Starting word
C
C
IR, SR, AR, DM, HR, LR
St
St
E
E
E: End word IR, SR, AR, DM, HR, LR
Note ASFT(17) is an expansion instruction for the SRM1. The function code 17 is the factory setting and can be changed for the SRM1 if desired. Limitations
230
St and E must be in the same data area, and E must be greater than or equal to St. DM 6144 to DM 6655 cannot be used for St or E.