[go: up one dir, main page]

CN114443136A - Data transmission method, system, equipment and storage medium for upper computer and PLC - Google Patents

Data transmission method, system, equipment and storage medium for upper computer and PLC Download PDF

Info

Publication number
CN114443136A
CN114443136A CN202111630784.2A CN202111630784A CN114443136A CN 114443136 A CN114443136 A CN 114443136A CN 202111630784 A CN202111630784 A CN 202111630784A CN 114443136 A CN114443136 A CN 114443136A
Authority
CN
China
Prior art keywords
data
address
upper computer
transmission channel
encoded data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111630784.2A
Other languages
Chinese (zh)
Inventor
王吉鹰
孙安宝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Flexem Technology Co ltd
Original Assignee
Shanghai Flexem Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Flexem Technology Co ltd filed Critical Shanghai Flexem Technology Co ltd
Priority to CN202111630784.2A priority Critical patent/CN114443136A/en
Publication of CN114443136A publication Critical patent/CN114443136A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/22Microcontrol or microprogram arrangements
    • G06F9/223Execution means for microinstructions irrespective of the microinstruction function, e.g. decoding of microinstructions and nanoinstructions; timing of microinstructions; programmable logic arrays; delays and fan-out problems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30145Instruction analysis, e.g. decoding, instruction word fields

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Programmable Controllers (AREA)

Abstract

The application relates to a data transmission method, a system, equipment and a storage medium of an upper computer and a PLC (programmable logic controller), which comprises the steps of obtaining a control instruction sent to the PLC by the upper computer; establishing a control instruction transmission channel and acquiring first address coding data of the control instruction transmission channel; the PLC equipment acquires a control instruction in the instruction transmission channel and sends a response instruction to the upper computer; establishing a response instruction transmission channel, acquiring second address coding data of the response instruction transmission channel, and acquiring and storing third address coding data of the upper computer; acquiring and storing data information of the first address coding data and the second address coding data, and outputting fourth address coding data; judging whether the third address coding data and the fourth address coding data are the same, if so, matching the response instruction with the control instruction; if not, the response command does not match the control command. The method and the device have the effect of being convenient for judging whether the result of the PLC equipment returning the response result to the matched upper computer is accurate or not.

Description

一种上位机与PLC的数据传输方法、系统、设备及存储介质A data transmission method, system, device and storage medium between a host computer and a PLC

技术领域technical field

本申请涉及数据传输技术领域,尤其是涉及一种上位机与PLC的数据传输方法、系统、设备及存储介质。The present application relates to the technical field of data transmission, and in particular, to a data transmission method, system, device and storage medium between a host computer and a PLC.

背景技术Background technique

可编程控制器 PLC(Programmable Logic Controller) 是一种专为工业环境下应用而设计的数字运算操作的电子系统。它主要将外部的输入信号如:按键、感应器、开关及脉波等的状态读取后,依据这些输入信号的状态或数值并根据内部储存预先编写的程序,以微处理机执行逻辑、顺序、计时、计数及算术运算,产生相对应的输出信号如:继电器的开关、控制机械设备的操作。通过电脑可轻易的编辑/修改程序及监控装置的状态,进行现场程序的维护与试机调整。Programmable Logic Controller PLC (Programmable Logic Controller) is an electronic system specially designed for digital operation operation in industrial environment. It mainly reads the state of external input signals such as: buttons, sensors, switches and pulses, etc., and executes logic and sequence according to the state or value of these input signals and the pre-written program stored in the interior. , timing, counting and arithmetic operations, to generate corresponding output signals such as: relay switch, control the operation of mechanical equipment. The computer can easily edit/modify the program and monitor the status of the device, and carry out on-site program maintenance and commissioning adjustment.

可编程控制器PLC因其安全可靠性、抗干扰能力强、性价比高、编程简单等优点广泛应用于工业自动化控制,在工业自动化控制中经常通过PLC监控现场设备,需要对现场设备的数据信息进行实时采集与管理。Programmable controller PLC is widely used in industrial automation control due to its advantages of safety and reliability, strong anti-interference ability, high cost performance and simple programming. Real-time collection and management.

相关技术中,一般通过上位机对PLC设备进行监测和控制,上位机就是用于工业控制中的一台计算机,主要作用是监控与控制各个设备的运行状况,当出现问题时,在显示屏上能够体现出来,便于及时发现问题并且给出相应的解决办法,起到控制管理与决策的作用。上位机将操控指令传达给PLC,之后PLC会对这一指令的正确性做出判断,然后会将判断结果反送给上位机,实现二者之间的通信,通过双方共同判断而执行最为准确的操作指令,从而加强控制系统的实际工作效果。In the related art, PLC equipment is generally monitored and controlled through the host computer. The host computer is a computer used in industrial control. Its main function is to monitor and control the operation status of each equipment. It can be reflected, it is convenient to find problems in time and give corresponding solutions, and play the role of control management and decision-making. The upper computer transmits the control instruction to the PLC, and then the PLC will judge the correctness of the instruction, and then send the judgment result back to the upper computer to realize the communication between the two, and the execution is most accurate through the joint judgment of both parties. the operating instructions, thereby enhancing the actual working effect of the control system.

然而,若有多台上位机同时对一台PLC设备进行不同功能的控制时,PLC设备需要分别响应每台上位机的控制指令,并将响应结果返回至匹配的上位机,为此需要判断PLC设备将响应结果返回至匹配的上位机的结果是否准确,亟待改进。However, if multiple upper computers control different functions of a PLC device at the same time, the PLC device needs to respond to the control commands of each upper computer and return the response results to the matching upper computer. Therefore, it is necessary to judge the PLC Whether the result of the device returning the response result to the matching host computer is accurate needs to be improved.

发明内容SUMMARY OF THE INVENTION

为了便于判断PLC设备将响应结果返回至匹配的上位机的结果是否准确,本申请提供一种上位机与PLC的数据传输方法、系统、设备及存储介质。In order to facilitate judging whether the result of the PLC device returning the response result to the matching host computer is accurate, the present application provides a data transmission method, system, device and storage medium between the host computer and the PLC.

第一方面,本申请提供的一种上位机与PLC的数据传输方法采用如下的技术方案:In the first aspect, a data transmission method between a host computer and a PLC provided by the application adopts the following technical solutions:

一种上位机与PLC设备的数据传输方法,包括以下步骤:A data transmission method between a host computer and a PLC device, comprising the following steps:

获取各上位机向PLC设备发送的控制指令;Obtain the control instructions sent by each host computer to the PLC device;

建立控制指令传输通道,将各所述控制指令存储至控制指令传输通道中,将所述控制指令传输通道的地址进行编码以得出第一地址编码数据;establishing a control command transmission channel, storing each of the control commands in the control command transmission channel, and encoding the address of the control command transmission channel to obtain first address encoded data;

PLC设备获取所述指令传输通道内的各个控制指令,并向各上位机发送回应指令;The PLC device obtains each control command in the command transmission channel, and sends a response command to each host computer;

建立回应指令传输通道,将各所述回应指令存储至回应指令传输通道中,将所述回应指令传输通道的地址进行编码以得出第二地址编码数据;establishing a response command transmission channel, storing each of the response commands in the response command transmission channel, and encoding the address of the response command transmission channel to obtain second address encoded data;

获取并存储上位机的地址并进行编码以得出第三地址编码数据;Obtain and store the address of the host computer and encode it to obtain the encoded data of the third address;

获取并存储第一地址编码数据和第二地址编码数据的数据信息,基于相关算法将所述第一地址编码数据与第二地址编码数据进行数据处理,以输出第四地址编码数据;Acquire and store the data information of the first address encoded data and the second address encoded data, and perform data processing on the first address encoded data and the second address encoded data based on a correlation algorithm to output the fourth address encoded data;

判断所述第三地址编码数据与第四地址编码数据是否相同,若相同,所述回应指令与控制指令相匹配;若不相同,所述回应指令与所述控制指令不匹配。It is judged whether the coded data of the third address and the coded data of the fourth address are the same, if they are the same, the response command matches the control command; if not, the response command does not match the control command.

通过采用上述技术方案,将各个上位机向PLC设备发送的控制指令存储至控制指令传输通道中,将PLC设备发送的回应指令存储至回应指令传输通道中,实现对控制指令和回应指令的中转,减少了错误的回应指令直接发送至上位机的情况发生,此外将控制指令传输通道的地址以及回应指令传输通道的地址进行编码以得出第一地址编码数据和第二地址编码数据,采用算法对第一地址编码数据和第二地址编码数据进行处理后输出的第四地址编码数据与代表上位机地址的第三地址编码数据进行匹配,若第三地址编码数据与第四地址编码数据相同,则代表PLC设备与各个上位机的指令回应准确,若第三地址编码数据与第四地址编码数据不同,则代表PLC设备与各个上位机的指令回应产生错误,一方面便于判断PLC设备将响应结果返回至匹配的上位机的结果是否准确,另一方面,在第三地址编码数据与第四地址编码数据不同时,可以准确的寻找出与PLC设备通信发生错误的上位机,便于工作人员的调试和维护工作。By adopting the above technical solution, the control instructions sent by each host computer to the PLC equipment are stored in the control instruction transmission channel, and the response instructions sent by the PLC equipment are stored in the response instruction transmission channel, so as to realize the transfer of the control instructions and the response instructions, It reduces the situation that the wrong response command is directly sent to the host computer. In addition, the address of the control command transmission channel and the address of the response command transmission channel are encoded to obtain the first address encoded data and the second address encoded data. After the first address encoded data and the second address encoded data are processed, the outputted fourth address encoded data is matched with the third address encoded data representing the address of the host computer. If the third address encoded data is the same as the fourth address encoded data, then It means that the command response of the PLC device and each host computer is accurate. If the encoded data of the third address is different from the encoded data of the fourth address, it means that the command response of the PLC device and each host computer has an error. On the one hand, it is easy to judge that the PLC device will return the response result. Whether the result to the matching host computer is accurate, on the other hand, when the coded data of the third address is different from the coded data of the fourth address, the host computer that has an error in communication with the PLC device can be accurately found, which is convenient for the staff to debug and maintenance work.

优选的,所述第一地址编码数据、第二地址编码数据、第三地址编码数据以及第四地址编码数据均采用二进制编码数据。Preferably, the coded data of the first address, the coded data of the second address, the coded data of the third address and the coded data of the fourth address are all binary coded data.

通过采用上述技术方案,将第一地址编码数据、第二地址编码数据、第三地址编码数据以及第四地址编码数据均采用二进制编码数据,便于对地址编码的实现以及方便后续对数据的处理。By adopting the above technical scheme, the first address encoded data, the second address encoded data, the third address encoded data and the fourth address encoded data are all binary encoded data, which facilitates the realization of address encoding and subsequent data processing.

优选的,获取并存储上位机所处的第三地址编码数据具体包括:Preferably, acquiring and storing the encoded data of the third address where the host computer is located specifically includes:

获取与PLC设备进行通信上位机数据信息;Obtain the data information of the upper computer that communicates with the PLC equipment;

将所述上位机数据信息进行编码以获取第三地址编码数据;Encoding the host computer data information to obtain third address encoded data;

所述第三地址编码数据采用素数数据,即只能被一或自身整除,所述第三地址数据包括第一因数编码数据和第二因数编码数据。The third address coded data adopts prime number data, that is, it can only be divisible by one or itself, and the third address data includes the first factor coded data and the second factor coded data.

通过采用上述技术方案,将第三地址数据采用素数数据,由于素数数据只能被一或自身整除,因此第一因数编码数据和第二因数编码数据具有唯一关联性,提高了第一因数编码数据和第二因数编码数据之间的关联性。By adopting the above technical solution, the third address data is prime number data. Since the prime number data can only be divisible by one or itself, the first factor encoded data and the second factor encoded data have a unique correlation, which improves the first factor encoded data. and the correlation between the second factor encoded data.

优选的,所述基于相关算法将所述第一地址编码数据与第二地址编码数据进行数据处理,以输出第四地址编码数据具体包括:Preferably, performing data processing on the first address encoded data and the second address encoded data based on a correlation algorithm to output the fourth address encoded data specifically includes:

获取第一地址编码数据与第二地址编码数据;obtaining the first address encoded data and the second address encoded data;

所述第一地址编码数据与所述第一因数编码数据相同,所述第二地址编码数据与第二因数编码数据相同;The first address coded data is the same as the first factor coded data, and the second address coded data is the same as the second factor coded data;

基于相关算法将所述第一地址编码数据与第二地址编码数据相乘,以得出第四地址编码数据。The first address encoded data and the second address encoded data are multiplied based on a correlation algorithm to obtain fourth address encoded data.

通过采用上述技术方案,由于第四地址编码数据基于第一因数编码数据和第二因数编码数据产生,便于提高第四地址编码数据与第三地址编码数据的关联性。By adopting the above technical solution, since the fourth address encoded data is generated based on the first factor encoded data and the second factor encoded data, it is convenient to improve the correlation between the fourth address encoded data and the third address encoded data.

优选的,若所述第三地址编码数据与第四编码数据相同之后还包括:Preferably, if the third address encoded data is the same as the fourth encoded data, it further includes:

PLC设备将所述回应指令发送至对应上位机,以使得所述上位机基于所述回应指令确认当前通信是否正常。The PLC device sends the response command to the corresponding upper computer, so that the upper computer confirms whether the current communication is normal based on the response command.

通过采用上述技术方案,便于对上位机与PLC设备之间的通信是否正常进行检测。By adopting the above technical solution, it is convenient to detect whether the communication between the upper computer and the PLC device is normal.

优选的,若所述第三地址编码数据与第四地址编码数据不相同之后,还包括:Preferably, if the encoded data of the third address is different from the encoded data of the fourth address, the method further includes:

基于相关算法逐一将所述第一地址编码数据逐一与所述第二地址编码数据相乘,以得出各个第四地址编码数据;Multiply the first address encoded data with the second address encoded data one by one based on a correlation algorithm to obtain each fourth address encoded data;

暂存与所述第三地址编码数据相同的第四编码数据;temporarily store the same fourth encoded data as the encoded data of the third address;

获取暂存的所述第四编码数据对应的第一地址编码数据所在控制指令传输通道和第二地址编码数据所在的回应指令传输通道;Obtain the control instruction transmission channel where the temporarily stored first address encoded data corresponding to the fourth encoded data is located and the response instruction transmission channel where the second address encoded data is located;

将回应指令传输通道中的回应指令传输至对应上位机。Transmit the response command in the response command transmission channel to the corresponding host computer.

通过采用上述技术方案,当检测出PLC设备与各个上位机之间响应结果发生错误后再次进行数据的处理,直至得出与第三地址编码数据相同的第四编码数据,再将对应的回复指令发送至对应的上位机,从而对响应结果的调整和纠正。By adopting the above technical solution, when an error in the response result between the PLC device and each host computer is detected, the data is processed again until the fourth encoded data that is the same as the encoded data of the third address is obtained, and then the corresponding reply instruction Send it to the corresponding host computer to adjust and correct the response result.

第二方面,本申请提供一种上位机与PLC的数据传输系统采用如下的技术方案:In the second aspect, the application provides a data transmission system between a host computer and a PLC using the following technical solutions:

一种上位机与PLC的数据传输系统,包括:A data transmission system between an upper computer and a PLC, comprising:

采集存储模块,用于采集并存储上位机向PLC设备发送的控制指令;The acquisition and storage module is used to acquire and store the control instructions sent by the host computer to the PLC equipment;

地址编码模块,用于对控制指令传输通道、回应指令传输通道以及上位机地址进行编码,以生成第一地址编码数据、第二地址编码数据以及第三地址编码数据;The address encoding module is used to encode the control command transmission channel, the response command transmission channel and the address of the host computer to generate the first address encoded data, the second address encoded data and the third address encoded data;

数据计算模块,用于将第一地址编码数据和第二地址编码数据相乘并生成第四地址编码数据;a data calculation module for multiplying the first address encoded data and the second address encoded data to generate the fourth address encoded data;

匹配模块,用于将第四地址编码数据与第三编码数据进行匹配。The matching module is used for matching the encoded data of the fourth address with the encoded data of the third address.

第三方面,本申请提供一种电子设备采用如下的技术方案:In the third aspect, the application provides a kind of electronic equipment adopting the following technical scheme:

一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上述的数据传输方法。An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the above-mentioned data transmission method when executing the computer program.

第四方面,本申请提供一种包含计算机可执行指令的存储介质采用如下的技术方案:In a fourth aspect, the present application provides a storage medium containing computer-executable instructions using the following technical solutions:

一种包含计算机可执行指令的存储介质,所述计算机可执行指令在由计算机处理器执行时实现上述的数据传输方法。A storage medium containing computer-executable instructions that, when executed by a computer processor, implement the above-described data transmission method.

通过采用上述技术方案,由计算机程序控制整个方法的运行,有助于提高整个方法运行的稳定性和精确性。By adopting the above technical solution, the operation of the entire method is controlled by a computer program, which helps to improve the stability and accuracy of the operation of the entire method.

综上所述,本申请包括以下至少一种有益技术效果:To sum up, the present application includes at least one of the following beneficial technical effects:

将各个上位机向PLC设备发送的控制指令存储至控制指令传输通道中,将PLC设备发送的回应指令存储至回应指令传输通道中,实现对控制指令和回应指令的中转,减少了错误的回应指令直接发送至上位机的情况发生,此外将控制指令传输通道的地址以及回应指令传输通道的地址进行编码以得出第一地址编码数据和第二地址编码数据,采用算法对第一地址编码数据和第二地址编码数据进行处理后输出的第四地址编码数据与代表上位机地址的第三地址编码数据进行匹配,若第三地址编码数据与第四地址编码数据相同,则代表PLC设备与各个上位机的指令回应准确,若第三地址编码数据与第四地址编码数据不同,则代表PLC设备与各个上位机的指令回应产生错误,一方面便于判断PLC设备将响应结果返回至匹配的上位机的结果是否准确,另一方面,在第三地址编码数据与第四地址编码数据不同时,可以准确的寻找出与PLC设备通信发生错误的上位机,便于工作人员的调试和维护工作;Store the control commands sent by each host computer to the PLC device in the control command transmission channel, and store the response commands sent by the PLC device in the response command transmission channel, realize the transfer of control commands and response commands, and reduce wrong response commands. The situation of sending directly to the host computer occurs. In addition, the address of the control command transmission channel and the address of the response command transmission channel are encoded to obtain the first address encoded data and the second address encoded data. After the second address encoded data is processed, the outputted fourth address encoded data is matched with the third address encoded data representing the address of the host computer. If the third address encoded data is the same as the fourth address encoded data, it means that the PLC device is connected to each host computer. If the coded data of the third address is different from the coded data of the fourth address, it means that there is an error in the command response of the PLC device and each host computer. On the one hand, it is convenient to judge that the PLC device returns the response result to the matching host computer. Whether the result is accurate or not, on the other hand, when the coded data of the third address is different from the coded data of the fourth address, the upper computer that has an error in communication with the PLC equipment can be accurately found, which is convenient for the staff to debug and maintain;

当检测出PLC设备与各个上位机之间响应结果发生错误后再次进行数据的处理,直至得出与第三地址编码数据相同的第四编码数据,再将对应的回复指令发送至对应的上位机,从而对响应结果的调整和纠正。When it is detected that the response result between the PLC device and each host computer has an error, the data processing is performed again until the fourth encoded data that is the same as the third address encoded data is obtained, and then the corresponding reply command is sent to the corresponding host computer. , so as to adjust and correct the response results.

附图说明Description of drawings

图1为本申请实施例主要体现上位机与PLC设备的数据传输方法步骤的流程示意图;1 is a schematic flowchart of the steps of a data transmission method mainly embodying a host computer and a PLC device in an embodiment of the present application;

图2为本申请实施例主要体现上位机与PLC设备的数据传输系统的示意图;2 is a schematic diagram of a data transmission system mainly embodying a host computer and a PLC device according to an embodiment of the application;

附图标记:1、采集存储模块;2、地址编码模块;3、数据计算模块;4、匹配模块。Reference numerals: 1. Acquisition and storage module; 2. Address coding module; 3. Data calculation module; 4. Matching module.

具体实施方式Detailed ways

以下结合附图1-2对本申请作进一步详细说明。The present application will be further described in detail below in conjunction with accompanying drawings 1-2.

本具体实施例仅仅是对本发明的解释,其并不是对本发明的限制,本领域技术人员在阅读完本说明书后可以根据需要对本实施例做出没有创造性贡献的修改,但只要在本发明的权利要求范围内都受到专利法的保护。This specific embodiment is only an explanation of the present invention, and it does not limit the present invention. Those skilled in the art can make modifications without creative contribution to the present embodiment as required after reading this specification, but as long as the rights of the present invention are used All claims are protected by patent law.

本申请实施例公开一种上位机与PLC设备的数据传输方法,包括以下步骤:The embodiment of the present application discloses a data transmission method between a host computer and a PLC device, comprising the following steps:

S100.获取各上位机向PLC设备发送的控制指令。S100. Obtain the control instructions sent by each upper computer to the PLC device.

其中,各个上位机与PLC设备发送的控制指令不同,将各个上位机发出的控制指令进行汇总后再进行统一分配,便于提高控制指令发送至PLC设备的稳定性。Among them, the control commands sent by each host computer and the PLC device are different, and the control commands sent by each host computer are aggregated and then distributed uniformly, which is convenient to improve the stability of the control commands sent to the PLC device.

S200.建立控制指令传输通道,将各控制指令存储至控制指令传输通道中,将控制指令传输通道的地址进行编码以得出第一地址编码数据。S200. Establish a control command transmission channel, store each control command in the control command transmission channel, and encode the address of the control command transmission channel to obtain first address encoded data.

其中,控制指令传输通道可以采用单独的控制器或计算器进行生成,将各控制指令存储至控制指令传输通道中,并通过控制器或计算机获取控制指令的地址并进行编码,从而得到第一地址编码数据。Wherein, the control command transmission channel can be generated by a separate controller or calculator, each control command is stored in the control command transmission channel, and the address of the control command is obtained and encoded by the controller or computer, so as to obtain the first address encoded data.

S300.PLC设备获取指令传输通道内的各个控制指令,并向各上位机发送回应指令。The S300.PLC device obtains each control command in the command transmission channel, and sends a response command to each host computer.

S400.建立回应指令传输通道,将各回应指令存储至回应指令传输通道中,将回应指令传输通道的地址进行编码以得出第二地址编码数据。S400. Establish a response command transmission channel, store each response command in the response command transmission channel, and encode the address of the response command transmission channel to obtain second address encoded data.

其中,将PLC设备发送的回应指令存储至回应指令通道中,再使用单独的控制器和计算机获取回应指令传输通道的地址并进行编码,从而得出第二地址编码数据。The response command sent by the PLC device is stored in the response command channel, and the address of the response command transmission channel is obtained and encoded by a separate controller and computer, thereby obtaining the second address encoded data.

将各个上位机向PLC设备发送的控制指令存储至控制指令传输通道中,将PLC设备发送的回应指令存储至回应指令传输通道中,实现对控制指令和回应指令的中转,减少了错误的回应指令直接发送至上位机的情况发生,Store the control commands sent by each host computer to the PLC device in the control command transmission channel, and store the response commands sent by the PLC device in the response command transmission channel, realize the transfer of control commands and response commands, and reduce wrong response commands. When it is sent directly to the host computer,

S500. 获取并存储上位机的地址并进行编码以得出第三地址编码数据。S500. Acquire and store the address of the host computer and encode it to obtain the encoded data of the third address.

其中,首先获取与PLC设备进行通信的上位机的数据信息,数据信息包括上位机的地址信息获取机器码信息,再采用计算机或控制器将上位机的数据信息进行编码,从而得到第三地址编码数据。其中第三地址编码数据为素数数据,此处的素数数据指代的是只能被一或者自身整除的数据,第三地址编码数据具体包括第一因数编码数据和第二因数编码数据,第一因数编码数据和第二因数编码数据为第三地址编码数据的两个因子数据。Among them, first obtain the data information of the upper computer that communicates with the PLC equipment, the data information includes the address information of the upper computer to obtain the machine code information, and then use the computer or the controller to encode the data information of the upper computer, so as to obtain the third address code data. The third address encoded data is prime number data, and the prime number data here refers to data that can only be divisible by one or itself. The third address encoded data specifically includes first factor encoded data and second factor encoded data. The factor encoded data and the second factor encoded data are two factor data of the third address encoded data.

S600.获取并存储第一地址编码数据和第二地址编码数据的数据信息,基于相关算法将第一地址编码数据与第二地址编码数据进行数据处理,以输出第四地址编码数据。S600. Acquire and store data information of the first address encoded data and the second address encoded data, and perform data processing on the first address encoded data and the second address encoded data based on a correlation algorithm to output fourth address encoded data.

其中,采用计算机或控制器存储第一地址编码数据和第二地址编码数据的数据信息,第一地址编码数据与第一因数编码数据相同,第二地址编码数据与第二因数编码数据相同;Wherein, adopt the computer or the controller to store the data information of the first address encoded data and the second address encoded data, the first address encoded data is identical with the first factor encoded data, and the second address encoded data is identical with the second factor encoded data;

采用计算机内预先存储的乘法算法程序,将第一地址编码数据与第二地址编码数据相乘,以得出第四地址编码数据。Using the multiplication algorithm program pre-stored in the computer, the first address encoded data and the second address encoded data are multiplied to obtain the fourth address encoded data.

应当指出的是,第一地址编码数据、第二地址编码数据、第三地址编码数据以及第四地址编码数据均采用二进制编码数据,便于计算机或控制器实现地址编码以及方便后续对数据的乘法处理。It should be pointed out that the encoded data of the first address, the encoded data of the second address, the encoded data of the third address and the encoded data of the fourth address all use binary encoded data, which is convenient for the computer or controller to realize the address encoding and facilitate the subsequent multiplication processing of the data. .

例如,将各个上位机的第三地址编码数据为2、3、5、7、11、13、17、19、23、29、31、37、41、43、47等,此处为二进制数据转化为十进制数据,便于解释说明,第三地址编码数据均为素数数据。采用三组数据为例进行阐述,若一个上位机的第三地址编码数据2,其第一因子编码数据为1,其对应的第一地址编码数据为1,第二因子编码数据为2,其对应的第二地址编码数据为2。一个上位机的第三地址编码数据为3,第一因子编码数据为1,其对应的第一地址编码数据为1,第二因子编码数据为3,其对应的第二地址编码数据为3。一个上位机的第三地址编码数据为5,第一因子编码数据为1,其对应的第一地址编码数据为1,第二因子编码数据为5,其对应的第二地址编码数据为5。For example, the encoding data of the third address of each host computer is 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, etc., here is binary data conversion It is decimal data, which is convenient for explanation, and the coded data of the third address are all prime number data. Taking three sets of data as an example to illustrate, if the third address encoded data of a host computer is 2, the first factor encoded data is 1, the corresponding first address encoded data is 1, and the second factor encoded data is 2, the The corresponding second address encoded data is 2. The coded data of the third address of a host computer is 3, the coded data of the first factor is 1, the corresponding coded data of the first address is 1, the coded data of the second factor is 3, and the coded data of the corresponding second address is 3. The coded data of the third address of a host computer is 5, the coded data of the first factor is 1, the corresponding coded data of the first address is 1, the coded data of the second factor is 5, and the coded data of the corresponding second address is 5.

S700.判断第三地址编码数据与第四地址编码数据是否相同,若相同,回应指令与控制指令相匹配;若不相同,回应指令与控制指令不匹配。S700. Determine whether the encoded data of the third address is the same as the encoded data of the fourth address. If they are the same, the response command matches the control command; if not, the response command does not match the control command.

其中,当出现响应结果偏差时,第一地址编码数据与第二地址编码数据相乘后输出的第四地址编码数据与第三地址编码数据必然产生误差,从而提高响应结果判断的准确性。Wherein, when a response result deviation occurs, the fourth address encoded data and the third address encoded data output after multiplying the first address encoded data and the second address encoded data will inevitably produce errors, thereby improving the accuracy of the response result judgment.

将控制指令传输通道的地址以及回应指令传输通道的地址进行编码以得出第一地址编码数据和第二地址编码数据,采用算法对第一地址编码数据和第二地址编码数据进行处理后输出的第四地址编码数据与代表上位机地址的第三地址编码数据进行匹配,若第三地址编码数据与第四地址编码数据相同,则代表PLC设备与各个上位机的指令回应准确,若第三地址编码数据与第四地址编码数据不同,则代表PLC设备与各个上位机的指令回应产生错误,一方面便于判断PLC设备将响应结果返回至匹配的上位机的结果是否准确,另一方面,在第三地址编码数据与第四地址编码数据不同时,可以准确的寻找出与PLC设备通信发生错误的上位机,便于工作人员的调试和维护工作。The address of the control command transmission channel and the address of the response command transmission channel are encoded to obtain the first address encoded data and the second address encoded data, and an algorithm is used to process the first address encoded data and the second address encoded data. The coded data of the fourth address is matched with the coded data of the third address representing the address of the host computer. If the coded data of the third address is the same as the coded data of the fourth address, it means that the command response of the PLC device and each host computer is accurate. The coded data is different from the coded data of the fourth address, which means that an error occurs in the command response between the PLC device and each host computer. When the coded data of the third address is different from the coded data of the fourth address, the upper computer that has an error in communication with the PLC equipment can be accurately found, which is convenient for the debugging and maintenance work of the staff.

若第三地址编码数据与第四编码数据相同之后,PLC设备将回应指令发送至对应上位机,以使得上位机基于回应指令确认当前通信是否正常。若第三地址编码数据与第四地址编码数据不相同之后,采用计算机内部的乘法算法逐一将第一地址编码数据逐一与第二地址编码数据相乘,以得出各个第四地址编码数据,暂存与第三地址编码数据相同的第四编码数据,再次获取暂存的第四编码数据对应的第一地址编码数据所在控制指令传输通道和第二地址编码数据所在的回应指令传输通道,再将回应指令传输通道中的回应指令传输至对应上位机,从而实现对响应结果的调整和纠正。If the coded data of the third address is the same as the coded data of the fourth address, the PLC device sends a response command to the corresponding upper computer, so that the upper computer confirms whether the current communication is normal based on the response command. If the coded data of the third address is different from the coded data of the fourth address, use the multiplication algorithm inside the computer to multiply the coded data of the first address and the coded data of the second address one by one to obtain the coded data of each fourth address. Store the fourth coded data that is the same as the third address coded data, obtain again the control command transmission channel where the first address coded data corresponding to the temporarily stored fourth coded data is located and the response command transmission channel where the second address coded data is located, and then The response command in the response command transmission channel is transmitted to the corresponding upper computer, so as to realize the adjustment and correction of the response result.

本申请实施例还公开一种上位机与PLC的数据传输系统,包括:The embodiment of the present application also discloses a data transmission system between an upper computer and a PLC, including:

采集存储模块1,用于采集并存储上位机向PLC设备发送的控制指令;The acquisition and storage module 1 is used to acquire and store the control instructions sent by the host computer to the PLC equipment;

地址编码模块2,用于对控制指令传输通道、回应指令传输通道以及上位机地址进行编码,以生成第一地址编码数据、第二地址编码数据以及第三地址编码数据;The address encoding module 2 is used to encode the control command transmission channel, the response command transmission channel and the address of the host computer to generate the first address encoded data, the second address encoded data and the third address encoded data;

数据计算模块3,用于将第一地址编码数据和第二地址编码数据相乘并生成第四地址编码数据;Data calculation module 3, for multiplying the first address encoded data and the second address encoded data and generating the fourth address encoded data;

匹配模块4,用于将第四地址编码数据与第三编码数据进行匹配。The matching module 4 is configured to match the encoded data of the fourth address with the encoded data of the third address.

本申请实施例还公开一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上述的数据传输方法。The embodiments of the present application further disclose an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, where the processor implements the above data transmission method when executing the computer program.

本申请实施例还公开一种包含计算机可执行指令的存储介质,所述计算机可执行指令在由计算机处理器执行时实现上述的数据传输方法。计算机可执行指令的存储介质例如包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(RandomAccess Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The embodiment of the present application also discloses a storage medium containing computer-executable instructions, where the computer-executable instructions implement the above-mentioned data transmission method when executed by a computer processor. The storage medium of computer-executable instructions includes, for example: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other various programs that can store program codes medium.

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

Claims (9)

1. A data transmission method of an upper computer and a PLC is characterized by comprising the following steps:
acquiring control instructions sent by the upper computers to the PLC equipment;
establishing a control instruction transmission channel, storing each control instruction into the control instruction transmission channel, and coding the address of the control instruction transmission channel to obtain first address coding data;
the PLC equipment acquires each control instruction in the instruction transmission channel and sends a response instruction to each upper computer;
establishing a response instruction transmission channel, storing each response instruction into the response instruction transmission channel, and encoding the address of the response instruction transmission channel to obtain second address encoded data;
acquiring and storing the address of the upper computer and coding to obtain third address coding data;
acquiring and storing data information of first address coding data and second address coding data, and performing data processing on the first address coding data and the second address coding data based on a correlation algorithm to output fourth address coding data;
judging whether the third address coding data is the same as the fourth address coding data, if so, matching the response instruction with the control instruction; if not, the response instruction is not matched with the control instruction.
2. The data transmission method of the upper computer and the PLC according to claim 1, wherein: the first address coding data, the second address coding data, the third address coding data and the fourth address coding data all adopt binary coding data.
3. The data transmission method of the upper computer and the PLC according to claim 1, wherein: the acquiring and storing of the third address coding data of the upper computer specifically comprises:
acquiring data information of an upper computer communicating with the PLC equipment;
encoding the data information of the upper computer to obtain third address encoded data;
the third address coding data adopts prime number data, namely the prime number data can be only divided by one or self, and the third address data comprises first factor coding data and second factor coding data.
4. The data transmission method of the upper computer and the PLC according to claim 1, wherein:
the data processing the first address encoding data and the second address encoding data based on the correlation algorithm to output fourth address encoding data specifically includes:
acquiring first address coding data and second address coding data;
the first address encoded data is the same as the first factor encoded data, and the second address encoded data is the same as the second factor encoded data;
and multiplying the first address encoding data and the second address encoding data based on a correlation algorithm to obtain fourth address encoding data.
5. The data transmission method between the upper computer and the PLC according to claim 1, wherein: if the third address encoding data is the same as the fourth encoding data, the method further comprises the following steps:
and the PLC equipment sends the response instruction to a corresponding upper computer so that the upper computer confirms whether the current communication is normal or not based on the response instruction.
6. The data transmission system between a host computer and a PLC according to claim 1, comprising:
if the third address encoding data is different from the fourth address encoding data, the method further comprises:
multiplying the first address coding data one by one with the second address coding data one by one based on a correlation algorithm to obtain fourth address coding data;
temporarily storing fourth encoded data which is the same as the third address encoded data;
acquiring a control instruction transmission channel where first address coded data corresponding to the temporarily stored fourth coded data is located and a response instruction transmission channel where second address coded data is located;
and transmitting the response instruction in the response instruction transmission channel to the corresponding upper computer.
7. The utility model provides a data transmission system of host computer and PLC which characterized in that includes:
the acquisition and storage module (1) is used for acquiring and storing a control instruction sent to the PLC equipment by the upper computer;
the address coding module (2) is used for coding the control instruction transmission channel, the response instruction transmission channel and the upper computer address to generate first address coding data, second address coding data and third address coding data;
a data calculation module (3) for multiplying the first address encoding data and the second address encoding data and generating fourth address encoding data;
and the matching module (4) is used for matching the fourth address coding data with the third coding data.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the data transmission method according to any one of claims 1 to 6 when executing the computer program.
9. A storage medium containing computer-executable instructions, which when executed by a computer processor implement the data transmission method of any one of claims 1-6.
CN202111630784.2A 2021-12-28 2021-12-28 Data transmission method, system, equipment and storage medium for upper computer and PLC Pending CN114443136A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111630784.2A CN114443136A (en) 2021-12-28 2021-12-28 Data transmission method, system, equipment and storage medium for upper computer and PLC

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111630784.2A CN114443136A (en) 2021-12-28 2021-12-28 Data transmission method, system, equipment and storage medium for upper computer and PLC

Publications (1)

Publication Number Publication Date
CN114443136A true CN114443136A (en) 2022-05-06

Family

ID=81366290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111630784.2A Pending CN114443136A (en) 2021-12-28 2021-12-28 Data transmission method, system, equipment and storage medium for upper computer and PLC

Country Status (1)

Country Link
CN (1) CN114443136A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114791723A (en) * 2022-05-11 2022-07-26 傲拓科技股份有限公司 A large-scale PLC system and its data compression method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010052114A1 (en) * 2000-03-14 2001-12-13 Sony Corporation Data processing apparatus
WO2016050857A1 (en) * 2014-09-30 2016-04-07 Technische Universität Dresden Method for processing data in order to determine if an error occurred in an execution of a program, and data processing assemblies for producing program code
CN110187685A (en) * 2019-05-30 2019-08-30 深圳创龙智新科技有限公司 A kind of data transmission method, device, electronic equipment and storage medium
CN111817820A (en) * 2020-05-28 2020-10-23 珠海格力电器股份有限公司 Equipment coding method and device and coding system based on two buses
CN113807777A (en) * 2021-08-30 2021-12-17 北京京东乾石科技有限公司 Site confirmation method, task switching method, apparatus, device, and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010052114A1 (en) * 2000-03-14 2001-12-13 Sony Corporation Data processing apparatus
WO2016050857A1 (en) * 2014-09-30 2016-04-07 Technische Universität Dresden Method for processing data in order to determine if an error occurred in an execution of a program, and data processing assemblies for producing program code
CN110187685A (en) * 2019-05-30 2019-08-30 深圳创龙智新科技有限公司 A kind of data transmission method, device, electronic equipment and storage medium
CN111817820A (en) * 2020-05-28 2020-10-23 珠海格力电器股份有限公司 Equipment coding method and device and coding system based on two buses
CN113807777A (en) * 2021-08-30 2021-12-17 北京京东乾石科技有限公司 Site confirmation method, task switching method, apparatus, device, and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114791723A (en) * 2022-05-11 2022-07-26 傲拓科技股份有限公司 A large-scale PLC system and its data compression method
CN114791723B (en) * 2022-05-11 2023-09-29 傲拓科技股份有限公司 Large-scale PLC system and data compression method thereof

Similar Documents

Publication Publication Date Title
CN107695775B (en) Heavy digital control machine tool heat error compensation control system and thermal error compensation method based on CPS
CN101916098B (en) Multi-axis motion control card with absolute coded disk reading function
CN101976074A (en) Industrial control system based on field bus and control network
CN105353715A (en) Realization method of logic control of VB/VC (Microsoft Visual Basic 6.0/Microsoft Visual C++) and PLC (Programmable Logic Controller) on the basis of serial communication
CN114443136A (en) Data transmission method, system, equipment and storage medium for upper computer and PLC
CN102713857B (en) Method and device for performing failsafe hardware-independent floating-point arithmetic
JP2014119907A (en) Communication unit, communication system, control method, and program
JP6136228B2 (en) Communication coupler, communication system, control method, and program
CN105262490A (en) Self-adaptive system based on Manchester coding and decoding, and method thereof
CN116225932A (en) Automatic chip verification method, system, equipment and medium
CN104579548A (en) Management data input/output multi source agreement-based transmission method and device
CN104850527B (en) Communications protocol processor
JP2015225574A (en) Control device, control method and program
CN210867555U (en) Control equipment and control system of servo motor
CN103186129A (en) Method and system for control system redundancy
CN115499521A (en) Multi-channel multi-interface protocol digital acquisition control system for bottom equipment
CN103346943B (en) Data transmission method and system
CN104486181A (en) Modbus protocol-based slave unit
CN112948194A (en) Communication protocol testing method and device
CN114615312B (en) Data communication method, device, computer equipment and computer readable storage medium
CN116545800A (en) Programmable gateway based on edge calculation
TWI569148B (en) Automatic detection of transmission
CN112637011A (en) Data transmission method, data transmission device, and storage medium
CN116915895B (en) Hart equipment control method, device, system and equipment based on mobile phone
CN103531255B (en) A kind of NUCLEAR REACTOR POWER PROTECTIVE AMPLIFYING EQUIPMENT and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination