Modbus

<< Click to Display Table of Contents >>

 

Modbus

Use PLC or Block Tags to manipulate Modbus registers, using the parameters on the next table.

Parameters for Modbus Tags

Device

Identifier of the Modbus slave

Item

Modbus parameters, in the format XXmmmmm[.tt][.ss]

N1/B1

Not used

N2/B2

Not used

N3/B3

Not used

N4/B4

Not used

 

In the Item parameter of these Tags, inform the parameters of the Modbus Tag using the format XXmmmmm[.tt][.ss], as described next:

The XX parameter represents the type of Modbus command (FCode):

cl: Coils | Bits | Read 01 / Write 15

di: Discrete Input (read only) | Bits | Read 02

hr: Holding Register | Words | Read 03 / Write 16

ir: Input Register (read only) | Words | Read 04

scl: Single Coil | Bit | Read 01 / Write 05

shr: Single Holding Register | Word | Read 03 / Write 06

The mmmmm parameter indicates the Modbus memory address

The .tt parameter is optional and indicates the type of interpretation applied to data. If not informed, data is interpreted as a Word data type:

.u16: Word

.i16: 16-bit integer

.u32: DWord

.i32: 32-bit integer

.f: 32-bit floating point

.d: 64-bit double

The .ss parameter is optional and indicate the byte order applied to data. If not informed, the byte order applied is .msb (by7 by6 by5 by4 by3 by2 by1 by0):

.sb: Swap Byte (by6 by7 by4 by5 by2 by3 by0 by1)

.sw: Swap Word (by5 by4 by7 by6 by1 by0 by3 by2)

.swsb: Swap Word + Byte (by4 by5 by6 by7 by0 by1 by2 by3)

.sdw: Swap DWord (by3 by2 by1 by0 by7 by6 by5 by4)

.sdwsb: Swap DWord + Byte (by2 by3 by0 by1 by6 by7 by4 by5)

.sdwsw: Swap DWord + Word (by1 by0 by3 by2 by5 by4 by7 by6)

.sdwswsb: Swap DWord + Word + Byte (by0 by1 by2 by3 by4 by5 by6 by7)

 

Usage Examples

Reading a Holding Register at memory position 120:

Tag.ParamDevice: 1 (one)

Tag.ParamItem: hr120

 

Reading a Holding Register at memory position 120 with inverted bytes (Swap Byte):

Tag.ParamDevice: 1 (one)

Tag.ParamItem: hr120.sb

 

Reading a Holding Register at memory position 120 with inverted bytes (Swap Byte) and a signed integer (int16):

Tag.ParamDevice: 1 (one)

Tag.ParamItem: hr120.i16.sb

Was this page useful?