Q Corresponding Serial Communication Module User's Manual


Add to my manuals
358 Pages

advertisement

Q Corresponding Serial Communication Module User's Manual | Manualzz

7 DATA COMMUNICATION USING THE BIDIRECTIONAL PROTOCOL

MELSEC-Q

7.1 Data Reception from the External Device

This section explains the data reception from the external device.

7.1.1 Receiving methods

The following shows how to receive data sent from the external device using the bidirectional protocol. Since the size of each message received is recognized using the

"data length" information contained in the message, messages of any size can be sent from the external device.

3)

PLC CPU

Sequence program

Read

(BIDIN instructions)

2)

Read request

Arbirary data

(00

H

to FF

H

)

Q series C24

Buffer memory

Receive area

(When normal)

1)

Arbitrary data

ENQ Data length Data area

Sum check code

(When abnormal) (00

H

to FF

H

)

Ignored

Error code NAK

2)

4)

ACK

External device

7

Contents

Reception data read request signal

BIDIN instruction completion device

BIDIN instruction

CH1/CH2

X3/XA

Control Timing

BIDIN

7 - 2 7 - 2

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

1) When the control code ENQ is received, the Q series C24 starts data reception processing.

When the data specified by the data length is received, the Q series C24 ends the reception processing of that data.

If "Sum check" is set with GX Developer, the Q series C24 checks whether the message is normal or abnormal using the sum check code received immediately after the message and the sum check code calculated by internal processing.

If "No sum check" is set with GX Developer, messages are not checked using the sum check codes.

2) If the message has normally been received, the reception data read request signal

(X3/XA) turns ON.

If an error has been detected when receiving the message, the Q series C24 sends an abnormal end response (NAK message) to the external device.

The reception data read request will not be sent to the PLC CPU.

(The reception abnormal detection signal (X4/XB) does not come on.)

3) Control data is stored in the device designated with the BIDIN instruction and then the BIDIN instruction is executed.

Receive data is read from the receive area of the buffer memory.

4) When the BIDIN instruction has been executed, the Q series C24 sends a normal end response (ACK message) to the external device.

7 - 3 7 - 3

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

7.1.2 Arrangement and contents of the receive area and the receive data

This section shows the arrangement and contents of the receive area and the receive data for performing data reception using the bidirectional protocol.

CH1 address

600

H

601

H to

7FF

H

(Default)

(1) Receive area

The receive area is a memory that stores the received data length (receive data count) and data area received from an external device.

The receive area is allocated to addresses 600

H

to 7FF

H

(CH1 side) and A00

H

to

BFF

H

(CH2 side) at initial setting.

Buffer memory

The units of data length (word/byte) is in accordance with the word/byte units designation in GX Configurator-SC.

Receive data count storage area

Data length

The contents of data length of the received message are stored.

Receive data storage area

• Data area

The contents of the data area of the received message are stored in ascending address order.

7 - 4 7 - 4

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

POINT

(1) The position and size of the receive area in the buffer memory can be changed with GX Configurator-SC in accordance with the specifications of the external device and the received data length. (See Sections 8.4.5 and 8.4.7.)

(a) When changing the position and size of the receive area in the buffer memory with GX Configurator-SC, specify as follows:

1) Receive buffer memory head address designation

Designate the starting address for the area to be used as the receive area in the user definable area of the buffer memory (address: 400

H

to

1AFF

H

, 2600

H

to 3FFF

H

).

2) Receive buffer memory length designation

Designate by addresses the length of the area (0001

H

to 1A00

H

) to be used as the receive area in the user definable area of the buffer memory (address: 400

H

to 1AFF

H

, 2600

H

to 3FFF

H

).

(b) If the following functions are also used when the position and size of the receive area in the buffer memory are changed, make sure that the addresses of the receive area do not overlap with those for the buffer memory that stores the transmission and reception data to be used by these functions.

1) MC protocol buffer memory read/write function

2) MC protocol on-demand function

3) Non procedure protocol transmission/receive function

4) Bidirectional protocol transmission/receive function

5) Communication data monitoring function

(2) When sending data to the Q series C24 from the external device, one of the following two adjustments should be made so that the relationship shown below is maintained.

1) Reduce the send data size.

2) Increase the receive area.

(Receive data storage area)

(Size of data portion sent from the external device)

7 - 5 7 - 5

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(2) Arrangement of receive data

The following example illustrates the arrangement of data received from the external device when it is stored in the receive area.

1) The receive message is stored to the Q series C24 buffer memory (receive data storage area).

2) The data is stored to the receive data storage area in low address (L) (H), next address (L) (H) order.

If the received data is "ABCDEFG123", it will be stored as shown below (for the CH1 side):

Q series C24

Receive data count storage area

Receive data storage area

Receive area

(buffer memory)

(00

H

)

B

(42

H

)

D

(44

H

)

F

(46

H

)

1

(31

H

)

3

(33

H

)

5

(05

H

)

A

(41

H

)

C

(43

H

)

E

(45

H

)

G

(47

H

)

2

(32

H

)

Receive data (response message)

Data length

ENQ (0005

H

)

L H

A B C D E F G 1 2 3

Sum check code

L H

05

H

00

H

41

H

42

H

43

H

44

H

45

H

46

H

47

H

31

H

32

H

33

H

47

H

02

H

Transmission data (response message)

ACK

06

H

(Normal completion)

External device

When the data length unit is in bytes, 00

H

is stored in the higher byte of the last data storage position in the receive area when the data length of the message is an even byte.

(3) Contents of receive data

The contents of receive data, including the receive data as indicated in

Section 7.2.2, are explained below.

(a) Control codes

The types of control codes are shown in the table below.

Signal name

ENQ

ACK

NAK

Code

(hexadecimal)

05

H

06

H

15

H

Contents

Enquiry

Acknowledge

Negative

Acknowledge

Application

Code for starting data transmission.

Response code to the opposite side when data was received normally.

Response code to the opposite side when data could not be received normally. (Error code is sent immediately after the response code.)

1) For data communication from the external device to the Q series C24 the Q series C24 checks and processes the control code received.

It cannot be read from the sequence program.

2) For data communication from the Q series C24 to the external device

The control code to be transmitted is added by the Q series C24.

7 - 6 7 - 6

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(b) Data length

This indicates the number of bytes or words for the data portion of the message.

The unit of data length (words/bytes) is in accordance with the word/byte units designation in GX Configurator-SC.

1) For data communication from the external device to the Q series C24

The Q series C24 checks the length of the data received.

When the reception is normal, the Q series C24 stores the receive data in the receive data storage area of the Q series C24 buffer memory, assigning the first byte as the lower byte (L).

2) For data communication from the Q series C24 to the external device

The length of the transmission data is the number of the transmission data designated by the sequence program using the BIDOUT instruction.

The Q series C24 sends this value as is from the lower byte (L).

(c) Data portion

This consists of an array of original one-byte data to be transmitted to the external device side, which can handle 00

H

to FF

H

code data.

1) For data communication from the external device to the Q series C24

If the receive data portion is normal, the Q series C24 takes the codes as is and stores them in the receive data storage area in sequence, beginning with the youngest address.

The storage size is in accordance with the data length in the message

(See item (b) above) and the word/byte units designation in GX

Configurator-SC.

2) For data communication from the Q series C24 to the external device

The transmission data portion is the number of the transmission data designated by the sequence program using the BIDOUT instruction.

The Q series C24 sends the transmission data using the existing codes until the transmission data count is reached in accordance with the word/byte units designation in GX Configurator-SC to the transmission data designation area.

7 - 7 7 - 7

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(d) Sum check code

The sum check code expresses the numeric value for the lower two bytes

(16 bits) of the results (sum) from the addition of the data length and the data portion in the message as binary code data.

When "Sum check" is specified with the transmission setting in GX

Developer, it is necessary to add a sum check code at the end of the message.

1) For data communication from the external device to the Q series C24

The Q series C24 checks and processes the sum check code received.

It cannot be read from the sequence program.

When "No sum check" is specified, once a data portion of message corresponding to the data length is received, the succeeding data received will be ignored up to the control code that follows (See (a)).

The following example shows the contents of a sum check code in the message.

2) For data communication from the Q series C24 to the external device

The sum check code to be transmitted is calculated and added by the Q series C24. When "No sum check" is specified, no sum check code is transmitted.

(Example) The following shows the sum check code when "ABCDEFGHIJ " and the numeric value 100 are sent as data

(when the unit is in bytes).

Arbitrary data

Data

External device side

E

N

Q

L

Data length

(000C

H

)

H

A B C D E F G H I J

L

100

(0064

H

)

H L

Sum check code

H

05

H

0C

H

00

H

41

H

42

H

43

H

44

H

45

H

46

H

47

H

48

H

49

H

4A

H

64

H

00

H

27

H

03

H

Q series C24

0C

H

+ 00

H

+ 41

H

+ 42

H

+ 43

H

+ 44

H

+ 45

H

+ 46

H

+

47

H

+ 48

H

+ 49

H

+ 4A

H

+ 64

H

+ 00

H

Contents of 0327

H

memory b15

0 0 0 0

(H) to

0

Added value = 0327

H

0 1 b8 b7

1 0 0 1

(L) to

0 0 1 b1 b0

1 1

03

H

27

H

(L) (H)

7 - 8 7 - 8

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(e) Error code

The error code indicates the definition of the error during NAK response.

(For more details on the error codes, see Chapter 10.)

1) For data communication from the external device to the Q series C24

For error codes from the external device, transmit the codes specified by the user.

The error codes (0022

H

to 005F

H

) that are not used by the Q series C24 can be used.

The Q series C24 stores the received error codes as a completion status in the control code for the BIDOUT instruction.

They are also stored in the data transmission result storage area in the buffer memory (address: 257

H

).

2) For data communication from the Q series C24 to the external device

The error codes are added by the Q series C24.

When an error code is transmitted, the Q series C24 writes the same error code in the data reception result storage area of the buffer memory

(address: 258

H

).

7 - 9 7 - 9

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

7.1.3 Sequence program for data reception

This section explains the sequence program for data reception.

For details on the BIDIN instruction for data reception, see Chapter 9.

X3 Read request

(CH1)

Create control data from D0

M0 M1

G.BIDIN

Un D0 D10 M0

Processing for normal completion

(stores receive data, etc.)

Q series C24 ready signal

(X1E)

1)

Reception data read request signal

BIDIN instruction

(X3)

BIDIN instruction complete device

BIDIN instruction complete device +1

(Normal completion)

(OFF)

Receive data count storage area

(Buffer memory address: 600

H

)

Receive data storage area

(Buffer memory address: 601

H

to 7FF

H

) m

2)

3)

BIDIN

4) n

Receive data

One scan

Data reception Response transmission

1) Start the local station PLC.

The values specified with GX Developer are stored in the Q series C24.

2) When data is received from the external device, the reception data read request signal turns ON.

3) After the control data for the BIDIN instruction is stored in the device, the sequence program executes the BIDIN instruction and reads the receive data.

4) When the reading of receive data is completed, a response message (ACK message when the operation was completed normally) is sent and the device that has completed the BIDIN instruction turns ON.

7 - 10 7 - 10

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(Program example)

When Q series C24 I/O signals are from X/Y00 to X/Y1F:

Designate the receive channel.

Clear the receive data count storage device to 0.

Designate the allowable receive data count.

With the normal completion, the receive data within the allowable receive data count

(user designated) is read from the receive data storage area in the buffer memory.

• After the BIDIN instruction is executed,

• the user designated read completion signal (M0) comes on for 1 scan.

The reading of received data is performed by the PLC CPU.

Q series C24

Address

258

H

Buffer memory

Data reception result storage area

D 0

D 1

D 2

D 3

For normal completion

Interface number

Reception result

Receive data count

Allowable receive data count

(1)

(0)

(n)

(10)

D10 to

D m

Receive data

Receive data to

600

H

601

H to

7FF

H

Receive data count storage area

Receive data storage area

When the received data count is larger than the allowable received data count, only the data up to the allowable received data count will be stored and the excess data will be discarded.

7 - 11 7 - 11

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

POINT

(1) Receive data can also be read using interrupt programs.

For more details on reading receive data with interrupt programs, see Chapter

4 of the User's Manual (Application).

Note that if the reading of data received from the same interface is to be performed, it is not possible to combine the reading of data received by the main program and reading of data received by the interrupt program.

Accordingly, use one or the other of the above programs to read the data received.

(2) The SPBUSY instruction is used to read the execution status when using a dedicated instruction. (See Chapter 9.)

(3) More than one BIDIN instruction cannot be executed simultaneously.

Execute the next BIDIN instruction only after the execution of the first BIDIN instruction is completed.

(4) If the communication data count is set in byte units and the receive data count is an odd byte when requesting the reading of receive data to the PLC CPU,

00

H

is stored in the higher byte of the final data storage position in the receive data storage area.

7 - 12 7 - 12

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

7.1.4 How to detect reception errors

This section explains how to detect errors that may occur when receiving data from the external device.

The following items are considered as the primary causes of errors that may occur during data reception.

Cause of reception error

A transmission error occurred because of noise.

A timeout occurred for the no-reception monitoring time (timer 0).

A timeout occurred for the transmission monitoring time (timer 2)

Data that could not be converted with the ASCII-BIN conversion was detected.

Received the data length that was too long to store in the receiving area.

Simultaneous transmissions occurred.

Reference section

User's Manual

(Application)

Section 6.1

Section 6.2

Chapter 13

Section 7.1.2

Section 7.3

(1) Confirmation using the sequence program

(a) Detecting the occurrence of a reception error

1) The single (XE/XF) is on when the ERR LED is on.

2) The receive error code is confirmed and read in the buffer memory data reception result storage area (address: 258

H

/268

H

).

For details on how to check the error code contents and corrective actions, see Chapter 10.

(b) How to turn off the ERR LED and clear the error code (see Section 10.1.2)

1) To turn off only the ERR LED, write a "1" to the LED OFF request area

(addresses 0

H

/1

H

) in the buffer memory.

2) To turn off the ERR LED and clear the error code, turn ON the ERR LED

OFF request output signal (YE/YF).

(Example) To perform the ERR LED OFF and the error code clear on the CH1 side

Read command

7 - 13 7 - 13

7 DATA COMMUNICATIONS USING BIDIRECTIONAL PROTOCOL

MELSEC-Q

(2) Confirmation using the module and GX Configurator-SC

1) Confirmation using the display LED

When the Q series C24 detects an error, including a transmission error, the

ERR LED lights up. (See Chapter 10.)

2) Confirmation using GX Configurator-SC

• The monitor function is used to check for errors. (See Sections 8.6.3 and

8.6.6.)

• The ERR LED is turned off with the ERR LED OFF function. (See Section

8.6.10.)

3) Confirming the error code

Use one of the following to confirm the error code.

• GX Configurator-SC monitor function (See Section 8.6.6.)

• GX Developer buffer memory monitor function (monitors addresses

258

H

/268

H

)

(3) Handling of receive data when a reception error occurs

1) All of the receive data for which an error was detected is ignored and an response message indicating an abnormal completion (NAK message) is sent to the external device.

When an error is detected during message reception, the Q series C24 does not issue a reception data read request to the PLC CPU.

2) The receive area in the buffer memory will contain the data received normally just prior to the error occurrence. (Data will not be rewritten.)

7.1.5 Receive data clear

Data communications using the bidirectional protocol must be performed after a response message is received in reply to the preceding data transmission.

If the Q series C24 detects an error while receiving data, it sends an NAK message

(response message) to the external device after the data reception completion and ignores the data being received when the error was detected.

Therefore, the receive data does not have to be cleared.

7 - 14 7 - 14

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

Download PDF

advertisement

Table of contents