The text of a manual · part 13 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 1 PC Setup and Other Features, pages 111 to 120
Pages 111 to 120 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 111
Section
Communications Functions Transmission Frame Format
Setting
Data length
Stop bits
Parity
00
1
7
1
Even
01
1
7
1
Odd
02
1
7
1
None
03
1
7
2
Even
04
1
7
2
Odd
05
1
7
2
None
06
1
8
1
Even
07
1
8
1
Odd
08
1
8
1
None
09
1
8
2
Even
10
1
8
2
Odd
11
1
8
2
None
Baud Rate
Transmission Delay Time
Stop bits
Setting
1-9
Baud rate
00
1,200 bps
01
2,400 bps
02
4,800 bps
03
9,600 bps
04
19,200 bps
Depending on the devices connected to the RS-232 port, it may be necessary to allow time for transmission. When that is the case, set the transmission delay to regulate the amount of time allowed. Bit 15
0
DM 6647: RS-232C port DM 6652: Peripheral port Transmission delay (4 digits BCD; unit: 10 ms) Default: No delay
1-9-2 Wiring Ports Refer to the CQM1 Operation Manual, CPM1 Operation Manual, CPM1A Operation Manual or SRM1 Master Control Units Operation Manual for information on wiring the communications ports.
1-9-3 CQM1 Host Link Communications Host link communications were developed by OMRON for the purpose of connecting PCs and one or more host computers by RS-232C cable, and controlling PC communications from the host computer. Normally the host computer issues a command to a PC, and the PC automatically sends back a response. Thus the communications are carried out without the PCs being actively involved. The PCs also have the ability to initiate data transmissions when direct involvement is necessary. In general, there are two means for implementing host link communications. One is based on C-mode commands, and the other on FINS (CV-mode) commands. The CQM1 supports C-mode commands only. For details on host link communications, refer to Section 6 Host Link Commands.
91
Page 112
Section
Communications Functions Communications Procedure
1-9
This section explains how to use the host link to execute data transmissions from the CQM1. Using this method enables automatic data transmission from the CQM1 when data is changed, and thus simplifies the communications process by eliminating the need for constant monitoring by the computer.
1, 2, 3...
1. Check to see that AR 0805 (RS-232C Port Transmit Ready Flag) is ON. 2. Use the TXD(48) instruction to transmit the data. S: Beginning word no. of transmission data
(@)TXD(48) S C N
C: Control data Bits 00 to 03 0: Leftmost bytes first 1: Rightmost bytes first Bits 12 to 15 0: RS-232C port 1: Peripheral port N: Number of bytes of data to be sent (4 digits BCD) 0000 to 0256
From the time this instruction is executed until the data transmission is complete, AR 0805 (or AR 0813 for the peripheral port) will remain OFF. It will turn ON again upon completion of the data transmission. The TXD(48) instruction does not provide for a response, so in order to receive confirmation that the computer has received the data, the computer’s program must be written so that it gives notification when data is written from the CQM1. The transmission data frame is as shown below for data transmitted in the Host Link Mode by means of the TXD(48) instruction. @ x 101 x 100 Node No.
E
X
Header code (Must be “EX”)
Data (up to 122 characters)
FCS
↵
Terminator
To reset the RS-232C port (i.e., to restore the initial status), turn ON SR 25209. To reset the peripheral port, turn ON SR 25208. These bits will turn OFF automatically after the reset. If the TXD(48) instruction is executed while the CQM1 is in the middle of responding to a command from the computer, the response transmission will first be completed before the transmission is executed according to the TXD(48) instruction. In all other cases, data transmission based on a TXD(48) instruction will be given first priority. Application Example
This example shows a program for using the RS-232C port in the Host Link Mode to transmit 10 bytes of data (DM 0000 to DM 0004) to the computer. The default values are assumed for all the PC Setup (i.e., the RS-232C port is used in Host Link Mode, the node number is 00, and the standard communications conditions are used.) From DM 0000 to DM 0004, “1234” is stored in every word. From the computer, execute a program to receive CQM1 data with the standard communications conditions.
00100 AR0805 @TXD(48) DM 0000 #0000 #0010
92
If AR 0805 (the Transmit Ready Flag) is ON when IR 00100 turns ON, the ten bytes of data (DM 0000 to DM 0004) will be transmitted.
Page 113
Section
Communications Functions
1-9
The following type of program must be prepared in the host computer to receive the data. This program allows the computer to read and display the data received from the PC while a host link read command is being executed to read data from the PC. 10 ’CQM1 SAMPLE PROGRAM FOR EXCEPTION 20 CLOSE 1 30 CLS 40 OPEN ”COM:E73” AS #1 50 KEYIN 60 INPUT ”DATA ––––––––”,S$ 70 IF S$=” ” THEN GOTO 190 80 PRINT ”SEND DATA = ”;S$ 90 ST$=S$ 100 INPUT ”SEND OK? Y or N?=”,B$ 110 IF B$=”Y” THEN GOTO 130 ELSE GOTO KEYIN 120 S$=ST$ 130 PRINT #1,S$ ’Sends command to PC 140 INPUT #1,R$ ’Receives response from PC 150 PRINT ”RECV DATA = ”;R$ 160 IF MID$(R$,4,2)=”EX” THEN GOTO 210 ’Identifies command from PC 170 IF RIGHT$(R$,1)<>”” THEN S$=” ”:GOTO 130 180 GOTO KEYIN 190 CLOSE 1 200 END 210 PRINT ”EXCEPTION!! DATA” 220 GOTO 140 The data received by the computer will be as shown below. (FCS is “59.”) “@00EX1234123412341234123459CR”
1-9-4 CPM1/CPM1A Host Link Communications Host link communications were developed by OMRON for the purpose of connecting PCs and one or more host computers by RS-232C cable, and controlling PC communications from the host computer. Normally the host computer issues a command to a PC, and the PC automatically sends back a response. Thus the communications are carried out without the PCs being actively involved. The PCs also have the ability to initiate data transmissions when direct involvement is necessary. In general, there are two means for implementing host link communications. One is based on C-mode commands, and the other on FINS (CV-mode) commands. The CPM1/CPM1A supports C-mode commands only. For details on host link communications, refer to Section 6 Host Link Commands. PC Setup Settings
Word Bit DM 6650 00 to 07
The CPM1/CPM1A’s peripheral port settings must be set properly in order to use the host link communications, as shown in the following table. Function Port settings1
Setting 00
00: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) 01: Settings in DM 6651 08 to 11
Link area for one-to-one PC link via peripheral port 0: LR 00 to LR 15
0 (Any value is OK)
12 to 15
Communications mode1 0: Host link; 2: One-to-one PC link (slave); 3: One-to-one PC link (master); 4: NT link
0
93
Page 114
Section
Communications Functions Word Bit DM 6651 00 to 07
08 to 15
DM 6652 00 to 15 DM 6653 00 to 07 08 to 15
Function
Setting
00: 1.2K, 01: 2.4K, 02: 4.8K, 03: 9.6K, 04: 19.2K
00 (Any value is OK)
Baud rate1
Frame format1 Start Length 00: 1 bit 7 bits 01: 1 bit 7 bits 02: 1 bit 7 bits 03: 1 bit 7 bits 04: 1 bit 7 bits 05: 1 bit 7 bits 06: 1 bit 8 bits 07: 1 bit 8 bits 08: 1 bit 8 bits 09: 1 bit 8 bits 10: 1 bit 8 bits 11: 1 bit 8 bits Transmission delay (Host Link)1 0000 to 9999: In ms. Node number (Host link)1 00 to 31 (BCD) Not used.
Note
94
1-9
Stop 1 bit 1 bit 1 bit 2 bit 2 bit 2 bit 1 bit 1 bit 1 bit 2 bit 2 bit 2 bit
Parity Even Odd None Even Odd None Even Odd None Even Odd None
00 (Any value is OK)
0000 00 to 31 00 (Any value is OK)
1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be turned ON, and the default setting (0, 00, or 0000) will be used. 2. For information on the host link settings for another OMRON PC, refer to that PC’s Operation Manual. 3. If an out-of-range value is set, the following communications conditions will result. In that case, reset the value so that it is within the permissible range. Communications mode: Host Link Communications format: Standard settings (1 start bit, 7-bit data; even parity, 2 stop bits, 9,600 bps) Transmission delay: No Node number: 00
Page 115
Section
Communications Functions Example Program
1-9
This example shows a BASIC program that reads the status of the CPM1’s inputs in IR 000. For more details, refer to Section 6 Host Link Commands. An FCS (frame check sequence) check isn’t performed on the received response data in this program. Be sure that the host computer’s RS-232C port is configured correctly before executing the program. 1010 ’CPM1 SAMPLE PROGRAM 1020 ’SET THE COMMAND DATA 1030 S$=”@00RR00000001” 1040 FCS=0 1050 FOR I=1 TO LEN(S$) 1060 FCS=FCS XOR ASC(MID$(S$,I,1)) 1070 NEXT I 1080 FCS$=(FCS):IF LEN(FCS$)=1 THEN FCS$=”0”+FCS$ 1090 CLOSE 1 1100 CLS 1110 PRINT ”SENDING COMMAND” 1120 OPEN ”COM:E73” AS #1 1130 PRINT #1,S$ + FCS + CHR$(13); 1140 CLS 1150 PRINT ”RECEIVING RESPONSE DATA” 1160 LINE INPUT #1,A$ 1170 PRINT A$ 1180 END
1-9-5 SRM1 Host Link Communications Host link communications were developed by OMRON for the purpose of connecting PCs and one or more host computers by RS-232C cable, and controlling PC communications from a host computer. Normally the host computer issues a command to a PC, and the PC automatically sends back a response. Thus the communications are carried out without the PCs being actively involved. The PCs also have the ability to initiate data transmissions when direct involvement is necessary. In general, there are two means for implementing host link communications. One is based on C-mode commands, and the other on FINS (CV-mode) commands. The SRM1 supports C-mode commands only. For details on host link communications, refer to Section 6 Host Link Commands. PC Setup Settings Word
The SRM1’s peripheral port and RS-232C port settings must be set properly in order to use the host link communications, as shown in the following table.
Bit
Function
Setting
Peripheral Port Settings The following settings are effective after transfer to the PC. DM 6650 00 to 03 Port settings 0: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) 1: Settings in DM 6651
To match host parameters
(Other settings will cause a non-fatal error, the default setting (0) will be used, and AR 1302 will turn ON.) 04 to 07 08 to 11 12 to 15
Not used. Not used. Communications mode 0: Host link; 1: No protocol
0 0 0: Host link
(Other settings will cause a non-fatal error, the default setting (0) will be used, and AR 1302 will turn ON.)
95
Page 116
Section
Communications Functions Word DM 6651
DM 6652
DM 6653
Bit 00 to 07
Baud rate 00: 1.2K, 01: 2.4K, 02: 4.8K, 03: 9.6K, 04: 19.2K
08 to 15
Frame format Start 00: 1 bit 01: 1 bit 02: 1 bit 03: 1 bit 04: 1 bit 05: 1 bit 06: 1 bit 07: 1 bit 08: 1 bit 09: 1 bit 10: 1 bit 11: 1 bit
00 to 15
00 to 07
08 to 11
12 to 15
DM 6654
Function
00 to 07
08 to 15
Length 7 bits 7 bits 7 bits 7 bits 7 bits 7 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits
Stop 1 bit 1 bit 1 bit 2 bit 2 bit 2 bit 1 bit 1 bit 1 bit 2 bit 2 bit 2 bit
1-9
Setting To match host parameters Parity Even Odd None Even Odd None Even Odd None Even Odd None
(Other settings will cause a non-fatal error, the default setting (00) will be used, and AR 1302 will turn ON.) Transmission delay (Host Link) 0000 to 9999 (BCD): Set in units of 10 ms. (Other settings will cause a non-fatal error, the default setting (0000) will be used, and AR 1302 will turn ON.) Node number (Host link) 00 to 31 (BCD) (Other settings will cause a non-fatal error, the default setting (0000) will be used, and AR 1302 will turn ON.) Start code enable (RS-232C, effective when bits 12 to 15 of DM 6650 are set to 1.) 0: Disable 1: Set
To match host parameters
To match host parameters 00 to 31
Any
End code enable (RS-232C, effective when bits 12 to 15 of DM 6650 are set to 1.) 0: Disable (number of bytes received) 1: Set (specified end code) 2: CR, LF Start code (effective when bits 08 to 11 of DM6650 are set to 1.) 00: 256 bytes 01 to FF: 1 to 255 bytes
Any
End code (no protocol)
Any
Any
When bits 12 to 15 of DM6653 are set to 0: 00: 256 bytes 01 to FF: 1 to 255 bytes When bits 12 to 15 of DM6653 are set to 1: Setting: 00 to FF (binary)
Note If an out-of-range value is set, the following communications conditions will result. In that case, reset the value so that it is within the permissible range. Communications mode: Communications format:
Transmission delay: Node number: Word
Bit
Host Link Standard settings (1 start bit, 7-bit data; even parity, 2 stop bits, 9,600 bps) No 00
Function
Setting
RS-232C Port Settings The following settings are effective after transfer to the PC. DM 6645 00 to 03 Port settings 0: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) 1: Settings in DM 6646
96
To match host parameters
Page 117
Section
Communications Functions Word
Bit
Function
04 to 07
CTS control settings 0: Disable; 1: Set Link words for 1:1 link 0: LR 00 to LR 15; Other: Not effective Communications mode 0: Host link; 1: RS-232C (no protocol); 2: 1:1 data link slave; 3: 1:1 data link master; 4: NT Link
0
00 to 07
Baud rate 00: 1.2K, 01: 2.4K, 02: 4.8K, 03: 9.6K, 04: 19.2K
To match host parameters
08 to 15
Frame format Start Length Stop Parity 00: 1 bit 7 bits 1 bit Even 01: 1 bit 7 bits 1 bit Odd 02: 1 bit 7 bits 1 bit None 03: 1 bit 7 bits 2 bit Even 04: 1 bit 7 bits 2 bit Odd 05: 1 bit 7 bits 2 bit None 06: 1 bit 8 bits 1 bit Even 07: 1 bit 8 bits 1 bit Odd 08: 1 bit 8 bits 1 bit None 09: 1 bit 8 bits 2 bit Even 10: 1 bit 8 bits 2 bit Odd 11: 1 bit 8 bits 2 bit None Transmission delay (Host Link) 0000 to 9999 (BCD): Set in units of 10 ms, e.g., setting of 0001 equals 10 ms
To match host parameters
Node number (Host link, effective when bits 12 to 15 of DM 6645 are set to 0.) 00 to 31 (BCD) Start code enable (RS-232C, effective when bits 12 to 15 of DM 6645 are set to 1.) 0: Disable; 1: Set End code enable (RS-232C, effective when bits 12 to 15 of DM 6645 are set to 1.) 0: Disable (number of bytes received) 1: Set (specified end code) 2: CR, LF Start code (RS-232C) 00: 256 bytes 01 to FF: 1 to 255 bytes
00 to 31
End code enable (RS-232C)
Any
08 to 11 12 to 15
DM 6646
DM 6647
00 to 15
DM 6648
00 to 07 08 to 11 12 to 15
DM 6649
1-9
00 to 07
08 to 15
Setting
0: Host link
To match host parameters
Any Any
Any
00 to FF (BIN)
Note If an out-of-range value is set, the following communications conditions will result. In that case, reset the value so that it is within the permissible range. Communications mode: Communications format:
Transmission delay: Node number:
Host Link Standard settings (1 start bit, 7-bit data; even parity, 2 stop bits, 9,600 bps) No 00
97
Page 118
Section
Communications Functions Example Program
1-9
This example shows a BASIC program that reads the status of the SRM1’s inputs in IR 000. For more details, refer to Section 6 Host Link Commands. An FCS (frame check sequence) check isn’t performed on the received response data in this program. Be sure that the host computer’s RS-232C port is configured correctly before executing the program. 1000 ’ 1010 ’SRM1 Sample Program for PC-9801 N88-BASIC 1020 ’ 1050 ’ 1060 ’ Set value RS-232C SPEED:9600BPS,PARITY:EVEN,DATA:7,STOP:2 1070 OPEN ”COM:E73” AS #1 1080 *REPEAT 1090 ’ Transmission data input 1100 INPUT ”send data:”,SEND$ 1110 ’ FCS Calculation 1120 FCS=0 1130 FOR IFCS=1 TO LEN(SEND$) 1140 FCS=FCS XOR ASC(MID$(SEND$;IFCS,1) 1150 NEXT 1160 FCS$=RIGHT$(”0”+HEX$(FCS),2) 1170 ’ Communications execute 1180 ZZZ$=SEND$+FCS$+”*”+CHR$(13) 1190 PRINT #1,ZZZ$; 1200 ’ Response check 1210 RECCNT=0:TMP$=”” 1220 *DRECLOOP 1230 IF LOC(1)<>0 THEN *DREC1 1240 RECCNT=RECCNT+1 1250 IF RECCNT=5000 THEN *DRECERR ELSE *DRECLOOP 1260 *DREC1 1270 TMP$=TMP$+INPUT$(LOC(1),#1) 1280 IF RIGHT$(TMP$,1)=CHR$(13) THEN *DRECEND ELSE RECCNT=0:GOTO *DRECLOOP 1290 *DRECERR 1300 TMP$=”No response!!”+CHR$(13) 1310 *DRECEND 1320 RECV$=TMP$ 1330 PRINT ”receive data:”;RECV$ 1340 ’ Go to transmission data input 1350 GOTO *REPEAT 1360 ’ Processing complete 1370 CLOSE #1 1380 END
1-9-6 RS-232C Communications (CQM1/SRM1 Only) This section explains RS-232C communications. By using RS-232C communications, the data can be printed out by a printer or read by a bar code reader. Handshaking is not supported for RS-232C communications. Communications Procedure Transmissions 1, 2, 3...
98
1. Check to see that AR 0805 (the RS-232C Port Transmit Ready Flag) has turned ON.
Page 119
Section
Communications Functions
1-9
2. Use the TXD(48) instruction to transmit the data. (@)TXD(48)
S: Leading word no. of data to be transmitted S
C: Control data
C
N: Number of bytes to be transmitted (4 digits BCD), 0000 to 0256
N
From the time this instruction is executed until the data transmission is complete, AR 0805 ( or AR0813 for the peripheral port) will remain OFF. (It will turn ON again upon completion of the data transmission.) Start and end codes are not included when the number of bytes to be transmitted is specified. The largest transmission that can be sent with or without start and end codes in 256 bytes, N will be between 254 and 256 depending on the designations for start and end codes. If the number of bytes to be sent is set to 0000, only the start and end codes will be sent. 256 bytes max.
Start code
Data
End code
To reset the RS-232C port (i.e., to restore the initial status), turn on SR 25209. To reset the peripheral port, turn on SR 25208. These bites will turn OFF automatically after the reset. Receptions 1, 2, 3...
1. Confirm that AR 0806 (RS-232C Reception Complete Flag) or AR 0814 (Peripheral Reception Complete Flag) is ON. 2. Use the RXD(47) instruction to receive the data. (@)RXD(47)
D: Leading word no. for storing reception data D C N
C: Control data Bits 00 to 03 0: Leftmost bytes first 1: Rightmost bytes first Bits 12 to 15 0: RS-232C port 1: Peripheral port N: Number of bytes stored (4 digits BCD), 0000 to 0256
3. The results of reading the data received will be stored in the AR area. Check to see that the operation was successfully completed. The contents of these bits will be reset each time RXD(47) is executed. RS-232C port AR 0800 to AR 0803
Peripheral port AR 0808 to AR 0811
Error
AR 0804
AR0812
Communications error
AR 0807
AR0815
Reception Overrun Flag (After reception was completed, the subsequent data was received before the data was read by means of the RXD(47) instruction.)
AR 09
AR10
Number of bytes received
RS-232C port error code (1 digit BCD) 0: Normal completion 1: Parity error 2: Framing error 3: Overrun error
To reset the RS-232C port (i.e., to restore the initial status), turn ON SR 25209. To reset the peripheral port, turn ON SR 25208. These bits will turn OFF automatically after the reset.
99
Page 120
Section
Communications Functions
1-9
The start code and end code are not included in AR 09 or AR 10 (number of bytes received). Application Example
This example shows a program for using the RS-232C port in the RS-232C Mode to transmit 10 bytes of data (DM 0100 to DM 0104) to the computer, and to store the data received from the computer in the DM area beginning with DM 0200. Before executing the program, the following PC Setup setting must be made. DM 6645: 1000 (RS-232C port in RS-232C Mode; standard communications conditions) DM 6648: 2000 (No start code; end code CR/LF) The default values are assumed for all other PC Setup settings. From DM 0100 to DM 0104, 3132 is stored in every word. From the computer, execute a program to receive CQM1 data with the standard communications conditions. 00100 DIFU(13)
00101
00101 AR0805 @TXD(48) DM 0100 #0000
If AR 0805 (the Transmit Ready Flag) is ON when IR 00100 turns ON, the ten bytes of data (DM 0100 to DM 0104) will be transmitted, leftmost bytes first.
#0010 AR0806 @RXD(47) DM 0200 #0000 AR09
When AR 0806 (Reception Completed Flag) goes ON, the number of bytes of data specified in AR 09 will be read from the CQM1’s reception buffer and stored in memory starting at DM 0200, leftmost bytes first.
The data will be as follows: “31323132313231323132CR LF”
1-9-7 CQM1 One-to-one Link Communications If two CQM1s are linked one-to-one by connecting them together through their RS-232C ports, they can share common LR areas. When two CQM1s are linked one-to-one, one of them will serve as the master and the other as the slave. Note The peripheral port cannot be used for 1:1 links. One-to-one Links
A one-to-one link allows two CQM1s to share common data in their LR areas. As shown in the diagram below, when data is written into a word the LR area of one of the linked Units, it will automatically be written identically into the same word of the other Unit. Each PC has specified words to which it can write and specified words that are written to by the other PC. Each can read, but cannot write, the words written by the other PC. Master
Master area
Slave 1
Write “1”
Master area
Written automatically. Slave area
1
1
Write Slave area
The word used by each PC will be as shown in the following table, according to the settings for the master, slave, and link words. DM 6645 setting
Communications Procedure
100
LR 00 to LR 63
LR 00 to LR 31
LR 00 to LR 15
Master words
LR00 to LR31
LR00 to LR15
LR00 to LR07
Slave words
LR32 to LR63
LR16 to LR31
LR08 to LR15
If the settings for the master and the slave are made correctly, then the one-toone link will be automatically started up simply by turning on the power supply to both the CQM1s and operation will be independent of the CQM1 operating modes.