A data transmission method, system and device of a host computer and a PLC and a storage medium
By establishing a transmission channel between the host computer and the PLC device and performing address encoding processing, the problem of accurate response results of PLC devices under the control of multiple host computers was solved, communication stability and error identification were achieved, and the system's debugging and maintenance efficiency was improved.
Patent Information
- Application Number
- CN202111630784.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2041-12-28
AI Technical Summary
When multiple host computers control a single PLC device simultaneously, the PLC device needs to respond to the control commands of each host computer and return the response results to the matching host computer. In the existing technology, it is difficult to determine the accuracy of the response results, which may lead to erroneous response commands being sent directly to the host computer.
By establishing a transmission channel for control commands and response commands, address encoding is performed and processed using algorithms to generate fourth address encoded data to match the third address encoded data, ensuring the accuracy of communication between the PLC device and the host computer. Binary and prime number encoding are used to improve correlation and detect and correct errors.
It enables accurate judgment of PLC device response results and identification of errors by the host computer, improves communication stability and maintenance efficiency, reduces the sending of error response commands, and facilitates debugging and maintenance.
Smart Images

Figure CN114443136B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data transmission, and in particular to a data transmission method, system and device for an upper computer and a PLC (Programmable Logic Controller), and a storage medium. BACKGROUND
[0002] The programmable controller PLC (Programmable Logic Controller) is an electronic system designed for digital operation in an industrial environment. It mainly reads the states of external input signals such as buttons, sensors, switches and pulses, and according to the states or values of these input signals and the internal stored pre-written program, it executes logic, sequence, timing, counting and arithmetic operations by a microprocessor to generate corresponding output signals such as relay switches and control mechanical equipment operation. The program and the status of the monitoring device can be easily edited / modified by a computer for on-site program maintenance and commissioning adjustment.
[0003] The programmable controller PLC is widely used in industrial automation control due to its safety and reliability, strong anti-interference ability, high cost performance and simple programming. In industrial automation control, the PLC is often used to monitor field devices, and real-time collection and management of data information of the field devices are required.
[0004] In related technologies, the PLC device is generally monitored and controlled by an upper computer. The upper computer is a computer used in industrial control, and its main function is to monitor and control the running status of each device. When a problem occurs, it can be reflected on the display screen, which facilitates timely discovery of problems and gives corresponding solutions, thereby playing a role in control management and decision-making. The upper computer transmits control instructions to the PLC, which then judges the correctness of the instructions and returns the judgment result to the upper computer, thereby realizing communication between the two and executing the most accurate operation instructions through joint judgment, thereby enhancing the actual working effect of the control system.
[0005] However, when multiple upper computers simultaneously control a PLC device with different functions, the PLC device needs to respond to the control instructions of each upper computer and return the response results to the matching upper computer. Therefore, it is necessary to determine whether the result of returning the response results of the PLC device to the matching upper computer is accurate, and improvement is needed. SUMMARY
[0006] In order to facilitate the determination of whether the result of returning the response results of the PLC device to the matching upper computer is accurate, the present application provides a data transmission method, system and device for an upper computer and a PLC, and a storage medium.
[0007] In a first aspect, the application provides a data transmission method for a host computer and a PLC, which adopts the following technical scheme:
[0008] A data transmission method for a host computer and a PLC device, comprising the following steps:
[0009] Obtaining control instructions sent by each host computer to the PLC device;
[0010] Establishing a control instruction transmission channel, storing each control instruction in the control instruction transmission channel, and encoding the address of the control instruction transmission channel to obtain first address code data;
[0011] The PLC device obtains each control instruction in the instruction transmission channel and sends a response instruction to each host computer;
[0012] Establishing a response instruction transmission channel, storing each response instruction in the response instruction transmission channel, and encoding the address of the response instruction transmission channel to obtain second address code data;
[0013] Obtaining and storing the address of the host computer and encoding it to obtain third address code data;
[0014] Obtaining and storing data information of the first address code data and the second address code data, and performing data processing on the first address code data and the second address code data based on a relevant algorithm to output fourth address code data;
[0015] Judging whether the third address code data and the fourth address code data are the same, if they are the same, the response instruction matches the control instruction; if they are not the same, the response instruction does not match the control instruction.
[0016] By adopting the technical scheme, the control instructions sent by each host computer to the PLC device are stored in the control instruction transmission channel, and the response instructions sent by the PLC device are stored in the response instruction transmission channel, so that the control instructions and the response instructions are transferred, and the situation that the error response instructions are directly sent to the host computer is reduced. In addition, the address of the control instruction transmission channel and the address of the response instruction transmission channel are encoded to obtain first address code data and second address code data. The fourth address code data output after the first address code data and the second address code data are processed by the algorithm is matched with the third address code data representing the address of the host computer. If the third address code data is the same as the fourth address code data, it means that the instruction response of the PLC device to each host computer is accurate. If the third address code data is different from the fourth address code data, it means that the instruction response of the PLC device to each host computer is incorrect. On the one hand, it is convenient to judge whether the result that the PLC device returns the response result to the matched host computer is accurate. On the other hand, when the third address code data is different from the fourth address code data, the host computer with the communication error with the PLC device can be accurately found, so as to facilitate the debugging and maintenance work of the staff.
[0017] Preferably, the first address code data, the second address code data, the third address code data, and the fourth address code data are all binary code data.
[0018] By adopting the technical scheme, the first address code data, the second address code data, the third address code data, and the fourth address code data are all binary code data, which facilitates the implementation of address coding and the subsequent processing of data.
[0019] Preferably, the third address code data of the host computer is obtained and stored, and specifically includes:
[0020] Obtaining host computer data information for communication with the PLC device;
[0021] Encoding the host computer data information to obtain the third address code data;
[0022] The third address code data adopts prime data, that is, can only be divided by one or itself, and the third address data includes first factor code data and second factor code data.
[0023] By adopting the technical scheme, the third address data adopts prime data. Since the prime data can only be divided by one or itself, the first factor code data and the second factor code data have unique correlation, thereby improving the correlation between the first factor code data and the second factor code data.
[0024] Preferably, the correlation algorithm-based data processing of the first address coding data and the second address coding data outputs fourth address coding data, specifically including:
[0025] Obtaining the first address coding data and the second address coding data;
[0026] The first address coding data is the same as the first factor coding data, and the second address coding data is the same as the second factor coding data;
[0027] The correlation algorithm-based multiplication of the first address coding data and the second address coding data obtains the fourth address coding data.
[0028] By adopting the above technical solution, since the fourth address coding data is generated based on the first factor coding data and the second factor coding data, the correlation between the fourth address coding data and the third address coding data is improved.
[0029] Preferably, if the third address coding data is the same as the fourth coding data, the method further includes:
[0030] The PLC device sends the response instruction to the corresponding host computer, so that the host computer confirms whether the current communication is normal based on the response instruction.
[0031] By adopting the above technical solution, whether the communication between the host computer and the PLC device is normal can be detected.
[0032] Preferably, if the third address coding data is not the same as the fourth address coding data, the method further includes:
[0033] The correlation algorithm-based multiplication of the first address coding data and the second address coding data obtains the fourth address coding data;
[0034] Temporarily storing the fourth coding data that is the same as the third address coding data;
[0035] Obtaining the first address coding data and the second address coding data corresponding to the fourth coding data temporarily stored in the control instruction transmission channel and the response instruction transmission channel;
[0036] Transmitting the response instruction in the response instruction transmission channel to the corresponding host computer.
[0037] By adopting the above technical solution, when the response result between the PLC device and each host computer is detected to be incorrect, data processing is performed again until the fourth coding data that is the same as the third address coding data is obtained, and the corresponding response instruction is sent to the corresponding host computer, so that the response result is adjusted and corrected.
[0038] In a second aspect, the application provides a data transmission system of a host computer and a PLC, which adopts the following technical scheme:
[0039] A data transmission system of a host computer and a PLC, comprising:
[0040] A collection and storage module, configured to collect and store a control instruction sent by the host computer to the PLC device;
[0041] An address coding module, configured to code a control instruction transmission channel, a response instruction transmission channel and a host computer address to generate first address coding data, second address coding data and third address coding data;
[0042] A data calculation module, configured to multiply the first address coding data and the second address coding data to generate fourth address coding data;
[0043] A matching module, configured to match the fourth address coding data with the third coding data.
[0044] In a third aspect, the application provides an electronic device, which adopts the following technical scheme:
[0045] An electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the data transmission method as described above when executing the computer program.
[0046] In a fourth aspect, the application provides a storage medium containing computer executable instructions, which adopts the following technical scheme:
[0047] A storage medium containing computer executable instructions, which implements the data transmission method as described above when executed by a computer processor.
[0048] By adopting the above technical scheme, the operation of the entire method is controlled by the computer program, which helps to improve the stability and accuracy of the operation of the entire method.
[0049] In summary, the application has at least one of the following beneficial technical effects:
[0050] The control instructions sent by each host computer to the PLC device are stored in a control instruction transmission channel, and the response instructions sent by the PLC device are stored in a response instruction transmission channel, so that the control instructions and the response instructions are transferred, and the situation that the error response instructions are directly sent to the host computer is reduced. In addition, the address of the control instruction transmission channel and the address of the response instruction transmission channel are encoded to obtain first address code data and second address code data. The fourth address code data output after the first address code data and the second address code data are processed by an algorithm is matched with third address code data representing the address of the host computer. If the third address code data is the same as the fourth address code data, it means that the response of the PLC device to the instructions of each host computer is accurate. If the third address code data is different from the fourth address code data, it means that the response of the PLC device to the instructions of each host computer has an error. On the one hand, it is convenient to judge whether the result of returning the response result of the PLC device to the matched host computer is accurate. On the other hand, when the third address code data is different from the fourth address code data, the host computer with which the communication error of the PLC device occurs can be accurately found, so as to facilitate the debugging and maintenance work of the staff.
[0051] When it is detected that the response result between the PLC device and each host computer has an error, the data is processed again until the fourth code data same as the third address code data is obtained, and then the corresponding response instruction is sent to the corresponding host computer, so as to adjust and correct the response result. BRIEF DESCRIPTION OF DRAWINGS
[0052] Fig. 1 The embodiment of the present application mainly embodies the flowchart of the data transmission method steps of the host computer and the PLC device.
[0053] Fig. 2 The embodiment of the present application mainly embodies the schematic diagram of the data transmission system of the host computer and the PLC device.
[0054] The drawings show that: 1, a collection and storage module; 2, an address coding module; 3, a data calculation module; 4, a matching module. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings Figs. 1-2 The present application is further described in detail.
[0056] The present embodiment is only an explanation of the present application, and is not a limitation of the present application. Those skilled in the art can make modifications to the present embodiment without creative contribution after reading the present specification, but as long as the modifications are within the scope of the claims of the present application, they are protected by the patent law.
[0057] The embodiment of the present application discloses a data transmission method of a host computer and a PLC device, comprising the following steps:
[0058] S100. Obtain the control instructions sent by each host computer to the PLC device.
[0059] The control instructions sent by each host computer to the PLC device are different, and the control instructions sent by each host computer are summarized and then uniformly distributed, so as to improve the stability of the control instructions sent to the PLC device.
[0060] S200. Establish a control instruction transmission channel, store each control instruction in the control instruction transmission channel, and encode the address of the control instruction transmission channel to obtain first address coding data.
[0061] The control instruction transmission channel can be generated by a separate controller or computer, each control instruction is stored in the control instruction transmission channel, and the address of the control instruction is obtained by the controller or computer and encoded to obtain the first address coding data.
[0062] S300. The PLC device obtains each control instruction in the instruction transmission channel and sends a response instruction to each host computer.
[0063] S400. Establish a response instruction transmission channel, store each response instruction in the response instruction transmission channel, and encode the address of the response instruction transmission channel to obtain second address coding data.
[0064] The response instructions sent by the PLC device are stored in the response instruction channel, and then a separate controller and computer are used to obtain the address of the response instruction transmission channel and encode it to obtain the second address coding data.
[0065] The control instructions sent by each host computer to the PLC device are stored in the control instruction transmission channel, and the response instructions sent by the PLC device are stored in the response instruction transmission channel, which realizes the transfer of the control instructions and the response instructions, and reduces the occurrence of the situation that the error response instructions are directly sent to the host computer,
[0066] S500. Obtain and store the address of the host computer and encode it to obtain third address coding data.
[0067] The data information of the upper computer communicating with the PLC device is acquired first, including the address information of the upper computer and the machine code information, and then the data information of the upper computer is encoded by a computer or a controller to obtain third address code data. The third address code data is prime data, which means data that can only be divided by one or itself. The third address code data specifically includes first factor code data and second factor code data, and the first factor code data and the second factor code data are two factor data of the third address code data.
[0068] S600. Acquire and store the data information of the first address code data and the second address code data, and perform data processing on the first address code data and the second address code data based on a related algorithm to output fourth address code data.
[0069] The computer or the controller is used to store the data information of the first address code data and the second address code data, the first address code data is the same as the first factor code data, and the second address code data is the same as the second factor code data.
[0070] The multiplication algorithm program stored in the computer in advance is used to multiply the first address code data and the second address code data to obtain the fourth address code data.
[0071] It should be pointed out that the first address code data, the second address code data, the third address code data and the fourth address code data are all binary code data, which is convenient for the computer or the controller to realize address coding and convenient for subsequent multiplication processing of data.
[0072] For example, the third address code data of each upper computer is 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, etc. Here, the binary data is converted into decimal data for easy explanation and description. The third address code data is prime data. Three groups of data are used as an example for description. If the third address code data of one upper computer is 2, the first factor code data is 1, the corresponding first address code data is 1, the second factor code data is 2, and the corresponding second address code data is 2. The third address code data of one upper computer is 3, the first factor code data is 1, the corresponding first address code data is 1, the second factor code data is 3, and the corresponding second address code data is 3. The third address code data of one upper computer is 5, the first factor code data is 1, the corresponding first address code data is 1, the second factor code data is 5, and the corresponding second address code data is 5.
[0073] S700. Determine whether the third address coding data and the fourth address coding data are the same, if the same, the response instruction matches the control instruction; if not the same, the response instruction does not match the control instruction.
[0074] Wherein, when the response result deviation occurs, the fourth address coding data output after the first address coding data and the second address coding data are multiplied will inevitably produce errors with the third address coding data, thereby improving the accuracy of the response result determination.
[0075] The addresses of the control instruction transmission channel and the addresses of the response instruction transmission channel are encoded to obtain the first address coding data and the second address coding data, the fourth address coding data output after the first address coding data and the second address coding data are processed by the algorithm is matched with the third address coding data representing the host computer address, if the third address coding data and the fourth address coding data are the same, it represents that the instruction response of the PLC device and each host computer is accurate, if the third address coding data and the fourth address coding data are different, it represents that the instruction response of the PLC device and each host computer produces an error, on the one hand, it is convenient to determine whether the result of the PLC device returning the response result to the matched host computer is accurate, on the other hand, when the third address coding data and the fourth address coding data are different, the host computer which has communication error with the PLC device can be accurately found out, which is convenient for the debugging and maintenance work of the staff.
[0076] If the third address coding data and the fourth coding data are the same, the PLC device sends the response instruction to the corresponding host computer, so that the host computer confirms whether the current communication is normal based on the response instruction. If the third address coding data and the fourth address coding data are not the same, the first address coding data is multiplied with the second address coding data one by one by using the multiplication algorithm inside the computer to obtain each fourth address coding data, the fourth coding data which is the same as the third address coding data is temporarily stored, the first address coding data and the second address coding data of the response instruction transmission channel corresponding to the temporarily stored fourth coding data are obtained again, and then the response instruction in the response instruction transmission channel is transmitted to the corresponding host computer, thereby realizing the adjustment and correction of the response result.
[0077] The embodiment of the application also discloses a data transmission system of a host computer and a PLC, comprising:
[0078] The acquisition and storage module 1 is used for acquiring and storing the control instruction sent by the host computer to the PLC device.
[0079] The address coding module 2 is used for encoding the control instruction transmission channel, the response instruction transmission channel and the host computer address to generate the first address coding data, the second address coding data and the third address coding data.
[0080] a data calculation module 3 configured to multiply the first address encoding data and the second address encoding data and generate fourth address encoding data;
[0081] a matching module 4 configured to match the fourth address encoding data with the third encoding data.
[0082] The embodiment of the present application further discloses an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the data transmission method as above when executing the computer program.
[0083] The embodiment of the present application further discloses a storage medium containing computer executable instructions, which implement the data transmission method as above when executed by a computer processor. The storage medium of computer executable instructions includes, for example, a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0084] To make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
Claims
1. A data transmission method of a host computer and a PLC, characterized by, The method comprises the following steps: acquiring control instructions sent by each host computer to the PLC device; establishing a control instruction transmission channel, storing each control instruction in the control instruction transmission channel, and encoding the address of the control instruction transmission channel to obtain first address code data; the PLC device acquires each control instruction in the instruction transmission channel and sends a response instruction back to each host computer; establishing a response instruction transmission channel, storing each response instruction in the response instruction transmission channel, and encoding the address of the response instruction transmission channel to obtain second address code data; acquiring and storing the address of the host computer and encoding it to obtain third address code data; acquiring and storing data information of the first address code data and the second address code data, and performing data processing on the first address code data and the second address code data based on a relevant algorithm to output fourth address code data; determining whether the third address code data and the fourth address code data are the same, if they are the same, the response instruction matches the control instruction; if they are not the same, the response instruction does not match the control instruction; acquiring and storing the third address code data of the host computer comprises: acquiring host computer data information for communication with the PLC device; encoding the host computer data information to obtain third address code data; the third address code data uses prime data, that is, it can only be divided by one or itself, and the third address code data includes first factor code data and second factor code data; the data processing on the first address code data and the second address code data based on a relevant algorithm to output fourth address code data comprises: acquiring the first address code data and the second address code data; the first address code data is the same as the first factor code data, and the second address code data is the same as the second factor code data; multiplying the first address code data and the second address code data based on a relevant algorithm to obtain fourth address code data.
2. The data transmission method from the upper computer to the PLC according to claim 1, characterized in that: The first address code data, the second address code data, the third address code data, and the fourth address code data all use binary code data.
3. The data transmission method from the upper computer to the PLC according to claim 1, characterized in that: if the third address code data and the fourth address code data are the same, the PLC device further sends the response instruction to the corresponding host computer to enable the host computer to confirm whether the current communication is normal based on the response instruction. comprises:
4. The data transmission method between the host computer and the PLC according to claim 1, wherein, if the third address code data and the fourth address code data are not the same, further comprising: multiplying each of the first address code data and the second address code data based on a relevant algorithm to obtain each fourth address code data; temporarily storing the fourth code data that is the same as the third address code data; acquiring the control instruction transmission channel where the first address code data corresponding to the temporarily stored fourth code data is located and the response instruction transmission channel where the second address code data is located; transmitting the response instruction in the response instruction transmission channel to the corresponding host computer. comprises:
5. A data transmission system of a host computer and a PLC, characterized by, a collection and storage module (1) for collecting and storing control instructions sent by a host computer to a PLC device; An address coding module (2) is configured to encode a control instruction transmission channel, a response instruction transmission channel, and an upper computer address to generate first address coding data, second address coding data, and third address coding data; A data calculation module (3) is configured to multiply the first address coding data and the second address coding data to generate fourth address coding data; A matching module (4) is configured to match the fourth address coding data with the third address coding data; Specifically used for: obtaining upper computer data information communicated with a PLC device; encoding the upper computer data information to obtain third address coding data; The third address coding data adopts prime data, i.e., can only be divided by one or itself, and the third address coding data includes first factor coding data and second factor coding data; The data calculation module (3) is specifically configured to: obtain the first address coding data and the second address coding data; The first address coding data is the same as the first factor coding data, and the second address coding data is the same as the second factor coding data; multiply the first address coding data and the second address coding data based on a correlation algorithm to obtain the fourth address coding data.
6. An electronic device, comprising: A computer program product includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the data transmission method according to any one of claims 1-4 when executing the computer program.
7. A storage medium containing computer-executable instructions, wherein: The computer executable instructions implement the data transmission method according to any one of claims 1-4 when executed by the computer processor.
Citation Information
Patent Citations
Data transmission method, data transmission device, electronic equipment and storage medium
CN110187685A
Equipment coding method and device and coding system based on two buses
CN111817820A