Power distribution system and power distribution system communication method based on Modbus access module
By loading configuration files in the smart distribution terminal, analyzing and using the Modbus access module to communicate with the lower computer, the problem that developers need to develop software and debug in advance in advance is solved, and efficient power distribution system communication and data processing is achieved.
Patent Information
- Application Number
- CN202311518739.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-14
- Publication Date
- 2025-05-16
AI Technical Summary
In the prior art, developers need to develop software for communication equipment that supports Modbus regulations in advance, resulting in a large amount of work and debuggers find problems that cannot be modified in time, which affects the progress of the on-site project.
A distribution system communication method based on the Modbus access module is provided. The configuration file is loaded through the intelligent distribution terminal. The configuration file is configured by the configuration tool to configure the relevant information of the accessed computer, including device attributes, telemetry data model, power data model, remote signal data model and remote control data model. Use the Modbus access module to analyze configuration files, establish communication between the intelligent power distribution terminal and the lower computer, and realize data acquisition and remote control command issuance.
Configuring device information and data models through configuration tools reduces the need for developers to develop sensors for program development, avoids duplicate development, and debuggers can modify the configuration in time to solve problems, improving the progress and efficiency of on-site engineering.
Smart Images

Figure CN120017435A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power electronics, and in particular relates to a power distribution system and a communication method for the power distribution system based on a Modbus access module. Background Art
[0002] Modbus is a serial communication protocol that has become the industry standard for communication protocols in the industrial field and is now a common connection method between industrial electronic equipment.
[0003] At present, most of the sensors, protocol converters, power equipment protection devices and other communication devices on the market support Modbus protocol. At the same time, due to the simple and flexible characteristics of Modbus protocol, the data storage methods of sensors or communication devices (hereinafter referred to as lower computers) designed by various manufacturers vary greatly. This makes it very difficult to parse the upper computer data. Developers can only develop targeted programs for sensors of different manufacturers or even different models in advance, which consumes too much development time. When the on-site debugging personnel find problems later, they cannot modify them in time, which affects the progress of the on-site project. Summary of the invention
[0004] The purpose of the present invention is to provide a power distribution system and a power distribution system communication method based on a Modbus access module, so as to solve the problem that developers need to develop software for communication equipment supporting the Modbus protocol in advance, which causes a large workload, and debuggers cannot modify problems in time when they find them.
[0005] In order to solve the above technical problems, the present invention provides a distribution system communication method based on Modbus access module, realizes Modbus-rtu and Modbus-tcp protocol communication, and the intelligent distribution terminal loads a configuration file, wherein the configuration file is obtained by configuring the relevant information of the lower computer connected to the intelligent distribution terminal for Modbus communication by a configuration tool, and the relevant information includes device attributes, telemetry data model, electricity data model, telesignaling data model and remote control data model, and the device attributes include device information and communication parameters of the connected lower computer; the Modbus access module in the intelligent distribution terminal is used to parse the configuration file, and the communication between the intelligent distribution terminal and the lower computer is established by using the device attribute information obtained by the analysis, and then the telemetry data model, electricity data model, telesignaling data model and remote control data model information are obtained by the analysis, so that the intelligent distribution terminal obtains the telemetry data, electricity data and telesignaling data of the lower computer and the intelligent distribution terminal sends a remote control command to the lower computer.
[0006] The beneficial effects of the above technical scheme are as follows: the present invention finds that the data storage methods of sensors designed by various manufacturers are quite different, which makes it difficult for the upper computer to parse. It is necessary to develop programs for sensors in advance, which takes a long time to develop. When problems are found in the later debugging, they cannot be modified in time. Therefore, the present invention configures the relevant information of the lower computer through the configuration tool to generate a configuration file, and then the intelligent terminal loads the configuration file, parses the file to obtain the corresponding telemetry data model, electricity data model, remote signaling data model and remote control data model information, and accordingly realizes that the intelligent power distribution terminal obtains the telemetry data, electricity data, and remote signaling data of the lower computer, and the intelligent power distribution terminal sends a remote control command to the lower computer. This method configures the device attributes, telemetry data model, electricity data model, remote signaling data model and remote control data model through the configuration tool, so that developers no longer need to develop programs for the connected sensors, avoiding repeated development of programs. Moreover, the later debugging personnel find problems and modify them in time through the configuration tool, and then the intelligent power distribution terminal loads the file analysis again to obtain the telemetry data, electricity data, and remote signaling data of the lower computer, and the intelligent power distribution terminal sends a remote control command to the lower computer.
[0007] Furthermore, the means by which the intelligent distribution terminal in the step obtains the telemetry or electricity data of the lower computer is: to parse each group of data in the telemetry or electricity message, and to compare the function code and register address in each group of data with the entries of the telemetry or electricity data model obtained by the parsing one by one; if a certain entry is consistent with the function code and register address in a certain group of data, it is determined that the group of data corresponds to the entry, and then the corresponding actual telemetry data or electricity data is obtained according to the group of parsed data.
[0008] The beneficial effect of the above technical solution is: the present invention finds that by parsing the function code and register address in each group of data in the telemetry or electricity message and comparing them one by one with the entries in the telemetry data model or electricity data model obtained by parsing the configuration file, the telemetry data model or electricity data model contains the information corresponding to the telemetry or electricity of the lower computer, so the telemetry data or electricity data of the lower computer can be accurately obtained.
[0009] Furthermore, the means by which the intelligent distribution terminal in the step obtains the telesignaling data of the lower computer is: parsing each group of data in the telesignaling message, and comparing the function code and register address in each group of data with the entries of the telesignaling data model obtained by parsing one by one. If a certain entry is consistent with the function code and register address in a certain group of data, it is determined that the group of data corresponds to the entry, and then the corresponding actual telesignaling data is obtained based on the group of parsed data.
[0010] The beneficial effect of the above technical solution is: the present invention finds that by parsing the function code and register address in each group of data in the telesignal message and comparing them one by one with the entries in the telesignal data model obtained by parsing the configuration file, the telesignal data model contains the information corresponding to the telesignal of the lower computer, so the telesignal data of the lower computer can be accurately obtained.
[0011] Furthermore, the means by which the intelligent distribution terminal in the step sends the remote control command to the lower computer is: when the intelligent distribution terminal receives the remote control message that needs to be sent, it checks whether the remote control point number in the remote control message is the remote control point number supported by the intelligent distribution terminal according to the remote control data model obtained by parsing, and if so, adds the remote control message to the corresponding remote control linked list; the remote control messages in the remote control linked list are sent to the lower computer one by one in the following manner: take out a group of remote control messages from the remote control linked list and organize the remote control command message to be sent to the lower computer according to the remote control data model; if the control message replied by the lower computer is received within the required time and the meaning represented by the content of the control message is that the remote control command is successfully executed, then the remote control is successful.
[0012] The beneficial effects of the above technical scheme are as follows: the present invention finds that by checking whether the remote control point number in the remote control message is the remote control point number supported by the intelligent power distribution terminal according to the remote control data model obtained by analysis and adding the message to the linked list, then taking out and organizing the remote control command message according to the remote control data model and sending it to the lower computer, and receiving the control message replied by the lower computer within the required time, the remote control is successful. The remote control message is checked according to the remote control data model, and the remote control command message is organized, thereby ensuring the accuracy of the remote control command, and the remote control message is temporarily stored through the linked list, thereby ensuring that multiple remote control commands can be sent.
[0013] Furthermore, the parsing of data in the step needs to be combined with the parsing type, and the parsing type includes discrete parsing, bitwise parsing and enumeration parsing.
[0014] The beneficial effects of the above technical solution are as follows: the present invention adopts different types of parsing for different types of data, specifically discrete parsing, bitwise parsing and enumeration parsing. This method can parse sensors with different data storage methods, so that developers do not need to develop programs for sensors with different data storage methods, thereby reducing the development time.
[0015] Furthermore, the relevant information in the step also includes a Modbus coefficient, which is represented by a coefficient to be multiplied to obtain the real data; if the parsed data is parsed in a non-floating point type, the actual telemetry data or electricity data is the product of the parsed data and the Modbus coefficient.
[0016] The beneficial effect of the above technical solution is that the present invention solves the inaccuracy of non-floating point data after parsing by configuring Modbus coefficients, so that the acquired telemetry data or electricity data is closer to the actual data.
[0017] Furthermore, the relevant information in the steps also includes time synchronization function information, and the specific time synchronization function information includes a time synchronization control word and a time synchronization cycle; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the time synchronization function with the lower computer according to the time synchronization function information obtained by parsing, and the corresponding means are: when the polling time is reached, the time synchronization control word is cast and the time synchronization cycle is reached, the synchronization message is organized according to the time synchronization function information and sent to the lower computer.
[0018] The beneficial effects of the above technical solution are as follows: the present invention finds that the synchronization between the upper computer and the lower computer is ensured through the time synchronization function, thereby ensuring that the intelligent distribution terminal obtains the synchronized lower computer data and improving the accuracy of the data stored in the intelligent distribution terminal.
[0019] Furthermore, the relevant information in the step also includes read-set value information, and the specific read-set value information is the manufacturer's protocol point table information of the lower computer; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the read-set value function with the lower computer based on the read-set value information obtained by parsing, and the corresponding means are: when the intelligent distribution terminal receives a read-set value message that needs to be sent, it checks whether the set value point number in the read-set value message is a set value point number supported by the intelligent distribution terminal based on the read-set value information obtained by parsing, and if so, adds the read-set value message to the corresponding read-set value linked list; the read-set value messages in the read-set value linked list are sent to the lower computer one by one in the following manner: take out a group of read-set value messages from the read-set value linked list and organize the read-set value command message to be sent to the lower computer based on the set value information; if the read-set value message replied by the lower computer is received within the required time, the read message is parsed to obtain the corresponding read-set value data.
[0020] The beneficial effects of the above technical solution are as follows: by reading set values, the present invention can understand the configuration of equipment in the power distribution system, monitor the power distribution system and understand the status of the system, and further, through the power distribution system communication method based on the Modbus access module, it can avoid repeated software program development for the program of the set value reading function.
[0021] Furthermore, the relevant information in the step also includes write-set value information; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the write-set value function with the lower computer according to the write-set value information obtained by parsing, and the corresponding means are: when the intelligent distribution terminal receives the write-set value message that needs to be sent, it checks whether the set value point number in the write-set value message is the set value point number supported by the intelligent distribution terminal according to the write-set value information obtained by parsing, and if so, adds the write-set value message to the corresponding write-set value linked list; the write-set value messages in the write-set value linked list are sent to the lower computer one by one in the following manner: take out a group of write-set value messages from the fixed value linked list and organize the data part of the message according to the data information in the write-set value message and organize the write-set value command message according to the fixed value information and send it to the lower computer; if the content of the message received from the lower computer within the required time indicates that the write-set value command is successfully executed, then the write-set value command is successfully executed.
[0022] The beneficial effects of the above technical solution are as follows: by writing set values, the present invention can understand the parameters and thresholds in the power distribution system and make changes, thereby improving the flexibility and responsiveness of the system and adjusting the thresholds or parameters according to different situations. Furthermore, the power distribution system communication method based on the Modbus access module can avoid repeated software program development for the program of the set value writing function.
[0023] To solve the above technical problems, the present invention also provides a power distribution system, including an intelligent power distribution terminal and a lower computer, wherein the power distribution system communication method based on the Modbus access module of the above steps is adopted between the intelligent power distribution terminal and the lower computer.
[0024] The beneficial effects of the above technical solution are: this system includes an intelligent distribution terminal and a lower computer, wherein the beneficial effects of the distribution system communication method based on the Modbus access module adopted between the intelligent distribution terminal and the lower computer have been introduced in detail in the distribution system communication method based on the Modbus access module, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a communication block diagram between the upper computer and the lower computer of the present invention;
[0026] Figure 2 It is the program configuration file configuration process of the present invention;
[0027] Figure 3 It is the configuration tool home page of the present invention;
[0028] Figure 4 It is the configuration tool device information description page of the present invention;
[0029] Figure 5 It is the polling message queue and time synchronization function configuration of the present invention;
[0030] Figure 6 are the configuration program operating parameters and sensor settings of the present invention;
[0031] Figure 7 is the telemetry data configuration of the present invention;
[0032] Figure 8 It is the remote signaling data configuration of the present invention;
[0033] Fig. 9 It is the remote control point configuration of the present invention;
[0034] Fig.10 It is the main flow chart of the Modbus access module of the present invention;
[0035] Fig.11 This is the telemetry or electricity message parsing process of the present invention;
[0036] Fig.12 This is the remote signaling message parsing process of the present invention;
[0037] Fig.13 It is the remote control operation process of the present invention;
[0038] Fig.14 This is the fixed value reading operation flow of the present invention;
[0039] Fig.15 This is the writing set value operation flow of the present invention;
[0040] Fig.16 This is the time synchronization operation process of the present invention. DETAILED DESCRIPTION
[0041] The main idea of the present invention is that the intelligent distribution terminal loads a configuration file, wherein the configuration file is obtained by configuring the configuration tool with the relevant information of the lower computer connected to the intelligent distribution terminal for Modbus communication, and the relevant information includes device attributes, telemetry data model, electricity data model, telesignaling data model and remote control data model, and the device attributes include device information and communication parameters of the connected lower computer; the Modbus access module in the intelligent distribution terminal is used to parse the configuration file, and the device attribute information obtained by the analysis is used to realize the communication between the intelligent distribution terminal and the lower computer, and then the telemetry data model, electricity data model, telesignaling data model and remote control data model information are obtained by the analysis, so as to realize the intelligent distribution terminal obtaining the telemetry data, telesignaling data and electricity data of the lower computer and the intelligent distribution terminal sending remote control commands to the lower computer.
[0042] The present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0043] An embodiment of a power distribution system communication method based on Modbus access module:
[0044] like Figure 1 As shown, the upper computer (i.e., intelligent terminal) can read the real-time data such as telesignaling, telemetering, and electricity consumption in the lower computer to the upper computer, and at the same time realize the control operation, fixed value reading and writing, clock reading and clock synchronization functions of the lower computer.
[0045] 1) The upper computer can access multiple lower computers at the same time and communicate with lower computer devices at different addresses by polling.
[0046] 2) Through the retransmission mechanism, the communication status between the upper computer and the lower computer n is determined (if the number of retransmissions exceeds the limit, it is considered that the communication with the lower computer n has failed, n = 1, 2, 3...).
[0047] 3) The program first caches the received message from the lower computer into a larger array (such as 1024 bytes, the length should be at least 3 times the maximum length of the Modbus single-frame message (256 bytes)), and defines pointer 1 to record the write position of the new message (loop overwrite). Define pointer 2 to record the read position and find the message header byte by byte. Subsequent bytes are determined by the Modbus protocol to determine whether the message is correct or complete. Pointer 2 always lags behind or is synchronized with pointer 1 to ensure that no complete message is lost.
[0048] 4) Access to telesignaling data is achieved through function codes 01 or 02; function codes 01 and 02 are read coil status and input status respectively (the usage is the same in terms of protocol), one address occupies one bit, that is, one byte contains 8 address data, which is generally used to save telesignaling data (status 0 or 1).
[0049] 5) The reading and access of telesignaling, telemetering, electricity (or telepulse) and fixed value data are realized through the 03 or 04 function code; the 03 and 04 function codes are read holding register and input register respectively (the usage is the same in terms of the protocol), one address contains two bytes, which are generally used to save telemetering and electricity data (some manufacturers also use it to save telesignaling data), and the telemetering and electricity data are parsed in the same way.
[0050] The point table provided by the sensor manufacturer usually contains coefficients. Two bytes of data multiplied by the coefficients are the resulting telemetry data. However, some longer data uses multiple registers to represent a number, usually no more than 4 registers, so the telemetry parsing type is up to 8 bytes.
[0051] Some manufacturers use two registers to describe an int (four bytes), float (four bytes), double (eight bytes), long long (eight bytes) type variable data, such as float type: the four-byte data in the message is stored in the memory corresponding to the four-byte float variable position, then the float variable data read out is the telemetry data, and no coefficient is required.
[0052] Some manufacturers also use 03 or 04 function codes to save telemetering data, so that a register can save 16 telemetering data parsing (i.e. two parsing methods: bit parsing and enumeration parsing. When parsing by bit, one register address can save 16 telemetering data, and the telemetering status is obtained according to the register address and data offset (0-15) in the configuration file; when parsing by enumeration type, the register address stores several enumeration values. Generally, there are several enumeration values, which represents several telemetering models, and when one of the telemetering states is true (1), the other enumeration states should be false (0). For example, the data stored at address 0x0001 in the point table provided by the manufacturer is the battery charging and discharging status: 0-trickle charge, 1-floating charge, 2-equalizing charge, 3-discharging.) represents four telemetering states, and when one of the states is true, the other states need to be set to false. Of course, the data at the address of the register can also be used as a telemetering model data.
[0053] 6) Use function code 05 or 06 to implement remote control (or control) function (05 is commonly used, and a few manufacturers use function code 06); theoretically, the remote control command should use function code 05, and the single fixed value should use function code 06, but because the message formats of the two are similar, some manufacturers will mix them. For example, if you use function code 06 to enter a specified number, it represents a specified operation, but in the eyes of the upper computer, this is one or more groups of remote control commands, which may be split into multiple remote control point numbers; so when receiving a reply with function code 06 from the lower computer, this module will judge it as a remote control or fixed value reply based on the register address.
[0054] 7) The fixed value modification function is realized through the 06 function code, including reading fixed values and writing fixed values; the data parsing method of the read fixed value operation is consistent with the telemetry data parsing method, but the write fixed value operation is opposite to the read fixed value. For example, if the parsing method of a fixed value is "2-byte unsigned high first and low later", the coefficient is "0.1", and the two-byte data read in hexadecimal is "01 02", then the parsed data is (01*256+02)*0.1=25.8. When receiving the write fixed value command, the fixed value is written as 25.8, which requires reverse calculation and organization into a hexadecimal "01 02" message.
[0055] 8) The clock synchronization function is realized through the 0x10 function code (if there is a need to read the clock, the "year, month, day, hour, minute, second" can be read or written as 6 fixed values according to the needs of the master station, or it can be configured as telemetry data and configured with polling messages for periodic polling reading. However, the clock synchronization command generally requires that the "year, month, day, hour, minute, second" data be written in one frame of message at the same time). Generally, there is only one clock source in a project and it is deployed on the host computer. Therefore, the time synchronization function is to synchronize the clocks of the lower computer with the upper computer to ensure the correctness of the stored time stamp when the lower computer log, historical data and other functions trigger event recording; the upper computer generally does not read the clock of the lower computer, it only needs to ensure that the clock of the lower computer is synchronized with the upper computer. If there is a need to read the clock, the time data can be divided and stored and read separately in the following two ways, but writing the clock generally requires that the clock data be written in one frame of message at the same time. "Year, month, day, hour, minute, second" are used as 6 fixed values to be read or written according to the requirements of the master station. "Year, month, day, hour, minute, second" are used as 6 telemetry data and polling messages are configured for periodic polling reading; if the time to be written to the lower machine is "2023-8-11 16:29:47".
[0056] Explanation of register length (non-BCD code, year->second as an example): When the register length is 3, the corresponding time message format is a 6-byte hexadecimal message (year minus 2000): 17 08 0B 10 1D 2F. When the register length is 6, the 12-byte hexadecimal message is: 07E7 00 08 00 0B 00 10 00 1D 00 2F.
[0057] BCD code explanation (6 register length, year -> second as an example): Without using BCD code, the 12-byte message is: 07 E7 0008 00 0B 00 10 00 1D 00 2F; using BCD code, the 12-byte message is: 20 23 00 08 00 11 00 16 0029 00 47
[0058] Time sequence explanation (6 register length, BCD code as an example): year->second: 20 23 00 08 00 11 00 16 0029 00 47, second->year: 00 47 00 29 00 16 00 11 00 08 20 23.
[0059] In short, the corresponding messages are organized through the ModbusModbus protocol and the above protocols, where MOUBUS includes ModbusModbus-Rtu or Modbus-Tcp; Modbus-Rtu generally uses serial port communication, with CRC check at the end of the message, and the instruction message structure consists of five parts: address code (one byte), function code (one byte), starting address (two bytes), data (N bytes), and check code (two bytes). Modbus-Tcp uses network port communication, and the message has an MBAP message header (transaction processing identifier + protocol identifier + length + unit identifier). The instruction message structure consists of a transaction processing identifier (two bytes, which can be simply understood as a message sequence number, plus 1 after each communication), a protocol identifier (two bytes, fixed to 00 00 to indicate the Modbus-Tcp protocol), a length (two bytes, indicating the length of the following data, in bytes), a unit identifier (1 byte, which can be understood as a device address), a function code (one byte), a starting address (two bytes), and data (N bytes). See the table below for details:
[0060]
[0061] Therefore, the communication method of the power distribution system based on the Modbus access module is as follows:
[0062] 1. The intelligent power distribution terminal loads a configuration file, wherein the configuration file is obtained by configuring the configuration tool with the relevant information of the lower computer connected to the intelligent power distribution terminal for Modbus communication. The relevant information includes device attributes, telemetry data model, electricity data model, telesignaling data model and remote control data model. The device attributes include the device information and communication parameters of the connected lower computer.
[0063] Configuration files can be in json, xml, yaml, ini, and csv formats. Figure 2 As shown in the figure: The configuration tool configures the access to the lower computer for Modbus communication with the intelligent power distribution terminal, including:
[0064] a) Configure device properties, describe the module information, managed devices, communication parameters, and communication protocols, such as Figure 3 and Figure 4 As shown; the communication protocol can be configured as Modbus-Rtu or Modbus-Tcp. The message structures of the two are slightly different, but the communication methods used are the same.
[0065] b) To configure the real-time data polling message, you need to configure the function code, register starting address and register length to be read, and then configure the real-time data polling message for each slave computer according to the device address.
[0066] c) Periodic time synchronization function configuration is as follows Figure 5 As shown in the time synchronization configuration, the time synchronization function needs to configure the time synchronization control word, time synchronization cycle, starting register address, register length, whether it is broadcast time synchronization mode, broadcast address, message time format sorting method (year->second or second->year), and whether the time data message uses BCD code (this configuration includes various common lower computer synchronization message formats).
[0067] 1) Timing control word: start or stop the timing function;
[0068] 2) Timing cycle: that is, the interval time of periodic timing (invalid when the timing control word is not cast), unit: min;
[0069] 3) Starting register address: the address number of the starting register where the lower computer writes the clock;
[0070] 4) Register length: 3 registers or 6 registers;
[0071] 5) Broadcast synchronization mode: Yes or No. If yes, a broadcast synchronization message is sent according to the broadcast address. Otherwise, the time is synchronized for each device according to the device address of the lower computer.
[0072] 6) Broadcast address: Invalid in non-broadcast timing mode;
[0073] 7) Time message format sorting method: year->second or second->year;
[0074] 8) Whether the time message format uses BCD code: Yes or No;
[0075] d) Configure program operation parameters and lower computer settings, such as Figure 6 As shown, the program running parameters need to configure the read and write function codes to 0. When it is necessary to read and write the host computer set value, it can be configured according to the manufacturer's specification point table;
[0076] e) Configure telemetry or electricity data model, Figure 7 It is the telemetry data model configuration interface. The electricity data model configuration interface is the same as the telemetry data model configuration interface;
[0077] f) Configure the remote signaling data model, such as Figure 8 As shown;
[0078] g) Configure the remote control data model, such as Fig. 9 shown.
[0079] Configuration parameters or data register addresses support hexadecimal and decimal numbers, but when configuring hexadecimal numbers, add the "0x" field in front of the number to declare it;
[0080] Telemetry and electricity analysis mode: fixed length of 2, 4, 8 bytes optional, signed or unsigned data optional, high and low byte arrangement order optional, and 4 bytes optional short floating point or integer data, 8 bytes long floating point or long integer data.
[0081] Telesignal parsing method: divided into discrete parsing, bit-by-bit parsing, and enumeration parsing. Generally, telesignal data is transmitted using function codes 01 or 02, and the discrete data can be parsed according to the register address and offset (the data register in the message - the starting register address); there are also a few manufacturers that store multiple telesignal data in a single register of function codes 03 or 04. In this case, multiple groups of telesignal data may share one register. In this case, the data can also be parsed according to the different offsets of the telesignal data (1 register, 2 bytes, a total of 16 bits, that is, one register can store 16 telesignal data, and the offset is 0-15).
[0082] h) Configure the Modbus coefficient. The Modbus coefficient is the coefficient that needs to be multiplied to get the real data (e.g., message data 123, coefficient 0.1, the real data is 123*0.1=12.3). In particular, if the parsing type is a floating point type, no coefficient is required, and the real data can be obtained by storing it as a floating point variable. If the parsing method of the parsed telemetry data or electricity data is a non-floating point type, the actual telemetry data or electricity data is the product of the parsed data and the Modbus coefficient.
[0083] 2. Use the Modbus access module in the intelligent power distribution terminal to parse the configuration file, and use the device attribute information obtained by the analysis to establish communication between the intelligent power distribution terminal and the lower computer, and then use the analysis to obtain the telemetry data model, electricity data model, telesignaling data model and remote control data model information, so as to enable the intelligent power distribution terminal to obtain the telemetry data, electricity data and telesignaling data of the lower computer and send remote control commands to the lower computer.
[0084] The Modbus access module in the intelligent power distribution terminal is used to parse the configuration file, and the Modbus access module runs the main process Fig.10 As shown in the figure, the priority of interpolation messages is: remote control message > fixed value message > synchronization message > real-time data polling message, and all function messages are organized and sent immediately when the polling time is reached:
[0085] 1) Parse the configuration file to obtain the configuration or parameters related to the functions such as remote signaling, telemetering, electricity, remote control, set value, and timing;
[0086] 2) Open the communication channel according to the serial port or network port parameters in the configuration file;
[0087] 3) Check whether the remote control command is received, if yes, organize and insert the control message as required;
[0088] 4) Check whether a fixed value read / write operation command is received, if yes, organize and insert frames to send relevant operation messages as required;
[0089] 5) Check whether the periodic time synchronization function has been enabled and the time synchronization period has been reached. If so, organize and insert frames to send synchronization messages;
[0090] 6) Check the timer to see if the polling time has been reached. If so, send an interpolation message or send a real-time data polling message in the order of the polling message (the priority of the interpolation message is higher than the polling message. When there is an interpolation message, the real-time data polling message needs to wait until the next polling cycle to be sent);
[0091] 7) Check whether the reply message from the lower computer is received, and if so, parse the message data;
[0092] 8) Repeat steps 3-7.
[0093] a) Process of obtaining telemetry data or electricity data, such as Fig.11 shown.
[0094] 1) When the program starts, the configuration file is parsed to obtain the function code, register address, parsing method, coefficient and other related configurations of each telemetry data or electricity data;
[0095] 2) When the program receives a telemetry or electricity message, it parses each group of data in the message one by one and compares them one by one with the entries in the telemetry data model or electricity data model according to the function code and register address (calculated by register first address + register address offset). When the function code and register address of the data in the message are exactly the same as an entry in the telemetry data model, it is considered that this group of data corresponds to the telemetry entry; when the function code and register address of the data in the message are exactly the same as an entry in the electricity data model, it is considered that this group of data corresponds to the electricity entry;
[0096] 3) Obtain the data according to the analysis type and data coefficient analysis;
[0097] 4) Loop through the methods described in steps 2 and 3 to complete parsing of all data in the frame message.
[0098] b) Obtaining remote signaling data process, such as Fig.12 shown.
[0099] 1) When the program starts, parse the configuration file to obtain the relevant configurations such as each remote signaling data function code, register address, parsing method, offset / enumeration value, log type, etc.;
[0100] 2) When the program receives the telesignal message, it analyzes each bit in the message one by one and compares it with the entries in the telesignal model according to the function code and register address. When the function code and register address of the data in the message are exactly the same as an entry in the configuration file, it is considered that this group of data corresponds to the telesignal entry;
[0101] 3) According to the different analysis types, the telesignal can be divided into three methods: discrete analysis, bit analysis, and enumeration analysis. The corresponding telesignal data is analyzed. Discrete analysis: find the corresponding register address bit data; bit analysis: locate the bit data according to the register address and offset; enumeration analysis: only one telesignal value of the enumeration value is true, and the telesignal status is obtained according to the enumeration value, and the other telesignal values of the register address are set to 0;
[0102] 4) Loop through the methods described in steps 2 and 3 to complete parsing of all data in the frame message.
[0103] c) The intelligent power distribution terminal sends remote control commands to the lower computer process, such as Fig.13 shown.
[0104] 1) When the program starts, the configuration file is parsed to obtain the relevant configurations such as the function code, register address, sub-command code and combined command code of each remote control model;
[0105] 2) When this program receives the remote control message that needs to be sent, it checks whether it is the remote control point number supported by this module. Otherwise, the reply fails. If it is, it is added to the remote control linked list (using the linked list supports receiving multiple remote control commands at the same time, and executes each control command one by one according to the first-in-first-out principle);
[0106] 3) Take out the first group of remote control nodes in the remote control linked list, send Modbus control message according to the function code and the sub-command code or the combined command code, and start the timeout timing at the same time;
[0107] 4) When receiving the control message from the lower computer, parse the lower computer's reply result (determine whether the high bit of the function code is 1. For example, if the function code 05 is sent and the lower computer replies with the function code 05, it means that the command is successfully executed. If the lower computer replies with the function code 0x85, it means that the lower computer fails to execute the control command) and reply the remote control result to the upper computer. If the lower computer does not reply after the timeout, it will also reply with a timeout. After replying the operation result to the upper computer, clear the node. At the same time, regardless of whether the operation result is "successful", "failed" or "timeout", it should be recorded in the log with the operation type of "operation";
[0108] 5) Loop through steps 3-4 until the linked list is empty.
[0109] d) Implement the clock synchronization operation process, such as Fig.16 shown.
[0110] 1) When the program starts, the configuration file is parsed to obtain the time synchronization control word, time synchronization cycle, starting register address, register length (3 or 6), whether the broadcast time synchronization mode, the broadcast address (invalid when the non-broadcast time synchronization mode), the message sorting method (year->second or second->year), whether the time message uses BCD code and other related configurations;
[0111] 2) When the polling time is up, the synchronization control word is cast and the synchronization cycle is reached, the synchronization message of the corresponding format is organized according to the configuration and sent out with frame insertion;
[0112] 3) Repeat step 2.
[0113] e) Reading set value operation process, such as Fig.14 shown.
[0114] 1) When the program starts, the configuration file is parsed to obtain the relevant configurations such as the function code, register address, data parsing method, data coefficient, etc. for each fixed value model;
[0115] 2) When this program receives the set value reading message that needs to be sent, check whether it is the set value point number supported by this module. Otherwise, the reply to the upper part fails. If it is, add it to the set value linked list (take the received set value as a node according to the device, load the set value to be operated of the same lower device address into the same node, if there is a new set value command, add it to the end of the linked list, and execute each set value operation command one by one according to the first-in-first-out principle);
[0116] 3) Take out the first group of fixed value nodes in the fixed value chain table, and send Modbus messages in frames according to the function code and register address (if the fixed value register addresses are continuous, they are combined into one frame for reading (to ensure that one frame message does not exceed the 256 bytes limited by the Modbus protocol, the number of registers read is limited to a maximum of 125 registers (the head and tail of the uplink message are fixed at 5 bytes, one register is 2 bytes, that is, 125*2+5=255 bytes)), if they are not continuous, they are read separately), and start the timeout timing at the same time;
[0117] 4) When receiving the fixed value message from the lower computer, determine whether the data is successful. If yes, parse the lower computer reply data according to the parsing method and coefficient, and reply the corresponding data to the upper computer. Otherwise, the reply fails. If the lower computer does not reply within the time limit, it will also reply to the upper computer that the time limit has expired. After replying the operation result to the upper computer, clear the node;
[0118] 5) Loop through steps 3-4 until the linked list is empty.
[0119] f) Write the set value operation process, such as Fig.15 shown.
[0120] 1) When the program starts, the configuration file is parsed to obtain the relevant configurations such as the write function code, register address, data parsing method, data coefficient, etc. of each fixed value model;
[0121] 2) When this program receives a set value writing message that needs to be sent, it checks whether it is a set value point number supported by this module. Otherwise, the reply fails. If it is, it is added to the set value linked list (the received set value is regarded as a node according to the device, and the set value to be operated of the same lower device address is loaded into the same node. If there is a new set value command, it is added to the linked list, and each set value operation command is executed one by one according to the first-in-first-out principle);
[0122] 3) Take out the first group of fixed value nodes in the fixed value chain table, organize the data message according to the data to be sent, the analysis type and the coefficient, and then send the Modbus message in frames according to the function code and register address (one data per frame), and start timing at the same time;
[0123] 4) When receiving the fixed value message from the lower computer, determine whether the data is successful and reply with the corresponding result. If the lower computer does not reply within the time limit, it will also reply with a timeout. After replying the operation result to the upper computer, clear the node; at the same time, no matter the operation result is "successful", "failed" or "timeout", the modified entry and the corresponding value should be recorded in the log with the operation type of "operation";
[0124] 5) Loop through steps 3-4 until the linked list is empty.
[0125] A power distribution system embodiment:
[0126] An embodiment of a power distribution system of the present invention includes an intelligent power distribution terminal and a lower computer, wherein a power distribution system communication method based on a Modbus access module is adopted between the intelligent power distribution terminal and the lower computer. The essence is that the intelligent power distribution terminal loads a configuration file, wherein the configuration file is obtained by configuring the configuration tool to obtain the relevant information of the lower computer connected to the intelligent power distribution terminal for Modbus communication, and the relevant information includes device attributes, telemetry data model, electricity data model, telesignaling data model and remote control data model, and the device attributes include the device information and communication parameters of the connected lower computer; the Modbus access module in the intelligent power distribution terminal is used to parse the configuration file, and the communication between the intelligent power distribution terminal and the lower computer is established by using the device attribute information obtained by the analysis, and then the telemetry data model, electricity data model, telesignaling data model and remote control data model information obtained by the analysis are used to correspondingly realize that the intelligent power distribution terminal obtains the telemetry data, electricity data, and telesignaling data of the lower computer, and the intelligent power distribution terminal sends a remote control command to the lower computer. This method configures device properties, telemetry data models, electricity data models, telesignaling data models, and remote control data models through configuration tools, so that developers no longer need to develop programs for connected sensors. In addition, later debugging personnel can promptly modify problems found through configuration tools, and then the smart distribution terminal can load file parsing to obtain the telemetry data, electricity data, and telesignaling data of the lower computer, and the smart distribution terminal can send remote control commands to the lower computer.
Claims
1. A communication method for a power distribution system based on a Modbus access module, characterized in that: The steps include: 1) The intelligent power distribution terminal loads a configuration file, wherein the configuration file is obtained by configuring the configuration tool with the relevant information of the lower computer connected to the intelligent power distribution terminal for Modbus communication, and the relevant information includes device attributes, telemetry data model, electricity data model, telesignaling data model and remote control data model, and the device attributes include the device information and communication parameters of the connected lower computer; 2) Use the Modbus access module in the intelligent distribution terminal to parse the configuration file, and use the device attribute information obtained by the analysis to establish communication between the intelligent distribution terminal and the lower computer, and then use the telemetry data model, electricity data model, telesignaling data model and remote control data model information obtained by the analysis, so as to enable the intelligent distribution terminal to obtain the telemetry data, electricity data and telesignaling data of the lower computer and send remote control commands to the lower computer.
2. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The means by which the intelligent distribution terminal obtains the telemetry data or electricity data of the lower computer is: parsing each group of data in the telemetry or electricity message, and comparing the function code and register address in each group of data with the items of the telemetry data model or electricity data model obtained by parsing one by one. If a certain entry is consistent with the function code and register address in a certain group of data, it is determined that the group of data corresponds to the entry, and then the corresponding actual telemetry data or electricity data is obtained based on the parsed data of the group.
3. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The means by which the intelligent distribution terminal obtains the telesignaling data of the lower computer is: parsing each group of data in the telesignaling message, and comparing the function code and register address in each group of data with the entries of the telesignaling data model obtained by parsing one by one. If a certain entry is consistent with the function code and register address in a certain group of data, it is determined that the group of data corresponds to the entry, and then the corresponding actual telesignaling data is obtained based on the parsed data of the group.
4. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The means by which the intelligent power distribution terminal sends remote control commands to the lower computer is as follows: when the intelligent power distribution terminal receives a remote control message that needs to be sent, it checks whether the remote control point number in the remote control message is a remote control point number supported by the intelligent power distribution terminal according to the remote control data model obtained by parsing. If so, the remote control message is added to the corresponding remote control linked list; the remote control messages in the remote control linked list are sent to the lower computer one by one in the following manner: a group of remote control messages in the remote control linked list are taken out and the remote control command messages are organized and sent to the lower computer according to the remote control data model. If a control message replied by the lower computer is received within the required time and the content of the control message indicates that the remote control command is successfully executed, the remote control is successful.
5. The power distribution system communication method based on Modbus access module according to claim 3, characterized in that: When parsing data, you need to combine the parsing type, which includes discrete parsing, bitwise parsing, and enumeration parsing.
6. The power distribution system communication method based on Modbus access module according to claim 2, characterized in that: The related information also includes a Modbus coefficient, which is represented by a coefficient to be multiplied to obtain real data; if the parsed data is parsed in a non-floating point type, the actual telemetry data or electricity data is the product of the parsed data and the Modbus coefficient.
7. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The relevant information also includes time synchronization function information, and the specific time synchronization function information includes a time synchronization control word and a time synchronization cycle; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the time synchronization function with the lower computer based on the time synchronization function information obtained by parsing, and the corresponding means are: when the polling time arrives, the time synchronization control is enabled and the time synchronization cycle is reached, the synchronization message is organized according to the time synchronization function information and sent to the lower computer.
8. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The related information also includes read-set value information, and the specific read-set value information is the manufacturer's protocol point table information of the lower computer; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the read-set value function with the lower computer based on the read-set value information obtained by parsing, and the corresponding means are: when the intelligent distribution terminal receives a read-set value message that needs to be sent, it checks whether the set value point number in the read-set value message is a set value point number supported by the intelligent distribution terminal based on the read-set value information obtained by parsing, and if so, adds the read-set value message to the corresponding read-set value linked list; the read-set value messages in the read-set value linked list are sent to the lower computer one by one in the following manner: take out a group of read-set value messages from the read-set value linked list and organize the read-set value command message to be sent to the lower computer based on the set value information; if the read-set value message replied by the lower computer is received within the required time, the read message is parsed to obtain the corresponding read-set value data.
9. The power distribution system communication method based on Modbus access module according to claim 1, characterized in that: The related information also includes write-set value information; after the intelligent distribution terminal loads the configuration file, the intelligent distribution terminal implements the write-set value function with the lower computer according to the write-set value information obtained by parsing, and the corresponding means are: when the intelligent distribution terminal receives the write-set value message that needs to be sent, it checks whether the set value point number in the write-set value message is the set value point number supported by the intelligent distribution terminal according to the write-set value information obtained by parsing, and if so, adds the write-set value message to the corresponding write-set value chain list; the write-set value messages in the write-set value chain list are sent to the lower computer one by one in the following manner: take out a group of write-set value messages from the set value chain list and organize the data part of the Modbus message according to the data information in the write-set value message, and organize the write-set value command message according to the set value information and send it to the lower computer; if the content of the message received from the lower computer within the required time indicates that the write-set value command is executed successfully, then the write-set value command is executed successfully.
10. A power distribution system, comprising an intelligent power distribution terminal and a lower computer, characterized in that: The intelligent power distribution terminal and the lower computer are used to communicate with each other using the power distribution system communication method based on the Modbus access module as described in claims 1 to 9.