Motion control method and system, electronic equipment and readable storage medium
By sorting and storing position values in the PLC system and switching buffer matching, the problem of inefficiency in the prior art is solved, and more efficient matching and more accurate action signal triggering is achieved.
Patent Information
- Application Number
- CN202510064195.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-15
AI Technical Summary
When existing PLC systems process multi-type mixed and large-scale position comparison data, they are inefficient, resulting in an increase in matching time and prone to false triggering or missed triggering of action signals.
Reduce unnecessary matching operations by sorting and storing the position values on the same motion track according to the position comparison type rules corresponding to the cache area where it is located, and immediately switch to the next cache area for matching when the match fails.
It reduces matching time, improves matching efficiency, avoids mistriggering or mistriggering of action signals, and improves the performance of the PLC system.
Smart Images

Figure CN119806034A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motion control, and in particular to a motion control method, system, electronic equipment and readable storage medium. Background Art
[0002] In the motion control of PLC (Programmable Logic Controller) system, there are many types of position comparisons, such as position advance, position lag, time advance, time lag, etc., according to different application processes and requirements. In the actual motion trajectory, comparisons are often required at multiple positions, and these comparisons may involve many different types.
[0003] In the related art, the position comparison data is usually stored in a certain storage space according to the order of user input, and all the data in the storage space must be traversed each time the position comparison is performed. However, this method works well when processing a single, small number of position comparisons, but for the situation of multi-type mixed, large amount of position comparison data in actual applications, it is inefficient because it takes more comparison time.
[0004] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the invention
[0005] The purpose of the present invention is to provide a motion control method, system, electronic device and readable storage medium, which can reduce the matching time, improve the matching efficiency, avoid the situation of false triggering or missed triggering of action signals, and improve the performance of the PLC system.
[0006] In order to solve the above technical problems, the present invention provides a motion control method, comprising:
[0007] Get the current position value of the motor;
[0008] Performing a matching operation on the current position value and the first position value to be selected in the buffer area, if the matching fails, replacing the buffer area and repeating the matching operation until the matching succeeds, triggering an action signal corresponding to the position value that successfully matches;
[0009] Among them, each of the cache areas is used to store position values of the corresponding position comparison type, and the position values of each position comparison type on the same motion trajectory are stored in the corresponding cache area in order according to the rules corresponding to the position comparison type, and the selected position value is the position value that has not been matched in the cache area.
[0010] Optionally, the process of matching the current position value with the first position value to be selected in the buffer area includes:
[0011] Determine the difference between the current position value and the first position value to be selected in the buffer;
[0012] In response to the difference being less than a preset threshold, determining that the current position value and the first position value to be selected in the buffer area match successfully;
[0013] In response to the difference being not less than the preset threshold, it is determined that the current position value and the first position value to be selected in the buffer area fail to match.
[0014] Optionally, the motion control method further includes:
[0015] In response to the existence of a candidate position value in the current cache area where the successfully matched position value is located, a matching operation is performed on the current position value and the first candidate position value in the current cache area. If the match is successful, an action signal of the successfully matched position value is triggered and this step is repeated until there is no candidate position value in the current cache area or the match fails, the cache area is replaced and the matching operation is repeated.
[0016] Optionally, the motion control method further includes:
[0017] Deleting the successfully matched position value from the current buffer area;
[0018] or,
[0019] A match completion mark is added to the position value of the successful match in the current buffer area.
[0020] Optionally, the motion control method further includes:
[0021] Creating multiple buffer areas in one-to-one correspondence according to multiple position comparison types included in the motion trajectory; the position comparison types include an advance class and a lag class, and the rules corresponding to the position comparison types include a large-to-small rule corresponding to the advance class and a small-to-large rule corresponding to the lag class;
[0022] For each of the cache areas, if the position comparison type corresponding to the cache area is the leading type, the position values in the cache area are stored in order from large to small; if the position comparison type corresponding to the cache area is the lagging type, the position values in the cache area are stored in order from small to large.
[0023] Optionally, the motion control method further includes:
[0024] Acquire position comparison data selected by the user for the motion trajectory; the position comparison data includes a position value and a position comparison type;
[0025] For each of the position comparison data, the position value in the position comparison data is written into a candidate buffer area corresponding to the position comparison type in the position comparison data.
[0026] Optionally, the process of matching the current position value with the first position value to be selected in the buffer area, and if the match fails, replacing the buffer area and repeating the matching operation includes:
[0027] Obtaining the matching priority of each of the buffer areas corresponding to the motion trajectory;
[0028] The target cache area is determined from all unmatched cache areas in descending order of the matching priority, and the current position value is matched with the first position value to be selected in the target cache area. If the match fails, repeat this step.
[0029] In order to solve the above technical problems, the present invention further provides a motion control system, comprising:
[0030] The acquisition module is used to obtain the current position value of the motor;
[0031] A matching control module, used for matching the current position value with the first position value to be selected in the buffer area, and if the matching fails, replacing the buffer area and repeating the matching operation until the matching succeeds, thereby triggering an action signal corresponding to the position value that successfully matches;
[0032] Among them, each of the cache areas is used to store position values of the corresponding position comparison type, and the position values of each position comparison type on the same motion trajectory are stored in the corresponding cache area in order according to the rules corresponding to the position comparison type, and the selected position value is the position value that has not been matched in the cache area.
[0033] In order to solve the above technical problems, the present invention further provides an electronic device, comprising:
[0034] Memory for storing computer programs;
[0035] A processor is used to implement the steps of any one of the motion control methods described above when executing the computer program.
[0036] To solve the above technical problems, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the motion control method described in any one of the above items are implemented.
[0037] The present invention provides a motion control method, which sorts and stores position values on the same motion trajectory according to the position comparison type rules corresponding to the buffer area where the position values are located, thereby reducing unnecessary matching operations. When the match fails, the next buffer area is immediately switched to instead of continuing to search in the same buffer area, thereby reducing the matching time and improving the matching efficiency. Since the position values are stored in the buffer area in an orderly manner, it is possible to more accurately judge whether to trigger the position comparison, thereby avoiding the situation of false triggering or missed triggering, and improving the performance of the PLC system.
[0038] The present invention also provides a motion control system, an electronic device and a computer-readable storage medium, which have the same beneficial effects as the above-mentioned motion control method. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 A flow chart of the steps of the first motion control method provided by the present invention;
[0041] Figure 2 A schematic diagram of storing position comparison data provided by the present invention;
[0042] Figure 3 A flow chart of the steps of the second motion control method provided by the present invention;
[0043] Figure 4 A schematic diagram of the structure of a motion control system provided by the present invention;
[0044] Figure 5 A schematic diagram of the structure of an electronic device provided by the present invention;
[0045] Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0046] The core of the present invention is to provide a motion control method, system, electronic device and readable storage medium, which can reduce matching time, improve matching efficiency, avoid false triggering or missed triggering of action signals, and improve the performance of the PLC system.
[0047] 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] First, please refer to Figure 1 The present invention provides a motion control method, comprising:
[0049] S101: Get the current position value of the motor;
[0050] In this embodiment, the current position value of the motor can be obtained according to a preset acquisition cycle, and the acquisition cycle can be the same as the control cycle of the motor. This synchronization method can ensure that the latest position value of the motor is obtained in each control cycle, and provide accurate data basis for subsequent position comparison and control actions. For example, assuming that the control cycle of the motor is 10ms, the current position value of the motor can be automatically obtained every 10ms to ensure the continuity and real-time nature of the control. The current position value of the motor can also be obtained when the preset conditions are met. The triggering conditions for obtaining the current position value are not specifically limited in this embodiment. It can be understood that the current position value of the motor can specifically be the position value corresponding to the motion trajectory currently being executed by the PLC system, so as to perform accurate position comparison and trigger control actions.
[0051] S102: Matching the current position value with the first position value to be selected in the buffer; wherein each buffer is used to store position values of corresponding position comparison types, and position values of each position comparison type on the same motion trajectory are sorted and stored in the corresponding buffer according to the rules corresponding to the position comparison type, and the position value to be selected is a position value that has not been matched in the buffer;
[0052] S103: If the matching fails, replace the buffer area and repeat the matching operation;
[0053] S104: If the match is successful, trigger an action signal corresponding to the position value of the successful match.
[0054] In this embodiment, before executing this step, it also includes the operation of pre-creating multiple cache areas corresponding to multiple position comparison types. For example, assuming that the position comparison types include position advance, position lag, time advance and time lag, the multiple cache areas include position advance cache area, position lag cache area, time advance cache area and time lag cache area. Multiple position comparison data on a motion trajectory are stored in the corresponding cache areas. The position comparison data includes position value and position comparison type. For example, position value A, whose corresponding position comparison type is position advance, is written into the position advance cache area. The position values in each cache area are sorted and stored according to the rules corresponding to the position comparison type. The rules corresponding to the position comparison type include but are not limited to the sorting rules of position values from large to small (i.e., descending order), the sorting rules from small to large (i.e., ascending order), etc.
[0055] Taking three buffer areas as an example, the three buffer areas include buffer area A, buffer area B and buffer area C. Since each position value is sorted and stored in its corresponding buffer area according to its position comparison type according to a preset rule, when performing position comparison, this embodiment compares the current position value with the first candidate position value A in buffer area A. P1 Perform a matching operation. The position value to be selected is the position value in the buffer A that has not been matched with the current position value. The first position value A to be selected P1 Refers to the first position value stored in cache A according to the preset rules. If the match is successful, the position value A is triggered. P1 If the corresponding action signal fails to match, no operation is performed on the position value in buffer A, and it is directly switched to buffer B, and the current position value and the first candidate position value B in buffer B are matched. P1 Perform a matching operation. If the match is successful, the position value B is triggered. P1 If the corresponding action signal fails to match, it will directly switch to buffer area C and continue to match the current position value with the first candidate position value in buffer area C until the match succeeds. If all buffer areas fail to match, you can start matching again from buffer area A, or perform other processing according to the actual situation.
[0056] It can be understood that each position value is sorted and stored in the corresponding buffer area according to its position comparison type according to the preset rules, making the matching operation more efficient. The PLC system can quickly locate the position value that may be matched, avoiding the time consumption of searching one by one in the disordered data. If the current buffer area used for matching fails to match, the position comparison in the buffer area can be stopped immediately and directly switched to the next buffer area, thereby reducing unnecessary data comparison judgments, improving the efficiency of real-time position comparison, and improving the response speed of the PLC system. For the situation where multiple position comparison types are mixed in the same motion trajectory, the comparison judgment of a single buffer area is changed from one by one to the comparison judgment of multiple buffer areas after sorting, which reduces the judgment of sequential traversal, thereby improving the efficiency of position comparison. Since the position values are stored in order in the buffer area, it can be more accurately judged whether to trigger the position comparison, thereby avoiding the situation of false triggering or missed triggering, and ensuring the accuracy and reliability of the control action.
[0057] It can be seen that in this embodiment, the position values on the same motion trajectory are sorted and stored according to the position comparison type rules corresponding to the cache area where they are located, which can reduce unnecessary matching operations. When the match fails, it immediately switches to the next cache area instead of continuing to search in the same cache area, thereby reducing the matching time and improving the matching efficiency. Since the position values are stored in order in the cache area, it can be more accurately determined whether to trigger the position comparison, thereby avoiding false triggering or missed triggering, and improving the performance of the PLC system.
[0058] Based on the above embodiments:
[0059] In an exemplary embodiment, the process of matching the current position value with the first position value to be selected in the buffer includes:
[0060] Determine the difference between the current position value and the first candidate position value in the buffer;
[0061] In response to the difference being less than a preset threshold, determining that the current position value and the first position value to be selected in the buffer area match successfully;
[0062] In response to the difference being not less than a preset threshold, it is determined that the current position value and the first position value to be selected in the buffer area fail to match.
[0063] In this embodiment, when performing a matching operation, first obtain the difference between the current position value and the first position value to be selected in the buffer area. This difference can be an absolute difference or a relative difference, which can be set according to the actual application scenario and control requirements. If the difference is less than the preset threshold, it means that the motor has approached or reached the target position, and the trigger condition of the action signal corresponding to the first position value to be selected is met. At this time, it is determined that the match is successful, the action signal corresponding to the first position value to be selected is triggered, and the corresponding control action is performed. If the difference is greater than or equal to the preset threshold, it is determined that the current position value and the first position value to be selected in the buffer area fail to match. Considering that the position values in each buffer area are stored in a preset order, the first position value to be selected fails to match, indicating that other position values will also fail to match. At this time, the buffer area is directly replaced for matching, avoiding the time consumption of continuing to search in the current buffer area. Among them, the preset threshold can be set and adjusted according to the actual engineering needs to adapt to different application scenarios. The preset threshold can also be adaptively set according to the fault tolerance range of each position value or action signal for the motion trajectory.
[0064] In an exemplary embodiment, the motion control method further includes:
[0065] In response to the existence of a candidate position value in the current cache area where the successfully matched position value is located, a matching operation is performed on the current position value and the first candidate position value in the current cache area. If the match is successful, an action signal of the successfully matched position value is triggered and this step is repeated until there is no candidate position value in the current cache area or the match fails, the cache area is replaced and the matching operation is repeated.
[0066] In this embodiment, if there is a successfully matched position value in a certain cache area, after the action signal corresponding to the position value is triggered, the cache area is determined as the current cache area, and it is determined whether there are any candidate position values in the current cache area that have not been matched with the current position value. If so, the current position value and the first candidate position value in the current cache area are matched. At this time, the first candidate position value is the next candidate position value of the successfully matched position value. If the match is successful, it is continued to be determined whether there are any candidate position values in the current cache area, and the above steps are repeated until there are no candidate position values in the current cache area or the first candidate position value and the current position value fail to match, at which time the cache area is replaced.
[0067] For example, it is assumed that the buffer area A includes position values A arranged in sequence P1 , A P2 , A P3 , none of the three position values have been matched, and the position value A P1 That is, the first position value to be selected in buffer area A. First, the current position value and position value A P1If the difference between the two is less than the preset threshold, it means the match is successful and the trigger position value A P1 The corresponding action signal, due to A P1 It has been matched once and is no longer a candidate position value. At this time, position value A P2 For the first candidate position value in buffer A, the current position value and position value A are P2 If the difference between the two is less than the preset threshold, it means the match is successful and the trigger position value A P2 The corresponding action signal, due to A P2 It has been matched once and is no longer a candidate position value. At this time, position value A P3 For the first candidate position value in buffer A, the current position value and position value A are P3 If the difference between the two is not less than the preset threshold, it means that the match fails, and the buffer area B is switched to perform the above matching operation. P3 If the difference between the two is less than the preset threshold, it means the match is successful and the trigger position value A P3 After the action signal is received, there are no other position values to be selected in buffer area A, and the buffer area B is switched to perform the above matching operation.
[0068] It can be understood that matching is performed in sequence according to the sorting order of the position values in the buffer area, which ensures the orderliness and logic of the matching process and avoids confusion and repeated matching. Once the match is successful, the action signal of the corresponding position value is triggered immediately, which ensures the timeliness and accuracy of the control action and meets the requirements of real-time control. When a position value fails to match or there is no position value to be selected in the buffer area, it can quickly judge and switch to the next buffer area for matching, reducing unnecessary matching operations and time consumption, and improving the efficiency of the system.
[0069] In an exemplary embodiment, the motion control method further includes:
[0070] Delete the successfully matched position value from the current cache.
[0071] In this embodiment, if the current position value is equal to a position value in the buffer (such as A P1 ) After a successful match, the position value is directly deleted from the current cache area, thereby updating the list of candidate position values in the cache area, making the next candidate position value become the new first candidate position value. By deleting the successfully matched position value, the amount of data storage in the cache area can be reduced, reducing the storage burden of the system. Subsequent matching operations only need to focus on the remaining candidate position values, simplifying the matching logic, improving matching efficiency, and ensuring that each position value is matched only once, avoiding errors or redundant operations caused by repeated matching.
[0072] In an exemplary embodiment, the motion control method further includes: adding a matching completion mark to the successfully matched position value in the current buffer area.
[0073] In this embodiment, if the current position value is equal to a position value in the buffer (such as A P1 ) After the match is successful, a match completion mark is added to the position value. The match completion mark can be a specific identifier or status flag to indicate that the position value has been successfully matched. By adding a mark instead of deleting the position value, the complete information of the position value is retained, which is convenient for subsequent recording, querying and analysis. The matching process can be flexibly managed according to the status of the mark. For example, you can check at any time which position values have been matched successfully and which have not been matched, which is convenient for dynamic adjustment and optimization. In addition, adding a mark will not change the structure of the cache area, making the management of the cache area simpler and more stable.
[0074] As an optional embodiment, a suitable solution can be selected according to the needs and characteristics of the actual application scenario. If the storage space requirement is high and there is no need to retain the matching history information, you can choose to delete the successfully matched position value. If it is necessary to record the matching process or perform complex matching management, you can choose to add a matching completion mark to the successfully matched position value. This embodiment is not specifically limited here.
[0075] In an exemplary embodiment, the motion control method further includes:
[0076] Multiple buffer areas are created one by one according to multiple position comparison types included in the motion trajectory; the position comparison types include an advance class and a lag class, and the rules corresponding to the position comparison types include a large-to-small rule corresponding to the advance class and a small-to-large rule corresponding to the lag class;
[0077] For each cache area, if the position comparison type corresponding to the cache area is the leading type, the position values in the cache area are stored in order from large to small. If the position comparison type corresponding to the cache area is the lagging type, the position values in the cache area are stored in order from small to large.
[0078] It can be understood that in the motion control of the PLC system, multiple motion trajectories will be included. This embodiment creates a cache area for each motion trajectory according to the position comparison type contained in each motion trajectory. For example, assuming that the motion trajectory L1 includes three position comparison types, three cache areas can be established, and the motion trajectory L2 includes four position comparison types, and four cache areas can be established. This creation method allows the position comparison data of each motion trajectory to be stored independently, and unnecessary cache area comparisons can be reduced when changing the cache area, thereby improving the efficiency of position comparison. Of course, the same number of cache areas can also be created for each motion trajectory according to the position comparison type contained in each motion trajectory, such as creating four cache areas for each motion trajectory.
[0079] In this embodiment, for each cache area, since each of them corresponds to a different position comparison type, different position comparison types correspond to different rules corresponding to the position comparison type. The rule corresponding to the position comparison type is the sorting rule of the position value in the cache area. This embodiment divides the position comparison type into two categories, namely, the leading category and the lagging category. The leading category includes but is not limited to time advance, position advance, etc. The action signal of this type of position comparison type needs to be triggered before reaching or passing a certain position or time point. The lagging category includes but is not limited to time lag, position lag, etc. The action signal of this type of position comparison type needs to be triggered after passing a certain position or time point. For the leading cache area, the corresponding position comparison type rule is the descending rule. For the lagging cache area, the corresponding position comparison type rule is the ascending rule. The specific sorting rules are as follows:
[0080] Position advance buffer area: The position advance data of the same trajectory is stored in descending order from large to small. In this way, when the motor approaches a set position, it can match a larger position value first to ensure that the action signal is triggered in time before reaching the position.
[0081] Position lag buffer: The position lag data of the same trajectory is stored in ascending order from small to large. When the motor passes a set position, a smaller position value can be matched first to ensure that the action signal is triggered in time after passing the position.
[0082] Time advance buffer area: The time advance data of the same trajectory is stored in descending order from large to small. In this way, when the time is close to a certain set time point, the earlier time point can be matched first to ensure that the action signal is triggered in time before the time point.
[0083] Time lag buffer area: The time lag data of the same trajectory is stored in ascending order from small to large. In this way, when the time exceeds a certain set time point, the later time point can be matched first to ensure that the action signal is triggered in time after the time point.
[0084] In an exemplary embodiment, the motion control method further includes:
[0085] Obtaining the position comparison data selected by the user for the motion trajectory; the position comparison data includes a position value and a position comparison type;
[0086] For each position comparison data, the position value in the position comparison data is written into a candidate buffer area corresponding to the position comparison type in the position comparison data.
[0087] In this embodiment, the motion trajectory and the position comparison data for the motion trajectory can be selected and input by the user. It can be understood that there will be multiple points on a motion trajectory, and each time the control system moves to a corresponding point, it needs to perform a corresponding action. The user can input the position value on the motion trajectory and the position comparison type corresponding to the position value at one time, and then write the position value into the corresponding cache area according to the position comparison type based on the data input by the user, and sort and store it. The user only needs to input the necessary data, and the solution of this embodiment can automatically complete the subsequent storage and sorting work, simplifying the configuration process and reducing the user's workload. Figure 2 As shown, after the user inputs the target trajectory and the position comparison data, each position comparison data is stored in a different cache area. In the position advance cache area, the position comparison data is arranged in descending order, and in the position lag cache area, the position comparison data is arranged in ascending order. In the time advance cache area, the position comparison data is arranged in descending order, and in the time lag cache area, the position comparison data is arranged in ascending order.
[0088] As another optional embodiment, in addition to position comparison data based on user input, position comparison data on the motion trajectory (such as key position points and position comparison types of key position points) can also be automatically determined based on task requirements, current environmental conditions, historical experience, etc., to improve the accuracy, efficiency and reliability of position control.
[0089] In an exemplary embodiment, a process of matching the current position value with the first position value to be selected in the buffer area, and if the match fails, replacing the buffer area and repeating the matching operation includes:
[0090] Get the matching priority of each buffer area corresponding to the motion trajectory;
[0091] Determine the target buffer from all unmatched buffers in descending order of matching priority, match the current position value with the first candidate position value in the target buffer, and repeat this step if the match fails.
[0092] In this embodiment, the matching priority of each buffer area corresponding to each motion trajectory is also set. The matching priority is set according to the actual application requirements and control logic, and is used to determine the matching order of each buffer area in the current cycle. Assuming that the matching priority of each buffer area is in the order of position advance buffer area, position lag buffer area, time advance buffer area, and time lag buffer area from high to low, then in the current cycle, the current position value of the motor in the current cycle is first compared with the first candidate position value of the position advance buffer area. If the match is successful, a cyclic comparison is performed in the position advance buffer area. If the match fails, it is directly switched to the position lag buffer area, and so on. Finally, it switches to the time lag buffer area, and then waits for the next cycle to be processed. Refer to Figure 3 In this embodiment, in each cycle, there is no need to traverse all position values to determine whether the current cycle needs to perform a corresponding action. When the first candidate position value in a cache area is not satisfied, it is directly switched to the next cache area, which can avoid invalid matching operations in an empty cache area, reduce unnecessary calculations and time consumption, and improve matching efficiency.
[0093] It can be understood that due to the setting of matching priority, the data in the cache may change dynamically. For example, some actions have been completed, and the corresponding position value is deleted from the cache or marked as matched. By first determining whether there is data in the cache, it is possible to flexibly adapt to these changes and ensure the accuracy and effectiveness of the matching operation. Specifically, after obtaining the current position value, it is possible to determine whether there is data in the cache before matching. If there is no data, it is possible to directly switch to the next cache, further reducing unnecessary calculations and time consumption, and improving matching efficiency.
[0094] In this embodiment, by setting the matching priority and matching in order of priority, the cache area that may be matched can be quickly located, thereby reducing unnecessary matching operations and improving matching efficiency. For example, by giving priority to matching the position advance cache area, it is possible to ensure that the action is triggered in time before the motor reaches the critical position, avoiding delays or errors caused by improper matching order. In addition, the setting of the matching priority enables the system to give priority to critical cache areas according to actual control requirements, thereby improving the accuracy and reliability of the control action. For example, in some application scenarios, position advance actions may be more critical than position-lag or time-related actions. By giving priority to matching the position advance cache area, the timely execution of these critical actions can be ensured.
[0095] In summary, the motion control method provided by the present invention first classifies and stores different types of position comparison data, and then arranges them in ascending or descending order. Therefore, each position comparison can stop the comparison processing immediately if the comparison condition is not met, thereby reducing unnecessary data comparison judgments and improving the efficiency of real-time position comparison.
[0096] Second, please refer to Figure 4 The present invention also provides a motion control system, comprising:
[0097] An acquisition module 11 is used to acquire the current position value of the motor;
[0098] The matching control module 12 is used to match the current position value with the first position value to be selected in the buffer area. If the match fails, the buffer area is replaced and the matching operation is repeated until the match succeeds, thereby triggering an action signal corresponding to the position value that successfully matches;
[0099] Among them, each cache area is used to store the position value of the corresponding position comparison type, and the position values of each position comparison type on the same motion trajectory are stored in the corresponding cache area in order according to the rules corresponding to the position comparison type, and the selected position value is the position value that has not been matched in the cache area.
[0100] In an exemplary embodiment, the process of matching the current position value with the first position value to be selected in the buffer includes:
[0101] Determine the difference between the current position value and the first candidate position value in the buffer;
[0102] In response to the difference being less than a preset threshold, determining that the current position value and the first position value to be selected in the buffer area match successfully;
[0103] In response to the difference being not less than a preset threshold, it is determined that the current position value and the first position value to be selected in the buffer area fail to match.
[0104] In an exemplary embodiment, the motion control system is further configured to:
[0105] In response to the existence of a candidate position value in the current cache area where the successfully matched position value is located, a matching operation is performed on the current position value and the first candidate position value in the current cache area. If the match is successful, an action signal of the successfully matched position value is triggered and this step is repeated until there is no candidate position value in the current cache area or the match fails, the cache area is replaced and the matching operation is repeated.
[0106] In an exemplary embodiment, the motion control system is further configured to:
[0107] Delete the successfully matched position value from the current cache;
[0108] In an exemplary embodiment, the motion control system is further configured to: add a matching completion mark to the successfully matched position value in the current buffer area.
[0109] In an exemplary embodiment, the motion control system is further configured to:
[0110] Multiple buffer areas are created one by one according to multiple position comparison types included in the motion trajectory; the position comparison types include an advance class and a lag class, and the rules corresponding to the position comparison types include a large-to-small rule corresponding to the advance class and a small-to-large rule corresponding to the lag class;
[0111] For each cache area, if the position comparison type corresponding to the cache area is the leading type, the position values in the cache area are stored in order from large to small. If the position comparison type corresponding to the cache area is the lagging type, the position values in the cache area are stored in order from small to large.
[0112] In an exemplary embodiment, the motion control system is further configured to:
[0113] Obtaining the position comparison data selected by the user for the motion trajectory; the position comparison data includes a position value and a position comparison type;
[0114] For each position comparison data, the position value in the position comparison data is written into a candidate buffer area corresponding to the position comparison type in the position comparison data.
[0115] In an exemplary embodiment, a process of matching the current position value with the first position value to be selected in the buffer area, and if the match fails, replacing the buffer area and repeating the matching operation includes:
[0116] Get the matching priority of each buffer area corresponding to the motion trajectory;
[0117] Determine the target buffer from all unmatched buffers in descending order of matching priority, match the current position value with the first candidate position value in the target buffer, and repeat this step if the match fails.
[0118] Third, please refer to Figure 5 The present invention also provides an electronic device, comprising:
[0119] A memory 21, used for storing computer programs;
[0120] The processor 22 is used to implement the steps of the motion control method described in any one of the above embodiments when executing the computer program.
[0121] The electronic device also includes:
[0122] The input interface 23 is connected to the processor 22 via the communication bus 26, and is used to obtain the computer programs, parameters and instructions imported from the outside, and save them in the memory 21 under the control of the processor 22. The input interface can be connected to an input device to receive parameters or instructions manually input by the user. The input device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the terminal housing.
[0123] The display unit 24 is connected to the processor 22 via the communication bus 26 and is used to display the data sent by the processor 22. The display unit can be a liquid crystal display or an electronic ink display.
[0124] The network port 25 is connected to the processor 22 via the communication bus 26, and is used to communicate with various external terminal devices. The communication technology used in the communication connection can be a wired communication technology or a wireless communication technology, such as mobile high-definition link technology, universal serial bus, high-definition multimedia interface, wireless fidelity technology, Bluetooth communication technology, low-power Bluetooth communication technology, communication technology based on IEEE802.11s, etc.
[0125] For an introduction to an electronic device provided by the present invention, please refer to the above embodiments, and the present invention will not be described in detail here.
[0126] The electronic device provided by the present invention has the same beneficial effects as the above-mentioned motion control method.
[0127] Fourth, please refer to Figure 6 The present invention further provides a computer-readable storage medium 30, on which a computer program 31 is stored. When the computer program 31 is executed by a processor, the steps of the motion control method described in any one of the above embodiments are implemented.
[0128] The computer-readable storage medium 30 may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0129] For an introduction to a computer-readable storage medium 30 provided by the present invention, please refer to the above embodiment, and the present invention will not be described in detail here.
[0130] A computer-readable storage medium 30 provided by the present invention has the same beneficial effects as the above-mentioned motion control method.
[0131] In a fifth aspect, the present invention further provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the motion control method described in any one of the embodiments above.
[0132] For an introduction to a computer program product provided by the present invention, please refer to the above embodiments, and the present invention will not be described in detail here.
[0133] A computer program product provided by the present invention has the same beneficial effects as the above-mentioned motion control method.
[0134] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0135] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A motion control method, characterized in that: include: Get the current position value of the motor; Performing a matching operation on the current position value and the first position value to be selected in the buffer area, if the matching fails, replacing the buffer area and repeating the matching operation until the matching succeeds, triggering an action signal corresponding to the position value that successfully matches; Among them, each of the cache areas is used to store position values of the corresponding position comparison type, and the position values of each position comparison type on the same motion trajectory are stored in the corresponding cache area in order according to the rules corresponding to the position comparison type, and the selected position value is the position value that has not been matched in the cache area.
2. The motion control method according to claim 1, characterized in that: The process of matching the current position value with the first position value to be selected in the buffer area includes: Determine the difference between the current position value and the first position value to be selected in the buffer; In response to the difference being less than a preset threshold, determining that the current position value and the first position value to be selected in the buffer area match successfully; In response to the difference being not less than the preset threshold, it is determined that the current position value and the first position value to be selected in the buffer area fail to match.
3. The motion control method according to claim 1, characterized in that: The motion control method further comprises: In response to the existence of a candidate position value in the current cache area where the successfully matched position value is located, a matching operation is performed on the current position value and the first candidate position value in the current cache area. If the match is successful, an action signal of the successfully matched position value is triggered and this step is repeated until there is no candidate position value in the current cache area or the match fails, the cache area is replaced and the matching operation is repeated.
4. The motion control method according to claim 3, characterized in that: The motion control method further comprises: Deleting the successfully matched position value from the current buffer area; or, A match completion mark is added to the position value of the successful match in the current buffer area.
5. The motion control method according to claim 1, characterized in that: The motion control method further comprises: Creating multiple buffer areas in one-to-one correspondence according to multiple position comparison types included in the motion trajectory; the position comparison types include an advance class and a lag class, and the rules corresponding to the position comparison types include a large-to-small rule corresponding to the advance class and a small-to-large rule corresponding to the lag class; For each of the cache areas, if the position comparison type corresponding to the cache area is the leading type, the position values in the cache area are stored in order from large to small; if the position comparison type corresponding to the cache area is the lagging type, the position values in the cache area are stored in order from small to large.
6. The motion control method according to claim 5, characterized in that: The motion control method further comprises: Acquire position comparison data selected by the user for the motion trajectory; the position comparison data includes a position value and a position comparison type; For each of the position comparison data, the position value in the position comparison data is written into a candidate buffer area corresponding to the position comparison type in the position comparison data.
7. The motion control method according to any one of claims 1 to 6, characterized in that: The process of matching the current position value with the first position value to be selected in the buffer area, and if the matching fails, replacing the buffer area and repeating the matching operation includes: Obtaining the matching priority of each of the buffer areas corresponding to the motion trajectory; The target cache area is determined from all unmatched cache areas in descending order of the matching priority, and the current position value is matched with the first position value to be selected in the target cache area. If the match fails, repeat this step.
8. A motion control system, characterized in that: include: The acquisition module is used to obtain the current position value of the motor; A matching control module, used for matching the current position value with the first position value to be selected in the buffer area, and if the matching fails, replacing the buffer area and repeating the matching operation until the matching succeeds, thereby triggering an action signal corresponding to the position value that successfully matches; Among them, each of the cache areas is used to store position values of the corresponding position comparison type, and the position values of each position comparison type on the same motion trajectory are stored in the corresponding cache area in order according to the rules corresponding to the position comparison type. The candidate position value is the position value that has not been matched in the cache area.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the motion control method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the motion control method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
A real-time data storage method
CN109189721A
Configurable motor speed and position high-speed parallel detection method and system, and medium
CN111446891A
Linear motor equipment, control method and device thereof and readable storage medium
CN119276159A
Motion control system
JP2006072399A
Digital control of motor drives
US20090009113A1