The text of a manual · part 40 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 6 Host Link Commands, pages 367 to 374
Pages 367 to 374 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 367
SECTION 6 Host Link Commands This section explains the methods and procedures for using host link commands, which can be used for host link communications via the CQM1/CPM1/CPM1A/SRM1 ports.
6-1 6-2
6-3
Communications Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command and Response Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2-1 Commands from the Host Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2-2 Commands from the PC (CQM1/SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2-3 Response End Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Host Link Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-1 IR/SR AREA READ –– RR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-2 LR AREA READ –– RL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-3 HR AREA READ –– RH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-4 PV READ –– RC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-5 TC STATUS READ –– RG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-6 DM AREA READ –– RD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-7 AR AREA READ –– RJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-8 IR/SR AREA WRITE –– WR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-9 LR AREA WRITE –– WL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-10 HR AREA WRITE –– WH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-11 PV WRITE –– WC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-12 TC STATUS WRITE –– WG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-13 DM AREA WRITE –– WD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-14 AR AREA WRITE –– WJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-15 SV READ 1 –– R# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-16 SV READ 2 –– R$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-17 SV READ 3 –– R% (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-18 SV CHANGE 1 –– W# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-19 SV CHANGE 2 –– W$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-20 SV CHANGE 3 –– W% (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-21 STATUS READ –– MS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-22 STATUS WRITE –– SC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-23 ERROR READ –– MF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-24 FORCED SET –– KS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-25 FORCED RESET –– KR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-26 MULTIPLE FORCED SET/RESET –– FK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-27 FORCED SET/RESET CANCEL –– KC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-28 PC MODEL READ –– MM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-29 TEST–– TS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-30 PROGRAM READ –– RP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-31 PROGRAM WRITE –– WP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-32 COMPOUND COMMAND –– QQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-33 ABORT –– XZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-34 INITIALIZE –– . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3-35 Undefined Command –– IC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
350 352 352 355 355 356 356 356 357 357 358 358 359 359 360 360 361 362 362 363 364 364 365 366 367 368 369 370 370 371 372 373 374 375 375 376 376 376 378 378 379
349
Page 368
Section
Communications Procedure Command Chart
Header code
6-1
The commands listed in the chart below can be used for host link communications with the CQM1/CPM1/CPM1A/SRM1. These commands are all sent from the host computer to the PC. PC mode
Name
Applicable PCs
Page
RR
IR/SR AREA READ
RUN Valid
MON Valid
PRG Valid
All
356
RL
LR AREA READ
Valid
Valid
Valid
All
356
RH
HR AREA READ
Valid
Valid
Valid
All
357
RC
PV READ
Valid
Valid
Valid
All
357
RG
TC STATUS READ
Valid
Valid
Valid
All
358
RD
DM AREA READ
Valid
Valid
Valid
All
358
RJ
AR AREA READ
Valid
Valid
Valid
All
359
WR
IR/SR AREA WRITE
Not valid
Valid
Valid
All
359
WL
LR AREA WRITE
Not valid
Valid
Valid
All
360
WH
HR AREA WRITE
Not valid
Valid
Valid
All
360
WC
PV WRITE
Not valid
Valid
Valid
All
361
WG
TC STATUS WRITE
Not valid
Valid
Valid
All
362
WD
DM AREA WRITE
Not valid
Valid
Valid
All
362
WJ
AR AREA WRITE
Not valid
Valid
Valid
All
363
R#
SV READ 1
Valid
Valid
Valid
All
364
R$
SV READ 2
Valid
Valid
Valid
All
364
R%
SV READ 3
Valid
Valid
Valid
CQM1 only
365
W#
SV CHANGE 1
Not valid
Valid
Valid
All
366
W$
SV CHANGE 2
Not valid
Valid
Valid
All
367
W%
SV CHANGE 3
Not valid
Valid
Valid
CQM1 only
368
MS
STATUS READ
Valid
Valid
Valid
All
369
SC
STATUS WRITE
Valid
Valid
Valid
All
370
MF
ERROR READ
Valid
Valid
Valid
All
370
KS
FORCED SET
Not valid
Valid
Valid
All
371
KR
FORCED RESET
Not valid
Valid
Valid
All
372
FK
MULTIPLE FORCED SET/RESET
Not valid
Valid
Valid
All
373
KC
FORCED SET/RESET CANCEL
Not valid
Valid
Valid
All
374
MM
PC MODEL READ
Valid
Valid
Valid
All
375
TS
TEST
Valid
Valid
Valid
All
375
RP
PROGRAM READ
Valid
Valid
Valid
All
376
WP
PROGRAM WRITE
Not valid
Not valid
Valid
All
376
COMPOUND COMMAND
Valid
Valid
Valid
All
377
XZ
ABORT (command only)
Valid
Valid
Valid
All
379
INITIALIZE (command only)
Valid
Valid
Valid
All
379
IC
Undefined command (response only)
---
---
---
All
379
6-1
Communications Procedure Host link communications are executed by means an exchange of commands and responses between the host computer and the PC. With the CQM1, there are two communications methods that can be used. One is the normal method, in which commands are issued from the host computer to the PC. The other method allows commands to be issued from the PC to the host computer.
350
Page 369
Section
Communications Procedure
6-1
Frame Transmission and Reception Commands and responses are exchanged in the order shown in the illustration below. The block of data transferred in a single transmission is called a “frame.” A single frame is configured of a maximum of 131 characters of data. The right to send a frame is called the “transmission right.” The Unit that has the transmission right is the one that can send a frame at any given time. The transmission right is traded back and forth between the host computer and the PC each time a frame is transmitted. The transmission right is passed from the transmitting Unit to the receiving Unit when either a terminator (the code that marks the end of a command or response) or a delimiter (the code that sets frames apart) is received. Commands from Host
In host link communications, the host computer ordinarily has the transmission right first and initiates the communications. The PC then automatically sends a response.
Frame (command)
Frame (command)
Unit no. Header code
Unit no. Header code
Text
Text
FCS Terminator
FCS Terminator
Host computer
Next frame transmission enabled (i.e., transmission right transferred) Unit no. Header code End code
Unit no. Header code End code
Text
Text
FCS Terminator
FCS Terminator
Frame (response)
Frame (response)
PC
Commands from PC (CQM1 Only)
With CQM1 PCs, it is also possible in host link communications for the PC to send commands to the host computer. In this case it is the PC that has the transmission right and initiates the communications. Host computer No response Unit no. Header code PC
Text FCS Terminator
When commands are issued to the host computer, the data is transmitted in one direction from the PC to the host computer. If a response to a command is required use a host link communications command to write the response from the host computer to the PC.
351
Page 370
Section
Command and Response Formats
6-2
6-2
Command and Response Formats This section explains the formats for the commands and responses that are exchanged in host link communications.
6-2-1 Commands from the Host Computer When a command is issued from the host computer, the command and response formats are as shown below. Command Format
@
When transmitting a command from the host computer, prepare the command data in the format shown below.
x 101 x 100
Node no.
Header code
Text
FCS
↵
Terminator
@ An “@” symbol must be placed at the beginning. Node No. Identifies the PC communicating with the host computer. Specify the node number set for the PC in the PC Setup (DM 6648, DM 6653). Header Code Set the 2-character command code. Text Set the command parameters. FCS Set a 2-character Frame Check Sequence code. See page 354. Terminator Set two characters, “” and the carriage return (CHR$(13)) to indicate the end of the command. Response Format
@
The response from the PC is returned in the format shown below. Prepare a program so that the response data can be interpreted and processed.
x 101 x 100
Node no.
x 161 x 160
Header code
End code
Text
FCS
↵
Terminator
@, Node No., Header Code Contents identical to those of the command are returned. End Code The completion status of the command (e.g., whether or not an error has occurred) is returned. Text Text is returned only when there is data such as read data. FCS, Terminator Refer to the corresponding explanations under “Command Format.” Long Transmissions
352
The largest block of data that can be transmitted as a single frame is 131 characters. A command or response of 132 characters or more must therefore be divided into more than one frame before transmission. When a transmission is split, the ends of the first and intermediate frames are marked by a delimiter instead of a terminator.
Page 371
Section
Command and Response Formats
6-2
Dividing Commands (Host Computer to PC) As each frame is transmitted by the host computer, the computer waits for the delimiter to be transmitted from the PC. After the delimiter has been transmitted, the next frame will then be sent. This procedure is repeated until the entire command has been transmitted.
Frame2 (command)
Frame3 (command)
Text
Text
Text
FCS Delimiter
FCS Delimiter
FCS Terminator
Frame1 (command) Unit no. Header code Host computer
Delimiter
PC
Delimiter
Unit no. Header code End code Text FCS Terminator Frame (response)
Dividing Responses (PC to Host Computer) As each frame is received by the host computer, a delimiter is transmitted to the PC. After the delimiter has been transmitted, the PC will transmit the next frame. This procedure is repeated until the entire response has been transmitted.
Frame (command) Unit no. Header code Host computer
Text FCS Terminator
Delimiter
Unit no. Header code End code PC
Text FCS Delimiter
Delimiter
Text
Text
FCS Delimiter
FCS Terminator
Frame2 (response)
Frame3 (response)
Frame1 (response)
353
Page 372
Section
Command and Response Formats
6-2
Precautions for Long Transmissions When dividing commands such as WR, WL, WC, or WD that execute write operations, be careful not to divide into separate frames data that is to be written into a single word. As shown in the illustration below, be sure to divide frames so that they coincide with the divisions between words.
Frame 1 @
0
0
W
Node no.
↵
Data
D
Header code
One word of data
Delimiter
FCS
Data from the same word is not divided. Frame 3
Data
One word of data
↵
Terminator
FCS
Data from the same word is not divided.
FCS (Frame Check Sequence) When a frame is transmitted, an FCS is placed just before the delimiter or terminator in order to check whether any data error has been generated. The FCS is 8-bit data converted into two ASCII characters. The 8-bit data is the result of an EXCLUSIVE OR performed on the data from the beginning of the frame until the end of the text in that frame (i.e., just before the FCS). Calculating the FCS each time a frame is received and checking the result against the FCS that is included in the frame makes it possible to check for data errors in the frame.
@
1
0
Node no.
R
R
0
0
Header code
0 Text
1
4
2 FCS
FCS calculation range ASCII code
354
@
40
1
31
0
30
R
52
1 Calculation result
31
0100 0000 XOR 0011 0001 XOR 0011 0000 XOR 0101 0010 0011 0100 ↓ 4
0001 0010 ↓ Converted to hexadecimal. 2 Handled as ASCII characters.
↵
Terminator
Page 373
Section
Command and Response Formats Example Program for FCS
6-2
This example shows a BASIC subroutine program for executing an FCS check on a frame received by the host computer. 400 *FCSCHECK 410 L=LEN(RESPONSE$) ’ . .......... Data transmitted and received 420 Q=0:FCSCK$=” ” 430 A$=RIGHT$(RESPONSE$,1) 440 PRINT RESPONSE$,A$,L 450 IF A$=”*” THEN LENGS=LEN(RESPONSE$)-3 ELSE LENGS=LEN(RESPONSE$)-2 460 FCSP$=MID$(RESPONSE$,LENGS+1,2) ’ . ... FCS data received 470 FOR I=1 TO LENGS ’ . .......... Number of characters in FCS 480 Q=ASC(MID$(RESPONSE$,I,1)) XOR Q 490 NEXT I 500 FCSD$=HEX$(Q) 510 IF LEN(FCSD$)=1 THEN FCSD$=”0”+FCSD$ ’ . .... FCS result 520 IF FCSD$<>FCSP$ THEN FCSCK$=”ERR” 530 PRINT”FCSD$=”;FCSD$,”FCSP$=”;FCSP$,”FCSCK$=”;FCSCK$ 540 RETURN
Note
1. Normal reception data includes the FCS, delimiter or terminator, and so on. When an error occurs in transmission, however the FCS or some other data may not be included. Be sure to program the system to cover this possibility. 2. In this program example, the CR code (CHR$(13)) is not entered for RESPONSE$. When including the CR code, make the changes in lines 430 and 450.
6-2-2 Commands from the PC (CQM1/SRM1 Only) In host link communications, commands are ordinarily sent from the host computer to the PC, but it is also possible for commands to be sent from the PC to the host computer. In Host Link Mode, any data can be transmitted from the PC to the host computer. To send a command to the host computer, use the TRANSMIT instruction (TXD(48)) in the PC program in Host Link Mode. TXD(48) outputs data from the specified port (the RS-232C port or the peripheral port). Refer to page 342 for details on using TXD(48). Reception Format
When TXD(48) is executed, the data stored in the words beginning with the first send word is converted to ASCII and output to the host computer as a host link command in the format shown below. The “@” symbol, node number, header code, FCS, and delimiter are all added automatically when the transmission is sent. At the host computer, it is necessary to prepare in advance a program for interpreting and processing this format. E
@ Node no.
X
Header code (Must be “EX”)
122 characters max.
Text
FCS
↵
Terminator
One byte of data (2 digits hexadecimal) is converted to two characters in ASCII for transmission, the amount of data in the transmission is twice the amount of words specified for TXD(48). The maximum number of characters for transmission is 122 and the maximum number of bytes that can be designated for TXD(48) is one half of that, or 61.
6-2-3 Response End Codes Refer to 8-7 Host Link Errors for a table listing the response end codes that may be returned in host link communications. An end code of 00 indicates normal completion of a command.
355
Page 374
Section
Host Link Commands
6-3
6-3
Host Link Commands This section explains the commands that can be issued from the host computer to the PC.
6-3-1 IR/SR AREA READ –– RR Reads the contents of the specified number of IR and SR words, starting from the specified word. Command Format @ x 101 x 100
Node no.
R
R
Header code x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100
Beginning word*
No. of words (0000 to 0256)
FCS
↵
Terminator
Note Beginning word: 0000 to 0255 in CQM1 PCs, 0000 to 0019 and 0200 to 0255 in CPM1/CPM1A/SRM1 PCs. Response Format @ x 101 x 100
Node no.
An end code of 00 indicates normal completion. R
R
Header code x 161 x 160 x 163 x 162 x 161 x 160
End code
Read data (1 word)
FCS
↵
Terminator
Read data (for number of words read)
Note
Parameters
1. Words 0020 to 0199 in CPM1/CPM1A/SRM1 PCs cannot be specified. If an attempt to read any of these words is made, a response of 0000 will be returned. 2. The response will be divided when reading more than 30 words of data. Read Data (Response) The contents of the number of words specified by the command are returned in hexadecimal as a response. The words are returned in order, starting with the specified beginning word.
6-3-2 LR AREA READ –– RL Reads the contents of the specified number of LR words, starting from the specified word. Command Format @ x 101 x 100
Node no.
R
Header code
Note
Response Format @ x 101 x 100
Node no.
L x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 Beginning word1
No. of words2
FCS
↵
Terminator
1. Beginning word: 0000 to 0063 in CQM1 PCs, 0000 to 0015 in CPM1/CPM1A/SRM1 PCs 2. No. of words: 0001 to 0064 in CQM1 PCs, 0001 to 0016 in CPM1/CPM1A/SRM1 PCs An end code of 00 indicates normal completion.
R
L
Header code x 161 x 160 x 163 x 162 x 161 x 160
End code
Read data (1 word) Read data (for number of words read)
356
FCS
↵
Terminator