Read digital inputs (function 2), Read analog in/outputs (function 3) – BECKHOFF BC7300 User Manual

Page 28

Advertising
background image

MODBUS

28

BC7300

Byte Name

Example

RTU

ASCII

Start frame

„:“

0x3A

Slave address 11

0x0B

„0B“

0x30, 0x42

Function code 1

0x01

„01“

0x30, 0x31

Byte Count 2

0x02

„02“

0x30, 0x32

Data bits 0..7 4

0x04

„04“

0x30, 0x34

Data bits 8..15 0

0x00

„00“

0x30, 0x30

Error Check

LRC / CRC

0x23
0x3D

„EE“

0x45, 0x45


End of frame

t1-t2-t3

CRLF

0xD, 0xA

Read Digital Inputs (Function 2)

READ INPUT STATUS

Function 2 can be used to read the digital input data.
In this example the first 10 digital inputs of slave number 11 are read. The
start address is zero. If an offset is to be entered, this is done in the "Start
address" field.


Query

Byte Name

Example

RTU

ASCII

Start frame

„:“

0x3A

Slave address 11

0x0B

„0B“

0x30, 0x42

Function code 2

0x02

„02“

0x30, 0x32

Start address high 0

0x00

„00“

0x30, 0x30

Start address low 0

0x00

„00“

0x30, 0x30

Count high 0

0x00

„00“

0x30, 0x30

Count low 10

0x0A

„10“

0x31, 0x30

Error Check

LRC / CRC

0xF8
0xA7

„E3“

0x45, 0x33


End of frame

t1-t2-t3

CRLF

0xD, 0xA


Response

The Bus Terminal Controller answers with byte count 2, i.e. 2 bytes of data
are returned. The query was for 10 bits, and these are now distributed over
2 bytes. The first bit in the input process image of the BC7300 is set, and
the Bus Coupler returns a "1" in the first data byte.

Byte Name

Example

RTU

ASCII

Start frame

„:“

0x3A

Slave address 11

0x0B

„0B“

0x30, 0x42

Function code 2

0x02

„02“

0x30, 0x32

Byte Count 2

0x02

„02“

0x30, 0x32

Data 0..7 1

0x01

„01“

0x30, 0x31

Data 8..15 0

0x00

„00“

0x30, 0x30

Error Check

LRC / CRC

0x20
0x29

„F0“

0x46, 0x30


End of frame

t1-t2-t3

CRLF

0xD, 0xA

Read Analog In/Outputs (Function 3)

1

READ

HOLDING

REGISTERS

Function 3 can be used to read the input and output words and the
registers.

In this example the first two analog outputs of slave number 11 are read.
The analog outputs begin at offset 0x800 (hex). The length indicates the
number of channels to be read.

1

From Firmware B4 reading with function 3 is allowed.

Advertising