Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
45
Добавлен:
11.10.2020
Размер:
3.2 Mб
Скачать

MODBUS Functions 151

Description of the MODBUS Functions

6.3.4 Function code FC4 (Read input registers)

This function reads contents of input registers from the slave device in word format.

Request

The request specifies a reference number (start register) and the word count (register quantity) of the registers to be read. The reference number of the request is zero based, therefore, the first register starts at address 0.

Example: Read registers 0 and 1:

Byte

Field name

Example

Byte 0, 1

Transaction identifier

0x0000

Byte 2, 3

protocol identifier

0x0000

Byte 4, 5

length field

0x0006

Byte 6

unit identifier

0x01 not used

Byte 7

MODBUS function code

0x04

Byte 8, 9

reference number

0x0000

Byte 10, 11

Word count

0x0002

Response

The register data of the response is packed as 2 bytes per register. The first byte has the higher value bits, the second the lower values.

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x04

Byte 8

Byte count

0x04

Byte 9, 10

Value Register 0

0x1234

Byte 11, 12

Value Register 1

0x2345

The contents of register 0 are shown by the value 0x1234 and the contents of register 1 is 0x2345.

Exception

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x84

Byte 8

Exception code

0x01 or 0x02

WAGO-I/O-SYSTEM 750 ETHERNET TCP/IP

152 MODBUS Functions

Description of the MODBUS Functions

6.3.5 Function Code FC5 (Write Coil)

This function writes a single output bit to the slave device.

Request

The request specifies the reference number (output address) of output bit to be written. The reference number of the request is zero based; therefore, the first coil starts at address 0.

Example: Turn ON the second output bit (address 1):

 

Byte

Field name

Example

 

Byte 0, 1

Transaction identifier

0x0000

 

Byte 2, 3

protocol identifier

0x0000

 

Byte 4, 5

length field

0x0006

 

Byte 6

unit identifier

0x01 not used

 

Byte 7

MODBUS function code

0x05

 

Byte 8, 9

reference number

0x0001

 

Byte 10

ON/OFF

0xFF

 

Byte 11

 

0x00

Response

 

 

 

Byte

Field name

Example

 

.....

 

 

 

Byte 7

MODBUS function code

0x05

 

Byte 8, 9

Reference number

0x0001

 

Byte 10

Value

0xFF

 

Byte 11

 

0x00

Exception

 

 

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x85

Byte 8

Exception code

0x01, 0x02 or 0x03

WAGO-I/O-SYSTEM 750 ETHERNET TCP/IP

MODBUS Functions 153

Description of the MODBUS Functions

6.3.6 Function Code FC6 (Write single register)

This function writes the value of one single output register to a slave device in word format.

Request

The request specifies the reference number (register address) of the first output word to be written. The value to be written is specified in the “Register Value” field. The reference number of the request is zero based; therefore, the first register starts at address 0.

Example: Write a value of 0x1234 to the second output register.

Byte

Field name

Example

Byte 0, 1

Transaction identifier

0x0000

Byte 2, 3

protocol identifier

0x0000

Byte 4, 5

length field

0x0006

Byte 6

Unit identifier

0x01 not used

Byte 7

MODBUS function code

0x06

Byte 8, 9

reference number

0x0001

Byte 10, 11

Register Value

0x1234

Response

The reply is an echo of the inquiry.

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x06

Byte 8, 9

Reference number

0x0001

Byte 10, 11

Register Value

0x1234

Exception

 

 

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x85

Byte 8

Exception code

0x01 or 0x02

WAGO-I/O-SYSTEM 750 ETHERNET TCP/IP

154 MODBUS Functions

Description of the MODBUS Functions

6.3.7 Function Code FC11 (Get comm event counter)

This function returns a status word and an event counter from the slave device’s communication event counter. By reading the current count before and after a series of messages, a master can determine whether the messages were handled normally by the slave.

Following each successful new processing, the counter counts up. This counting process is not performed in the case of exception replies, poll commands or counter inquiries.

Request

Byte

Field name

Example

Byte 0, 1

Transaction identifier

0x0000

Byte 2, 3

protocol identifier

0x0000

Byte 4, 5

length field

0x0002

Byte 6

unit identifier

0x01 not used

Byte 7

MODBUS function code

0x0B

Response

The reply contains a 2-byte status word and a 2-byte event counter. The status word only contains zeroes.

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x0B

Byte 8, 9

Status

0x0000

Byte 10, 11

Event Count

0x0003

The event counter shows that 3 (0x0003) events were counted.

Exception

Byte

Field name

Example

.....

 

 

Byte 7

MODBUS function code

0x85

Byte 8

Exception code

0x01 or 0x02

WAGO-I/O-SYSTEM 750 ETHERNET TCP/IP

Соседние файлы в папке 750-841