Modbus protocol display |modbus Communication display |modbus display electronic screen function code sharing

Source: Internet
Author: User

Modbus protocol display |modbus Communication display |modbus display electronic screen function code sharing, mainly used to achieve "preset multiple register function code."

The "0X1F" function code of the MODBUS-RTU protocol is photographed as follows:

An example of the "0X1F" function code for the MODBUS-RTU protocol is as follows:

Example: The request is placed in 2 registers from the Modbus display device 17, the starting register is 40002, the preset value is 0AH and 02H.
QUERY
Field Name
Slave Address
Function
Starting Address Hi
Starting Address Lo
No. of registers Hi
No. of registers Lo
Byte Count
Data Hi
Data Lo
Data Hi
Data Lo
Error Check (LRC or CRC)


Example
(Hex)
11
10
00
01
00
02
04
00
0A
01
02

Preset multiple Registers

void Isr_usart1 (void) {
unsigned int crc=0,i=0;
unsigned char x=0;
Nx,ny correction
if (nx==0) {
x=4;
}else{
X=nx-1;
}
Industrial Modbus Display parameter processing
if (rxdata[0]==ip_num[x][0]&&rxdata[1]==0x03) {
CRC=CRC16 (rxdata,5);
if (crc== (rxdata[6]<<8) +rxdata[5]) {
Verify that the correct receive processing data enters
modbus_num[x][0]= (rxdata[3]<<8) +rxdata[4];
}
}
Modbus Communication Time parameter processing
if (rxdata[0]==0x55&&rxdata[1]==0x03) {
CRC=CRC16 (rxdata,19);
if (crc== (rxdata[20]<<8) +rxdata[19]) {
Verify that the correct receive processing data enters
for (i=0;i<8;i++) {
Time_buf[i]=rxdata[4+2*i];
}
for (i=0;i<7;i++) {
time_num[0+2*i]=time_buf[i]>>4;
time_num[1+2*i]=time_buf[i]&0x0f;
}
}
}
}

---------by the vertical display photoelectric technology to provide, please do not reprint, thank you!

Director of vertical display photoelectric project: Xu Fei
English name: Parserval
Contact Tel: 13927460644
0796-7203100
qq:13654984
Email:[email protected]
[email protected]
website: http://www.ledsup.com
Zip: 518038

Modbus protocol Display |modbus Communication display |modbus display electronic screen function code to realize the codeshare

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.