CN106569440A - Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol - Google Patents

Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol Download PDF

Info

Publication number
CN106569440A
CN106569440A CN201610937257.9A CN201610937257A CN106569440A CN 106569440 A CN106569440 A CN 106569440A CN 201610937257 A CN201610937257 A CN 201610937257A CN 106569440 A CN106569440 A CN 106569440A
Authority
CN
China
Prior art keywords
data
microprocessor
modbus
touch screen
rtu protocol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610937257.9A
Other languages
Chinese (zh)
Inventor
马新甜
傅冠生
何啸月
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ningbo CRRC New Energy Technology Co Ltd
Original Assignee
Ningbo CRRC New Energy Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ningbo CRRC New Energy Technology Co Ltd filed Critical Ningbo CRRC New Energy Technology Co Ltd
Priority to CN201610937257.9A priority Critical patent/CN106569440A/en
Publication of CN106569440A publication Critical patent/CN106569440A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/042Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
    • G05B19/0423Input/output
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/25Pc structure of the system
    • G05B2219/25257Microcontroller

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Selective Calling Equipment (AREA)

Abstract

The invention discloses a method for achieving communication between a microprocessor and a touch screen based on an MODBUS-RTU protocol, and the method comprises the steps that S1, the microprocessor collects the data detected by a sensor system; S2, the microprocessor transmits the data to the touch screen through the MODBUS-RTU protocol. The method enables the communication between the processor and the touch screen to be smoother in a transmission mode through a specific MODBUS-RTU transmission data frame. Meanwhile, because all data received by the microprocessor is converted into a transmission format needed by the MODBUS-RTU protocol, the method is enabled to be better in expansibility and transportability.

Description

A kind of method communicated based on MODBUS-RTU protocol realizations microprocessor and touch screen
Technical field
The present invention relates to communication technique field, more particularly to one kind is based on MODBUS-RTU protocol realizations microprocessor and touches The method for touching screen communication
Background technology
At present, various industrial field bus are widely used in the control of all types of industries field process, improve industry The real-time and reliability of data collecting system.
MODBUS-RTU agreements so that it is simple, efficiently, open, free, reliability and the advantages of grow with each passing hour, in work Factory's automatic field, is widely used by each producer, shows its powerful vitality and vigor.
Simultaneously in order to realize touch screen to governor circuit monitor in real time, display and same management, need to give birth to different vendor The data acquisition equipment of product interconnects to form network, realizes to data monitoring, the networking for showing.
The Chinese patent of Publication No. CN104656604A, open one kind " realizes man-machine friendship using MODBUS communication protocols Mutual safety and stability control device of electric network and its method ", it is set to man machine interface to support serial ports MODBUS communication protocols Touch screen, data transfer adopts serial link MODBUS transmission means, but it arranges multiple Interruptions and causes transmission data Slowly, it is unfavorable for that data are smoothly transmitted.
The content of the invention
The technical problem to be solved is, for the above-mentioned deficiency of prior art, proposes a kind of data transfer Fast, be capable of achieving different vendor data acquisition equipment formed network and with preferable autgmentability and portability based on The method that MODBUS-RTU protocol realizations microprocessor is communicated with touch screen.
It is to propose that one kind is micro- based on MODBUS-RTU protocol realizations that the present invention solves the technical scheme of its technical problem employing The method that processor is communicated with touch screen, it includes step:
S1:The data that microprocessor collecting sensor system detectio is arrived;
S2:Microprocessor sends data to touch screen by MODBUS-RTU agreements.
Further, the sensing system includes:Voltage sensor, current sensor, temperature sensor and/or smog Sensor.
Further, the microprocessor by the Data Format Transform for receiving be a frame data by address field, function code, The data form that data segment and check code are constituted.
Further, step S2 also comprises the steps:
S21:Initialization;
S22:Detect whether that serial ports interrupts, if removing to interrupt without if flag bit is received, data are terminated if having and is sent out Send;
S23:The data that process is received, judge whether station number is 1, and whether data length goes beyond the scope;If station number is not 1 Or data length goes beyond the scope, empty the data that receive and point out mistake;If station number is 1 and data length is without departing from scope, Then continue to until receiving enough frame data;
S24:Whether the CRC check position that detection sends is equal to the CRC check position for calculating, if being not equal to, empties what is received Data simultaneously point out mistake;
S25:It is judged as reading holding register order or preset single register command;
S26:Send data;
S27:Detect whether to distribute, if not distributing, return to step S22.
Further, the analogue signal for detecting is converted to digital signal by the sensing system by AD conversion system And be stored in microprocessor.
Further, the microprocessor is STM32F103 microprocessors.
Further, the address field is 1 byte, and function code is 1 byte, and data segment is 0-252 byte, is verified Code is 1 byte.
Further, the transmission time of at least 3.5 bytes is spaced between every frame data;It is described per in frame data each Transmission time of the interval less than 1.5 bytes between byte.
The present invention is by specific MODBUS-RTU transmitting data frames and transmission means so that microprocessor and touch screen it Between communication it is more smoothly;Simultaneously because all of data that microprocessor is received are converted into the biography needed for MODBUS-RTU Transport format so that the autgmentability and portability of the application is more preferably.
Description of the drawings
Fig. 1 is the population structure block diagram of the application;
Fig. 2 is the application data transfer flow process figure.
Specific embodiment
The following is the specific embodiment of the present invention and combine accompanying drawing, technical scheme is further described, But the present invention is not limited to these embodiments.
Refer to Fig. 1, the system master communicated based on MODBUS-RTU protocol realizations microprocessor and touch screen of the application To be made up of microprocessor, the sensing system being made up of multiple sensors and the part of touch screen three.
Temperature sensor, Smoke Sensor, voltage sensor, current sensor are included in sensing system, certainly also Other sensors can be set.Those sensors are mainly used in the parameters in collection site environment.Those sensor acquisition To current signal digital signal is converted into after AD conversion and is stored in the inside FLASH of microprocessor.
Microprocessor can also receive other data, such as in the application actual application, energy-storage system passes through CAN The data sent, and the IO make-and-break signals of each relay.
By the data is activation for receiving to touch screen by two-way communication between microprocessor and touch screen, microprocessor, Also the control instruction sent by touch screen can be received.
In the present embodiment, MODBUS-RTU agreement two-way communications are passed through between microprocessor and touch screen.
In the present embodiment, microprocessor preferably adopts STM32F103 microprocessors.
Before a communication, need that the data of microprocessor internal are converted to the data form needed for MODBUS-RTU.This In embodiment, every frame data are converted to the data form being made up of address field, function code, data segment and check code.Wherein It is 1 byte for 0-252 byte, check code for 1 byte, data segment that location domain is 1 byte, function code.
For the ease of subsequent data transmission, prevent occurring error of transmission between Frame and Frame, also limit in the application Determine between Frame and Frame, and the transmission time between each byte in Frame inside.In the present embodiment, Frame with Transmission time between Frame should be at least above the transmission time of 3.5 bytes, and the transmission time between each byte of frame in should Less than the transmission time of 1.5 bytes.The restriction of above-mentioned transmission time, be applicant combine sensor type and MODBUS-RTU protocol transmissions characteristic is through a large amount of creative works gained.Can be caused by the restriction of above-mentioned transmission time be System can have preferable transfer rate can prevent data from misdeeming again, data-crosstalk the problems such as generation.
The means of communication between microprocessor and touch screen are concrete as shown in Figure 2:
It comprises the steps:
Initialization;
Using MODBUS_init () initialization function, to systematic parameter initialization, communication serial port initialization and the string that communicates Mouth interrupts initialization.
Detect whether that serial ports interrupts, if removing to interrupt without if flag bit is received, data is activation is terminated if having;
Above-mentioned functions are realized by USART2_IRQHandler () function, anti-locking system is constantly in during interruption.
The data that process is received, judge whether station number is 1, and whether data length goes beyond the scope;If station number for 1 or Data length goes beyond the scope, and empties the data that receive and points out mistake;If station number is 1 and data length is without departing from scope, after Continued access is received until receiving enough frame data;
The data received by MODBUS-RCV () function start to process.During receiving data, can also pass through upper Frame and Frame are stated, the transmission time of byte comes whether continuous verification data transmission is interrupted and data between Frame Integrity.
After receiving enough frame data, detect whether the CRC check position in the Frame for receiving is equal to the CRC check for calculating Position, if being not equal to, empties the data that receive and points out mistake;
It is judged as reading holding register order or preset single register command according to Frame;
Send data;
Detect whether to distribute, if not distributing, return detects whether that serial ports interrupts.
In the present embodiment, communicated by MODBUS-RTU protocol realizations microprocessor and man machine interface, ensureing program work( Can realize simultaneously, taking into full account the autgmentability and transplantability of program.Suitably modified just can making with above-mentioned is done in other designs Method.Solve development amount in prior art big, the complicated problem of code maintenance.
Specific embodiment described herein is only explanation for example spiritual to the present invention.Technology neck belonging to of the invention The technical staff in domain can be made various modifications to described specific embodiment or supplement or replaced using similar mode Generation, but without departing from the spiritual of the present invention or surmount scope defined in appended claims.

Claims (8)

1. it is a kind of based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, it is characterised in that:Including step Suddenly:
S1:The data that microprocessor collecting sensor system detectio is arrived;
S2:Microprocessor sends data to touch screen by MODBUS-RTU agreements.
2. it is according to claim 1 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, its It is characterised by:The sensing system includes:Voltage sensor, current sensor, temperature sensor and/or Smoke Sensor.
3. it is according to claim 1 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, its It is characterised by:The microprocessor by the Data Format Transform for receiving be a frame data by address field, function code, data segment and The data form that check code is constituted.
4. according to claim 1 or 3 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, It is characterized in that:Step S2 also comprises the steps:
S21:Initialization;
S22:Detect whether that serial ports interrupts, if removing to interrupt without if flag bit is received, data is activation is terminated if having;
S23:The data that process is received, judge whether station number is 1, and whether data length goes beyond the scope;If station number for 1 or Data length goes beyond the scope, and empties the data that receive and points out mistake;If station number is 1 and data length is without departing from scope, after Continued access is received until receiving enough frame data;
S24:Whether the CRC check position that detection sends is equal to the CRC check position for calculating, if being not equal to, empties the data for receiving And point out mistake;
S25:It is judged as reading holding register order or preset single register command;
S26:Send data;
S27:Detect whether to distribute, if not distributing, return to step S22.
5. it is according to claim 1 and 2 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, It is characterized in that:The analogue signal for detecting is converted to digital signal and is stored by the sensing system by AD conversion system In microprocessor.
6. it is according to claim 1 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, its It is characterised by:The microprocessor is STM32F103 microprocessors.
7. it is according to claim 3 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, its It is characterised by:The address field is 1 byte, and function code is 1 byte, and data segment is 0-252 byte, and check code is 1 Byte.
8. it is according to claim 7 based on MODBUS-RTU protocol realizations microprocessor and touch screen communication method, its It is characterised by:The transmission time of at least 3.5 bytes is spaced between every frame data;Between described each byte interior per frame data Transmission time of the interval less than 1.5 bytes.
CN201610937257.9A 2016-10-25 2016-10-25 Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol Pending CN106569440A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610937257.9A CN106569440A (en) 2016-10-25 2016-10-25 Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610937257.9A CN106569440A (en) 2016-10-25 2016-10-25 Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol

Publications (1)

Publication Number Publication Date
CN106569440A true CN106569440A (en) 2017-04-19

Family

ID=58534666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610937257.9A Pending CN106569440A (en) 2016-10-25 2016-10-25 Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol

Country Status (1)

Country Link
CN (1) CN106569440A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628536A (en) * 2018-05-28 2018-10-09 湖北工业大学 A kind of STM32 and serial ports touch screen communication module of man-machine interface interaction
CN110677398A (en) * 2019-09-20 2020-01-10 成都艾克赛特信息科技有限公司 AC and GC integrated communication protocol, communication system and method for full liquid crystal instrument
CN112822083A (en) * 2021-01-25 2021-05-18 华电通用轻型燃机设备有限公司 MODBUS application layer-oriented data verification method and system
CN114603547A (en) * 2020-12-07 2022-06-10 山东新松工业软件研究院股份有限公司 Communication method of cleaning robot controller and teaching box

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2219089A1 (en) * 2009-02-02 2010-08-18 Siemens Aktiengesellschaft Method for operating an automation system, corresponding computer program and automation device in an automation system
CN102447602A (en) * 2011-12-26 2012-05-09 苏州工业园区广福汽保机电设备有限公司 System for quickly exchanging Modbus and Canbus communication data
CN103235542A (en) * 2013-02-01 2013-08-07 哈尔滨理工大学 Field programmable gate array (FPGA)-based multipath standard signal acquisition and transmission device
CN203965910U (en) * 2014-06-30 2014-11-26 北京龙鼎源科技有限公司 Long-distance transport pipes valve chamber monitoring box
CN104486181A (en) * 2014-11-13 2015-04-01 华晨汽车集团控股有限公司 Modbus protocol-based slave unit
CN104656604A (en) * 2014-09-23 2015-05-27 国网电力科学研究院 Power grid security and stability control device and method for realizing man-machine interaction by utilizing MODBUS communication protocol
CN105278437A (en) * 2014-06-16 2016-01-27 上海宝信软件股份有限公司 Modbus RTU/ASCII protocol realization method based on S7-300/400 PLC
CN105629934A (en) * 2016-01-26 2016-06-01 安徽理工大学 Coal washery multi-stage band conveying multi-touch screen multi-CAN board parallel connection long-distance centralized control device
CN205540716U (en) * 2016-02-03 2016-08-31 北京长城华瑞科技有限公司 System communication module

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2219089A1 (en) * 2009-02-02 2010-08-18 Siemens Aktiengesellschaft Method for operating an automation system, corresponding computer program and automation device in an automation system
CN102447602A (en) * 2011-12-26 2012-05-09 苏州工业园区广福汽保机电设备有限公司 System for quickly exchanging Modbus and Canbus communication data
CN103235542A (en) * 2013-02-01 2013-08-07 哈尔滨理工大学 Field programmable gate array (FPGA)-based multipath standard signal acquisition and transmission device
CN105278437A (en) * 2014-06-16 2016-01-27 上海宝信软件股份有限公司 Modbus RTU/ASCII protocol realization method based on S7-300/400 PLC
CN203965910U (en) * 2014-06-30 2014-11-26 北京龙鼎源科技有限公司 Long-distance transport pipes valve chamber monitoring box
CN104656604A (en) * 2014-09-23 2015-05-27 国网电力科学研究院 Power grid security and stability control device and method for realizing man-machine interaction by utilizing MODBUS communication protocol
CN104486181A (en) * 2014-11-13 2015-04-01 华晨汽车集团控股有限公司 Modbus protocol-based slave unit
CN105629934A (en) * 2016-01-26 2016-06-01 安徽理工大学 Coal washery multi-stage band conveying multi-touch screen multi-CAN board parallel connection long-distance centralized control device
CN205540716U (en) * 2016-02-03 2016-08-31 北京长城华瑞科技有限公司 System communication module

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628536A (en) * 2018-05-28 2018-10-09 湖北工业大学 A kind of STM32 and serial ports touch screen communication module of man-machine interface interaction
CN110677398A (en) * 2019-09-20 2020-01-10 成都艾克赛特信息科技有限公司 AC and GC integrated communication protocol, communication system and method for full liquid crystal instrument
CN114603547A (en) * 2020-12-07 2022-06-10 山东新松工业软件研究院股份有限公司 Communication method of cleaning robot controller and teaching box
CN112822083A (en) * 2021-01-25 2021-05-18 华电通用轻型燃机设备有限公司 MODBUS application layer-oriented data verification method and system

Similar Documents

Publication Publication Date Title
CN106569440A (en) Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol
CN109510759B (en) System and method for realizing rapid universal multi-protocol gateway
CN104199298A (en) Controller area network (CAN) bus Baud rate self-adapting method
CN101404556A (en) One-wire bus communication method
CN103888320A (en) Switch device and method for measuring transmission delay through FPGA
CN107483372B (en) Data transmission method and system based on industrial Internet of Things
CN204613720U (en) A kind of coal preparation plant PLC centralized control system based on wireless telecommunications
CN103023715A (en) Fault monitoring method based on RS485 bus communication link
CN104796464A (en) Multi-protocol conversion warning condition information remote transmission system and method based on MODBUS
CN104052579A (en) Automatic MODBUS-RTU communication baud rate matching method
CN108645450A (en) A kind of smart city environment friendly system and its working method
CN106656960A (en) Hilscher-based credible data acquisition system and method
CN105551222A (en) Embedded bridge health monitoring system
CN105243039A (en) Serial port communication system and method
CN201516981U (en) Monitoring substation device of rubber belt conveyor
CN204789798U (en) Distribution lines running state monitoring device and monitoring system
CN112533207A (en) Data verification method, device and system of wireless sensor
CN104486181A (en) Modbus protocol-based slave unit
CN104656604B (en) A kind of utilization MODBUS communication protocols realize the safety and stability control device of electric network and its method of man-machine interaction
CN114785659A (en) Instruction configuration method and device, electronic equipment and computer-readable storage medium
CN103941700B (en) A kind of automation process safety monitoring system based on Modbus agreement
JP2014096698A (en) Communication device
CN204465598U (en) A kind of multiprotocol conversion alert Information Remote Transmission System based on MODBUS
CN114363347A (en) Self-adaptive industrial equipment data acquisition method and system
CN102411352A (en) Wireless analog control method, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20170419

RJ01 Rejection of invention patent application after publication