PLC control method and PLC control system

By adopting an independent data reception buffer allocation strategy in the PLC lower computer, the problem of poor concurrent processing capabilities of the PLC lower computer is solved, and multi-task parallel processing is realized, which improves system performance and reliability.

CN119472491AActive Publication Date: 2025-02-18HYBRIBIO MEDTECH DEVICE CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510053691.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-02-18
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

The concurrent processing capabilities of existing PLC lower-level computers are poor, resulting in low processing efficiency.

Method used

Using an independent data receiving buffer area allocation strategy, one controlled device corresponds to a data receiving buffer area, thereby extracting command parameters to control the controlled device, realizing multi-task parallel processing.

Benefits of technology

It effectively reduces data conflicts, improves the performance and reliability of PLC downstream computers, simplifies the development environment, and realizes fault isolation and flexible expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119472491A_ABST
    Figure CN119472491A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial control, and discloses a PLC control method and a PLC control system.The method comprises the steps that a request message sent by an upper computer is received, and the request message comprises at least one request address and equipment control information; a data receiving cache region is selected according to the request address, the equipment control information is mapped to a structural body of the data receiving cache region, and the data receiving cache region is in one-to-one correspondence with the controlled equipment; and extracting the command parameter from the data receiving cache region to control a controlled device corresponding to the data receiving cache region. According to the method, data conflicts can be effectively reduced, multi-task parallel processing is realized, the development environment can be simplified, fault isolation, flexible expansion and the like are realized, and the performance and reliability of the PLC lower computer are remarkably improved. In addition, the development complexity of the PLC lower computer is simplified, the logical judgment of the PLC lower computer is reduced, the logical judgment is processed by the upper computer, and the control efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial control, and in particular to a PLC control method and a PLC control system. Background Art

[0002] A programmable logic controller (PLC) is a special-purpose computer used for industrial automation control that can automatically perform logical judgment and control operations. PLC plays a vital role in modern manufacturing and industrial control systems.

[0003] The assembly line control system is generally composed of a host computer, a PLC slave computer and electrical components. In some traditional assembly line control systems based on PLC slave computers, for example, in the molecular detection blood screening assembly line control system, the PLC slave computer undertakes a large number of logical judgment tasks. The PLC slave computer usually needs to communicate with the host computer and other devices. When the amount of data processed is large and involves multiple device control tasks, the PLC slave computer usually uses a cyclic scanning method to process inputs, execute control logic, update outputs, etc. This means that the PLC slave computer needs to read all input signals, execute program logic and update output status in sequence in each scanning cycle, resulting in poor concurrent processing capabilities and low processing efficiency of the PLC slave computer. Summary of the invention

[0004] In view of this, the present invention provides a PLC control method and a PLC control system to solve the problem of poor concurrent processing capability of the PLC lower computer in the prior art.

[0005] In a first aspect, the present invention provides a PLC control method, which is applied to a PLC lower computer, and the method comprises: Receive a request message sent by a host computer, wherein the request message includes at least one request address and device control information; Select a data receiving buffer area according to the request address, and map the device control information to the structure of the data receiving buffer area, wherein the data receiving buffer area corresponds to the controlled device one by one; The command parameters are extracted from the data receiving buffer area to control the controlled device corresponding to the data receiving buffer area.

[0006] In an optional implementation, the upper computer and the PLC lower computer are connected via Modbus TCP communication, and the PLC lower computer and the controlled device are connected via Ether CAT communication.

[0007] In an optional implementation manner, the request message further includes: a transaction identifier, a protocol identifier, a length, a unit identifier, and a function code; after receiving the request message sent by the host computer, it also includes: Parse the request message; According to the function code in the request message, determine to execute the data receiving buffer area read operation or the data receiving buffer area write operation; When it is determined to perform a write operation on the data receiving buffer area, the data receiving buffer area is selected according to the request address, and the device control information is mapped to the structure of the data receiving buffer area.

[0008] In an optional implementation, extracting command parameters from a data receiving buffer area to control a controlled device corresponding to the data receiving buffer area includes: Scan the data receiving buffer area to find out whether there is a valid command field in the data receiving buffer area. The valid command field is a non-zero command field in the structure and the command status flag of the non-zero command field is pending; If there is a valid command field in the data receiving buffer area, extract the command parameter corresponding to the valid command field; The object instance is retrieved according to the controlled device identifier, where the controlled device identifier is the identifier of the controlled device corresponding to the data receiving buffer area where the valid command field exists; The function block is called according to the retrieved object instance and command parameters, and the corresponding controlled device is controlled through the function block.

[0009] In an optional implementation manner, after controlling the corresponding controlled device, the method further includes: Receive a command response message sent by the controlled device; The command status flag in the corresponding data receiving buffer area is updated according to the command response message.

[0010] In an optional implementation, controlling a corresponding controlled device through a function block includes: Convert command parameters into EtherCAT control instructions, which include: command type, target address, and control information; Send EtherCAT control instructions to the controlled device.

[0011] In a second aspect, the present invention provides a PLC control method, which is applied to a host computer, and the method includes: Determine the command to be sent; A request message is constructed according to the command to be sent, and the request message is sent to the PLC lower computer. The request message includes a transaction identifier, a protocol identifier, a length, a unit identifier, a function code, a request address, and device control information; wherein the request address includes one or more.

[0012] In an optional embodiment, the method comprises: When the function code indicates the execution of a data receiving buffer read operation, the structure in the data receiving buffer of the PLC lower computer is read.

[0013] In an optional embodiment, the method comprises: Get the current verification code of the PLC lower computer; Determine whether the current verification code is consistent with the saved verification code; When the current verification code is inconsistent with the saved verification code, a prompt message is issued.

[0014] In a third aspect, the present invention provides a PLC control system, the system comprising: A host computer, used to execute the PLC control method in any one of the above embodiments applied to the host computer; The PLC slave computer is communicatively connected with the upper computer and is used to execute the PLC control method in any one of the above-mentioned embodiments applied to the PLC slave computer.

[0015] The beneficial effects of the present invention are as follows: The PLC control method provided by the present invention has one controlled device corresponding to one data receiving buffer area, and extracts command parameters from the corresponding data receiving buffer area to control the corresponding controlled device. An independent data receiving buffer area allocation strategy is adopted, which can effectively reduce data conflicts, realize multi-task parallel processing, and simplify the development environment, realize fault isolation and flexible expansion, and significantly improve the performance and reliability of the PLC lower computer. In addition, the present invention also simplifies the development complexity of the PLC lower computer, reduces the logical judgment of the PLC lower computer, and hands the logical judgment to the upper computer for processing, thereby improving the control efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 is a flow chart of a PLC control method according to an embodiment of the present invention; Figure 2 Schematic diagram of the communication method of the PLC slave computer according to an embodiment of the present invention; Figure 3 Schematic diagram of the structure of a PLC control system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0019] In the related technologies, not only does the PLC lower computer undertake a large number of logic judgment tasks, resulting in poor concurrent processing capabilities and greatly reduced communication speed and efficiency of the PLC lower computer, but also because the control logic of the PLC lower computer usually relies on graphical programming methods such as ladder diagrams and function blocks, which makes the development of the PLC lower computer more complex for some complex control logics, and to a certain extent also affects the reliability and scalability of the PLC system.

[0020] In view of this, according to an embodiment of the present invention, a PLC control method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0021] In this embodiment, a PLC control method is provided, which is applied to a PLC slave computer and is used to realize data interaction between the PLC slave computer and the master computer, and between the PLC slave computer and the controlled device. Figure 1 is a flow chart of a PLC control method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps: Step S101, receiving a request message sent by a host computer, wherein the request message includes at least one request address and device control information. The device control information in this embodiment is the request data in the request message.

[0022] Step S102, select a data receiving buffer area according to the request address, and map the device control information to the structure of the data receiving buffer area, wherein the data receiving buffer area corresponds one-to-one to the controlled device, and the structure includes: a controlled device identifier, a command, input parameters related to the command, output parameters related to the command, and a command status flag.

[0023] Step S103, extracting command parameters from the data receiving buffer area to control the controlled device corresponding to the data receiving buffer area. The controlled device includes various types of motors, sensors and other electrical devices, which are combined with mechanical structures to complete automation tasks.

[0024] In this embodiment, taking the molecular detection blood screening assembly line as an example, the controlled device is a motor. Specifically, the development environment of the host computer is Widows Visual studio. The host computer is responsible for the control logic design, process automation, status monitoring and information management of the entire assembly line, and communicates with the PLC slave computer through industrial Ethernet, and can use the Modbus TCP communication protocol. The PLC slave computer uses the Codesys development environment and supports a variety of programming languages ​​​​of the IEC 61131-3 standard (such as ST, LD, FBD, etc.). The PLC slave computer is mainly used to receive instructions from the host computer, control the operation of electrical components such as motors (stepper motors, servo motors), sensors (photoelectric sensors, position sensors, temperature sensors), and perform specific physical operations. In other words, it is possible to communicate with the host computer through Modbus TCP, and control the controlled equipment through the EtherCAT high-speed communication protocol. For details, please refer to Figure 2 shown.

[0025] In this embodiment, the host computer is responsible for the control logic of the assembly line (automated process, status monitoring, informationization, etc.), including data consistency and synchronization, avoiding errors caused by data inconsistency, and improving the reliability and stability of the system. The PLC slave computer is developed using Codesys, and the PLC slave computer control system is designed to communicate with the host computer and efficiently execute the commands of the host computer. Specifically, first configure the motor control and IO system, insert various types of motor equipment into the Codesys project, and create instances corresponding to each controlled device. Then configure the Modbus TCP system, insert the network device and create an instance of the Modbus TCP slave device to communicate with the host computer through the standard modbus protocol. Then configure the data receiving buffer area of ​​the Modbus TCP slave device, and the number of data receiving buffer areas is consistent with the number of controlled devices. The data receiving buffer (for example, the size is 1000 words ("word" is a memory unit representing two bytes)), maps the data receiving buffer to an array of 100 structures, one structure corresponds to one device control information. Taking the motor as an example, the device control information includes: motor ID, command, input parameters of related commands, output parameters of related commands, command status flag of whether the command is completed, etc. The information code of the structure is as follows: / / Typedef tagMotCtlCmd { short sId; / / Motor ID short cmd; / / Command, such as return to zero, relative movement, absolute movement short InData[4]; / / Input parameters related to the command short OutData[3]; / / Output parameters related to the command short OutDone; / / Command status flag, output status information after completion, so that the host computer can detect whether the motor has completed the command and can receive the next information }MotCtrlCmd; / / Then design a general ST function block of the above command (cmd), develop it in ST language, convert the device control information into control instructions that can be recognized by the ST function block, so as to realize the control of the motor through the control instructions.

[0026] In the present embodiment, a controlled device corresponds to a data receiving buffer area, and command parameters are extracted from the corresponding data receiving buffer area to control the corresponding controlled device. An independent data receiving buffer area allocation strategy is adopted, which can effectively reduce data conflicts, realize multi-task parallel processing, and can also simplify the development environment, realize fault isolation and flexible expansion, and significantly improve the performance and reliability of the PLC lower computer. In addition, the data receiving buffer area is mapped to the structure array, and each structure corresponds to the control information of a motor, including the controlled device identification, command, input parameter, output parameter and command status flag. This structured data management method makes data processing more efficient and orderly, and supports the optimization of multi-task scheduling algorithm, supports multi-task parallel processing, reduces task waiting time, improves the overall performance of the system, and is particularly outstanding in the multi-motor collaborative working scene. In addition, the present invention also simplifies the development complexity of the PLC lower computer, reduces the logical judgment of the PLC lower computer, and hands the logical judgment to the upper computer for processing, thereby improving the control efficiency.

[0027] In some optional implementations, the upper computer and the PLC lower computer are connected via ModbusTCP communication, and the PLC lower computer and the controlled device are connected via EtherCAT communication.

[0028] Specifically, the host computer is connected to the network through the Ethernet interface. For example, the connection interface of the Modbus MasterService class can be called to specify the IP address and port of the PLC slave computer to initiate a TCP connection request. The PLC slave computer is connected to the network through the Ethernet interface, accepts the TCP connection request, and establishes a TCP connection. Then the host computer constructs a Modbus TCP request message according to the commands and data to be sent.

[0029] Furthermore, the PLC slave computer is connected to the network through the EtherCAT communication module, and establishes an EtherCAT communication connection with the controlled device. The controlled device is also connected to the network through the EtherCAT slave interface to receive control instructions from the PLC slave computer.

[0030] In this embodiment, an efficient communication mechanism is designed to effectively improve the communication efficiency between the upper computer and the PLC lower computer, and between the PLC lower computer and the controlled device.

[0031] In some optional implementations, the request message further includes: a transaction identifier, a protocol identifier, a length, a unit identifier, and a function code; after the above step S101, i.e., receiving the request message sent by the host computer, it also includes: Parse the request message.

[0032] According to the function code in the request message, determine whether to perform a data receiving buffer read operation or a data receiving buffer write operation.

[0033] When it is determined to perform a write operation on the data receiving buffer area, the data receiving buffer area is selected according to the request address, and the device control information is mapped to the structure of the data receiving buffer area.

[0034] In this embodiment, the request message specifically includes the following parts: Transaction Identifier: 2 bytes, used to identify the association between the request and the response; Protocol Identifier: 2 bytes, fixed value 0x0000, indicating the use of Modbus protocol; Length: 2 bytes, indicating the number of bytes of subsequent data; Unit Identifier: 1 byte, indicating the address of the target controlled device; Function Code: 1 byte, indicating the type of operation requested (such as reading the input data receiving buffer, writing the output data receiving buffer, etc.); Request address (address), including the address of the requested data receiving buffer area, etc.; Request data (i.e., device control information in this embodiment) (Data): contains specific data of the request, such as data value, etc.; The upper computer sends the constructed request message to the PLC lower computer through the established TCP connection. Further, the PLC lower computer processes the request, that is, receives the request message and parses the request message to extract the transaction identifier, function code, data and other information. Then the PLC lower computer performs corresponding operations according to the function code, such as reading data from the data receiving buffer area, writing data from the data receiving buffer area, etc. Finally, the PLC lower computer constructs a response message based on the result of the request. The response message includes the following parts: Transaction Identifier: Same as the request message, used to identify the association between the request and the response; Protocol Identifier: 2 bytes, fixed value 0x0000; Length: 2 bytes, indicating the number of bytes of subsequent data; Unit Identifier: 1 byte, the same as the request message; Function Code: 1 byte, the same as the request message; Request data (Data): Contains specific data requested, such as the data receiving buffer address, data value, etc.

[0035] The host computer sends control commands to the PLC slave computer through Modbus TCP and saves them in the data receiving buffer area of ​​the corresponding motor of the PLC slave computer. The following is an example: The host computer sends the constructed request message to the PLC slave computer through the established TCP connection. The message is as follows (write a 10-word motor control information to the starting address 0x6000): Transaction identifier: 0x0001; Protocol identifier: 0x0000; Length: 0x0006; Unit identifier: 0x01; Function code: 0x06 (write data receiving buffer); Data receiving buffer address: 0x6000; Request data: 0x0001, 0x0002, 0x0003, ... 0x0000 (the meaning of the data corresponds to the information described in TypedeftagMotCtlCmd).

[0036] The PLC lower computer receives the request message sent by the upper computer through the TCP connection, parses the request message, extracts the transaction identifier, function code, data receiving buffer address, data and other information, and writes the above 10 data into the data receiving buffer with the starting address of 0x6000.

[0037] In this embodiment, through intelligent decision support and distributed control, complex logic judgment tasks are converted to be undertaken by the upper computer with rich computing resources, reducing the burden on the PLC lower computer and improving the overall performance of the assembly line system. In addition, a dedicated memory space is set for each controlled device, which can effectively improve the system concurrency and real-time performance.

[0038] In some optional implementations, extracting command parameters from the data receiving buffer area to control a controlled device corresponding to the data receiving buffer area includes: Scan the data receiving buffer area to find out whether there is a valid command field in the data receiving buffer area. The valid command field is a non-zero command field in the structure and the command status flag of the non-zero command field is pending. That is, only when the value of the command field is non-zero, it indicates that there is a valid command to be processed, for example, the 0x0001 control instruction indicates that the motor needs to be started.

[0039] When there is a valid command field in the data receiving buffer area, the command parameter corresponding to the valid command field is extracted.

[0040] The object instance is retrieved according to the controlled device identifier, and the controlled device identifier is the identifier of the controlled device corresponding to the data receiving buffer area where the valid command field exists.

[0041] The function block is called according to the retrieved object instance and command parameters, and the corresponding controlled device is controlled through the function block.

[0042] The PLC lower computer scans the data receiving buffer, retrieves the object instance according to the data, finds the corresponding command parameters, and passes the command parameters to the ST function block. Specifically, scan and traverse all structures in the data receiving buffer to find the valid command field of the structure, that is, the cmd non-zero field, such as the value of 0x0001, and the OutDone field is 0x0000. Then, according to the motor ID, find the motor instance AxisInst, where the instance is a parameter that can be called by subsequent function blocks, and the motor ID cannot be called by the function block.

[0043] The specific object instance retrieval process includes: obtaining the device list, traversing the devices, checking the devices, and returning the instance. The code is as follows: / / EC_Master is the EtherCAT master object, through which the device list is obtained EC_Master = GetEtherCATMaster(); / / Traverse all slave devices for each slave in EC_Master.Slaves do / / Check the device and get the ID of the slave device Slave_ID = slave.GetID(); / / Check if the slave device ID is the target ID if Slave_ID<>sIdthen / / If yes, return the instance return AxisInst; end if end for / / Then extract the command parameters related to the command from the structure, for example, extract the value of the InData field from the structure, and pass the extracted command parameters to the predefined general ST function block. Then execute the corresponding command according to the passed command parameters. For example, assuming that the value of the cmd field is 0x0001, it means starting the motor. Call the ST function block MotorControl corresponding to cmd and pass the parameters AxisInst and InData. In the ST function block, execute the logic of starting the motor according to the command parameters.

[0044] In this embodiment, data can be extracted from multiple data receiving buffers respectively, and then a common function block can be called uniformly. No matter which data receiving buffer the data comes from, the same function block can be called for processing. A multi-task scheduling mechanism is used to process control commands of multiple controlled devices at the same time, which effectively reduces the amount of code, improves code versatility, and improves concurrent processing capabilities.

[0045] In some optional implementations, after controlling the corresponding controlled device, the method further includes: Receive a command response message sent by the controlled device; The command status flag in the corresponding data receiving buffer area is updated according to the command response message.

[0046] Still taking the above example where the value of the cmd field is 0x0001, in the ST function block, after executing the logic of starting the motor according to the command parameters, the output parameter OutData and the command completion flag OutDone are set. Update status information: Set the OutDone field to 0x0001, indicating that the command has been completed.

[0047] In this embodiment, updating the command status flag can facilitate the host computer to determine whether the command is executed according to the command status flag, thereby ensuring that the host computer can monitor the working status of each controlled device in real time.

[0048] In some optional implementations, controlling the corresponding controlled device through the function block includes: The command parameters are converted into EtherCAT control instructions. The EtherCAT control instructions include: command type, target address, and control information.

[0049] Send EtherCAT control instructions to the controlled device.

[0050] The PLC slave computer is connected to the network through the EtherCAT communication module and establishes an EtherCAT communication connection with the controlled device. Similarly, the controlled device is connected to the network through the EtherCAT slave interface to receive the control instructions of the PLC slave computer. The PLC slave computer constructs EtherCAT control instructions based on the commands and internal logic of the upper computer. The control instructions include the following parts: Command type: indicates the type of operation to be performed (such as starting the motor, stopping the motor, etc.); Target address: indicates the address of the target electrical component; Control information: contains specific control parameters, such as the speed and direction of the motor.

[0051] The PLC lower computer control system sends the constructed control instructions to the corresponding controlled device through the established EtherCAT connection.

[0052] For the controlled device, the controlled device receives the control command sent by the PLC lower computer through the EtherCAT connection. The control command is parsed to extract the command type, target address, control information and other information. Then the controlled device performs the corresponding operation according to the command type, such as starting the motor, stopping the motor, etc. After the execution of the operation is completed, the controlled device constructs a response message according to the execution result. The response message includes the following parts: Command type: Same as control command; Target address: same as control instruction; Control information: contains execution results, such as success, failure, etc.

[0053] The controlled device sends the constructed response message to the PLC slave computer through the established EtherCAT connection. The PLC slave computer receives the response message sent by the controlled device through the EtherCAT connection, parses the response message, and extracts information such as command type, target address, and data. Finally, the PLC slave computer performs corresponding processing based on the response result, such as updating the internal status and recording logs.

[0054] In this embodiment, based on the EtherCAT control instructions, the communication efficiency between the PLC lower computer and the controlled device can be effectively improved.

[0055] The overall control process in this embodiment is as follows: 1) Initialize the system a. Load the configuration file: read parameters from the configuration file, such as the motor ID, data receiving buffer address, etc.

[0056] b. Establish a Modbus TCP or OPC UA connection: Establish a communication connection between the upper computer and the PLC lower computer.

[0057] c. System verification: compare the verification codes between the upper and lower computers to ensure the synchronization of the parameters of the upper and lower computers.

[0058] 2) Scan data to receive buffer data a. Traverse the data receiving buffer address range of each motor: traverse the data receiving buffer address range of each motor according to the data receiving buffer address range in the configuration file.

[0059] b. Read the commands and parameters in the data receiving buffer: Read the commands and related parameters from the data receiving buffer.

[0060] 3) Parsing commands and parameters a. Check the command field of each motor: Check the command field of each motor to see if there is a new command.

[0061] b. Extract commands and related parameters: Extract commands and related parameters from the data receiving buffer.

[0062] 4) Call the function block to process the command a. Call the corresponding function block according to the command field value: Call the corresponding function block according to the command field value, such as starting the motor, stopping the motor, etc.

[0063] b. Execute command: Execute the command and update the output parameters and command status flags.

[0064] 5) Update data receiving buffer data a. Write the command execution result back to the data receiving buffer area: Write the command execution result back to the corresponding data receiving buffer area.

[0065] b. Update status information: Update status information, such as command completion flag.

[0066] 6) Multitasking scheduling and interrupt handling a. Use multi-task scheduling mechanism to process commands of multiple motors: PLC uses multi-task scheduling mechanism to process commands of multiple motors at the same time.

[0067] b. Use interrupt mechanism to handle key events: Use interrupt mechanism to handle key events, such as motor status changes.

[0068] 7) Optimize communication protocol a. Batch read and write data receiving buffer area data: The host computer reads or writes data in multiple data receiving buffer areas at one time through the Modbus TCP protocol.

[0069] 8) Continuous monitoring and processing a. Execute the above steps repeatedly: Execute the above steps repeatedly to ensure the real-time performance and stability of the system.

[0070] In related technologies, control systems are often designed for specific devices and scenarios, lacking versatility and modular design, and are difficult to quickly adapt to new devices and needs. However, the present invention improves the versatility and flexibility of the system through standardized interfaces and communication protocols, as well as modular programming methods, making it easier for the system to adapt to different devices and application scenarios.

[0071] In the related art, there will also be shared memory conflicts, that is, in the existing PLC system, multiple motors may share the same memory space, resulting in data conflicts and communication bottlenecks. Its PLC system usually adopts a serial processing method, and the next task can only be processed after one task is completed, which affects the concurrent processing capability of the system. And due to the complexity of data transmission and processing, the existing PLC system may have a high delay, which affects the accuracy of real-time control. And the design of shared memory makes the system design and maintenance more complicated, and increases the difficulty of development and debugging. In the present invention, each controlled device occupies an independent memory space, which reduces data conflicts, improves concurrency and data reliability. Independent memory space makes data read and write operations more efficient, reduces the time for data search and processing, and improves communication efficiency. And supports multi-task parallel processing, reduces the waiting time between tasks, and improves the overall performance of the system. Independent memory space enables the PLC lower computer to quickly read and write the status information of the motor, and improves the real-time response capability of the system. Clear address mapping and modular design make the system clearer and easier to maintain. Independent memory space helps to achieve fault isolation and redundant design, and improves the reliability and fault tolerance of the system. In addition, when adding a new controlled device, only a new data receiving buffer area needs to be allocated, which does not affect the operation of the existing system, making system expansion more flexible.

[0072] In this embodiment, a PLC control method is also provided. The PLC control method is applied to a host computer to implement data interaction with the host computer. The process includes the following steps: Step S201, determining the command to be sent; Step S202, construct a request message according to the command to be sent, and send the request message to the PLC lower computer, the request message includes a transaction identifier, a protocol identifier, a length, a unit identifier, a function code, a request address, and device control information; wherein the request address includes one or more.

[0073] In this embodiment, one request address corresponds to one data receiving buffer area, and one data receiving buffer area corresponds to one controlled device. An independent data receiving buffer area allocation strategy is adopted, which can effectively reduce data conflicts, realize multi-task parallel processing, and simplify the development environment, realize fault isolation and flexible expansion, and significantly improve the performance and reliability of the PLC lower computer. In addition, the present invention also simplifies the development complexity of the PLC lower computer, reduces the logical judgment of the PLC lower computer, and hands the logical judgment to the upper computer for processing, thereby improving the control efficiency.

[0074] In some optional embodiments, the method comprises: When the function code indicates the execution of a data receiving buffer read operation, the structure in the data receiving buffer of the PLC lower computer is read.

[0075] The upper computer sends device control information to the PLC lower computer, and the information is saved in the data receiving buffer of the corresponding motor. After executing the command, the PLC lower computer will write the command completion status (OutDone) into the buffer for the upper computer to query, ensuring that the upper computer can monitor the working status of each motor in real time. During the execution of the command, if an abnormal situation (such as motor failure, communication interruption, etc.) is encountered, the PLC lower computer will immediately stop the current operation and write the error code into the buffer for the upper computer to query so that timely measures can be taken.

[0076] In some optional embodiments, the method comprises: Get the current verification code of the PLC slave computer.

[0077] Determine whether the current verification code is consistent with the saved verification code.

[0078] When the current verification code is inconsistent with the saved verification code, a prompt message is issued.

[0079] The host computer is responsible for the control logic design, process automation, status monitoring and information management of the entire assembly line. It communicates with the PLC slave computer through industrial Ethernet, using Modbus TCP or other high-speed communication protocols (such as EtherCAT, Profinet). After the system is started, the system is first checked. The host computer saves the check code of the last system operation. By comparing the check code saved by the host computer with the current check code obtained from the PLC slave computer, it can be determined whether the settings of the slave computer have changed. If the check code is different, the host computer will prompt the user and update the check code after the user confirms to ensure the synchronization of the upper and lower computer parameters.

[0080] Among them, the verification code is generated by the lower computer, and the verification code generation method is as follows: First, you need to prepare the key parameters of all instances. These parameters may include but are not limited to instance ID, speed, return to zero mode, etc. Assume that the information of each instance is stored in a data set, such as: / / TYPE InstanceInfo : STRUCT id:INT; / / Instance ID name:STRING

[32] ; / / instance name type:INT; / / instance type status:INT; / / instance status config_params : ARRAY[1..10] OF INT; / / instance configuration parameters, such as speed, return to zero mode, etc. creation_time:DATE_AND_TIME; / / Instance creation time modification_time:DATE_AND_TIME; / / Instance modification time END_STRUCT END_TYPE / / In this embodiment, a 32-bit CRC check code is used, and the polynomial is 0x04C11DB7. The following are the specific steps for generating the CRC check code: a. Initialize the CRC data receiving buffer: Initialize the CRC data receive buffer to 0xFFFFFFFF.

[0081] b. Process data byte by byte: For each instance's key parameter, convert it to a 32-bit integer and process it bit by bit.

[0082] For each 32-bit integer, we loop 32 times, processing one bit at a time.

[0083] c. Calculate the CRC value: In each loop, check whether the lowest bit (bit 0) of the CRC data receive buffer is 1.

[0084] If it is 1, the CRC data receive buffer is shifted right by one bit and XORed with the polynomial 0x04C11DB7.

[0085] If it is 0, only the CRC data receive buffer is shifted right by one position.

[0086] XOR the data bit with the highest bit (bit 31) of the CRC data receive buffer.

[0087] d. Final processing: After all data is processed, the value of the CRC data receiving buffer is XORed with 0xFFFFFFFF to obtain the final CRC check code.

[0088] In this embodiment, verification is performed through the verification code, which can ensure data consistency and synchronization, avoid errors caused by data inconsistency, and improve the reliability and stability of the system.

[0089] This embodiment also provides a PLC control system, such as Figure 3 As shown, the device comprises: The host computer is used to execute the PLC control method in any one of the above embodiments applicable to the host computer.

[0090] The PLC slave computer is communicatively connected with the upper computer and is used to execute the PLC control method in any one of the above-mentioned embodiments applicable to the PLC slave computer.

[0091] The further functional description of the above-mentioned upper computer and PLC lower computer is the same as that of the above-mentioned corresponding embodiments and will not be repeated here.

[0092] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A PLC control method, characterized in that: Applied to a PLC lower computer, the method includes: Receive a request message sent by a host computer, wherein the request message includes at least one request address and device control information; Selecting a data receiving buffer area according to the request address, and mapping the device control information to a structure of the data receiving buffer area, wherein the data receiving buffer area corresponds to the controlled device in a one-to-one manner; A command parameter is extracted from the data receiving buffer area to control the controlled device corresponding to the data receiving buffer area.

2. The method according to claim 1, characterized in that: The upper computer and the PLC lower computer are connected via Modbus TCP communication, and the PLC lower computer and the controlled device are connected via Ether CAT communication.

3. The method according to claim 2, characterized in that The request message also includes: transaction identifier, protocol identifier, length, unit identifier, function code; after receiving the request message sent by the host computer, it also includes: Parsing the request message; Determine, according to the function code in the request message, to perform a data receiving buffer read operation or a data receiving buffer write operation; When it is determined to perform a write operation on the data receiving buffer area, the data receiving buffer area is selected according to the request address, and the device control information is mapped to the structure of the data receiving buffer area.

4. The method according to claim 2, characterized in that: The extracting command parameters from the data receiving buffer area to control the controlled device corresponding to the data receiving buffer area includes: Scan the data receiving buffer area to find out whether there is a valid command field in the data receiving buffer area, wherein the valid command field is a non-zero command field in the structure and the command status flag of the non-zero command field is to be processed; In the case where there is a valid command field in the data receiving buffer area, extracting the command parameter corresponding to the valid command field; Retrieve an object instance according to a controlled device identifier, wherein the controlled device identifier is an identifier of a controlled device corresponding to the data receiving buffer area where the valid command field exists; The function block is called according to the retrieved object instance and the command parameter, and the corresponding controlled device is controlled through the function block.

5. The method according to claim 2, characterized in that: After controlling the corresponding controlled device, the method further includes: Receiving a command response message sent by the controlled device; The command status flag in the corresponding data receiving buffer area is updated according to the command response message.

6. The method according to claim 4, characterized in that The controlling the corresponding controlled device by the function block includes: Convert the command parameters into EtherCAT control instructions, wherein the EtherCAT control instructions include: command type, target address, and control information; The EtherCAT control instruction is sent to the controlled device.

7. A PLC control method, characterized in that: Applied to a host computer, the method includes: Determine the command to be sent; A request message is constructed according to the command to be sent, and the request message is sent to the PLC lower computer, wherein the request message includes a transaction identifier, a protocol identifier, a length, a unit identifier, a function code, a request address, and device control information; wherein the request address includes one or more.

8. The method according to claim 7, characterized in that The method comprises: When the function code indicates that a data receiving buffer read operation is performed, a structure in the data receiving buffer of the PLC lower computer is read.

9. The method according to claim 8, characterized in that The method comprises: Get the current verification code of the PLC lower computer; Determine whether the current verification code is consistent with the saved verification code; When the current verification code is inconsistent with the saved verification code, a prompt message is issued.

10. A PLC control system, characterized in that: The system comprises: A host computer, used to execute the PLC control method according to any one of claims 7 to 9 above; A PLC lower computer is communicatively connected with the upper computer and is used to execute the PLC control method described in any one of claims 1 to 6 above.

Citation Information

Patent Citations

  • Embedded type state monitoring information adaptor capable of operating under complex working conditions of numerically-controlled machine tool and method thereof

    CN101685301A

  • Method and device for reading data

    CN104503707A

  • Integrated control method and device, building control system, storage medium and processor

    CN111930496A

  • Method and device for binding PLC (Programmable Logic Controller) address of upper computer and electronic equipment

    CN115567481A

  • Device address management in an automation control system

    US20150066979A1