MODBUS Slave Protocol: Difference between revisions

From Smart LCD
Line 1: Line 1:
Smart LCD MODBUS Salve Product can be accessed by MODBUS Master devices for real-time control and access.
Smart LCD MODBUS Salve Product can be accessed by MODBUS Master devices for real-time control and access.


= VP variable addressed as MODBUS address =
== Basic ==
In SGTools, MENU --> View --> Show Modbus Holding Register Address.
 
=== Modbus Communication ===
The Modbus is a protocol, which is used to communicate between a host and one or multiple slave devices. Over the Modbus the host is able to communicate with up to 254 slaves. It can read or write data areas on these devices. The SMART LCD is operated as such a slave device. There are mainly two modes of communication: The binary RTU Mode and the ASCII Mode. The SMART LCD is operating in RTU Mode. Therefore, we only describe the RTU mode within this document.
 
The host issues a package, which consists of:
 
* An 8 Bit Device Address, to indicate which slave device shall be addressed
* An 8 Bit Function Code, to tell the addressed slave which data area is read or written
* Specific data, like addresses and data values
* A 2-Byte Error Check CRC to determine, whether the previous data are correct
 
{|
! colspan="4" |< - - - - - - - - - - - - - - - - - - - - MODBUS Package - - - - - - - - - - - - - - - - - - - - >
|-
|
Device Address (1byte)
|
Function (1byte)
|
Data (252bytes(max.))
|
Error Check (2bytes)
|-
|
! colspan="2" |< - - - - - - - - - - MODBUS Frame - - - - - - - - - - >
|
|}
When the host receives the previous frame reply from the slave device, the host needs an interval of 5ms before it can continue to send the next frame command. Since the SMART LCD is a Modbus slave device, a device address must be assigned to it. This address will be defined while designing the GUI with TOPWAY’s SGTools.
 
=== Modbus Function Codes ===
{| class="wikitable"
|'''Function Code'''
|'''Function Definition'''
|'''Address Range'''
|'''Object Type'''
|-
|0x03
|Read Multiple  Holding Registers
|0x0000 ~ 0xFFFF
|2 Bytes
|-
|0x06
|Write Single Holding  Register
|0x0000 ~ 0xFFFF
|2 Bytes
|-
|0x10
|Write Multiple Holding  Registers
|0x0000 ~ 0xFFFF
|2 Bytes
|-
|0x11
| colspan="3" |Report Slave ID
|-
|0x14
|Read File Record
| colspan="2" |1 File with 2048 Records of 128 Byte
|}
To access memory locations in the SMART LCD the host has to issue a Read or Write function, which includes a specific address. Each Read or Write function accesses a 2-Byte location within an area of up to 64k words. Since the multiple data areas (N16, N32, N64, etc.) are together larger than 64k Words, the different memory areas are separated into pages, a total of 5 pages. To select a specific page the Modbus Page Map Register must be written with the page number. The Page Map Register is located within the set of Special Function Registers. The Special Function Registers (SFR) are accessible on all pages at the same location. They are placed within the final 4k words of all pages.
 
=== Address Mapping ===
The following table gives an overview over the relationship between Modbus addresses, Modbus Memory Pages and the SMART LCD '''Address space'''
 
 
 
== VP variable addressing ==
In SGTools, MENU --> View --> Show Modbus Holding Register Address


can show up the VPs corresponding MODBUS ADDRESS for the display UI.
can show up the VPs corresponding MODBUS ADDRESS for the display UI.
Line 10: Line 76:
[[File:Show Modbus Holding Register Address 01.png]]  [[File:Show Modbus Holding Register Address 02.png]]
[[File:Show Modbus Holding Register Address 01.png]]  [[File:Show Modbus Holding Register Address 02.png]]


= Preserved MODBUS address for system functions =
= MODBUS address mapping =
{| class="wikitable"
{| class="wikitable"
|'''MODBUS Add'''
!VP type
|'''Register Name'''
!VP address
|'''Descriptions'''
!MODBUS PAGE
!MODBUS Page:Address
!
|-
| rowspan="2" |VP_STR
| rowspan="2" |0x000000
0x000080
 
<nowiki>:</nowiki>
 
0x01DF80
 
| rowspan="2" |0
|
|
|-
|-
|0XFFFF40
|
|Is_Ch_Eng
|reserved
|1=English KB input; 0=Chinese KB input
|-
|-
|0XFFFF41
|VP_REG
|Sys_PIP_State
|*1
|
|
|
|-
|VP_N16
|0x080000...
|4
|0x0000 - 0x7FFF
|
|
|-
|-
|0XFFFF42
|
|Touch_State
|
|0=
|
|0x8000 - 0xEFFF
|
|-
|-
|0xFFFF43
|
|Coord_X[0]
|
|lo byte of Touch coordinate X
|
|0xF000 - 0xFFFF
|
|-
|-
|0xFFFF44
|
|Coord_X[1]
|
|hi byte of Touch coordinate X
|
|
|
|-
|-
|0xFFFF45
|VP_N32
|Coord_Y[0]
|0x020000...
|lo byte of Touch coordinate Y
|1
|1:0x0000....
|
|-
|-
|0xFFFF46
|VP_N64
|Coord_Y[1]
|0x030000...
|hi byte of Touch coordinate Y
|6
|6:0x0000....
|
|-
|-
|0xFFFF47
|VP_G16
|Touch_Key_ID[0]
|0x060000...
|lo byte of Touch Key ID (for HMT150BTA-D only)
|3
|3:0x0000....
|
|-
|-
|0xFFFF48
|VP_BMP
|Touch_Key_ID[1]
|0x040000...
|hi byte of Touch Key ID (for HMT150BTA-D only)
|2
|20x0000...
|
|-
|-
|0xFFFF49
|VP_REG
|Touch_Key_En
|0xFFFF00....
|1=normal operation (power on default); 0=disable touch element function
|
| ---
|
|}
|}
{| class="wikitable"
|VP type
|SMART LCD VP Address
|Modbus PAGE: Address
|-
|VP_STR
|0x000000
0x000080
<nowiki>:</nowiki>
0x01DF80
|0:0x0000
0:0x0040
<nowiki>:</nowiki>
0:0xEFC0
|-
|VP_REG
|Special Function  Registers
|0:0xF000
<nowiki>:</nowiki>
0:0xFFFF
|-
|VP_N32
|0x020000
0x020004
<nowiki>:</nowiki>
0x02FFBC
|1:0x0000
1:0x0002
<nowiki>:</nowiki>
1:0x7FDE
|-
|VP_REG
|0x02FFE0 Timer 0  Count Reg.
0x02FFE4 Timer 1  Count Reg.
<nowiki>:</nowiki>
0x02FFFC Timer 7  Count Reg.
|1:0x7FF0
1:0x7FF2
<nowiki>:</nowiki>
1:0x7FFE
|-
|VP_N64
|0x030000
0x030008
<nowiki>:</nowiki>
0x03DFF8
|6:0x8000
6:0x8004
<nowiki>:</nowiki>
6:0x7FFC
|-
|VP_REG
|Special Function  Registers
|6:0xF000
<nowiki>:</nowiki>
6:0xFFFF
|-
|VP_N16
|0x080000


0x080002


<nowiki>:</nowiki>


变量
0x08FFFE
|4:0x0000


0x01FF00  :   带网口模块的 IP
4:0x0001


0x00FF80 : modbus产品版本号
<nowiki>:</nowiki>


0x1FE00 掩码
4:0x7FFF
|-
|Reserved
|Reserved
|4:0x8000


0x1FD80 网关
<nowiki>:</nowiki>


0x8FFFE : modbus产品串口通信状态
4:0xEFFF
|-
|VP_REG
|Special Function  Registers
|4:0xF000


0x01FF80 : HKT035BTB-1D 温度显示,  如 30.5℃
<nowiki>:</nowiki>


0x08FFF0 :  HKT035BTB-1D 温度值 * 10
4:0xFFFF
|-
|VP_BMP
|0x040000


0xFFFF50 : HKT035BTB-1D 设置温度显示单位   0   摄氏度         1   华氏度
<nowiki>:</nowiki>


0xFFFF51  HKT035BTB-1D 温度偏移 TEMPERATURE_OFT_VP
0x05DFFE
|2:0x0000


0xffff29: 当前背光值
<nowiki>:</nowiki>


0xffff2a HKT035BTB-1D 靠近退出屏保 控制是否使能  0:使能     !0: 禁用
2:0xEFFF
|-
|VP_REG
|Special Function  Registers
|2:0xF000


0xFFFF2B,2C  HKT035BTB-1D  PrePageID[2];
<nowiki>:</nowiki>


0x8FFFC  存储读取距离
2:0xFFFF
|-
|VP_G16
|0x060000


0x01FE80   页面名称
<nowiki>:</nowiki>


0x08FFEE  KNX VP
0x07DFFE
|3:0x0000


HMT101BTA-D
<nowiki>:</nowiki>


0xFFFF50 自动调光等级,
3:0xEFFF
|-
|VP_REG
|Special Function  Registers
|3:0xF000


0xFFFF51,52 AD采样值
<nowiki>:</nowiki>


0xFFFF53 ipmode;
3:0xFFFF
|-
|VP_Flash
 
(Flash Area)
|120K Bytes Flash  memory
 
Non-volatile  memory area,
 
which will remain unchanged even after power down
|5:0x0000


0xFFFF54  netinitstate;
<nowiki>:</nowiki>


多语言  默认语言设置 寄存器0xFFFF2D
5:0xEFFF
|-
|VP_REG
|Special Function  Registers
|5:0xF000


U盘升级功能可选 寄存器0xFFFF2E
<nowiki>:</nowiki>


字符串使用TTF字体,有空格时的对齐方式0xFFFF2F
5:0xFFFF
|}

Revision as of 18:07, 13 June 2025

Smart LCD MODBUS Salve Product can be accessed by MODBUS Master devices for real-time control and access.

Basic

Modbus Communication

The Modbus is a protocol, which is used to communicate between a host and one or multiple slave devices. Over the Modbus the host is able to communicate with up to 254 slaves. It can read or write data areas on these devices. The SMART LCD is operated as such a slave device. There are mainly two modes of communication: The binary RTU Mode and the ASCII Mode. The SMART LCD is operating in RTU Mode. Therefore, we only describe the RTU mode within this document.

The host issues a package, which consists of:

  • An 8 Bit Device Address, to indicate which slave device shall be addressed
  • An 8 Bit Function Code, to tell the addressed slave which data area is read or written
  • Specific data, like addresses and data values
  • A 2-Byte Error Check CRC to determine, whether the previous data are correct
< - - - - - - - - - - - - - - - - - - - - MODBUS Package - - - - - - - - - - - - - - - - - - - - >
Device Address (1byte)
Function (1byte)
Data (252bytes(max.))
Error Check (2bytes)
< - - - - - - - - - - MODBUS Frame - - - - - - - - - - >

When the host receives the previous frame reply from the slave device, the host needs an interval of 5ms before it can continue to send the next frame command. Since the SMART LCD is a Modbus slave device, a device address must be assigned to it. This address will be defined while designing the GUI with TOPWAY’s SGTools.

Modbus Function Codes

Function Code Function Definition Address Range Object Type
0x03 Read Multiple Holding Registers 0x0000 ~ 0xFFFF 2 Bytes
0x06 Write Single Holding Register 0x0000 ~ 0xFFFF 2 Bytes
0x10 Write Multiple Holding Registers 0x0000 ~ 0xFFFF 2 Bytes
0x11 Report Slave ID
0x14 Read File Record 1 File with 2048 Records of 128 Byte

To access memory locations in the SMART LCD the host has to issue a Read or Write function, which includes a specific address. Each Read or Write function accesses a 2-Byte location within an area of up to 64k words. Since the multiple data areas (N16, N32, N64, etc.) are together larger than 64k Words, the different memory areas are separated into pages, a total of 5 pages. To select a specific page the Modbus Page Map Register must be written with the page number. The Page Map Register is located within the set of Special Function Registers. The Special Function Registers (SFR) are accessible on all pages at the same location. They are placed within the final 4k words of all pages.

Address Mapping

The following table gives an overview over the relationship between Modbus addresses, Modbus Memory Pages and the SMART LCD Address space


VP variable addressing

In SGTools, MENU --> View --> Show Modbus Holding Register Address

can show up the VPs corresponding MODBUS ADDRESS for the display UI.

MODBUS HOST can access those VP in MODBUS address accordantly, in real time.

MODBUS address mapping

VP type VP address MODBUS PAGE MODBUS Page:Address
VP_STR 0x000000

0x000080

:

0x01DF80

0
reserved
VP_REG *1
VP_N16 0x080000... 4 0x0000 - 0x7FFF
0x8000 - 0xEFFF
0xF000 - 0xFFFF
VP_N32 0x020000... 1 1:0x0000....
VP_N64 0x030000... 6 6:0x0000....
VP_G16 0x060000... 3 3:0x0000....
VP_BMP 0x040000... 2 20x0000...
VP_REG 0xFFFF00.... ---
VP type SMART LCD VP Address Modbus PAGE: Address
VP_STR 0x000000

0x000080

:

0x01DF80

0:0x0000

0:0x0040

:

0:0xEFC0

VP_REG Special Function Registers 0:0xF000

:

0:0xFFFF

VP_N32 0x020000

0x020004

:

0x02FFBC

1:0x0000

1:0x0002

:

1:0x7FDE

VP_REG 0x02FFE0 Timer 0 Count Reg.

0x02FFE4 Timer 1 Count Reg.

:

0x02FFFC Timer 7 Count Reg.

1:0x7FF0

1:0x7FF2

:

1:0x7FFE

VP_N64 0x030000

0x030008

:

0x03DFF8

6:0x8000

6:0x8004

:

6:0x7FFC

VP_REG Special Function Registers 6:0xF000

:

6:0xFFFF

VP_N16 0x080000

0x080002

:

0x08FFFE

4:0x0000

4:0x0001

:

4:0x7FFF

Reserved Reserved 4:0x8000

:

4:0xEFFF

VP_REG Special Function Registers 4:0xF000

:

4:0xFFFF

VP_BMP 0x040000

:

0x05DFFE

2:0x0000

:

2:0xEFFF

VP_REG Special Function Registers 2:0xF000

:

2:0xFFFF

VP_G16 0x060000

:

0x07DFFE

3:0x0000

:

3:0xEFFF

VP_REG Special Function Registers 3:0xF000

:

3:0xFFFF

VP_Flash

(Flash Area)

120K Bytes Flash memory

Non-volatile memory area,

which will remain unchanged even after power down

5:0x0000

:

5:0xEFFF

VP_REG Special Function Registers 5:0xF000

:

5:0xFFFF