Disclosure of Invention
In order to adapt to the actual demands in the field of power communication, the invention overcomes the defects existing in the prior art, and solves the technical problems that: a collector and a power communication method and system of Modbus protocol equipment based on the collector are provided, so that communication between remote communication and the Internet of things equipment of the Modbus protocol is realized.
In order to solve the technical problems, the invention adopts the following technical scheme: the power communication method of the Modbus protocol equipment based on the collector is realized based on the collector and comprises the following steps:
s1, expanding 645 protocol data, and containing serial port baud rate and check bit information of Modbus equipment in a data field of 645 protocol messages through protocol specification;
S2, a collector is utilized to receive 645 protocol messages sent by an upper terminal, then the 645 protocol messages are analyzed through the collector, serial port configuration information, register address information and Modbus messages in the 645 protocol messages are extracted, and serial port baud rate and check bits are configured according to the serial port configuration information;
s3, after the serial port configuration is completed, the collector converts the message protocol type into Modbus, and then the Modbus message is sent to Modbus protocol equipment;
And S4, after receiving the data returned by the Modbus protocol equipment, the collector converts the protocol type into 645 type, and organizes 645 messages and sends the 645 messages back to the upper terminal.
The collector comprises a message data analysis module, a carrier communication module, a wireless communication module and a 485 communication module.
The extended 645 protocol data format is as follows:
In the extended 645 protocol, the format of the uplink and downlink frame data fields is as follows:
| Data content | Data format | Number of bytes |
| Data identification | BIN | 4 |
| Register address | BIN | 4 |
| Serial port control | BIN | 2 |
| Modbus message | BIN | L |
。
In the uplink frame and downlink frame data domains, the data bit format of the serial port control data is as follows:
in the step S3, when the Modbus message is sent to the Modbus protocol device, a step of setting a timer is further included.
In the step S4, if no data is acquired after the timeout, the acquirer stops receiving the Modbus message and starts the next cycle.
In the step S2, after receiving the 645 protocol packet sent by the upper terminal, the collector determines whether the packet is related to the Modbus, if so, analyzes the packet, and if not, completes the processing according to the normal service flow.
In addition, the invention also provides a collector for executing the method.
In addition, the invention also provides a Modbus protocol device communication system based on the collector, which comprises Modbus protocol devices, an upper terminal and the collector, wherein 645 protocol data of the upper terminal is expanded protocol data.
Compared with the prior art, the invention has the following beneficial effects:
1. The invention provides a collector and a power communication method and a power communication system of Modbus protocol equipment based on the collector, wherein a complete Modbus protocol message is contained in a data field of the 645 message by expanding 645 protocol, so that an upper terminal such as a concentrator and an intelligent power distribution terminal only needs to organize 645 message according to protocol specification, the message is transmitted to the collector through a power line, and after the collector receives the message, the collector analyzes according to protocol specification to extract the Modbus message, and the collector forwards the Modbus message to 485 and waits for a reply because the collector communicates with the Modbus equipment through 485; after receiving the reply, the received Modbus message is packed into 645 message according to the protocol regulation, and then is sent to the power line to be transmitted to the upper terminal.
2. Because the baud rate and check bits of communication of different Modbus protocol devices are different, most Modbus devices support baud rate configuration, some of the Modbus devices also support communication check bit configuration, and some of the Modbus devices are fixed and dead and cannot be changed. In view of diversity of Modbus equipment and lack of unified standards, the invention adopts a mode that communication parameters are read from top to bottom and the message is provided with configuration parameters, and the baud rate and check bit information are added into the data field of 645 protocol messages, so that the universality of the protocol is improved, and the invention can be applied to various Modbus protocol equipment. When Modbus protocol equipment is replaced, only the upper terminal is required to modify the issued message, and the collector does not need to change the program, so that the program is more stable and efficient.
Description of the preferred embodiments
In order to make the technical solution and advantages of the present invention more apparent, a technical solution of the present invention will be clearly and completely described below with reference to specific embodiments and drawings, it being apparent that the described embodiments are some but not all embodiments of the present invention; all other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
The embodiment of the invention provides a power communication method of Modbus protocol equipment based on a collector, which is characterized by comprising the following steps of.
S1, expanding 645 protocol data, and including serial port baud rate and check bit information of Modbus equipment in a data field of 645 protocol messages according to protocol rules.
Specifically, in this embodiment, the protocol content is extended to 645 as follows: firstly, adapting the RS485 communication rate to various rates; secondly, the check bit is adapted to odd check, even check and no check; stop bits, data bits are adaptable; specifically, the extended 645 protocol data format is shown in table 1.
Table 1 expanded 645 protocol data format
Control code: 11H, 91H;
data field length: 4-byte data identification+4-byte register address+2-byte serial port control information+Modbus message length L.
Specifically, in this embodiment, the downlink frame data field format is shown in table 2.
Table 2 downstream frame data field format
| Data content | Data format | Number of bytes |
| Data identification | BIN | 4 |
| Register address | BIN | 4 |
| Serial port control | BIN | 2 |
| Modbus message | BIN | L |
Wherein, include four parts:
1. And (3) data identification: 0x04B0FFFF;
2. Register address: and 4 bytes, which is used for storing the register address information of the modbus message sent at the time, because the reply frame of the modbus protocol does not have a register address.
3. Serial port control: 4 bits-baud rate, 2 bits-check, 1 bit-stop bit, 2 bits-data bit, 2 bits-stream control, the remainder reserved. The serial port control data format is shown in table 3.
Table 3 serial port control data format
Baud rate :{300bps(0),600bps(1),1200bps(2),2400bps(3),4800bps(4),7200bps(5),9600bps(6),19200bps(7),38400bps(8),57600bps(9),115200bps(10), adaptation (11),
Check bit: { no parity (0), odd parity (1), even parity (2) },
Data bits: {5 (0),6 (1),7 (2),8 (3) },
Stop bit: {1 (0),2 (1) },
Flow control: { none (0), hardware (1), software (2) }
4. Modbus message: complete Modbus message information
Specifically, in this embodiment, the format of the uplink frame data field is shown in table 4.
Table 2 uplink frame data field format
Wherein, include four parts:
1. And (3) data identification: 0x04B0FFFF;
2. Register address: and 4 bytes, which is used for storing the register address information of the modbus message sent at the time, because the reply frame of the modbus protocol does not have a register address.
3. Serial port control: 4 bits-baud rate, 2 bits-check, 1 bit-stop bit, 2 bits-data bit, 2 bits-stream control, the remainder reserved. The serial port control data format is the same as the downstream frame as shown in table 3.
4. Modbus message: complete Modbus message information.
S2, a collector is utilized to receive 645 protocol messages sent by an upper terminal, then the 645 protocol messages are analyzed through the collector, serial port configuration information, register address information and Modbus messages in the 645 protocol messages are extracted, and serial port baud rate and check bits are configured according to the serial port configuration information.
Specifically, in step S2, after receiving the 645 protocol packet sent by the upper terminal, the collector determines whether the packet is related to Modbus, if so, analyzes the packet, and if not, completes processing according to the normal service flow. The upper terminal can be a power distribution terminal or a concentrator, the collector has a power line carrier communication function, and after the concentrator or the power distribution terminal adds the address file of the collector equipment, the collector can communicate with the upper terminal according to a power line broadband carrier communication protocol. Specifically, the collector is a type II collector.
And S3, after the serial port configuration is completed, the collector converts the message protocol type into Modbus, and then the Modbus message is sent to the device adopting the Modbus protocol.
In the step S3, when the Modbus message is sent to the Modbus protocol device, a step of setting a timer is further included. The timer is set so as to facilitate the timeout processing and the serial port waiting receiving processing.
And S4, after receiving the return data sent by the Modbus protocol equipment, the collector converts the protocol type into 645 type, and organizes 645 messages to be sent back to the upper terminal.
In the step S4, if the return data is not received over time, the collector stops receiving the Modbus message and starts the next cycle.
In this embodiment, the collector checks each received 645 message conforming to the protocol format, monitors whether the data identifier of the 645 message is related to the Modbus protocol, i.e. determines whether the data identifier is 0x04b0ffff. If not, processing according to the normal business flow of the national network secondary mining program; if the communication protocol type is 0x04b0ffff, firstly extracting 645 information about serial port configuration in a message data field, carrying out serial port configuration according to a protocol, then extracting a complete Modbus protocol message in the data field, forwarding the complete Modbus protocol message to a 485 line, changing the communication protocol type into a Modbus protocol type by a program, waiting for a Modbus device to reply, and ending if data conforming to a Modbus protocol format is not received after timeout; if a message conforming to the protocol format is received, the protocol type is changed to be DLT645-07 protocol type, the message is organized to be 645 for replying, and the flow is ended.
Specifically, as shown in fig. 2, in this embodiment, the collector includes a message data parsing module, a carrier communication module, a wireless communication module, and a 485 communication module. The collector can receive the power line message through the carrier interface circuit, and the power line message is a message sent by the upper terminal. Specifically, after the upper terminal, for example, the concentrator or the power distribution terminal adds the device address file of the collector, the collector can communicate with the upper terminal according to the wideband carrier communication protocol of the voltage power line, and receive 645 protocol messages. In addition, the collector can also carry out wireless communication through the wireless module, so that the success rate and the reliability of communication are greatly ensured and improved, after 645 protocol messages conforming to a protocol format are received, a message data analysis module of the collector extracts related serial port configuration information, register address information and Modbus messages and records the related serial port configuration information, serial port baud rate and check bits are configured according to the serial port configuration information, after serial port configuration is completed, the Modbus messages are sent to Internet of things equipment of the Modbus protocol through 485 lines and a timer is started so as to carry out timeout processing and serial port waiting receiving processing, after the Modbus messages conforming to the protocol format are received by the serial ports, frame analysis and check are carried out according to the Modbus protocol format, after the Modbus messages conforming to the protocol format are received, the Modbus messages are organized into 645 protocol messages according to the protocol format and are sent to a power line, and therefore the whole communication flow is completed. Specifically, in this embodiment, the harvester model may be DCZL-PLCM 1667 type harvester.
Example two
An embodiment II of the present invention provides a collector for executing the power communication method described in the embodiment I, and in particular, an application program for implementing the power communication method described in the embodiment I is integrated therein.
Specifically, in this embodiment, a message data analysis module, a carrier communication module, a wireless communication module, and a 485 communication module are disposed in the collector. The message data analysis module can analyze Modbus messages and serial port configuration information contained in 645 protocol messages sent by the upper terminal, and then forwards the Modbus messages to related Modbus protocol devices through the 485 communication module and the wireless communication module according to the serial port configuration information.
Example III
As shown in fig. 3, a third embodiment of the present invention provides a communication system of a Modbus protocol device based on a collector, which includes a Modbus protocol device, an upper terminal, and a collector described in the second embodiment.
In summary, the invention is based on the collector including the carrier communication module and the 485 communication module, and extends the power line carrier communication protocol 645 protocol, so as to provide a communication external interface for the traditional internet of things device, thereby realizing the object connection function of the traditional Modbus protocol device. In view of diversity of Modbus devices and lack of unified standards, the invention adopts a mode that communication parameters are read from top to bottom and the message is provided with configuration parameters, and the baud rate and check bit information are added into the data field of 645 protocol messages, so that the universality of the program is improved.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.