Data transmission method and system and computer readable storage medium

CN119356732APending Publication Date: 2025-01-24CHANGSHA SUNYE ELECTRIC CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310913731.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-24
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

During the communication between the host and the slave, the controller needs to frequently determine whether the resolved command is a slave-associated command, resulting in low data transmission efficiency.

Method used

By setting a pre-stored command set in the communication card, after the host configures the control command, the communication card directly selects the corresponding control command from the pre-stored command set and sends it to the slave machine without making any judgment.

Benefits of technology

It improves the data transmission efficiency between the host and the slave, shortens the communication time between the host and the slave, and increases the communication speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356732A_ABST
    Figure CN119356732A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and system and a computer readable storage medium. The method comprises the following steps: receiving instruction configuration information sent by a host; generating a target control instruction based on the instruction configuration information and a pre-stored instruction set; and sending the target control instruction to the slave to enable the slave to execute the target control instruction. The corresponding control instruction is selected from the pre-stored instruction set of the communication card to be sent, so that the data transmission efficiency between the host and the slave is improved, the communication time between the host and the slave is shortened, and the communication speed between the host and the slave is improved. Besides, control instructions required for controlling the slave are configured in the host, different types of control instructions are selected from the pre-stored instruction set, and the communication card automatically records the currently selected control instruction set and automatically sends the selected control instruction set to the slave, so that different interaction data are selected, and the interaction efficiency is improved. And the effect of switching different command instructions for different application scenes is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial communication technology, and in particular to a data transmission method, system and computer-readable storage medium. Background Art

[0002] Inverters are widely used in industries such as CNC machine tools and automobiles. As the host computer, it is necessary to communicate with the inverter of the slave through the industrial bus to achieve the host's control of the slave or the host reading the operating data of the slave.

[0003] In the process of communication between the host and the slave, the host first sends the control instruction to the communication card, and the protocol parsing module of the communication card parses the control instruction and sends the parsed command to the controller of the communication card. Furthermore, only when the controller determines that the command parsed by the protocol parsing module is a command associated with the slave application, will it encapsulate the command and send it to the slave, thereby realizing the communication interaction between the host and the slave.

[0004] However, since the controller needs to determine whether the parsed command is a command associated with the slave each time, and then send the encapsulated command to the slave, the data transmission efficiency is low. Summary of the invention

[0005] The embodiments of the present application provide a data transmission method, system and computer-readable storage medium to improve the data transmission efficiency between a host and a slave.

[0006] The embodiment of the present application provides a data transmission method, which is applied to a communication card, wherein a first interface of the communication card is connected to a slave, and a second interface of the communication card is connected to a host. The data transmission method includes:

[0007] Receive command configuration information sent by the host;

[0008] Generate a target control instruction based on the instruction configuration information and a pre-stored instruction set;

[0009] The target control instruction is sent to the slave machine, so that the slave machine executes the target control instruction.

[0010] Optionally, the step of generating a target control instruction based on the instruction configuration information and a pre-stored instruction set includes:

[0011] A target control instruction matching the instruction configuration information is selected from the pre-stored instruction set.

[0012] Optionally, the step of selecting a target control instruction matching the instruction configuration information from the pre-stored instruction set includes:

[0013] Determine the instruction attribute, instruction type and instruction sequence number according to the instruction configuration information;

[0014] A target control instruction matching the instruction attribute, the instruction type and the instruction sequence number is selected from the pre-stored instruction set.

[0015] Optionally, after the step of generating a target control instruction based on the instruction configuration information and a pre-stored instruction set, the method further includes:

[0016] When the target control instruction includes a custom control instruction and a standard control instruction, combining and packaging the custom control instruction and the standard control instruction;

[0017] Send the encapsulated target control command to the slave.

[0018] Optionally, after the step of generating a target control instruction based on the instruction configuration information and a pre-stored instruction set, the method further includes:

[0019] Acquire the current data format of the target control instruction;

[0020] When the current data format is inconsistent with the target data format, converting the current data format of the target control instruction into the target data format, and sending the target control instruction after the data format conversion to the slave;

[0021] When the current data format is consistent with the target data format, the step of sending the target control instruction to the slave is performed.

[0022] Optionally, the step of converting the current data format of the target control instruction into the target data format includes:

[0023] When the current data format is the first data format, splitting the data corresponding to the target control instruction into target data corresponding to the target data format;

[0024] When the current data format is the second data format, the data corresponding to the target control instruction and the preset data are merged into target data corresponding to the target data format.

[0025] Optionally, after the step of generating a target control instruction based on the instruction configuration information and a pre-stored instruction set, the method further includes:

[0026] Determining a target address of the target control instruction, and determining the number and value of control parameters according to the target control instruction;

[0027] Encapsulating the target address, the quantity and the control parameter value;

[0028] The encapsulated data is sent to the slave device.

[0029] Optionally, the data transmission method further includes:

[0030] When the slave receives the operation data corresponding to the target control instruction, the slave forwards the operation data to the host.

[0031] In addition, to achieve the above object, the present invention also provides a data transmission system, comprising:

[0032] A host, the host is used to configure the instruction configuration information and send the instruction configuration information to the communication card;

[0033] A communication card for connecting the host and the slave, the communication card is used to receive instruction configuration information sent by the host; generate a target control instruction based on the instruction configuration information and a pre-stored instruction set; and send the target control instruction to the slave so that the slave executes the target control instruction;

[0034] A slave machine receives the target control instruction and executes the target control instruction.

[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a data transmission program is stored, and when the data transmission program is executed by a processor, the steps of the above-mentioned data transmission method are implemented.

[0036] A technical solution of a data transmission method, system and computer-readable storage medium provided in the embodiment of the present application, after receiving the command configuration information sent by the host, the communication card generates a target control instruction according to the pre-stored instruction set, and then sends the generated target control instruction to the slave. Compared with the related art, the controller of the communication card needs to determine whether the parsed command is a command associated with the slave each time, and then send the packaged command to the slave. Since the present application sets a pre-stored instruction set in the communication card, the host has configured the control instructions required to control the slave, and the corresponding control instruction is selected from the pre-stored instruction set of the communication card to send, without judgment, thereby improving the data transmission efficiency between the host and the slave, shortening the communication time between the host and the slave, and improving the communication speed between the host and the slave. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of a flow chart of a first embodiment of a data transmission method of the present invention;

[0038] Figure 2 It is a schematic diagram of data transmission in the prior art of the present invention;

[0039] Figure 3 This is a schematic diagram of data transmission according to the present invention;

[0040] Figure 4 Another data transmission schematic diagram of the present invention;

[0041] Figure 5 This is another data transmission schematic diagram of the present invention.

[0042] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. The above-mentioned drawings are only an embodiment diagram, not the entire invention. DETAILED DESCRIPTION

[0043] At present, in the communication process between the host and the slave, the host first sends the control instruction to the communication card, and the protocol parsing module of the communication card parses the control instruction and sends the parsed command to the controller of the communication card. Furthermore, only when the controller determines that the command parsed by the protocol parsing module is a command associated with the slave application, will it encapsulate the command and send it to the slave, thereby realizing the communication interaction between the host and the slave. However, since the controller needs to determine whether the parsed command is a command associated with the slave each time, and then send the encapsulated command to the slave, the data transmission efficiency is low.

[0044] Therefore, in order to solve the technical problem of low data transmission efficiency, the present application proposes a new data transmission method, including receiving instruction configuration information sent by the host; generating a target control instruction based on the instruction configuration information and a pre-stored instruction set; and sending the target control instruction to the slave, so that the slave executes the target control instruction. Specifically, after receiving the instruction configuration information sent by the host, the communication card generates a target control instruction according to the pre-stored instruction set, and then sends the generated target control instruction to the slave. Compared with the related art, the controller of the communication card needs to determine whether the parsed command is a command associated with the slave each time, and then send the packaged command to the slave. Since the present application sets a pre-stored instruction set in the communication card, when the host has configured the control instruction required to control the slave, the corresponding control instruction is selected from the pre-stored instruction set of the communication card and sent, without judgment, thereby improving the data transmission efficiency between the host and the slave, shortening the communication time between the host and the slave, and improving the communication speed between the host and the slave.

[0045] Secondly, in the existing technical solutions, for slave machines such as frequency converters, a single function code is often used to control the start and stop operation of the frequency converter. However, in fact, in addition to satisfying simple speed control, there are often more application scenarios that require the use of some complex control methods. Therefore, in order to satisfy both simple and complex application scenarios, multiple command instructions are required to complete.

[0046] Therefore, in order to realize the control of slaves in complex application scenarios, the present application pre-stores multiple control instructions in the communication card. In different application scenarios, the control instructions required are different. Therefore, after the host has configured the control instructions required to control the slave, different types of control instructions are selected from the pre-stored instruction set. The communication card automatically records the currently selected control instruction set and automatically sends the selected control instruction set to the slave, so that subsequent data transmission can correspond to the selected control instruction set. This achieves the effect of selecting different interactive data and switching different command instructions for different application scenarios.

[0047] Next, for the large amount of data interaction of the slave, the industrial communication protocol often adopts the method of small amount of data and high frequency interaction to update a large number of parameters. However, in fact, the bandwidth between the host and the communication card is relatively large, so exchanging the data of one parameter at a time cannot fully utilize the bandwidth. For example, refer to Figure 2 Assuming that the host and the communication card need to exchange 10 parameter values, then the host and the communication card, as well as the communication card and the slave, need to exchange data 10 times through the preset interface, each time exchanging 1 parameter data. In this case, the bandwidth is not fully utilized, resulting in a waste of resources.

[0048] Therefore, in order to fully utilize bandwidth and avoid wasting bandwidth resources, this application adopts a method of large-scale data interaction with low frequency to occupy the bandwidth and complete the transmission of large amounts of data. By customizing special data interaction instructions or indexes, multiple parameter data can be interacted through one data frame, thereby improving bandwidth utilization and reducing interaction frequency.

[0049] Finally, since the interactive data format is often not unified, for example, the data format of standard control instructions is different from that of custom control instructions, data transmission in different data formats cannot be supported.

[0050] Therefore, in order to support data transmission in different data formats, the present application automatically splits or assembles them into a unified data format for interaction according to the different data format sizes, and waits until the transmitted data reaches the slave or communication card, and then reversely decodes the correct data value according to the splitting and splicing rules.

[0051] In order to better understand the above technical solution, exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0052] like Figure 1As shown, in the first embodiment of the present application, the data transmission method of the present application includes the following steps:

[0053] Step S110, receiving instruction configuration information sent by the host.

[0054] Optionally, the host can be a host computer such as a computer, a mobile phone or other intelligent terminal device, or an embedded device or other terminal device. The host is provided with a second interface, and the host is connected to the second interface of the communication card through the second interface, and the second interface of the communication card includes an RS485 communication interface, a CAN communication interface or an Ethernet communication interface. The corresponding communication mode between the host and the communication card can be RS485 communication, CAN communication or Ethernet communication, etc. This application takes the host as an example of a host computer.

[0055] Optionally, a control application of the slave is installed on the host computer, and a configuration interface of the control instructions of the slave can be displayed on the host computer. The control instructions required by the slave are configured based on the displayed configuration interface of the control instructions to obtain instruction configuration information.

[0056] Optionally, when the slave needs to be controlled, the control instruction can be configured in the configuration interface of the control instruction, and the instruction configuration information is sent to the communication card, so that the communication card can receive the instruction configuration information sent by the host. Further, the control instruction required by the current slave or all the control instructions required in the future can also be configured on the host computer. After the configuration is completed, the instruction configuration information corresponding to the control instruction required by the current slave or the instruction configuration information corresponding to the control instruction required by the slave in the future is sent to the communication card, so that the communication card can receive the instruction configuration information sent by the host, thereby achieving the effect of the host sending the instruction configuration information in real time, and realizing the real-time control of the slave. Further, the control instruction required by the current slave or all the control instructions required in the future can also be configured in advance on the host computer. When the preset time is reached, the instruction configuration information corresponding to the control instruction required by the current slave or the instruction configuration information corresponding to the control instruction required by the slave in the future is sent to the communication card, so that the communication card can receive the instruction configuration information sent by the host, thereby achieving the effect of the host sending the instruction configuration information regularly, and realizing the timing control of the slave.

[0057] Optionally, when receiving feedback information from the slave, the corresponding instruction configuration information can be automatically matched based on the feedback information of the slave, and the matched instruction configuration information can be sent to the communication card, so that the communication card can receive the instruction configuration information sent by the host, and then determine the next control strategy for the slave based on the feedback information of the slave, thereby realizing intelligent control of the slave by the host.

[0058] Optionally, the instruction configuration information is used to characterize the relevant information of which control instruction is currently required by the slave. For example, the instruction configuration information includes but is not limited to one or more combinations of instruction attributes, instruction types, and instruction sequence numbers.

[0059] Step S120: generating a target control instruction based on the instruction configuration information and a pre-stored instruction set.

[0060] Optionally, a communication card has pre-stored instruction sets, i.e., pre-stored instruction sets. The pre-stored instruction sets may be fixed at the factory or updated according to actual needs. For example, when the connected slave changes or the function of the slave is upgraded, in order to be able to control the upgraded slave, the pre-stored instruction sets in the communication card should also be upgraded and changed to adapt to different models of slaves or to effectively control the newly added functions of the slave.

[0061] Optionally, the target control instruction may be one or more, and when there are multiple target control instructions, it is a combined control instruction. The target control instruction may be one setting multiple custom control instructions, one or more standard control instructions, or a combination of one or more custom control instructions and one or more standard control instructions.

[0062] Step S130: sending the target control instruction to the slave machine, so that the slave machine executes the target control instruction.

[0063] Optionally, the slave may be a frequency converter or other equipment. The slave is provided with a first interface, through which the slave is connected to the first interface of the communication card, and the first interface of the slave and the first interface of the communication card may be an SPI interface, a UART interface, a CAN interface, an Ethernet interface, etc. The corresponding communication mode between the slave and the communication card may be SPI communication, RS485 communication, CAN communication, or Ethernet communication, etc.

[0064] Optionally, the target control instruction can be sent to the slave machine in a scheduled or real-time manner, or the target control instruction can be sent to the slave machine when a request from the slave machine is received. When the slave machine receives the target control instruction, it performs the operation corresponding to the target control instruction. For example, when the target control instruction is a start control instruction, the slave machine starts the slave machine when it receives the start control instruction. When the target control instruction is an acceleration control instruction, the slave machine increases the running speed of the slave machine when it receives the acceleration control instruction.

[0065] For example, Figure 4As shown, the command configuration information to be used is first selected through the host computer software, and the selected command configuration information is sent to the communication card through the second interface. The communication card automatically saves the selected command configuration information, and the communication card and the slave transmit information through the first interface. Through the selector channel of the first interface, the communication card automatically sends the control instruction corresponding to the command configuration information selected by the host computer to the slave, and the slave saves this information to ensure that the data value of the subsequent interaction corresponds to the information specified by the command configuration information.

[0066] The command configuration information can be switched freely to adapt to different application scenarios. Figure 4 As shown, you can select custom instruction 1, or custom instruction 2, or standard instruction 1 specified by certain industry regulations, or standard instruction 2 specified by certain industry regulations, or even a combination of custom instruction sets and standard instructions specified by industry regulations. The selector channel automatically transmits the information of these freely selected instruction sets, and the slave will save them after receiving them. It is this method of freely selecting instruction sets that can increase the use scenarios of terminal devices and enhance their adaptability. For example, if you select control state instruction sets such as 0x1000 and 0x1100, you can control the slave to do simple speed mode and speed feedback. If you select control state instruction sets such as 0x2000 and 0x2100, you can control the slave to do speed mode and speed feedback, or position mode and position feedback, or torque mode and torque feedback. If you select control state instruction sets such as 0x6040 and 0x6041, you can measure and control the slave according to the industry definition of canopen402.

[0067] In other embodiments, the host can also obtain the operating data of the slave when receiving the response information of the slave based on the target control instruction, so as to monitor the operating condition of the slave. The operating data of the slave can be operating temperature, operating speed or other. Alternatively, the slave can feed back the operating data to the host in real time, so that the host can monitor the operating condition of the slave in real time and re-determine the corresponding control instruction according to the operating condition of the slave.

[0068] According to the above technical solution, this embodiment receives the instruction configuration information sent by the host; generates the target control instruction based on the instruction configuration information and the pre-stored instruction set; and sends the target control instruction to the slave so that the slave executes the target control instruction. Specifically, after receiving the instruction configuration information sent by the host, the communication card generates the target control instruction according to the pre-stored instruction set, and then sends the generated target control instruction to the slave. Compared with the related art, the controller of the communication card needs to determine whether the parsed command is a command associated with the slave each time, and then send the packaged command to the slave. Since the present application sets a pre-stored instruction set in the communication card, when the host has configured the control instructions required to control the slave, the corresponding control instruction is selected from the pre-stored instruction set of the communication card and sent, without judgment, thereby improving the data transmission efficiency between the host and the slave, shortening the communication time between the host and the slave, and improving the communication speed between the host and the slave.

[0069] Further, based on the first embodiment, in the second embodiment of the present application, step S120 further includes the following steps:

[0070] Step S121, selecting a target control instruction matching the instruction configuration information from the pre-stored instruction set.

[0071] Optionally, the pre-stored instruction set includes all control instructions that may be needed by the slave connected to the communication card, including control instructions of different instruction types, different instruction attributes and different instruction numbers. The instruction configuration information is not limited to one or more combinations of instruction attributes, instruction types, and instruction numbers. When the instruction configuration information includes instruction attributes, instruction types and instruction numbers, each instruction attribute includes control instructions of multiple instruction types with different instruction types, and each control instruction has a corresponding instruction number for uniquely identifying the control instruction, or each control instruction has a corresponding instruction number under each instruction attribute. Among them, the instruction attributes include custom attributes and industry standard attributes, and the instruction types include but are not limited to speed control instruction types, position control instruction types, start-stop control instruction types, etc. For example, custom attributes include custom speed control instruction types, position control instruction types, start-stop control instruction types, etc., and industry standard attributes include standard speed control instruction types, position control instruction types, start-stop control instruction types, etc. For example, under custom attributes, there is a custom speed control instruction 1. Under industry standard attributes, there is a standard speed control instruction 1.

[0072] Optionally, at least one of the instruction attribute, instruction type and instruction serial number can be determined according to the instruction configuration information; and a target control instruction matching at least one of the instruction attribute, the instruction type and the instruction serial number can be selected from a pre-stored instruction set. Specifically, the instruction attribute is determined according to the instruction configuration information; and a target control instruction matching the instruction attribute is selected from a pre-stored instruction set. Alternatively, the instruction type is determined according to the instruction configuration information; and a target control instruction matching the instruction type is selected from the pre-stored instruction set. Alternatively, the instruction attribute and instruction type are determined according to the instruction configuration information; and a target control instruction matching the instruction attribute and the instruction type is selected from the pre-stored instruction set. Alternatively, the instruction attribute, instruction type and instruction serial number are determined according to the instruction configuration information; and a target control instruction matching the instruction attribute, the instruction type and the instruction serial number is selected from the pre-stored instruction set, etc.

[0073] Furthermore, a first control instruction corresponding to custom attributes and / or industry standard attributes can be determined from a pre-stored instruction set of the communication card, and a control instruction set can be generated. From the control instruction set, a second control instruction corresponding to the instruction type and instruction sequence number can be determined, and the second control instruction can be determined as the target control instruction.

[0074] According to the above technical solution, in order to realize the control of slaves in complex application scenarios, this embodiment pre-stores multiple control instructions in the communication card. In different application scenarios, the control instructions required are different. Therefore, after the host has configured the control instructions required to control the slave, different types of control instructions are selected from the pre-stored instruction set. The communication card automatically records the currently selected control instruction set and automatically sends the selected control instruction set to the slave, so that the subsequent data transmission can correspond to the selected control instruction set. This achieves the effect of selecting different interactive data and switching different command instructions for different application scenarios.

[0075] Further, based on the first embodiment or the second embodiment, in the third embodiment of the present application, after step S120, the following steps are further included:

[0076] Step S210, when the target control instruction includes a custom control instruction and a standard control instruction, combining and packaging the custom control instruction and the standard control instruction;

[0077] Step S220, sending the packaged target control instruction to the slave device.

[0078] Optionally, when the target control instructions include multiple ones, the multiple target control instructions need to be encapsulated and packaged before being sent. On the one hand, this improves the data transmission efficiency. On the other hand, the slave machine needs to be controlled by different control instructions to realize the corresponding functions. This enables the slave machine to receive all the control instructions at the same time and perform corresponding control, thereby improving the control efficiency of the slave machine.

[0079] Further, based on any embodiment of the first embodiment to the third embodiment, in the fourth embodiment of the present application, after step S120, the following steps are further included:

[0080] Step S310, obtaining the current data format of the target control instruction;

[0081] When the current data format is inconsistent with the target data format, step S320 is executed to convert the current data format of the target control instruction into the target data format, and send the target control instruction after the data format conversion to the slave.

[0082] When the current data format is consistent with the target data format, step S130 is executed to send the target control instruction to the slave.

[0083] Optionally, the target data format is determined according to the type of communication card, and the types of communication cards include Modbus (Modicon's BUS, Modbus communication protocol) type, CanOPEN (Controller Area Network, architecture in control local area network) type or EtherCat (Ethernet for Control Automation Technology, Ethernet control automation technology) type, etc., and the target data formats corresponding to different types are different. For example, the data format of Modbus is to transmit 16 bits of data, so if the data format corresponding to the determined control instruction is not 16 bits of data, it needs to be converted to 16 bits before the target control instruction can be sent to the slave. When the slave receives the 16 bits of target control instruction, it can reversely decode the correct data value according to the rules of splitting and piecing together to obtain the corresponding target control instruction. It should be noted that the target control instruction of this application includes standard control instructions and custom control instructions. Since the data formats of standard control instructions and custom control instructions are different, data format conversion is required, and in the related art, since there is no combination of different control instructions, there is no need for data format conversion.

[0084] Optionally, when the current data format is inconsistent with the target data format, the step of converting the current data format of the target control instruction into the target data format includes: when the current data format is inconsistent with the target data format, determining a data format conversion method for the target control instruction; and based on the data format conversion method, converting the current data format of the target control instruction into the target data format. The data format conversion method may be splitting or merging.

[0085] Optionally, when the current data format is the first data format, the data format conversion method of the target control instruction is determined to be split into target data corresponding to the target control instruction; when the current data format is the second data format, the data format conversion method of the target control instruction is determined to be merged into the target data corresponding to the target control instruction and preset data. Specifically, when the current data format is the first data format, the data corresponding to the target control instruction is split into target data corresponding to the target data format; when the current data format is the second data format, the data corresponding to the target control instruction and preset data are merged into target data corresponding to the target data format. The preset data may be 0x00.

[0086] Specifically, refer to Figure 5 Because it is necessary to switch different control instructions for data interaction, the data formats corresponding to different instruction states are inevitably different, such as 8 bits, 16 bits, 32 bits, etc. The data format of Modbus is to transmit 16 bits of data. In order to be compatible with the Modbus format and transmit non-16 bits of data, the splicing and splitting method is adopted to split the 32 bits of data into 2 16 bits of data transmission. After transmitting to the slave, the slave will piece it together into a complete 32 bits of data; for 8 bits of data, it is pieced together into 16 bits of data, and the upper 8 bits are replaced by 0. After transmitting to the slave, the slave will strip the upper 8 bits to get the real 8 bits of data.

[0087] According to the above technical solution, this embodiment automatically splits or assembles different data formats into a unified data format for interaction according to different data format sizes, and waits until the transmitted data reaches the slave or communication card, and then reversely decodes the correct data value according to the splitting and splicing rules.

[0088] Further, based on any embodiment of the first embodiment to the fourth embodiment, in the fifth embodiment of the present application, after step S120, the following steps are further included:

[0089] Step S410, determining a target address of the target control instruction, and determining the number and value of control parameters according to the target control instruction;

[0090] Step S420, encapsulating the target address, the quantity and the control parameter value;

[0091] Step S430, sending the packaged data to the slave device.

[0092] Optionally, the target address is the address value of the parameter to be read or written, the number of control parameters is the number of parameters to be read or written, and the control parameter value is the data value of the Nth parameter to be read or written, where N can be one or more.

[0093] like Figure 2 As shown in the figure, the host and the communication card need to exchange the values ​​of 10 parameters. Therefore, the host and the communication card, as well as the communication card and the slave, need to exchange data 10 times through the preset interface, each time exchanging the data of one parameter. However, in fact, the bandwidth between the host and the communication card is relatively large, so exchanging the data of one parameter at a time cannot fully utilize the bandwidth. At this time, we can customize an instruction or index value and give it a specific meaning and data format, as shown in Table 1 below. For example, if 0x5500 is given a specific meaning and data format, the meaning of 0x5500 is the reading and writing of multiple parameters. The data format is the address value of the parameter to be read and written -> the number of parameters to be read and written -> the data value of the first parameter to be read and written -> the data value of the second parameter to be read and written -> the data value of the third parameter to be read and written -> the data value of the fourth parameter to be read and written -> the data value of the fifth parameter to be read and written -> the data value of the sixth parameter to be read and written -> the data value of the seventh parameter to be read and written ->…. With this setting, Figure 3 As shown in the figure, multiple parameters can be exchanged between the host and the communication card in one frame. The host sends this specific instruction to let the communication card get the information of multiple variables in one exchange. Then the communication card transmits the information to the slave and also exchanges multiple data in one frame. This reduces the number of exchanges but increases the amount of data in one exchange.

[0094] Table 1

[0095]

[0096]

[0097] According to the above technical solution, in order to fully utilize bandwidth and avoid wasting bandwidth resources, this application adopts a method of large-volume and low-frequency interaction to occupy bandwidth and complete the transmission of large amounts of data. By customizing special data interaction instructions or indexes, multiple parameter data can be interacted through one data frame, thereby improving bandwidth utilization and reducing interaction frequency.

[0098] The embodiments of the present invention provide embodiments of the data transmission method. It should be noted that although the logical order is shown in the flow chart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0099] like Figure 4 As shown, Figure 4 Schematic diagram of the structure of the data transmission system provided by the present invention. Figure 4 As shown, the data transmission system includes a communication card, a host and a slave, and each slave is connected to a corresponding communication card. The number of slaves can be one or more. The connection method between each slave and the communication card is as follows Figure 4 As shown. The slave also includes a first interface, the communication card is provided with a first interface and a second interface, and the host is provided with a second interface. The slave is connected to the first interface of the communication card through the first interface, and the host is connected to the second interface of the communication card through the second interface, so that the host can establish a connection relationship between the communication card and the slave, thereby realizing data transmission between the host and the slave, realizing the host's control over the slave, and the slave feeding back operating data to the host.

[0100] Optionally, the first interface of the slave and the first interface of the communication card can be an SPI interface, a UART interface, a CAN interface, an Ethernet interface, etc. The second interface of the communication card includes an RS485 communication interface, a Can communication interface or an Ethernet communication interface. The type of the corresponding communication bus between the host and the communication card can be RS485 or CAN or Ethernet communication.

[0101] Optionally, the communication card includes a plurality of different types of communication cards, specifically, the types of communication cards include Modbus (Modicons BUS, Modbus communication protocol) type, CanOPEN (Controller Area Network, architecture in control local area network) type or EtherCat (Ethernet for Control Automation Technology, Ethernet control automation technology) type, etc. Different types correspond to different ID numbers, and the ID numbers are used to mark different types of communication cards. Alternatively, the same communication card includes a plurality of different types of communication second interfaces.

[0102] Optionally, a selector channel is also provided at the first interface of the communication card. The communication card will match the command configuration information sent by the host with the corresponding control command, and automatically send it to the slave through the selector channel, and the slave will save this information to ensure that the data value of the subsequent interaction corresponds to the information specified by the command status set.

[0103] Optionally, the host is used to configure instruction configuration information and send the instruction configuration information to the communication card;

[0104] A communication card for connecting the host and the slave, the communication card is used to receive instruction configuration information sent by the host; generate a target control instruction based on the instruction configuration information and a pre-stored instruction set; and send the target control instruction to the slave so that the slave executes the target control instruction.

[0105] Optionally, the communication card is used to select a target control instruction matching the instruction configuration information from the pre-stored instruction set.

[0106] Optionally, the communication card is used to determine instruction attributes, instruction type and instruction serial number according to the instruction configuration information; and select a target control instruction that matches the instruction attributes, the instruction type and the instruction serial number from the pre-stored instruction set.

[0107] Optionally, the communication card is used for combining and packaging the custom control instruction and the standard control instruction when the target control instruction includes the custom control instruction and the standard control instruction; and sending the packaged target control instruction to the slave.

[0108] Optionally, the communication card is used to obtain the current data format of the target control instruction; when the current data format is inconsistent with the target data format, the current data format of the target control instruction is converted into the target data format, and the target control instruction after the data format conversion is sent to the slave; when the current data format is consistent with the target data format, the step of sending the target control instruction to the slave is executed.

[0109] Optionally, the communication card is used to split the data corresponding to the target control instruction into target data corresponding to the target data format when the current data format is the first data format; when the current data format is the second data format, merge the data corresponding to the target control instruction and preset data into target data corresponding to the target data format.

[0110] Optionally, the communication card is used to determine the target address of the target control instruction, and determine the number and control parameter values ​​of control parameters according to the target control instruction; encapsulate the target address, the number and the control parameter value; and send the encapsulated data to the slave.

[0111] Optionally, the communication card is used to forward the operating data to the host when the operating data corresponding to the target control instruction is received from the slave.

[0112] A slave machine receives the target control instruction and executes the target control instruction.

[0113] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which stores a data transmission program. When the data transmission program is executed by a processor, it implements the various steps of the data transmission method described above and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0114] Since the storage medium provided in the embodiments of the present application is the storage medium used to implement the method of the embodiments of the present application, based on the method introduced in the embodiments of the present application, the person skilled in the art can understand the specific structure and deformation of the storage medium, so it is not repeated here. All storage media used in the methods of the embodiments of the present application belong to the scope of protection of this application.

[0115] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0116] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0117] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, TV, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0118] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A data transmission method, characterized in that: Applied to a communication card, wherein the first interface of the communication card is connected to a slave, and the second interface of the communication card is connected to a host, the data transmission method comprises: Receive command configuration information sent by the host; Determine a target control instruction based on the instruction configuration information and a pre-stored instruction set, wherein the pre-stored instruction set is pre-stored in the communication card, and the pre-stored instruction set includes a plurality of control instructions; The target control instruction is sent to the slave machine through the selector channel of the communication card, so that the slave machine executes the target control instruction.

2. The data transmission method according to claim 1, characterized in that: The step of determining the target control instruction based on the instruction configuration information and the pre-stored instruction set includes: A target control instruction matching the instruction configuration information is selected from the pre-stored instruction set.

3. The data transmission method according to claim 2, characterized in that: The step of selecting a target control instruction matching the instruction configuration information from the pre-stored instruction set comprises: Determine the instruction attribute, instruction type and instruction sequence number according to the instruction configuration information; A target control instruction matching the instruction attribute, the instruction type and the instruction sequence number is selected from the pre-stored instruction set.

4. The data transmission method according to claim 1, characterized in that: After the step of determining the target control instruction based on the instruction configuration information and the pre-stored instruction set, the method further includes: When the target control instruction includes a custom control instruction and a standard control instruction, combining and packaging the custom control instruction and the standard control instruction; Send the encapsulated target control command to the slave.

5. The data transmission method according to claim 1, characterized in that: After the step of determining the target control instruction based on the instruction configuration information and the pre-stored instruction set, the method further includes: Acquire the current data format of the target control instruction; When the current data format is inconsistent with the target data format, converting the current data format of the target control instruction into the target data format, and sending the target control instruction after the data format conversion to the slave; When the current data format is consistent with the target data format, the step of sending the target control instruction to the slave is performed.

6. The data transmission method according to claim 5, characterized in that: The step of converting the current data format of the target control instruction into the target data format comprises: When the current data format is the first data format, splitting the data corresponding to the target control instruction into target data corresponding to the target data format; When the current data format is the second data format, the data corresponding to the target control instruction and the preset data are merged into target data corresponding to the target data format.

7. The data transmission method according to claim 1, characterized in that: After the step of determining the target control instruction based on the instruction configuration information and the pre-stored instruction set, the method further includes: Determining a target address of the target control instruction, and determining the number and value of control parameters according to the target control instruction; Encapsulating the target address, the quantity and the control parameter value; The encapsulated data is sent to the slave device.

8. The data transmission method according to claim 1, characterized in that: The data transmission method further comprises: When the slave receives the operation data corresponding to the target control instruction, the slave forwards the operation data to the host.

9. A data transmission system, characterized in that: The data transmission system comprises: A host, the host is used to configure the instruction configuration information and send the instruction configuration information to the communication card; A communication card for connecting the host and the slave, the communication card is used to receive instruction configuration information sent by the host; based on the instruction configuration information and a pre-stored instruction set, a target control instruction is determined, the pre-stored instruction set is pre-stored in the communication card, and the pre-stored instruction set includes a plurality of control instructions, and the target control instruction is sent to the slave through the selector channel of the communication card, so that the slave executes the target control instruction; A slave machine receives the target control instruction and executes the target control instruction.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data transmission program, and when the data transmission program is executed by a processor, the steps of the data transmission method according to any one of claims 1 to 8 are implemented.