A PLC-based floating-point number integration method and system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-14
AI Technical Summary
[0010]为此,本发明实施例提供一种基于PLC的浮点数整合方法及系统,以解决现有技术中六轴机器人向PLC传输浮点数时因协议差异和数据格式转换导致精度丢失、传输效率低及兼容性差的技术问题
[0033]本发明实施例在机器人端获取待传输的浮点数数据并进行IEEE754标准格式检查,将浮点数拆分为整数部分和小数部分,小数部分乘以预设放大系数后取整,连同正负标识一并作为传输数据;根据EtherNet/IP协议封装后通过以太网发送至PLC;PLC端接收数据并进行完整性校验,调用函数块将整数部分和小数部分分别转换为浮点数后相加,再根据正负标识进行符号处理,输出整合后的浮点数。本发明通过将浮点数拆分为五个字节传输并在PLC端精确还原,有效避免了传输过程中的精度损失,提高了机器人与PLC之间的数据传输效率和兼容性。
Smart Images

Figure CN122578657A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial automation control technology, specifically to a floating-point number integration method and system based on PLC. Background Technology
[0002] In industrial automated production processes, the collaborative control of six-axis robots and programmable logic controllers (PLCs) is a common architecture. The six-axis robot is responsible for performing high-precision spatial motion operations, while the PLC handles the logic control and data scheduling of the production process. In such systems, the robot often needs to transmit floating-point data to the PLC, such as joint coordinates, end-effector pose, velocity, and force feedback values, to support the PLC in making subsequent control decisions.
[0003] Currently, the main technical approaches for floating-point number transmission between robots and PLCs are as follows:
[0004] (1) Floating-point number transmission based on standard industrial Ethernet protocol
[0005] Protocols such as EtherNet / IP, Profinet, and EtherCAT all support direct transmission of IEEE 754 standard floating-point numbers. The advantage of this approach is that the protocol layer has defined complete data types and byte order rules, and the transmission process itself does not introduce precision loss. However, in actual deployment, it is necessary to ensure that both communicating parties agree on the byte order (big-endian / little-endian), otherwise parsing errors will occur. Furthermore, some PLC brands have different data block organization methods; for example, some models require floating-point number starting addresses to be aligned to 4 bytes, and improper configuration may cause data reading anomalies.
[0006] (2) Conversion and transmission based on string or fixed-point number format
[0007] In some applications, to avoid byte order compatibility issues, floating-point numbers are converted to ASCII strings or fixed-point integers (e.g., multiplying the decimal part by 100 and rounding down) for transmission. This method reduces the dependence on communication protocol data types, but increases the data volume (string representations typically occupy more bytes) and parsing computation overhead. Furthermore, the fixed-point conversion process itself introduces quantization errors, making it unsuitable for force control or precision positioning scenarios with high accuracy requirements.
[0008] (3) Custom data splitting and reorganization scheme
[0009] Some system integrators use a method of splitting 32-bit floating-point numbers into four bytes for separate transmission and then reassembling them on the PLC side. This method is highly flexible and adaptable to various communication interfaces, but it requires writing a dedicated parsing program on the PLC side. Furthermore, if the splitting rules (such as byte order and verification mechanisms) are not strictly defined, data restoration errors are prone to occur. In addition, existing splitting solutions focus primarily on the data transmission itself, with less attention paid to accuracy verification and anomaly handling mechanisms after the floating-point numbers are restored on the PLC side. Summary of the Invention
[0010] To address this, embodiments of the present invention provide a floating-point number integration method and system based on a PLC, thereby solving the technical problems of precision loss, low transmission efficiency, and poor compatibility caused by protocol differences and data format conversion when a six-axis robot transmits floating-point numbers to a PLC.
[0011] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0012] According to a first aspect of the present invention, a PLC-based floating-point number integration method is provided, the method comprising:
[0013] The robot acquires the floating-point data to be transmitted, performs a format check on the floating-point data to ensure that it conforms to the IEEE 754 standard, splits the floating-point data into an integer part and a fractional part, multiplies the fractional part by a preset amplification factor and rounds it to obtain an integerized fractional part, and uses the positive and negative identifiers of the floating-point data, the integer part and the integerized fractional part as the transmission data.
[0014] According to the EtherNet / IP communication protocol specification, the transmitted data is encapsulated and sent to the PLC via the Ethernet interface;
[0015] The PLC receives the transmitted data and verifies its integrity.
[0016] On the PLC side, a preset function block is called to convert the integer part into a first floating-point number, divide the integer-to-decimal part by the preset amplification factor to convert it into a second floating-point number, add the first floating-point number and the second floating-point number to obtain a third floating-point number, perform sign processing on the third floating-point number according to the positive and negative flags, and output the integrated floating-point number.
[0017] Furthermore, the preset amplification factor is 100, the integer part occupies two bytes, the integer-to-decimal part occupies two bytes, the positive / negative identifier occupies one bit in one byte, and the transmitted data occupies a total of five bytes.
[0018] Furthermore, if the floating-point data does not conform to the IEEE 754 standard, the format is converted to conform to the IEEE 754 standard before the splitting operation is performed.
[0019] Furthermore, the encapsulation includes adding a protocol header, a data length field, and a verification field.
[0020] Furthermore, the verification includes checking whether the number of data bytes is a preset value and checking whether the verification field is correct; if the verification fails, a retransmission request is sent to the robot.
[0021] Furthermore, the sign processing includes: if the positive / negative identifier is a first value, then the third floating-point number is multiplied by -1 to output the integrated floating-point number; if the positive / negative identifier is a second value, then the third floating-point number is directly output as the integrated floating-point number.
[0022] Furthermore, the method also includes:
[0023] The accuracy of the integrated floating-point number is verified by comparing it with the original floating-point number sent by the robot. If the difference exceeds a preset threshold, it is marked as abnormal data.
[0024] According to a second aspect of the present invention, a PLC-based floating-point integration system is provided, the system comprising:
[0025] The robot-side data processing module is used to acquire floating-point data to be transmitted, perform format checks on the floating-point data to ensure compliance with the IEEE 754 standard, split the floating-point data into an integer part and a fractional part, multiply the fractional part by a preset amplification factor and round it to obtain an integerized fractional part, and use the positive and negative identifiers of the floating-point data, the integer part and the integerized fractional part as the transmission data.
[0026] A communication protocol adaptation module is used to encapsulate the transmitted data according to the EtherNet / IP communication protocol specification;
[0027] The data transmission module is used to send the encapsulated transmission data to the PLC via an Ethernet interface;
[0028] The PLC-side data verification module is used to receive the transmitted data and verify the data integrity.
[0029] The PLC-side floating-point integration module is used to call a preset function block to convert the integer part into a first floating-point number, divide the integer-to-decimal part by the preset amplification factor to convert it into a second floating-point number, add the first floating-point number and the second floating-point number to obtain a third floating-point number, and perform sign processing on the third floating-point number according to the positive and negative identifier, and output the integrated floating-point number.
[0030] Furthermore, the robot-side data processing module is also used to perform format conversion when the floating-point data does not conform to the IEEE 754 standard.
[0031] Furthermore, the data transmission module is also used to receive a retransmission request from the PLC and resend the transmitted data when the data verification module at the PLC fails the verification.
[0032] The embodiments of the present invention have the following advantages:
[0033] This invention acquires the floating-point data to be transmitted on the robot side and performs IEEE 754 standard format checks. The floating-point number is split into an integer part and a fractional part. The fractional part is multiplied by a preset amplification factor and rounded down. This fractional part, along with a positive / negative identifier, is then transmitted as data. After encapsulation according to the EtherNet / IP protocol, the data is sent to the PLC via Ethernet. The PLC receives the data, performs integrity verification, calls a function block to convert the integer and fractional parts into floating-point numbers respectively, adds them together, performs sign processing according to the positive / negative identifier, and outputs the integrated floating-point number. This invention effectively avoids precision loss during transmission by splitting the floating-point number into five bytes for transmission and accurately restoring it on the PLC side, thus improving the data transmission efficiency and compatibility between the robot and the PLC. Attached Figure Description
[0034] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0035] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0036] Figure 1A schematic diagram of the logic structure of a PLC-based floating-point integrated system provided for an embodiment of the present invention;
[0037] Figure 2 A flowchart illustrating a PLC-based floating-point number integration method provided in an embodiment of the present invention;
[0038] Figure 3 A schematic diagram illustrating the declaration of program variables in a PLC-based floating-point number integration method provided in an embodiment of the present invention;
[0039] Figure 4 This is a schematic diagram illustrating the process of integrating a 5-byte integer into a floating-point number in a PLC-based floating-point number integration method provided in an embodiment of the present invention. Detailed Implementation
[0040] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] refer to Figure 1 This invention discloses a PLC-based floating-point number integration system, which includes: a robot-side data processing module 1; a communication protocol adaptation module 2; a data transmission module 3; a PLC-side data verification module 4; and a PLC-side floating-point number integration module 5.
[0042] Corresponding to the above-disclosed PLC-based floating-point number integration system, this invention also discloses a PLC-based floating-point number integration method. The following details a PLC-based floating-point number integration method disclosed in this invention, in conjunction with the above-described PLC-based floating-point number integration system.
[0043] refer to Figures 2 to 4 This invention discloses a floating-point number integration method based on PLC. The method involves acquiring floating-point data to be transmitted at the robot end, performing a format check on the floating-point data to ensure it conforms to the IEEE 754 standard, splitting the floating-point data into an integer part and a fractional part, multiplying the fractional part by a preset amplification factor and rounding it to obtain an integerized fractional part, and using the positive / negative identifier of the floating-point data, the integer part, and the integerized fractional part as the transmission data.
[0044] According to the EtherNet / IP communication protocol specification, the transmitted data is encapsulated and sent to the PLC via the Ethernet interface;
[0045] The PLC receives the transmitted data and verifies its integrity.
[0046] On the PLC side, a preset function block is called to convert the integer part into a first floating-point number, divide the integer-to-decimal part by the preset amplification factor to convert it into a second floating-point number, add the first floating-point number and the second floating-point number to obtain a third floating-point number, perform sign processing on the third floating-point number according to the positive and negative flags, and output the integrated floating-point number.
[0047] 1. Floating-point data acquisition and preprocessing
[0048] On the robot's end, the floating-point data that needs to be transmitted is acquired. This data can be collected by the robot's sensors or calculated by the robot's internal algorithms.
[0049] The acquired floating-point numbers are format-checked to ensure they conform to the IEEE 754 standard. If they do not conform to the standard, appropriate format conversion is performed to meet subsequent transmission requirements.
[0050] Depending on the PLC's data reception format and communication protocol requirements, floating-point numbers are split into multiple bytes of data. For example, a single-precision floating-point number (32-bit) is typically split into 4 bytes.
[0051] 2. Communication protocol adaptation
[0052] Determine that the PLC and robot use the EtherIP communication protocol.
[0053] According to the specifications of the selected communication protocol, the split byte data is encapsulated and transmitted.
[0054] 3. Data transmission
[0055] The packaged data is sent from the robot to the PLC via the communication interface.
[0056] 4. Data parsing and restoration
[0057] On the PLC side, after receiving the transmitted data, it first performs verification to check the integrity of the data.
[0058] According to the communication protocol and splitting rules, the received byte data is reassembled into floating-point numbers.
[0059] The accuracy of the restored floating-point number is verified to ensure that it is consistent with the original floating-point number sent by the KUKA robot.
[0060] Connect the PLC and the robot via Ethernet. Ensure a stable connection and that the electrical parameters meet the requirements.
[0061] 1. In the KUKA robot programming environment, write programs for data preprocessing and communication protocol adaptation. Implement functions for floating-point number format checking, splitting, and data encapsulation.
[0062] 2. Create a function block FC_Date to consolidate the data, splitting the floating-point number into two integers. The integer part of the floating-point number occupies two bytes, and the decimal part occupies two bytes. Additionally, floating-point numbers can be positive or negative, each occupying one bit of a byte. Therefore, after splitting the floating-point number, a total of 5 bytes are used.
[0063] 3. The program code is shown in Figure 3.
[0064] Figure 3 The code in the code declares program variables, where in1 represents the integer part of the robot data transmission, in2 represents the decimal part of the robot data transmission, and in3 represents the positive or negative sign of the robot data transmission.
[0065] refer to Figure 4 a:=INT_TO_REAL(in1);
[0066] This means converting the input value in1 from an integer to a floating-point number a.
[0067] b:=INT_TO_REAL(in2);
[0068] This means converting the input value in2 from an integer to a floating-point number b.
[0069] c:=a+b / 100;
[0070] The reason b / 100 is that the fractional part of the data is multiplied by 100 during transmission. Therefore, the fractional part needs to be divided by 100 here. The combined floating-point number c is then the floating-point number a plus the floating-point number b divided by 100. At this point, the floating-point number is the combined floating-point number, and the sign of the floating-point number does not need to be converted by the program.
[0071] IF in3=1 THEN
[0072] d:=c*-1;
[0073] ELSE
[0074] d:=c;
[0075] END_IF
[0076] The code above indicates that if the input `in3` is 1, the combined floating-point number will be negative. The output floating-point number `d` is equal to the floating-point number `c` multiplied by -1. Otherwise, the combined floating-point number will be positive, and the floating-point number `c` will be directly assigned to the floating-point number `d`.
[0077] out:=d;
[0078] The combined and positive / negative floating-point numbers are assigned to the variable out.
[0079] Once the above program is written, calling the function FC_Date in the program will convert a 5-byte integer into a floating-point number.
[0080] The present invention has the following beneficial effects:
[0081] 1. High-precision transmission: Through a rigorous format checking, splitting, and restoration process, the precision loss of floating-point numbers during transmission is effectively avoided, ensuring that the PLC can accurately obtain the status information of the KUKA robot, thereby improving the accuracy and stability of the production process.
[0082] 2. High-efficiency transmission: By adopting appropriate communication protocols and transmission strategies, the data transmission process has been optimized, transmission efficiency has been improved, and data latency has been reduced, enabling the PLC to make control decisions in a timely manner based on the latest robot data, thereby improving the response speed of the entire production system.
[0083] 3. Strong compatibility: The system supports a variety of common communication protocols and can be adapted to different models of KUKA robots and PLCs. It has good versatility and compatibility, reducing the difficulty and cost of system integration.
[0084] 4. High reliability: It is equipped with a retransmission mechanism and data verification function, which can promptly detect and correct errors in the transmission process, ensure the reliability of data transmission, and reduce production accidents caused by data transmission failures.
[0085] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. A floating-point number integration method based on PLC, characterized in that, The method includes: The robot acquires the floating-point data to be transmitted, performs a format check on the floating-point data to ensure that it conforms to the IEEE 754 standard, splits the floating-point data into an integer part and a fractional part, multiplies the fractional part by a preset amplification factor and rounds it to obtain an integerized fractional part, and uses the positive and negative identifiers of the floating-point data, the integer part and the integerized fractional part as the transmission data. According to the EtherNet / IP communication protocol specification, the transmitted data is encapsulated and sent to the PLC via the Ethernet interface; The PLC receives the transmitted data and verifies its integrity. On the PLC side, a preset function block is called to convert the integer part into a first floating-point number, divide the integer-to-decimal part by the preset amplification factor to convert it into a second floating-point number, add the first floating-point number and the second floating-point number to obtain a third floating-point number, perform sign processing on the third floating-point number according to the positive and negative flags, and output the integrated floating-point number.
2. The PLC-based floating-point number integration method as described in claim 1, characterized in that, The preset amplification factor is 100, the integer part occupies two bytes, the integer-to-decimal part occupies two bytes, the positive and negative identifier occupies one bit in one byte, and the transmitted data occupies a total of five bytes.
3. The PLC-based floating-point number integration method as described in claim 1, characterized in that, If the floating-point data does not conform to the IEEE 754 standard, the format is converted to conform to the IEEE 754 standard before the splitting operation is performed.
4. The PLC-based floating-point number integration method as described in claim 1, characterized in that, The encapsulation includes adding a protocol header, a data length field, and a verification field.
5. The PLC-based floating-point number integration method as described in claim 1, characterized in that, The verification includes checking whether the number of data bytes is a preset value and checking whether the verification field is correct; if the verification fails, a retransmission request is sent to the robot.
6. The PLC-based floating-point number integration method as described in claim 1, characterized in that, The symbol processing includes: if the positive / negative identifier is a first value, then the third floating-point number is multiplied by -1 and output as the integrated floating-point number; if the positive / negative identifier is a second value, then the third floating-point number is directly output as the integrated floating-point number.
7. The PLC-based floating-point number integration method as described in claim 1, characterized in that, The method further includes: The accuracy of the integrated floating-point number is verified by comparing it with the original floating-point number sent by the robot. If the difference exceeds a preset threshold, it is marked as abnormal data.
8. A PLC-based floating-point integrated system, characterized in that, The system includes: The robot-side data processing module is used to acquire floating-point data to be transmitted, perform format checks on the floating-point data to ensure compliance with the IEEE 754 standard, split the floating-point data into an integer part and a fractional part, multiply the fractional part by a preset amplification factor and round it to obtain an integerized fractional part, and use the positive and negative identifiers of the floating-point data, the integer part and the integerized fractional part as the transmission data. A communication protocol adaptation module is used to encapsulate the transmitted data according to the EtherNet / IP communication protocol specification; The data transmission module is used to send the encapsulated transmission data to the PLC via an Ethernet interface; The PLC-side data verification module is used to receive the transmitted data and verify the data integrity. The PLC-side floating-point integration module is used to call a preset function block to convert the integer part into a first floating-point number, divide the integer-to-decimal part by the preset amplification factor to convert it into a second floating-point number, add the first floating-point number and the second floating-point number to obtain a third floating-point number, and perform sign processing on the third floating-point number according to the positive and negative identifier, and output the integrated floating-point number.
9. A PLC-based floating-point integrated system as described in claim 8, characterized in that, The robot-side data processing module is also used to perform format conversion when the floating-point data does not conform to the IEEE 754 standard.
10. A PLC-based floating-point integrated system as described in claim 8, characterized in that, The data transmission module is also used to receive a retransmission request from the PLC and resend the transmitted data when the data verification module at the PLC fails the verification.