Realize the parallel temperature measure method of Modbus transmission
Technical field
The present invention relates to a kind of thermometry, particularly relate to a kind of parallel temperature measure method realizing Modbus transmission.
Background technology
Optimum degree is reached in order to make the performance of process automation system, must by arranging multiple temperature measuring point, strict control is carried out to the temperature spot in process, traditional method for supervising adopts instrument monitoring parameter, so, whole process automation system just needs to install a large amount of thermometric instruments, also needs to arrange a large amount of transmission lines simultaneously.If there is a kind of parallel temperature measure method based on Modbus transmission, when being applied to temperature instrumentation, the temperature instrumentation replacing multiple stage traditional with a temperature instrumentation can be made, so just greatly can reduce instrument cost, reduce routing complexity, simplify the operation, raise the efficiency.
The communication realizing between multiple equipment to allow a twisted-pair feeder, Modbus bus protocol is suggested, and thereafter, Modbus becomes automatic industrial field de facto standards soon.Modbus bus protocol is a kind of wide-open agreement, does not receive any patent fee, has countless instrument and meter for automation manufacturer to adopt this kind of agreement.Modbus bus protocol is the communication protocol of message transmission on the application layer, being a request/response protocol, specifying that it is served by providing different function codes.Modbus bus protocol is a kind of general purpose language be applied on electronic controller, and by this agreement, controller can communicate each other, and the opertaing device that different vendor produces can be linked to be industrial network, carries out Centralized Monitoring.Modbus bus protocol physical interface can be RS232, RS485, RS422, RJ45, communication media adopts Shielded Twisted Pair or optical fiber, when adopting RS232 interface twisted-pair feeder to make medium, the ultimate range of tape relay device is not 15m, maximum node number 247, communication speed 19.2Kbps.
Summary of the invention
The invention discloses a kind of parallel temperature measure method realizing Modbus transmission, during in order to realize transmitting based on Modbus, can parallel temperature measure, thus realize the temperature that multiple measuring control point measured by an industrial instrument simultaneously.
Above-mentioned purpose of the present invention is achieved through the following technical solutions:
A kind of parallel temperature measure method realizing Modbus transmission, wherein, message is interrupted in the Modbus request that Modbus main website receives DCS dispersion treatment unit, message is transferred to microprocessor by Modbus communication unit by Modbus main website, microprocessor carries out Measurement channel selection accordingly and carries out AD sampling and processing, according to Modbus response frame, the message processed is required that sending Modbus communication unit to sends by microprocessor, microprocessor exits interruption.
Realize the parallel temperature measure method of Modbus transmission as above, wherein, microprocessor carries out instrument initialization before running.
Realize the parallel temperature measure method of Modbus transmission as above, wherein, instrument initialization comprises: to microprocessor system initialization, read band EEPROM (Electrically Erasable Programmable Read Only Memo) data, communication module initialization, Measurement channel initialization.
Realize the parallel temperature measure method of Modbus transmission as above, wherein, microprocessor carries out the measurement of multiple point for measuring temperature temperature value, and by the data encapsulation of acquisition in a data response frame.
Realize as above Modbus transmission parallel temperature measure method, wherein, temperature value data through analog to digital conversion laggard enter microprocessor.
Realize the parallel temperature measure method of Modbus transmission as above, wherein, the Temperature numerical of the multiple point for measuring temperature of microprocessor Real-time Obtaining also stores in a register, after microprocessor receives parallel temperature claim frame, the Temperature numerical in multiple register is packaged into a Modbus Frame and transmits.
In sum, owing to have employed technique scheme, when the present invention realizes transmitting based on Modbus, can parallel temperature measure, make to use an industrial instrument of the method can record the temperature of multiple measuring control point simultaneously, thus reduce instrument cost further, reduce routing complexity, simplify the operation, raise the efficiency, the present invention can realize: transmitter can substitute eight traditional independent mount type instrument, temperature survey is carried out to multiple spot adjacent to each other, reduce the complicacy that measurement point is set, only need to carry out configuration to the parameter of a multi-passage temp. variable transporting device, support Modbus agreement bottom transmission mode---RS485 and UDP, can carry out temperature acquisition and request-reply in real time, reduce costs, the electronic unit total price of a multi-passage temp. variable transporting device than eight traditional single point temperature transmitters with low 5-6 doubly.
Accompanying drawing explanation
Fig. 1 is the parallel temperature measure ratio juris figure that the present invention realizes Modbus transmission;
Fig. 2 is the process flow diagram that the present invention realizes the parallel temperature measure method of Modbus transmission.
Embodiment
Below in conjunction with drawings and Examples, the present invention is described further:
Fig. 1 is the parallel temperature measure ratio juris figure that the present invention realizes Modbus transmission, Fig. 2 is the process flow diagram that the present invention realizes the parallel temperature measure method of Modbus transmission, refer to Fig. 1, Fig. 2, a kind of parallel temperature measure method realizing Modbus transmission, wherein, message is interrupted in the Modbus request that Modbus main website receives DCS dispersion treatment unit, message is transferred to microprocessor by Modbus communication unit by Modbus main website, microprocessor carries out Measurement channel selection accordingly and carries out AD sampling and processing, according to Modbus response frame, the message processed is required that sending Modbus communication unit to sends by microprocessor, microprocessor exits interruption.
In one embodiment of the invention: Modbus asks interruption 7; be responsible for transmitter when receiving Modbus request command frame; enter serial ports receive interruption in real time; CRC check is carried out according to Modbus protocol requirement while keeping the scene intact, if correctly, then income received frame address check; if correct; then carry out function code checking, when this function code is the real-time temperature values needing to read some passage, carry out next step action.During frame check, as long as there is check errors, then directly return errored response frame.
Modbus communication unit 3 of the present invention comprises RS485 interface and UDP interface.All power needed for temperature transmitter provides by supply module 4.Tributary address selects 5 to comprise toggle switch and the prompting of corresponding pilot lamp.
Microprocessor of the present invention carries out instrument initialization before running.
Instrument initialization of the present invention comprises: to microprocessor system initialization, read band EEPROM (Electrically Erasable Programmable Read Only Memo) data, communication module initialization, Measurement channel initialization.
Microprocessor of the present invention carries out the measurement of multiple point for measuring temperature temperature value, and by the data encapsulation of acquisition in a data response frame.
Temperature value data of the present invention through analog to digital conversion laggard enter microprocessor.
The Temperature numerical of the multiple point for measuring temperature of microprocessor Real-time Obtaining of the present invention also stores in a register, after microprocessor receives parallel temperature claim frame, the Temperature numerical in multiple register is packaged into a Modbus Frame and transmits.
In concrete use procedure of the present invention, the present invention can be applied in industrial control network: this industrial control network supports Modbus protocol transmission, wherein Modbus main website, there is the translation function of Digital and analog amount, the data that dispersion treatment unit in DCS system issues by it pass to self CPU by transceiver and CPLD programmable logic device (PLD), the data assemblies issued is become data block by CPU, dual port RAM is passed to by interrupt mode, its communication module is configured to main website automatically according to being forwarded the configuration data block come by dual port RAM, module is according to protocol configuration main website and carry out periodic data exchange with the communication module being configured to main website, realize data acquisition and sending function, after Modbus main website completes initializes itself, wait for the message that dispersion treatment unit sends over, the address sending corresponding transmitter to is judged according to message content, and wait for the reply message of this address transmitter, dispersion treatment unit is returned to as response after receiving message.After supporting that the temperature transmitter of parallel temperature measure have received Modbus claim frame based on Mobus transmission, first message is delivered in input buffer register, after message receives, microprocessor carries out packet parsing, then starts and selects Measurement channel and carry out AD sampling and processing.After having processed, by message according to the requirement of Modbus response frame, pass to Modbus communication unit 3 and carry out sending and exiting interruption, one time temperature acquisition terminates.