A method, system, device and medium for automatically determining Modbus data type
By automatically identifying Modbus data types, the problems of inconsistent data types and high configuration complexity in new energy stations are solved, efficient and automated equipment communication and maintenance are achieved, and operation costs are reduced.
Patent Information
- Application Number
- CN202411941116.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-04
AI Technical Summary
The Modbus protocol has problems such as inconsistent data types and high configuration complexity in new energy stations, resulting in high manual configuration error rate, poor flexibility, and requires a lot of human resources to configure and debug equipment.
By obtaining the list of Modbus measurement points, a standard measurement point list is generated, and the data type is automatically determined based on the function code and number of registers of the standard measurement points, and the method of automatically identifying the Modbus data type is realized.
It significantly reduces the need for manual intervention, improves communication smoothness and automation level between devices, reduces error rates and long-term operation costs, and enhances the maintainability of the system.
Smart Images

Figure CN119766911A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of new energy station communication, and relates to a method, system, device and medium for automatically determining Modbus data type. Background Art
[0002] Modbus is a widely used standard, but in actual deployment, especially when involving devices from multiple vendors, the Modbus protocol has some inherent limitations:
[0003] Non-standardized data type definitions: The Modbus standard itself does not have mandatory provisions for the specific meaning or data type of data, which means that different device manufacturers may have different ways of representing data.
[0004] High configuration complexity: When setting up a Modbus network, it is usually necessary to manually configure the data address and type of each device, which is not only time-consuming but also prone to errors.
[0005] Currently, many systems rely on manual configuration and documentation to manage the data types of Modbus devices, which is particularly inconvenient in large-scale renewable energy sites:
[0006] 1. Manual dependence: A large amount of human resources is required to configure and debug the equipment.
[0007] 2. High error rate: Due to human factors, the probability of data type configuration errors is high.
[0008] 3. Poor flexibility: Once the device or network changes, manual adjustments are required, which lacks flexibility. Summary of the invention
[0009] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a method, system, device and medium for automatically determining the Modbus data type. The method, system, device and medium have the characteristics of being independent of manual work, having a low error rate and high flexibility.
[0010] To achieve the above object, the present invention discloses a method for automatically identifying Modbus data types, comprising:
[0011] Get the Modbus measurement point list;
[0012] Generate a standard measuring point list based on the Modbus measuring point list;
[0013] The data type of the standard measuring point is determined according to the function code of each standard measuring point in the standard measuring point list and the number of registers used.
[0014] The method for automatically identifying Modbus data types described in the present invention is further improved in that:
[0015] Furthermore, when the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is Boolean type; when the function code of the standard measuring point is 3 or 4, the number of registers used by the standard measuring point is checked. When the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number.
[0016] Furthermore, for the wind speed measurement points stored in 2 registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th to 7th bytes in the response message are determined, and converted into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, the byte order is 1234; otherwise, it is converted into a floating point number according to the byte order 4321. When the converted value is within the range of wind speed, the byte order is 4321; otherwise, it is converted into a floating point number according to the byte order 2143. When the converted value is within the range of wind speed, the byte order is 2143; otherwise, it is converted into a floating point number according to the byte order 3412. When the converted value is within the range of wind speed, the byte order is 3412.
[0017] Furthermore, for the power measurement points stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the fourth byte to the seventh byte in the response message are determined, and then the byte order is determined.
[0018] The present invention discloses a system for automatically identifying Modbus data types, comprising:
[0019] Acquisition module, used to obtain the Modbus measurement point list;
[0020] A generation module is used to generate a standard measurement point list based on the Modbus measurement point list;
[0021] The determination module is used to determine the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used.
[0022] The system for automatically identifying Modbus data types described in the present invention is further improved in that:
[0023] Furthermore, when the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is Boolean type; when the function code of the standard measuring point is 3 or 4, the number of registers used by the standard measuring point is checked. When the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number.
[0024] Furthermore, for the wind speed measurement points stored in 2 registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th to 7th bytes in the response message are determined, and converted into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, the byte order is 1234; otherwise, it is converted into a floating point number according to the byte order 4321. When the converted value is within the range of wind speed, the byte order is 4321; otherwise, it is converted into a floating point number according to the byte order 2143. When the converted value is within the range of wind speed, the byte order is 2143; otherwise, it is converted into a floating point number according to the byte order 3412. When the converted value is within the range of wind speed, the byte order is 3412.
[0025] Furthermore, for the power measurement points stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the fourth byte to the seventh byte in the response message are determined, and then the byte order is determined.
[0026] The present invention discloses a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for automatically identifying Modbus data types are implemented.
[0027] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for automatically identifying Modbus data types are implemented.
[0028] The present invention has the following beneficial effects:
[0029] The method, system, device and medium for automatically determining Modbus data types described in the present invention determine the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used during specific operation, so as to significantly reduce the need for manual intervention, make communication between devices smoother, improve the overall automation level, and the automated recognition mechanism makes it easier for the system to adapt to changes in equipment, simplify the maintenance process, and reduce long-term operating costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0031] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] In the description of the present invention, it should be understood that the terms “include” and “comprises” indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.
[0034] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0035] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects are in an "or" relationship.
[0036] It should be understood that, although the terms first, second, third, etc. may be used to describe preset ranges, etc. in the embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are only used to distinguish preset ranges from each other. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.
[0037] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can usually be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0039] Various structural schematic diagrams of the embodiments disclosed in the present invention are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.
[0040] Embodiment 1
[0041] There are four main types of Modbus function codes, among which function codes 1 and 2 are used to process switch quantities, while function codes 3 and 4 are used to process analog quantities. The main problem currently is that the data types of function codes 3 and 4 are inconsistent between different devices. This is because the Modbus protocol uses registers to store data, each register occupies 2 bytes, but there is no unified regulation for the data format within the register. In new energy stations, commonly used Modbus data types include Boolean types (values are 0 and 1), integers (2 bytes), and single-precision floating point numbers (4 bytes).
[0042] The method for automatically identifying Modbus data types of the present invention comprises the following steps:
[0043] 1) Obtain the Modbus measurement point list provided by the equipment manufacturer;
[0044] In the Modbus measurement point list, set reasonable ranges for wind speed measurement points and power measurement points. The wind speed range is set to 0-50m / s, and the power range is set to -100kW to 1.2 times the installed capacity of the equipment. Among them, power less than 0 indicates equipment power consumption, and 1.2 times the installed capacity takes into account the possible over-generation of the equipment.
[0045] 2) Generate a standard measuring point list based on the Modbus measuring point list;
[0046] Check the function code of the measuring point. When the function code is 1 or 2, set the data type of the standard measuring point to Boolean type. When the function code of the standard measuring point is 3 or 4, check the number of registers used by the measuring point. When the measuring point uses 1 register, the data type of the standard measuring point is set to a 2-byte integer type. When the standard measuring point uses 2 registers, go to step 3).
[0047] 3) Assume that the data standard encoding is big-endian encoding. For example, the first byte of the value 0x11223344 stores the highest bit, and the last byte stores the lowest bit. Set the byte order to 1234, as shown in Table 1:
[0048] Table 1
[0049]
[0050] 4) Identification of wind speed measurement points. For wind speed measurement points stored in two registers, send a request message according to the Modbus standard protocol, obtain the response message returned by Modbus, find the 4th to 7th bytes in the message (if it is Modbus TCP, find the 10th to 13th bytes), and convert them into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, it is preliminarily judged that the byte order is 1234; otherwise, proceed to the next step of judgment.
[0051] 5) Try other byte orders:
[0052] The floating point number is converted according to the byte order 4321. When the converted value is within the range of wind speed, it is preliminarily determined that the byte order is 4321; otherwise, the next step of determination is performed.
[0053] The floating point number is converted according to the byte order 2143. If the converted value is within the range of wind speed, it is preliminarily determined that the byte order is 2143; otherwise, proceed to the next step of determination.
[0054] The floating point number is converted according to the byte order 3412. If the converted value is within the range of wind speed, it is preliminarily determined that the byte order is 3412; otherwise, the conversion is determined to have failed.
[0055] 6) Identification of power measurement points: For power measurement points stored in two registers, send a request message in accordance with the Modbus standard protocol, obtain a response message, find the 4th to 7th bytes in the message (if it is Modbus TCP, find the 10th to 13th bytes), and verify the determined byte order type. When the verified power value is within the given range, it is confirmed that the floating point number used is in the specified byte order.
[0056] 7) Automatic conversion of other floating-point measurement points: Automatically convert other floating-point types in the measurement point list based on the data type determined in the above steps.
[0057] The present invention has the following characteristics:
[0058] 1. Improve the level of automation: Automatic identification of Modbus data types can significantly reduce the need for manual intervention, making communication between devices smoother and improving the overall level of automation.
[0059] 2. Reduce error rate: Automatically identify data types through algorithms, reduce problems caused by human errors and improve system reliability.
[0060] 3. Enhanced maintainability: The automated identification mechanism makes it easier for the system to adapt to equipment changes, simplifies the maintenance process, and reduces long-term operating costs.
[0061] Embodiment 2
[0062] The system for automatically identifying Modbus data types of the present invention comprises:
[0063] Acquisition module, used to obtain the Modbus measurement point list;
[0064] A generation module is used to generate a standard measurement point list based on the Modbus measurement point list;
[0065] The determination module is used to determine the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used.
[0066] As an implementation scheme of the present invention, when the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is a Boolean type; when the function code of the standard measuring point is 3 or 4, the number of registers used by the standard measuring point is checked, and when the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number.
[0067] As an implementation scheme of the present invention, for a wind speed measurement point stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th to 7th bytes in the response message are determined, and converted into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, the byte order is 1234; otherwise, it is converted into a floating point number according to the byte order 4321. When the converted value is within the range of wind speed, the byte order is 4321; otherwise, it is converted into a floating point number according to the byte order 2143. When the converted value is within the range of wind speed, the byte order is 2143; otherwise, it is converted into a floating point number according to the byte order 3412. When the converted value is within the range of wind speed, the byte order is 3412.
[0068] As an implementation scheme of the present invention, for power measurement points stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th byte to the 7th byte in the response message are determined, and then the byte order is determined.
[0069] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0070] Embodiment 3
[0071] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for automatically identifying Modbus data types are implemented, for example, including: obtaining a Modbus measuring point list; generating a standard measuring point list according to the Modbus measuring point list; determining the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used; when the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is a Boolean type; when the function code of the standard measuring point is 3 or 4, checking the number of registers used by the standard measuring point, when the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number. The memory may include a memory, such as a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk memory, etc. The processor, network interface, and memory are interconnected through an internal bus, and the internal bus may be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard architecture bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory is used to store programs. Specifically, the program may include a program code, and the program code includes computer operation instructions. The memory may include a memory and a non-volatile memory, and provide instructions and data to the processor.
[0072] Embodiment 4
[0073] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the method for automatically identifying Modbus data types are implemented, for example, including: obtaining a Modbus measuring point list; generating a standard measuring point list according to the Modbus measuring point list; determining the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used; when the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is a Boolean type; when the function code of the standard measuring point is 3 or 4, checking the number of registers used by the standard measuring point, when the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number. Specifically, the computer-readable storage medium includes, but is not limited to, for example, a volatile memory and / or a non-volatile memory. The volatile memory may include a random access memory (RAM) and / or a cache memory, etc. The non-volatile memory may include a read-only memory (ROM), a hard disk, a flash memory, an optical disk, a magnetic disk, and the like.
[0074] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0075] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0076] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0077] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0078] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and disclosure of the invention. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0079] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
[0080] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A method for automatically identifying Modbus data types, characterized in that: include: Get the Modbus measurement point list; Generate a standard measuring point list based on the Modbus measuring point list; The data type of the standard measuring point is determined according to the function code of each standard measuring point in the standard measuring point list and the number of registers used.
2. The method for automatically identifying Modbus data types according to claim 1, characterized in that: When the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is Boolean type; when the function code of the standard measuring point is 3 or 4, check the number of registers used by the standard measuring point. When the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number.
3. The method for automatically identifying Modbus data types according to claim 2, characterized in that: For wind speed measurement points stored in 2 registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th to 7th bytes in the response message are determined, and converted into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, the byte order is 1234; otherwise, it is converted into a floating point number according to the byte order 4321. When the converted value is within the range of wind speed, the byte order is 4321; otherwise, it is converted into a floating point number according to the byte order 2143. When the converted value is within the range of wind speed, the byte order is 2143; otherwise, it is converted into a floating point number according to the byte order 3412. When the converted value is within the range of wind speed, the byte order is 3412.
4. The method for automatically identifying Modbus data types according to claim 2, characterized in that: For the power measurement points stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th byte to the 7th byte in the response message are determined, and then the byte order is determined.
5. A system for automatically identifying Modbus data types, characterized in that: include: Acquisition module, used to obtain the Modbus measurement point list; A generation module is used to generate a standard measurement point list based on the Modbus measurement point list; The determination module is used to determine the data type of the standard measuring point according to the function code of each standard measuring point in the standard measuring point list and the number of registers used.
6. The system for automatically identifying Modbus data types according to claim 5, characterized in that: When the function code of the standard measuring point is 1 or 2, the data type of the standard measuring point is Boolean type; when the function code of the standard measuring point is 3 or 4, check the number of registers used by the standard measuring point. When the number of registers used by the standard measuring point is 1, the data type of the standard measuring point is a 2-byte integer type; when the number of registers used by the standard measuring point is 2, the data type of the standard measuring point is a floating point number.
7. The system for automatically identifying Modbus data types according to claim 6, characterized in that: For wind speed measurement points stored in 2 registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th to 7th bytes in the response message are determined, and converted into floating point numbers according to the byte order 1234. When the converted value is within the range of wind speed, the byte order is 1234; otherwise, it is converted into a floating point number according to the byte order 4321. When the converted value is within the range of wind speed, the byte order is 4321; otherwise, it is converted into a floating point number according to the byte order 2143. When the converted value is within the range of wind speed, the byte order is 2143; otherwise, it is converted into a floating point number according to the byte order 3412. When the converted value is within the range of wind speed, the byte order is 3412.
8. The system for automatically identifying Modbus data types according to claim 6, characterized in that: For the power measurement points stored in two registers, a request message is sent to Modbus according to the Modbus standard protocol, a response message returned by Modbus is obtained, the 4th byte to the 7th byte in the response message are determined, and then the byte order is determined.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for automatically identifying Modbus data types according to any one of claims 1 to 4 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for automatically identifying Modbus data types according to any one of claims 1 to 4 are implemented.