Professional,Creditable,Successful
Modbus Setting Guide for T5L Screen
Secondary development platform: T5L OS Builder;
This guide is based on the example of DGUS Modbus RTU master/slave interface, serial port: UART4; Please
update the T5L OS core to V21 or above, code file can be downloaded at www.dwinhmi.com/cn.
1. Modbus Parameter Setting
Users can define the Modbus running parameters in the 22.bin profile at the position from 0x1C000 to 0x1FFFF
and the total storage of this range is 16KB; Users can also directly access the variables space from 0xE000 to
0xFFFF (8KW storage) through T5L OS to define.
Variables
Definition Description
Position
0xE000 Modbus run on mark Input 0x5AA5 to run Modbus communication
0xE001 Master/slave mark 0x0000: Modbus master, other: Modbus slave
0xE002 Baud rate setting Unit: Kbps, one fixed decimal, E.g.115200bps=0x480
0x0000=8N1(No parity),
0x0001=8E1(Even parity),
Serial mode 0x0002(Odd parity),
0xE003
0x0003=8N2(no parity, two stop bits),
Other=8N1
0xE004 Slave device position Device position of slave mode, default: 0x005A
Modbus output serial Range: 0x03-0x07, default: 0x04=UART4(this function cannot
0xE005: H
port be set, read only)
0xE005: L OS version Read only
0xE006-0xE007 Preserved
0x00(0xE008H): 0x5A=Valid, other=invalid
0x01(0xE008L): Modbus device position to write and read
0x02(0xE009H): Modbus command for write/read
0x03(0xE009L): Data length, 0x00 represent this line invalid
0x04(0xE00A): Instruction running time, ms, max: 9999ms),
as for read instruction this represents slave device response
The first line of Modbus time.
0xE008-0xE00F 0x06(0xE00B): Instruction running modes
instruction(16bytes)
0x0000:Run this instruction among all the pages;
0x0001: Run this instruction at specified page;
0x0002: Run this instruction only at variable buffer whose
variable position’s low byte is 0x5A, after running it will
remove the contents on this position.
0x08(0xE00C): 01mode=Page_ID, 02 mode=VP variable
position.
www.dwin.com.cn 1 Hotline: 86-400-018-9008
Professional,Creditable,Successful
0x0A(0xE00D): The starting position for writing and reading
data at variable memory space (0x0000-0xDFFF, 0x0000-
0x1000 is system variable interface)
0x0C(0xE00E): The starting position of Modbus device for data
writing and reading
0x0E(0xE00F): Communication bus status response
0x0000=failed, 0x00FF=succeeded; this content needs to be
removed after getting read.
Table 1 Definition of Each Position
2. Modbus Master Interface
Modbus
Function Data Length Modbus Starting Position
Instruction
0x01 Read inputting coil status The number of coil/8 Starting coil position
Read inputting bit variables The number of bit
0x02 Starting input position
status variable/8
0x03 Read staying registers data The number register*2 Starting position of staying register
Starting position of inputting
0x04 Read inputting registers data The number register*2
register
0x05 Place a single coil 0x02 Coil position
0x06 Reserve a single register 0x02 Register position
0x07 Read abnormal status 0x01 Random
0x0F Place multiple coils The number of coil Starting position of coils
0x10 Reserve multiple registers The number of register*2 Starting position of registers
Table 2 Modbus Master Instruction Code Table
www.dwin.com.cn 2 Hotline: 86-400-018-9008
Professional,Creditable,Successful
Remarks:
1.The variable data range that master device can read or write is 0x0000 to 0xDFFF, the program will
put the highest bit of the function code to 1 and return to the master device, representing a
communication error.
2.When the serial baud rate configuration parameter(0xE002) is 0x0000, UART4 baud rate will reset
to default (115200bps).
3.Write/read instructions responding time is 1-9999ms, default: 60ms; IF this position is 0x0000, the
running time will be default.
4.When using 0x0002 instruction running mode, the system will conduct the command when the VP
low byte is 0x5A and remove the contents of VP afterward, the instruction running timer will be reset.
5.180 Bytes data can be written or read at a single instruction line, if the data length is over this limit,
the system will regard this line as an invalid one and move on to the next.
6.The variable position(0xE00D) shall not be over 0xDFFF and its following data shall not exceed this
limit, otherwise, the instruction line will be regarded as invalid.
7.Bit variables of Modbus are defined based on LSB, while T5L platform based on MSB.
www.dwin.com.cn 3 Hotline: 86-400-018-9008
Professional,Creditable,Successful
3. Settings Guide of Modbus Slave Interface
Device position is defaulted as 0x005A
Modbus
Function Data Length Variable Memory Space Range
Instruction
Read variable space Character(1 char.=2 bytes) 0x0000-0xDFFF
0x03 Tx: 5A 03 14 00 00 02 CC D0 (read 4 bytes variable data from 0x1400)
Rx: 5A 03 04 00 01 00 02 C0 F7
Write data at single VP Character(1 char.=2 bytes) 0x0000-0xDFFF
Tx: 5A 06 14 00 00 01 40 D1(write 0x0001 at 0x1400)
0x06
Rx: 5A 06 14 00 00 01 40 D1
Write data to variable
Character(1 char.=2 bytes) 0x0000-0xDFFF
space
0x10 Tx: 5A 10 14 00 00 02 04 00 01 00 02 F8 8B(write 4 bytes variable data from 0x1400)
Rx: 5A 10 14 00 00 02 49 13
Table 3 Modbus Slave Instruction
Remarks:
(1) Master device can only read or write variable data at the range from 0x0000 to 0xDFFF,
otherwise, the system will send the function code, whose highest bit will be 1, back to the master
device, representing communication failure.
(2) Data length for reading or writing is 90 characters/180 bytes at most, otherwise, communication
fails.
www.dwin.com.cn 4 Hotline: 86-400-018-9008
Professional,Creditable,Successful
4. 22.Bin Profile Initialization
(1) Users should set initialization via 22.bin in the system configuration profile as shown below.
(2) Instruction running time parameter configuration (default: 60ms) is based on the baud rate and
the length of instructions. 20ms is suggested when baud rate is default (115200 bps).
(3) Pic 1 is a reference of Modbus master parameter configuration; the first line (16 bytes) is the
master interface parameter; user instructions start from 0x1C010-0x1FFFF; max: 1023 lines. Pic 2
is a reference of Modbus slave parameter configuration.
Pic 1:
Pic 2:
www.dwin.com.cn 5 Hotline: 86-400-018-9008