Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 46 of 60

C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 444 to 453

Pages 444 to 453 of 586

The original document is the PDF (3.4 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 C200HE-CPU42-E

Page 444

Host Link Communications

Section 8-2

Note If pin 5 of the CPU Unit’s DIP switch is ON, the standard communications settings will be used regardless of the settings in the PC Setup. The standard settings are as follows: Item

Setting

Node number

00

Start bits

1

Data length

7

Stop bits

2

Parity

Even

Baud rate

9,600 bps

Transmission delay time

None

8-2-2 Host Link Communications Host link communications are executed by means an exchange of commands and responses between the host computer and the PC. The command or response data that is transferred in one exchange is known as a frame and one frame can contain up to 131 characters of data. The frame formats for Host Link commands transmitted from the host computer and responses returned from the PC are described below. The PC automatically returns an ASCII-code response when it receives an ASCII-code command from the host computer. The host computer must have a program that controls the transmission and reception of the commands and responses. Command Frame 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

The header code and text depend on the Host Link command being transmitted. When a composite command is transmitted, there will be a second sub-header code. The FCS (Frame Check Sequence) code is calculated at the host computer and set in the command frame. The FCS calculation is described later in this section. The command frame may be up to 131 characters long. A command of 132 characters or more must be divided into more than one frame. To split the command, use a carriage return delimiter (↵, CHR$(13)) instead of a terminator. A terminator must be used at the end of the last frame. 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. Be sure to divide frames so that they coincide with the divisions between words. Item

Function

@

An “@” symbol must be placed at the beginning of every command.

Node no.

Identify the PC by the node number set in DM 6648 of the PC Setup.

Header code Set the 2-character command code.

426

Text

Set the command parameters.

FCS

Set a 2-character Frame Check Sequence code.

Terminator

Set two characters, and the carriage return (CHR$(13)) to indicate the end of the command.

Page 445

Host Link Communications Response Frame 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.

Section 8-2 x 161 x 160

Header code

End code

Text

FCS

↵

Terminator

The header code and text depend on the Host Link command that was received. The end code indicates the completion status of the command (e.g., whether or not an error has occurred). When the response is longer than 131 characters, it will be divided into more than one frame. A carriage return delimiter (↵, CHR$(13)) instead of a terminator will automatically be set at the end of the frame. A terminator will be set at the end of the last frame. Item

Function

@

An “@” symbol is placed at the beginning of every response.

Node no.

The PC’s node number set in DM 6648 of the PC Setup.

Header code

The 2-character command code is returned.

Text

The results of the command are returned.

FCS

The 2-character Frame Check Sequence code is returned.

Terminator

Two characters, and the carriage return (CHR$(13)) indicate the end of the response.

FCS (Frame Check Sequence) When a frame is transmitted, an FCS code is placed just before the delimiter or terminator in order to check whether an error has occurred in the transmission. 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

↵

Terminator

FCS calculation range ASCII code @

40

1

31

0

30

R

52

1 Calculation result

31

0100 0000 EOR 0011 0001 EOR 0011 0000 EOR 0101 0010 0011 0100 i 4

0001 0010 i Converted to hexadecimal. 2 Handled as ASCII characters.

427

Page 446

Host Link Communications

Section 8-2

Communications Sequence

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. An example communications sequence between the host computer and PC is described below. • The host computer sets a delimiter at the end of the first command frame and transmits the frame. • When the PC receives the delimiter, it returns the same delimiter to the host computer. • After receiving the delimiter from the PC, the host computer transmits the next frame. • The PC sets a delimiter at the end of the first response frame and transmits the frame. • When the host computer receives the delimiter, it returns the same delimiter to the PC. • After receiving the delimiter from the host computer, the PC transmits the next frame. • Long transmissions are managed by exchanging delimiters in this way. The last frame ends with a terminator. Frame2 (command)

Frame3 (command)

Text

Text

Text

FCS Delimiter

FCS Delimiter

FCS Terminator

Frame1 (command) @ Unit No. Header code Host computer

PC

Delimiter

Delimiter

@ Unit No. Header code End code Text FCS Terminator Frame (response)

Using the TXD(––) Instruction The TXD(––) instruction can be used to transmit data from the PC’s data area to the host computer. There is no response from the host computer. The TXD(––) instruction will be executed after the response has been transmitted if TXD(––) is executed while a response to a Host Link command is being returned to the host computer. Host computer No response @ Unit No. Header code PC

Text FCS Terminator

428

Page 447

Host Link Communications

Section 8-2

8-2-3 Example Programs Command Transmission

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 ’C200HX/HG/HE SAMPLE PROGRAM FOR EXCEPTION 20 CLOSE 30 CLS 40 OPEN ”COM:E73” AS #1 50 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 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 THEN S$=” ”:GOTO 130 180 GOTO 190 CLOSE 1 200 END 210 PRINT ”EXCEPTION!! DATA” 220 GOTO 140

Example Program for FCS

Note

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$,AS,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 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.

TXD(––) 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 a computer. From DM 0000 to DM 0004, “1234” is stored in every word.

429

Page 448

RS-232C Communications

Section 8-3 The default values are assumed for all of the PC Setup (i.e., the RS-232C port is used in Host Link mode, the node number is 00, and the standard communications parameters are used.)

00100 SR 26405 @TXD DM 0000 #0000 #0010

8-3

If SR 26405 (the Transmit Ready Flag) is ON when IR 00100 turns ON, the ten bytes of data (DM 0000 to DM 0004) will be transmitted.

RS-232C Communications This section explains RS-232C communications. The TXD(––) and RXD(––) instructions can be used with RS-232C communications to output data to a printer, input data from a bar code reader or transmit Host Link commands to other devices equipped with an RS-232C port.

RS-232C Connection

The following diagram shows the RS-232C connection when the RS-232C port is used in RS-232C mode (no protocol).

Device equipped with RS-232C mode an RS-232C port

PC Setup Parameters

The following parameters in the PC Setup must be set in advance to enable RS-232C mode communications through the RS-232C or peripheral ports. Communications Mode Set the communications mode to RS-232C mode. RS-232C port: Set bits 12 through 15 of DM 6645 to 1. Peripheral port: Set bits 12 through 15 of DM 6650 to 1. Standard Port Settings Standard settings or custom settings can be used for the RS-232C and peripheral ports. Refer to page 424 for details on the standard communications settings. Custom Port Settings Standard settings or custom settings can be used for the RS-232C and peripheral ports. Refer to page 425 for details on custom communications settings. Enabling Start and End Codes DM 6648: RS-232C port DM 6653: Peripheral port

Bit

15

0

0

End code usage 0: Not set (Amount of reception data specified.) 1: Set (End code specified.) 2: CR/LF Start code usage 0: Not set 1: Set (Start code specified.) Defaults: No start code; data reception complete at 256 bytes.

430

0

Page 449

RS-232C Communications

Section 8-3 Specify whether or not a start code is to be set at the beginning of the data, and whether or not an end code is to be set at the end. Instead of setting the end code, it is possible to specify the number of bytes to be received before the reception operation is completed. Both the codes and the number of bytes of data to be received are set in DM 6649 or DM 6654. Setting the Start Code, End Code, and Amount of Reception Data Bit 15

0

DM 6649: RS-232C port DM 6654: Peripheral port

End code or number of bytes to be received For end code: (00 to FF) For amount of reception data: 2 digits hexadecimal, 00 to FF (00: 256 bytes) Start code 00 to FF Defaults: No start code; data reception complete at 256 bytes.

8-3-1 Communications Frame Structure Up to 259 bytes of data (including the start and end codes) can be transferred with the execution of one TXD(––) or RXD(––) instruction. When there are two or more start codes, the first start code will be used. Likewise, when there are two or more end codes, the first end code will be used. Avoid using commonly occurring characters for the end code. Use CR and LF for the end code if data transmissions are being cut short because the end code is occurring within the body of the transmission data. • No start code and end code Data (specified number of bytes)

• Start code only ST

Data (specified number of bytes)

• End code only Data (256 bytes or less)

ED

• Both start code and end code ST

Data (257 bytes or less)

ED

• CR, LF specified for the end code Data (258 bytes or less)

CR

LF

CR

LF

• Both start code (00 to FF) and end code (CR, LF) ST

Data (259 bytes or less)

8-3-2 Communications Procedure Brief descriptions of the TXD(––) and RXD(––) are provided below. Transmission (TXD(––))

1, 2, 3...

Refer to 5-27-2 TRANSMIT – TXD(––) for more details. Always include the specified port’s Transmit Ready Flag as an execution condition for TXD(––) to ensure that this Flag is ON before the transmission can be executed. 1. Check to see that SR 26405 (RS-232C Port Transmit Ready Flag), SR 26413 (Peripheral Port Transmit Ready Flag), SR 28305 (Communications Board Port A Transmit Ready Flag), or SR 28313 (Communications Board Port B Transmit Ready Flag) is ON.

431

Page 450

RS-232C Communications

Section 8-3 2. Use the TXD(––) instruction to transmit the data. (Bits 08 to 11 are valid only when bits 12 to 15 are set to 0.) (@)TXD

S: Address of first word of data to be transmitted S C N

C: Control data Bits 00 to 03 0: Leftmost bytes first 1: Rightmost bytes first Bits 04 to 07 0: Normal data transmission operation 1: Status of bit 15 for the leftmost word of the transmission data is reflected on the RTS of the corresponding port. 2: Status of bit 15 for the leftmost word of the transmission data is reflected on the DTR of the corresponding port. 3: Statuses of bits 14 and 15 for the leftmost word of the transmission data are reflected on the RTS and DTR of the corresponding port. Bits 08 to 11 0: Built-in RS-232C port 1: Communications Board port A 2: Communications Board port B Bits 12 to 15 0: RS-232C port 1: Peripheral port 2: Host Link Unit #1 3: Host Link Unit #2 N: Number of bytes to be transmitted (4 digits BCD), 0000 to 0256 (start and end bits)

3. From the time this instruction is executed until the data transmission is complete, the Transmit Ready Flag (SR 26405, SR 26413, SR 28305, or SR 28313) will remain OFF. It will turn ON again upon completion of the data transmission. Reception (RXD(––))

Refer to 5-27-1 RECEIVE – RXD(––) for more details. 1, 2, 3...

1. Check to see that SR 26406 (RS-232C Port Reception Completed Flag) or SR 26414 (Peripheral Port Reception Completed Flag) is ON. 2. Use the RXD(––) instruction to receive the data. (Bits 08 to 11 are valid only when bits 12 to 15 are set to 0.) (@)RXD

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 04 to 07 0: Normal data reception operation 1: Reads the status of CTS of the corresponding port into bit 15 for the leftmost word of the reception data write. 2: Reads the status of DSR of the corresponding port into bit 15 for the leftmost word of the reception data write. 3: Reads the statuses of CTS and DSR of the corresponding port into bits 14 and 15 for the leftmost word of the reception data write. Bits 08 to 11 0: Built-in RS-232C port 1: Communications Board port A 2: Communications Board port B Bits 12 to 15 0: RS-232C port 1: Peripheral port N: Number of bytes stored (4 digits BCD), 0000 to 0256 (start and end bits)

432

Page 451

RS-232C Communications

Section 8-3 3. When RXD(––) is executed, the received data is transferred to the specified words (without the start and end codes) and the Reception Completed Flag is turned OFF. The start and end of reception are as follows: Start: Continuous reception status if the start code is not enabled. Reception starts when the start code is received if it is enabled. End: Reception ends when the end code is received or 259 bytes of data have been received. 4. The status resulting from reading the data received will be stored in the SR Area. Check to see that the operation was successfully completed. The contents of these bits will be reset each time RXD(––) is executed. RS-232C

Peripheral

Error

SR 26400 to SR 26403

SR 26408 to SR 26411

Communications port error code (1 digit BCD) 0: Normal completion 1: Parity error 2: Framing error 3: Overrun error

SR 26404

SR 26412

Communications Error Flag

SR 26407

SR 26415

Reception Overrun Flag (After reception was completed, the subsequent data was received before the data was read by means of the RXD instruction.)

SR 265

SR 266

Number of bytes received (not including start and end bits)

Note To reset the RS-232C port (i.e., to restore the initial status), turn ON SR 25209. To reset the Communications Board port A, turn ON SR 28900. To reset the Communications Board port B, turn ON SR 28901. These bits will turn OFF automatically after the reset.

8-3-3 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 settings must be made. DM 6645: 1000 (RS-232C port in RS-232C mode; standard settings) DM 6648: 2000 (No start code; end code CR/LF) The default values are assumed for all other PC Setup settings. The host computer must have the same communications settings and a program to receive the data transmitted from the PC. The data 3454 is stored in each word from DM 0100 to DM 0104. 00100 DIFU(13)

00101

00101 SR 26405 @TXD DM 0100 #0000

If SR 26405 (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 SR 26406 @RXD DM 0200 #0000 #0256

When SR 26406 (Reception Completed Flag) goes ON, the number of bytes of data specified in SR 265 will be read from the PC’s reception buffer and stored in memory starting at DM 0200, leftmost bytes first.

The data will be as follows: “34543454345434543454CR LF”

433

Page 452

One-to-one PC Links

8-4

Section 8-4

One-to-one PC Links If two PCs are linked one-to-one by connecting them together through their RS-232C ports, they can share common LR areas. When two PCs are linked one-to-one, one of them will serve as the master and the other as the slave. 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.

CPU

PS

CPU

C200HX/HG/HE

C200HX/HG/HE

Master Master area

PS

Slave 1

Write “1”

Master area

Written automatically. Slave area

Wiring

1

1

Write Slave area

Wire the cable as shown in the diagram below using the connector listed. Applicable Connectors The following connectors are applicable. One plug and one hood are included with the CPU Unit. The same connectors can be used for both ends of the cable. Plug: XM2A-0901 (OMRON) or equivalent Hood: XM2S-0911 (OMRON) or equivalent

C200HX/HG/HE

C200HX/HG/HE, C200HS, or CQM1

Signal Abb.

Pin No.

Pin No.

Signal Abb.

FG

1

1

FG

SD

2

2

SD

RD

3

3

RD

RS

4

4

RS

CS

5

5

CS

–

6

6

–

–

7

7

–

–

8

8

–

SG

9

9

SG

Note Ground the FG terminal of the PC to a resistance of 100 Ω or less.

434

Page 453

One-to-one PC Links PC Setup

Section 8-4 To use a 1:1 link, the only settings necessary are the communications mode and the link words. Set the communications mode for one of the PCs to one-to-one link master and the other PC to one-to-one link slave, and then set the link words in the PC designated as the master. Bits 08 to 11 are valid only for the master for link one-to-one. Bit 15

0

DM 6645: RS-232C port

Communications mode 2: One-to-one link slave 3: One-to-one link master Link words for one-to-one link 0: LR 00 to LR 63 1: LR 00 to LR 31 2: LR 00 to LR 15 Port settings 00: Standard communication parameters

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

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

Communications Procedure

If the settings for the master and the slave are made correctly, then the one-toone link will start up automatically when the PCs are turned on.

Application Example

This example shows a program for verifying the conditions for executing a oneto-one link using the RS-232C ports. Before executing the program, set the following PC Setup parameters. Master: DM 6645: 3200 (one-to-one link master; link words: LR 00 to LR 15) Slave: DM 6645: 2000 (one-to-one link slave) When the following programs are executed in the master and the slave, the status of IR 001 of each Unit will be reflected in IR 100 of the other Unit. IR 001 is an input word and IR 100 is an output word. In the Master 25313 (Always ON) MOV(21) 001 LR00

MOV(21) LR08 100

In the Slave 25313 (Always ON) MOV(21) 001 LR08

MOV(21) LR00 100

435