Method for realizing high precision and stability of PLCOPEN motion control
By separating user control logic tasks and motor control service tasks into different threads in the PLC system and providing asynchronous motor motion control services in units of functional blocks, the problem of insufficient motion control accuracy of high-speed motors in the PLC system is solved, and the motion control effect with high accuracy and stability is achieved.
Patent Information
- Application Number
- CN202411668747.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-02-28
AI Technical Summary
In the high-speed motor motion control, the existing PLC system has the change in the logic execution time written by the user, resulting in the issuance time of the motor control command that cannot meet the control needs, which in turn affects the control accuracy.
By separating the user control logic tasks from the motor control service tasks to different threads and providing motor motion control services in units of functional blocks, the motion commands are completed in asynchronous manner to ensure the stability and accuracy of the motor control service.
The high accuracy and stability of PLCOPEN motion control is achieved, the control accuracy deviation caused by command time problems is avoided, and the motor movement is ensured strictly as expected, which improves the control accuracy and stability of the entire system.
Smart Images

Figure HDA0005145246670000011 
Figure HDA0005145246670000021 
Figure HDA0005145246670000022
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of industrial automation control, and in particular to a method for realizing high precision and stability of PLCOPEN motion control. Background Art
[0002] The PLCopen motion control specification is a standard for regulating the function blocks required for various types of motion control. It defines single-axis motion control function blocks, multi-axis coordinated motion control function blocks, and state changes and rules in the motion control process. The core idea of the PLCopen motion control specification is to provide a common software framework that enables developers to write standardized motion control software on different programming platforms.
[0003] In order to perform high-precision motion control on high-speed motors, the PLC system needs to issue control instructions to the motors strictly according to a predetermined time period. At the same time, the control logic program written by the user needs to be executed in the PLC system. Since the execution time of the logic written by the user varies, the time for issuing motor control instructions cannot meet the control requirements, resulting in a control effect that cannot achieve the expected accuracy.
[0004] Therefore, it is necessary to provide a method for implementing high precision and stability of PLCOPEN motion control to solve the above technical problems. Summary of the invention
[0005] The present invention provides a method for realizing high precision and stability of PLCOPEN motion control, which solves the problem that the time for issuing motor control instructions cannot meet the control requirements due to the variation in the execution time of logic written by the user, thereby resulting in a control effect that cannot achieve the expected precision.
[0006] In order to solve the above technical problems, the present invention provides a method for realizing high precision and stability of PLCOPEN motion control, comprising the following steps:
[0007] S1, during the loading of the PLC application, separate the user control logic task and the motor control service task into different threads for execution;
[0008] S2, then using the function block as a unit, provides motor motion control services on the motor control task;
[0009] S3, the user control logic executes the motion control function block, sends a control request of the corresponding function block to the motor control service task and evaluates the motion state, then the motor control service task completes the motion command required by the current function block in an asynchronous manner, and then performs calculations according to the motion control algorithm, and converts the calculation results into signals that can be recognized by the servo motor, which are connected through the bus and servo motor interface and then transmitted to the motor for execution.
[0010] Preferably, the user control logic is a program developed by a PLC user using an IDE (Integrated Development Environment) of the PLC, and the motor control service is a service built into the PLC system.
[0011] Preferably, in the process of loading the PLC application, axis objects need to be created one by one, and a mapping relationship between the axis objects needs to be established on both sides.
[0012] Preferably, the process of creating an axis comprises the following steps:
[0013] Start the process of creating the axis on the PLC application side;
[0014] Call request to create an axis object on the motor control service;
[0015] The motor control service creates an axis object locally;
[0016] The motor control service returns the identifier of the newly created axis, which can be a unique integer;
[0017] The PLC application uses the returned axis ID as the identifier of the newly created axis within the application.
[0018] Preferably, the process of loading the PLC application program requires creating function block objects one by one and establishing a mapping relationship between the function block objects on both sides.
[0019] Preferably, the process of creating a function block comprises the following steps:
[0020] Call the initialization function of the function block. The name and parameter type of the initialization function of the function block are determined by the compiler. The function parameters include: a) the starting address of the data area of the function block;
[0021] The initialization function of the function block allocates a data exchange area for the function block;
[0022] The initialization function of the function block applies to create a mapped function block on the motor control service side. The application includes the address of the data exchange area. The data exchange area is accessed by both the user control logic and the motor control service. It must be protected by a lock to prevent data inconsistency errors caused by multi-threading.
[0023] The motor control service creates an internal data area corresponding to the function block internally;
[0024] The motor control service saves the address reference to the data exchange area of the function block in the internal data area of the internal function block;
[0025] The motor control service returns success;
[0026] The initialization function of the function block returns the address of the data exchange area of the function block;
[0027] The initialization program saves the returned address in the pointer area inside the function block. This area is invisible to the application and is internal data controlled by the PLC program compiler.
[0028] Preferably, the PLC application program periodically runs tasks in the user code in an independent thread.
[0029] Preferably, the process of one cycle operation comprises the following steps:
[0030] Synchronize the output type data of all function blocks from the data exchange area of the function blocks;
[0031] Before calling the motion control function block in the program, copy the input parameters of the called function block to the input data area of the function block;
[0032] Then call the execution function corresponding to the function block. The execution function is provided by the motion control library, and its function name and function parameters conform to the convention of the PLC compiler;
[0033] According to the logic of the user program, all function block calls are executed in sequence;
[0034] After all function block calls are executed, the input data areas of all function block data are assigned to the corresponding data exchange areas.
[0035] Preferably, the motor control service is executed in another thread in a periodic manner, and the periodic execution includes the following steps:
[0036] Read the current data from the motor;
[0037] Assign the input data of the function block from the data exchange area of the function block;
[0038] Execute the path planning algorithm to calculate the command instructions for the next motor cycle;
[0039] All function blocks are executed sequentially, and the function blocks perform logical processing based on their respective internal data areas;
[0040] Assign the output data in the internal data area of all function blocks to the data exchange area of the function blocks;
[0041] The motor control instructions output by the path planning algorithm are sent to the motor.
[0042] Preferably, the output end of the user control logic is connected to a storage module, the storage module includes a receiving unit, the output end of the receiving unit is connected to a clock unit, the output end of the clock unit is connected to a storage unit, the output end of the storage unit is connected to an output unit, and the storage unit is also connected to a deletion unit.
[0043] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0044] The present invention provides a method for realizing high precision and stability of PLCOPEN motion control. By separating the user control logic task and the motor control service task to different threads for execution, the influence of the user logic execution time change on the motor control instruction issuance time can be avoided. This separation enables the motor control service task to be executed more stably and accurately, reduces the control precision deviation caused by the instruction time problem, ensures that the motor motion can be carried out strictly as expected, and effectively improves the control precision of the entire system.
[0045] The motor control task is provided with services in functional blocks, and the functional block motion commands are completed asynchronously, making the motor control process more standardized and orderly. The operation of each functional block is relatively independent, reducing the mutual interference between different operations. Even if a functional block has an abnormality, it will not easily affect the operation of other parts, thereby enhancing the stability of the system in the process of executing motor control. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A flowchart of a first embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention;
[0047] Figure 2 A flow chart of a second embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention;
[0048] Figure 3 A flowchart of a third embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention;
[0049] Figure 4 A flowchart of a fourth embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention;
[0050] Figure 5A flowchart of a fifth embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention;
[0051] Figure 6 A flowchart of the sixth embodiment of a method for realizing high precision and stability of PLCOPEN motion control provided by the present invention. DETAILED DESCRIPTION
[0052] The present invention will be further described below in conjunction with the accompanying drawings and implementation modes.
[0053] First embodiment
[0054] Please refer to Figure 1 ,in, Figure 1 A block diagram of a method for implementing high precision and stability of PLCOPEN motion control provided by the present invention. A method for implementing high precision and stability of PLCOPEN motion control comprises the following steps:
[0055] S1, during the loading of the PLC application, separate the user control logic task and the motor control service task into different threads for execution;
[0056] S2, then using the function block as a unit, provides motor motion control services on the motor control task;
[0057] S3, the user control logic executes the motion control function block, sends a control request of the corresponding function block to the motor control service task and evaluates the motion state, then the motor control service task completes the motion command required by the current function block in an asynchronous manner, and then performs calculations according to the motion control algorithm, and converts the calculation results into signals that can be recognized by the servo motor, which are connected through the bus and servo motor interface and then transmitted to the motor for execution.
[0058] The user control logic is a program developed by a PLC user using the PLC's IDE (Integrated Development Environment), and the motor control service is a service built into the PLC system.
[0059] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0060] By separating the user control logic task and the motor control service task into different threads for execution, the influence of the user logic execution time on the motor control instruction issuance time can be avoided. This separation enables the motor control service task to be executed more stably and accurately, reduces the control accuracy deviation caused by instruction time problems, ensures that the motor movement can be carried out strictly as expected, and effectively improves the control accuracy of the entire system;
[0061] The motor control task is provided with services in functional blocks, and the functional block motion commands are completed asynchronously, making the motor control process more standardized and orderly. The operation of each functional block is relatively independent, reducing the mutual interference between different operations. Even if a functional block has an abnormality, it will not easily affect the operation of other parts, thereby enhancing the stability of the system in the process of executing motor control.
[0062] Second embodiment
[0063] Please refer to Figure 2 Based on the high precision and stability implementation method of PLCOPEN motion control provided by the first embodiment of the present application, the second embodiment of the present application proposes another high precision and stability implementation method of PLCOPEN motion control. The second embodiment is only a preferred method of the first embodiment, and the implementation of the second embodiment will not affect the independent implementation of the first embodiment.
[0064] Specifically, the difference between the method for implementing high precision and stability of PLCOPEN motion control provided by the second embodiment of the present application is that, in the process of loading the PLC application, axis objects need to be created one by one, and a mapping relationship between axis objects needs to be established on both sides.
[0065] The process of creating an axis includes the following steps:
[0066] Start the process of creating the axis on the PLC application side;
[0067] Call request to create an axis object on the motor control service;
[0068] The motor control service creates an axis object locally;
[0069] The motor control service returns the identifier of the newly created axis, which can be a unique integer;
[0070] The PLC application uses the returned axis ID as the identifier of the newly created axis within the application.
[0071] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0072] The problem of how to establish the data mapping relationship of all axis objects between the user control logic task and the motor control task when the user program is loaded is solved.
[0073] Third embodiment
[0074] Please refer to Figure 3Based on the high precision and stability implementation method of PLCOPEN motion control provided by the first embodiment of the present application, the third embodiment of the present application proposes another high precision and stability implementation method of PLCOPEN motion control. The third embodiment is only a preferred method of the first embodiment, and the implementation of the third embodiment will not affect the independent implementation of the first embodiment.
[0075] Specifically, the difference between the method for implementing high precision and stability of PLCOPEN motion control provided by the third embodiment of the present application is that, in the process of loading the PLC application, it is necessary to create function block objects one by one and establish a mapping relationship between the function block objects on both sides.
[0076] The process of creating a function block includes the following steps:
[0077] Call the initialization function of the function block. The name and parameter type of the initialization function of the function block are determined by the compiler. The function parameters include: a) the starting address of the data area of the function block;
[0078] The initialization function of the function block allocates a data exchange area for the function block;
[0079] The initialization function of the function block applies to create a mapped function block on the motor control service side. The application includes the address of the data exchange area. The data exchange area is accessed by both the user control logic and the motor control service. It must be protected by a lock to prevent data inconsistency errors caused by multi-threading.
[0080] The motor control service creates an internal data area corresponding to the function block internally;
[0081] The motor control service saves the address reference to the data exchange area of the function block in the internal data area of the internal function block;
[0082] The motor control service returns success;
[0083] The initialization function of the function block returns the address of the data exchange area of the function block;
[0084] The initialization program saves the returned address in the pointer area inside the function block. This area is invisible to the application and is internal data controlled by the PLC program compiler.
[0085] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0086] The problem of how to establish the data mapping relationship of all function block objects between the user control logic task and the motor control task when the user program is loaded is solved.
[0087] Fourth embodiment
[0088] Please refer to Figure 4 Based on the high precision and stability implementation method of PLCOPEN motion control provided by the first embodiment of the present application, the fourth embodiment of the present application proposes another high precision and stability implementation method of PLCOPEN motion control. The fourth embodiment is only a preferred method of the first embodiment, and the implementation of the fourth embodiment will not affect the independent implementation of the first embodiment.
[0089] Specifically, the fourth embodiment of the present application provides a method for implementing high precision and stability of PLCOPEN motion control, which is different in that, in a method for implementing high precision and stability of PLCOPEN motion control, the PLC application program periodically runs tasks in user code in an independent thread.
[0090] The process of one cycle operation includes the following steps:
[0091] Synchronize the output type data of all function blocks from the data exchange area of the function blocks;
[0092] Before calling the motion control function block in the program, copy the input parameters of the called function block to the input data area of the function block;
[0093] Then call the execution function corresponding to the function block. The execution function is provided by the motion control library, and its function name and function parameters conform to the convention of the PLC compiler;
[0094] According to the logic of the user program, all function block calls are executed in sequence;
[0095] After all function block calls are executed, the input data areas of all function block data are assigned to the corresponding data exchange areas.
[0096] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0097] It solves how to equivalently execute the function block programming logic in the user control logic in the motor control service.
[0098] Fifth embodiment
[0099] Please refer to Figure 5Based on the high precision and stability implementation method of PLCOPEN motion control provided by the first embodiment of the present application, the fifth embodiment of the present application proposes another high precision and stability implementation method of PLCOPEN motion control. The fifth embodiment is only a preferred method of the first embodiment, and the implementation of the fifth embodiment will not affect the independent implementation of the first embodiment.
[0100] Specifically, the difference of the high precision and stability implementation method of PLCOPEN motion control provided by the fifth embodiment of the present application is that, in a high precision and stability implementation method of PLCOPEN motion control, the motor control service is executed in a periodic manner in another thread, and the periodic execution includes the following steps:
[0101] Read the current data from the motor;
[0102] Assign the input data of the function block from the data exchange area of the function block;
[0103] Execute the path planning algorithm to calculate the command instructions for the next motor cycle;
[0104] All function blocks are executed sequentially, and the function blocks perform logical processing based on their respective internal data areas;
[0105] Assign the output data in the internal data area of all function blocks to the data exchange area of the function blocks;
[0106] The motor control instructions output by the path planning algorithm are sent to the motor.
[0107] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0108] It solves the problem of ensuring data synchronization while avoiding the inefficiency caused by long-term lock protection during the entire user task execution.
[0109] Sixth embodiment
[0110] Please refer to Figure 6 Based on the high precision and stability implementation method of PLCOPEN motion control provided by the first embodiment of the present application, the sixth embodiment of the present application proposes another high precision and stability implementation method of PLCOPEN motion control. The sixth embodiment is only a preferred method of the first embodiment, and the implementation of the sixth embodiment will not affect the independent implementation of the first embodiment.
[0111] Specifically, the difference of the high-precision and stability implementation method of PLCOPEN motion control provided by the sixth embodiment of the present application is that, in a high-precision and stability implementation method of PLCOPEN motion control, the output end of the user control logic is connected to a storage module, the storage module includes a receiving unit, the output end of the receiving unit is connected to a clock unit, the output end of the clock unit is connected to a storage unit, the output end of the storage unit is connected to an output unit, and the storage unit is also connected to a deletion unit.
[0112] When in use, the data edited by the user will be received by the receiving unit, and then the editing time will be marked by the clock unit, and then it will be sent to the storage unit for storage. When the data is stored for a long time, the deletion unit will delete the data that has been stored for more than a certain time according to the time marked by the clock unit. When the data needs to be retrieved, it can be retrieved through the output unit;
[0113] The storage time of data can be freely adjusted according to the specific usage of the user, and also needs to be operated accordingly according to the specific storage memory of the storage unit.
[0114] Compared with the related art, the method for realizing high precision and stability of PLCOPEN motion control provided by the present invention has the following beneficial effects:
[0115] Through the setting of the storage module, while the axes and function blocks are edited through the user control logic, the edited data can be stored inside the storage module, so that the user can retrieve the edited data later.
[0116] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for achieving high precision and stability of PLCOPEN motion control, characterized in that: The following steps are involved: S1, during the loading of the PLC application, separate the user control logic task and the motor control service task into different threads for execution; S2, then using the function block as a unit, provides motor motion control services on the motor control task; S3, the user control logic executes the motion control function block, sends a control request of the corresponding function block to the motor control service task and evaluates the motion state, then the motor control service task completes the motion command required by the current function block in an asynchronous manner, and then performs calculations according to the motion control algorithm, and converts the calculation results into signals that can be recognized by the servo motor, which are connected through the bus and servo motor interface and then transmitted to the motor for execution.
2. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: The user control logic is a program developed by a PLC user using the PLC's IDE (Integrated Development Environment), and the motor control service is a service built into the PLC system.
3. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: In the process of loading the PLC application, it is necessary to create axis objects one by one and establish a mapping relationship between the axis objects on both sides.
4. A method for realizing high precision and stability of PLCOPEN motion control according to claim 3, characterized in that: The process of creating an axis includes the following steps: Start the process of creating the axis on the PLC application side; Call request to create an axis object on the motor control service; The motor control service creates an axis object locally; The motor control service returns the identifier of the newly created axis, which can be a unique integer; The PLC application uses the returned axis ID as the identifier of the newly created axis within the application.
5. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: The process of loading the PLC application program requires creating function block objects one by one and establishing a mapping relationship between the function block objects on both sides.
6. A method for realizing high precision and stability of PLCOPEN motion control according to claim 5, characterized in that: The process of creating a function block includes the following steps: Call the initialization function of the function block. The name and parameter type of the initialization function of the function block are determined by the compiler. The function parameters include: a) the starting address of the data area of the function block; The initialization function of the function block allocates a data exchange area for the function block; The initialization function of the function block applies to create a mapped function block on the motor control service side. The application includes the address of the data exchange area. The data exchange area is accessed by both the user control logic and the motor control service. It must be protected by a lock to prevent data inconsistency errors caused by multi-threading. The motor control service creates an internal data area corresponding to the function block internally; The motor control service saves the address reference to the data exchange area of the function block in the internal data area of the internal function block; The motor control service returns success; The initialization function of the function block returns the address of the data exchange area of the function block; The initialization program saves the returned address in the pointer area inside the function block. This area is invisible to the application and is internal data controlled by the PLC program compiler.
7. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: The PLC application cyclically runs tasks in user code in independent threads.
8. A method for realizing high precision and stability of PLCOPEN motion control according to claim 7, characterized in that: The process of a cycle operation includes the following steps: Synchronize the output type data of all function blocks from the data exchange area of the function blocks; Before calling the motion control function block in the program, copy the input parameters of the called function block to the input data area of the function block; Then call the execution function corresponding to the function block. The execution function is provided by the motion control library, and its function name and function parameters conform to the convention of the PLC compiler; According to the logic of the user program, all function block calls are executed in sequence; After all function block calls are executed, the input data areas of all function block data are assigned to the corresponding data exchange areas.
9. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: The motor control service is executed in another thread in a periodic manner, and the periodic execution includes the following steps: Read the current data from the motor; Assign the input data of the function block from the data exchange area of the function block; Execute the path planning algorithm to calculate the command instructions for the next motor cycle; All function blocks are executed sequentially, and the function blocks perform logical processing based on their respective internal data areas; Assign the output data in the internal data area of all function blocks to the data exchange area of the function blocks; The motor control instructions output by the path planning algorithm are sent to the motor.
10. A method for realizing high precision and stability of PLCOPEN motion control according to claim 1, characterized in that: The output end of the user control logic is connected to a storage module, the storage module includes a receiving unit, the output end of the receiving unit is connected to a clock unit, the output end of the clock unit is connected to a storage unit, the output end of the storage unit is connected to an output unit, and the storage unit is also connected to a deletion unit.