Материал: m012900e

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

292 • Common MODBUS functions

Function code FC11 (Get comm event counter)

6.2.10Function code FC11 (Get comm event counter)

This function returns a status word and an event counter from the slave’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

0x10

 

 

 

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

 

 

 

Modular I/O System

ETHERNET TCP/IP

Common MODBUS functions • 293

Function code FC23 (Read/Write multiple registers)

6.2.11Function code FC23 (Read/Write multiple registers)

This function reads the register values and writes the values into a number of output words (also ”Output Register“).

Request

The first register is addressed with 0.

The inquiry message determines the registers to be read and set. The data is sent as 2 bytes per register.

Example: The data in register 3 is set to value 0x0123, and values 0x0004 and 0x5678 are read out of the two registers 0 and 1.

Byte

Byte 0

Byte 1-2

Byte 3-4

Byte 5-6

Byte 7-8

Byte 9

Byte 10-(B+9)

Field name

MODBUS function code

reference number for read

Word count for read (1-125)

reference number for write

Word count for read (1-100)

Byte Count

(B = 2 x word count for read)

Register Values

Example

0x17

0x0000

0x0002

0x0003

0x0001

0x02

0x0123

Response

 

 

 

 

 

Byte

Field name

Example

Byte 0

MODBUS function code

0x17

 

 

 

Byte 1

Byte Count

0x04

 

(B = 2 x word count for read)

 

 

 

 

Byte 2-(B+1)

Register Values

0x0004

 

 

0x5678

 

 

 

Exception

 

 

Byte

Field name

Example

Byte 0

MODBUS function code

0x97

 

 

 

Byte 1

Exception code

0x01 or 0x02

 

 

 

Note

Should register areas for read and write overlap, the results are undefined.

Modular I/O System

ETHERNET TCP/IP

294 • Common MODBUS functions Watchdog (Fieldbus failure)

6.2.12Watchdog (Fieldbus failure)

The watchdog serves for monitoring the data transfer between the master controls and the coupler/controller. For this the master cyclically actuates a time function (Time-out) in the coupler/controller.

In the case of fault free communication, the watchdog timer does not reach its end value. After each successful data transfer, the timer is reset.

If this time has elapsed a fieldbus failure has occurred.

In this case, the fieldbus coupler/controller answers all following MODBUS TCP/IP requests with the exception code 0x0004 (Slave Device Failure).

In the coupler/controller special registers are present for the selection and status inquiry of the watchdog by the master (Register addresses 0x1000 to 0x1008).

After switching on the supply voltage the watchdog is not yet activated. First step is to set the time-out value (Register 0x1000). The watchdog can be activated by writing a function code in the mask register (0x1001), which is unequal 0. A second activation possibility is to write a value in the toggle register (0x1003) deviating from 0.

Reading the minimum trigger time (Register 0x1004) reveals whether the watchdog fault reaction was activated. If this time value is 0, a fieldbus failure is assumed. The watchdog can be restarted in accordance with the previously mentioned two possibilities or using the register 0x1007.

If the watchdog is started it can only be stopped by the user for safety reasons via a certain path (register 0x1005 or 0x1008).

Modular I/O System

ETHERNET TCP/IP

Common MODBUS functions • 295

Watchdog (Fieldbus failure)

Watchdog Register:

The watchdog registers can be addressed in the same way as the described in MODBUS function codes (read and write). Specify the respective register address in place of the address of a module channel.

Register address 0x1000

Designation

Access

Default

Description

Watchdog time, WS_TIME

read / write

0x0000

This register saves the value for time exceeded (Time-out). To be able to start, the watchdog default value must have a value which is not equal to zero. The time is set as a multiple of 100 ms, 0x0009 means a time out time of 0.9 s. This value cannot be changed when the watchdog is running.

Register address 0x1001

Designation

Watchdog function coding mask, function code 1...16, WDFCM_1_16

Access

Read / write

Default

0x0000

Description

Using this mask the function codes can be set to trigger the watchdog function.

 

The function code can be selected via a ‘1’ to

 

( = 2(Function code-1)+ ....)

 

Bit 1001.0 corresponds to function code1,

 

Bit 1001.1 corresponds to function code2...

 

The watchdog function is started if a value is not equal to zero. If codes from

 

non-supported functions are entered in the mask the watchdog will not start.

 

An existing fault is reset and writing into the process illustration is possible.

 

Also here changes cannot be made while the watchdog is running.

Register address 0x1002

Designation

Watchdog function coding mask, function code 17...32, WD_FCM_17_32

Access

Read / write

Default

0x0000

Description

Same function as above, however, with the function codes 17 to 32. These

 

codes are not supported, for this reason the default value of this register should

 

not be changed. It is not possible to modify this value while the watchdog is

 

running.

 

 

Register address 0x1003

Designation

Access

Default

Description

Watchdog trigger, WD_TRIGGER

Read / write

0x0000

This register is used for an alternative trigger method. The watchdog is triggered by writing different values in this register. Values following each other must differ in size. Writing of a value not equal to zero starts the watchdog. In case of a watchdog fault this register is reset to zero.

Modular I/O System

ETHERNET TCP/IP

296 • Common MODBUS functions Watchdog (Fieldbus failure)

Register address 0x1004

Designation

Access

Default

Description

Minimum current trigger time, WD_AC_TRG_TIME

read / write

0xFFFF

Using this value the current watchdog status can be read. If the watchdog is triggered, the saved value is compared with the current value. If the current value is smaller than the saved value, this is replaced by the current value. The unit is 100 ms/digit. The saved value is changed by writing new values, which does not affect the watchdog. 0x000 is not permissible.

Register address 0x1005

Designation

Access

Default

Description

Stop watchdog, WD_AC_STOP_MASK

read / write

0x0000

The watchdog is stopped if here the value 0xAAAA is written first, followed by 0x5555. The watchdog fault reaction is blocked. A watchdog fault is reset and writing on the process data is possible again.

Register address 0x1006

Designation

While watchdog is running, WD_RUNNING

Access

Read

Default

0x0000

Description

Current watchdog status.

 

at 0x0: Watchdog not active,

 

at 0x1: Watchdog active.

 

Register address 0x1007

Designation

Restart watchdog, WD_RESTART

Access

read / write

Default

0x0001

Description

Writing 0x1 into the register starts the watchdog again.

 

If the watchdog was stopped before the overrun, it is not restarted.

 

Register address 0x1008

Designation

Simply stop watchdog WD_AC_STOP_SIMPLE

Access

read / write

Default

0x0000

Description

The watchdog is stopped by writing the value 0x0AA55 or 0X55AA, if it was

 

already active. The watchdog fault reaction is deactivated. An existing watch-

 

dog fault is reset and it is possible to write in the watchdog register again.

In all registers the length is 1, i.e. with each access only one word can be written or read.

Modular I/O System

ETHERNET TCP/IP