The text of a manual · part 39 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 359 to 366
Pages 359 to 366 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 359
Section 5-27
Communications Instructions Control Word
The value of the control word determines the port from which data will be read and the order in which data will be written to memory.
Digit number:
3 2 1 0
Byte order
0: Most significant bytes first 1: Least significant bytes first
Not used. (Set to 00.) Port
0: Specifies RS-232C port. 1: Specifies peripheral port.
The order in which data is written to memory depends on the value of digit 0 of C. Eight bytes of data 12345678... will be written in the following manner:
Digit 0 = 0
D D+1 D+2 D+3
Flags
ER:
MSB LSB 1 2 3 4 5 6 7 8
Digit 0 = 1
D D+1 D+2 D+3
MSB LSB 2 1 4 3 6 5 8 7
The CPU Unit is not equipped with an RS-232C port. Another device is not connected to the specified port. There is an error in the communications settings (PC Setup) or the operand settings. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) The destination words (D to D+(N÷2)–1) exceed the data area.
AR 08: AR 0806 will be turned ON when data has been received normally at the RS-232C port. Reset when RXD(47) is executed. AR 0814 will be turned ON when data has been received normally at the peripheral port. Reset when RXD(47) is executed. AR 09: Contains the number of bytes received at the RS-232C port. Reset to 0000 when RXD(47) is executed. AR 10: Contains the number of bytes received at the peripheral port. Reset to 0000 when RXD(47) is executed. Note Communications flags and counters can be cleared either by specifying 0000 for N or using the Port Reset Bits (SR 25208 for peripheral port and SR 25209 for RS-232C port.)
341
Page 360
Section 5-27
Communications Instructions
5-27-2 TRANSMIT – TXD(48) Operand Data Areas
Ladder Symbols
S: First source word TXD(48)
@TXD(48)
S
S
C
C
N
N
IR, SR, AR, DM, HR, TC, LR C: Control word # N: Number of bytes IR, SR, AR, DM, HR, TC, LR, #
Limitations
This instruction is available in the CQM1/SRM1 only. S and S+(N÷2)–1 must be in the same data area. DM 6144 to DM 6655 cannot be used for S or N. N must be BCD from #0000 to #0256. (#0000 to #0061 in host link mode)
Description
When the execution condition is OFF, TXD(48) is not executed. When the execution condition is ON, TXD(48) reads N bytes of data from words S to S+(N÷2)–1, converts it to ASCII, and outputs the data from the specified port. TXD(48) operates differently in host link mode and RS-232C mode, so these modes are described separately. Note
1. Flag AR 0805 will be ON when the CQM1 or SRM1 is capable of transmitting data through the RS-232C port and AR 0813 will be ON when the CQM1 or SRM1 is capable of transmitting data through the peripheral port. 2. Refer to 1-9 Communications Functions for details on using the TXD(48) instruction, setting communications protocol in the PC Setup, etc.
Host Link Mode
N must be BCD from #0000 to #0061 (i.e., up to 122 bytes of ASCII). The value of the control word determines the port from which data will be output, as shown below. Digit number:
3 2 1 0
Not used. (Set to 000.) Port
0: Specifies RS-232C port. 1: Specifies peripheral port.
The specified number of bytes will be read from S through S+(N/2)–1, converted to ASCII, and transmitted through the specified port. The bytes of source data shown below will be transmitted in this order: 12345678...
S S+1 S+2 S+3
342
MSB LSB 1 2 3 4 5 6 7 8
Page 361
Section 5-27
Communications Instructions
The following diagram shows the format for host link command (TXD) sent from the CQM1. The CQM1 automatically attaches the prefixes and suffixes, such as the node number, header, and FCS. @ X
X
Node number
X
X
Header code
X
X
.........
X
Data (122 ASCII characters max.)
X
X
FCS
∗
CR
Terminator
RS-232C Mode
N must be BCD from #0000 to #00256. The value of the control word determines the port from which data will be output and the order in which data will be written to memory.
Control Word
The value of the control word determines the port from which data will be read and the order in which data will be written to memory. Digit number:
3 2 1 0 Byte order
0: Most significant bytes first 1: Least significant bytes first
Not used. (Set to 00.) Port
0: Specifies RS-232C port. 1: Specifies peripheral port.
The specified number of bytes will be read from S through S+(NP2)–1 and transmitted through the specified port. S S+1 S+2 S+3
MSB LSB 1 2 3 4 5 6 7 8
When digit 0 of C is 0, the bytes of source data shown above will be transmitted in this order: 12345678... When digit 0 of C is 1, the bytes of source data shown above will be transmitted in this order: 21436587... Note When start and end codes are specified the total data length should be 256 bytes max., including the start and end codes. Flags
ER:
The CPU Unit is not equipped with an RS-232C port. Another device is not connected to the peripheral port. There is an error in the communications settings (PC Setup) or the operand settings. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) The source words (S to S+(N÷2)–1) exceed the data area.
AR 08: AR 0805 will be turned ON when it is possible to transmit through the RS-232C port. AR 0813 will be turned ON when it is possible to transmit through the peripheral port.
343
Page 362
Section 5-27
Communications Instructions
5-27-3 CHANGE RS-232C SETUP – STUP(––) Operand Data Areas
Ladder Symbols
N: RS-232C port specifier STUP(––)
@STUP(––)
N
N
S
S
000, 001, or 002 S: First source word
Limitations
IR, SR, AR, DM, HR, TC, LR, #
This instruction is available in the SRM1 only. N must be 000, 001, or 002 to specify IR 000, IR 001, or IR 002. S and S+4 must be in the same data area. (S can be set to #0000 to change the RS-232C settings to their defaults.) STUP(––) can’t be executed for the internal RS-232C port if pin 2 of the DIP switch is ON. STUP(––) can’t be executed within an interrupt subroutine.
Description
When the execution condition is OFF, STUP(––) is not executed. When the execution condition is ON, STUP(––) changes the PC Setup settings for the port specified by N. N determines which part of the RS-232C Setup is changed. N
Specified Port
IR 000
Built-in RS-232C port (PC Setup: DM 6645 to DM 6649)
IR 001
Communications Board port A (PC Setup: DM 6555 to DM 6559)
IR 002
Communications Board port B (PC Setup: DM 6550 to DM 6554)
If S is a word address, the contents of S through S+4 are copied to the 5 words in the PC Setup that contain the settings for the port specified by N. If S is input as the constant #0000, the settings for the specified port are returned to their default values.
Application Example
S
Function
Word address Constant (#0000)
The contents of S through S+4 are copied to the part of the PC Setup that contains the settings for the port specified by N. The settings for the port specified by N are returned to their default values.
This example shows a program that transfers the contents of DM 0100 through DM 0104 to the PC Setup area for Communications Board port A (DM 6555 through DM 6569). 00000
Address
Instruction
00000 00001
LD @STUP(––)
Operands
@STUP(––) 001 DM 0100
00000
DM
344
001 0100
Page 363
Section 5-28
Advanced I/O Instructions
The settings are transferred as shown below. The Changing RS-232C Setup Flag (SR 27504) will be turned OFF when the transfer has been completed.
The following table shows the function of the transferred setup data. Word
Flags
Content
Function
DM 0100
1001
DM 0101
0803
DM 0102
0000
Enables the communications settings in DM 0101 and sets the communications mode to RS-232C. Sets the following communications settings: 9,600 bps, 1 start bit, 8-bit data, 1 stop bit, no parity No transmission delay (0 ms)
DM 0103
2000
Enables the end code CR, LF.
DM 0104
0000
---
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) The port specifier (N) isn’t IR 000, IR 001, or IR 002. Port A has been specified, but pin 2 of the DIP switch is ON. The PC Setup is write-protected. (Pin 1 of the DIP switch is ON.) The specified source words exceed the data area. The instruction was executed from an interrupt program.
5-28 Advanced I/O Instructions 5-28-1 7-SEGMENT DISPLAY OUTPUT – 7SEG(88) Ladder Symbols
Operand Data Areas S: First source word
7SEG(88) IR, SR, AR, DM, HR, TC, LR S O: Output word O IR, SR, AR, HR, LR,TC, DM C
C: Control data 000 to 007
Limitations
This instruction is available in the CQM1 only. Do not use 7SEG(88) more than twice in the program.
Description
When the execution condition is OFF, 7SEG(88) is not executed. When the execution condition is ON, 7SEG(88) reads the source data (either 4 or 8-digit), converts it to 7-segment display data, and outputs that data to the 7-segment display connected to the output indicated by O. The value of C indicates the number of digits of source data and the logic for the Input and Output Units, as shown in the following table.
345
Page 364
Section 5-28
Advanced I/O Instructions Source data 4 digits (S)
Display’s data input logic Same as Output Unit Different from Output Unit
8 digits (S, S+1)
Same as Output Unit Different from Output Unit
Display’s latch input logic
C
Same as Output Unit Different from Output Unit Same as Output Unit Different from Output Unit Same as Output Unit Different from Output Unit Same as Output Unit Different from Output Unit
0000 0001 0002 0003 0004 0005 0006 0007
If there are 8 digits of source data, they are placed in S and S+1, with the most significant digits placed in S+1. If there are 4 digits of source data, they are placed in S. 7SEG(88) displays the 4 or 8-digit data in 12 cycles, and then starts over and continues displaying the data. Refer to page 125 for more information on 7SEG(88) and its applications. Flags
ER:
S and S+1 are not in the same data area. (When set to display 8-digit data.) Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) There is an error in operand settings.
SR 25409:
ON while 7SEG(88) is being executed.
5-28-2 DIGITAL SWITCH INPUT – DSW(87) Ladder Symbols
Operand Data Areas IW: Input word
DSW(87) IR, SR, AR, DM, HR, TC, LR IW OW: Output word OW R
IR, SR, AR, DM, HR, TC, LR R: First result word IR, SR, AR, DM, HR, TC, LR
Limitations
This instruction is available in the CQM1 only. DM 6144 to DM 6655 cannot be used for R.
Description
DSW(87) is used to read the value set on a digital switch connected to I/O Units. When the execution condition is OFF, DSW(87) is not executed. When the execution condition is ON, DSW(87) reads the value (either 4 or 8-digit) set on the digital switch from IW and places the result in R. If the value is an 8-digit number, it is placed in R and R+1, with the most significant digits placed in R+1. The number of digits is set in DM 6639 of the PC Setup. DSW(87) reads the 4 or 8-digit data in 12 cycles, and then starts over and continues reading the data. Refer to page 122 for more information on DSW(87) and its applications.
Flags
ER:
IW and/or OW are not allocated to the correct I/O Units. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.)
346
Page 365
Section 5-28
Advanced I/O Instructions
R and R+1 are not in the same data area. (When the CQM1 is set to receive 8-digit data.) SR 25410:
ON while DSW(87) is being executed.
5-28-3 HEXADECIMAL KEY INPUT – HKY(––) Ladder Symbols
Operand Data Areas IW: Input word
HKY(––) IR, SR, AR, DM, HR, TC, LR IW OW: Control signal output word OW D
IR, SR, AR, DM, HR, TC, LR D: First register word IR, SR, AR, DM, HR, TC, LR
Limitations
This instruction is available in the CQM1 only. D and D+2 must be in the same data area. Do not use HKY(––) more than twice in the program. DM 6144 to DM 6655 cannot be used for D.
Description
When the execution condition is OFF, HKY(––) is not executed. When the execution condition is ON, HKY(––) inputs data from a hexadecimal keypad connected to the input indicated by IW. The data is input in two ways: 1, 2, 3...
1. An 8-digit shift register is created in D and D+1. When a key is pressed on the hexadecimal keypad, the corresponding hexadecimal digit is shifted into the least significant digit of D. The other digits of D, D+1 are shifted left and the most significant digit of D+1 is lost. 2. The bits of D+2 and bit 4 of OW indicate key input. When one of the keys on the keypad (0 to F) is being pressed, the corresponding bit in D+2 (00 to 15) and bit 4 of OW are turned ON.
Note When one of the keypad keys is being pressed, input from the other keys is disabled. HKY(––) inputs each digit in 3 to 12 cycles, and then starts over and continues inputting. Refer to page 120 for more details on HKY(––). Flags
ER:
IIndirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) D and D+2 are not in the same data area.
SR 25408:
ON while HKY(––) is being executed.
5-28-4 TEN KEY INPUT – TKY(18) Ladder Symbols
Operand Data Areas IW: Input word
TKY(18) IR, SR, AR, DM, HR, TC, LR IW D1: First register word D1 D2
IR, SR, AR, DM, HR, TC, LR D2: Key input word IR, SR, AR, DM, HR, TC, LR
347
Page 366
Section 5-28
Advanced I/O Instructions Limitations
This instruction is available in the CQM1 only. D1 and D1+1 must be in the same data area. DM 6143 to DM 6655 cannot be used for D1.
Description
When the execution condition is OFF, TKY(18) is not executed. When the execution condition is ON, TKY(18) inputs data from a ten-key keypad connected to the input indicated by IW. The data is input in two ways: 1, 2, 3...
1. An 8-digit shift register is created in D1 and D1+1. When a key is pressed on the ten-key keypad, the corresponding BCD digit is shifted into the least significant digit of D1. The other digits of D1, D1+1 are shifted left and the most significant digit of D1+1 is lost. 2. The first ten bits of D2 indicate key input. When one of the keys on the keypad (0 to 9) is being pressed, the corresponding bit of D2 (00 to 09) is turned ON.
Note When one of the keypad keys is being pressed, input from the other keys is disabled. TKY(18) can be used in several locations in the program by changing the input word, IW. Refer to page 118 for more details on TKY(18). Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) D1 and D1+1 are not in the same data area.
348