A motion control method, system, electronic device and readable storage medium
By classifying and sorting the location comparison data by type in the PLC system, the problems of long matching time and low efficiency under mixed types and large amounts of location comparison data are solved, achieving more efficient matching and accurate action signal triggering.
Patent Information
- Application Number
- CN202510064195.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-01-15
AI Technical Summary
Existing PLC systems suffer from long matching times, low efficiency, and are prone to false or missed triggering of action signals when dealing with mixed types of data and large amounts of position comparison data.
The position comparison data is categorized by type and stored in a cache, and sorted according to the corresponding rules. When matching, it is first performed in one cache. If it fails, it switches to the next cache until a match is successful, triggering an action signal.
It reduces unnecessary matching operations, improves matching efficiency, avoids false triggering or missed triggering, and enhances the performance of the PLC system.
Smart Images

Figure CN119806034B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motion control, and in particular to a motion control method, system, electronic device, and readable storage medium. Background Technology
[0002] In motion control within a PLC (Programmable Logic Controller) system, various position comparison types exist depending on the application process and requirements, such as position advance, position lag, time advance, and time lag. In actual motion trajectories, comparisons are often required at multiple positions, and these comparisons may involve several different types.
[0003] In related technologies, position comparison data is typically stored in a storage space according to the user's input order. Each time a position comparison is performed, all data in the storage space must be traversed. However, while this method works reasonably well for handling single, small amounts of position comparisons, it becomes inefficient for real-world applications involving mixed types of position comparison data due to the increased comparison time required.
[0004] Therefore, how to provide a solution to the above-mentioned technical problems is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a motion control method, system, electronic device, and readable storage medium that can reduce matching time, improve matching efficiency, avoid false or missed triggering of motion signals, and improve the performance of PLC systems.
[0006] To solve the above-mentioned technical problems, the present invention provides a motion control method, comprising:
[0007] Get the current position value of the motor;
[0008] The current position value is matched with the first candidate position value in the buffer. If the match fails, the buffer is changed and the matching operation is repeated until the match is successful, and the action signal corresponding to the successfully matched position value is triggered.
[0009] Each of the buffer areas is used to store position values of the corresponding position comparison type, and the position values of each of the position comparison types on the same motion trajectory are sorted and stored in the corresponding buffer area according to the rules corresponding to the position comparison type. The candidate position value is the position value in the buffer area that has not been matched.
[0010] Optionally, the process of matching the current position value with the first candidate position value in the cache includes:
[0011] Determine the difference between the current position value and the first candidate position value in the buffer;
[0012] In response to the difference being less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer are successfully matched;
[0013] In response to the difference being not less than the preset threshold, it is determined that the current position value and the first candidate position value in the cache area have failed 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 where the successfully matched position value is located, the current position value is matched with the first candidate position value in the current cache. If the match is successful, the 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 or the match fails. Then the cache is changed and the matching operation is repeated.
[0016] Optionally, the motion control method further includes:
[0017] Remove the successfully matched position value from the current cache.
[0018] or,
[0019] Add a match completion marker to the position value of a successful match in the current cache area.
[0020] Optionally, the motion control method further includes:
[0021] Multiple buffers are created one-to-one with the multiple position comparison types included in the motion trajectory; the position comparison types include leading and lagging types, and the rules corresponding to the position comparison types include rules from large to small corresponding to the leading type, and rules from small to large corresponding to the lagging type.
[0022] For each cache region, if the position comparison type corresponding to the cache region is the ahead type, the position values in the cache region are stored in descending order; if the position comparison type corresponding to the cache region is the lag type, the position values in the cache region are stored in ascending order.
[0023] Optionally, the motion control method further includes:
[0024] Obtain location comparison data selected by the user for the motion trajectory; the location comparison data includes location values and location comparison types.
[0025] For each location comparison data, the location value in the location comparison data is written into the candidate cache area corresponding to the location comparison type in the location comparison data.
[0026] Optionally, the process of matching the current position value with the first candidate position value in the cache, and if the match fails, changing the cache and repeating the matching operation includes:
[0027] Obtain the matching priority of each of the buffer zones corresponding to the motion trajectory;
[0028] The target cache is determined from all unmatched caches in descending order of matching priority. The current position value is matched with the first candidate position value in the target cache. If the match fails, this step is repeated.
[0029] To address the aforementioned technical problems, the present invention also provides a motion control system, comprising:
[0030] The acquisition module is used to acquire the current position value of the motor;
[0031] The matching control module is used to match the current position value with the first candidate position value in the buffer. If the matching fails, the buffer is changed and the matching operation is repeated until the matching is successful, and the action signal corresponding to the successfully matched position value is triggered.
[0032] Each of the buffer areas is used to store position values of the corresponding position comparison type, and the position values of each of the position comparison types on the same motion trajectory are sorted and stored in the corresponding buffer area according to the rules corresponding to the position comparison type. The candidate position value is the position value in the buffer area that has not been matched.
[0033] To address the aforementioned technical problems, the present invention also provides an electronic device, comprising:
[0034] Memory, used to store computer programs;
[0035] A processor for executing the computer program to implement the steps of the motion control method as described in any of the above.
[0036] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the motion control method described in any of the preceding descriptions.
[0037] This invention provides a motion control method that sorts and stores position values on the same motion trajectory according to the position comparison type rules corresponding to their respective buffers. This reduces unnecessary matching operations. When a match fails, the system immediately switches to the next buffer instead of continuing to search within the same buffer, reducing matching time and improving matching efficiency. Since the position values are stored in an ordered manner within the buffers, it is possible to more accurately determine whether a position comparison has been triggered, thereby avoiding false triggers or missed triggers 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-described motion control method. Attached Figure Description
[0039] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart of the steps of the first motion control method provided by the present invention;
[0041] Figure 2 This is a schematic diagram of the storage of location comparison data provided by the present invention;
[0042] Figure 3 This is a flowchart of the steps of the second motion control method provided by the present invention;
[0043] Figure 4 This is a schematic diagram of the structure of a motion control system provided by the present invention;
[0044] Figure 5 This is 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 Implementation
[0046] The core of this 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 or missed triggering of motion signals, and improve the performance of PLC systems.
[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0048] Firstly, 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 acquired according to a preset acquisition cycle. This acquisition cycle can be the same as the motor's control cycle. This synchronization method ensures that the latest position value of the motor is acquired within each control cycle, providing accurate data for subsequent position comparisons and control actions. For example, assuming the motor's control cycle is 10ms, the current position value of the motor can be automatically acquired every 10ms to ensure the continuity and real-time performance of the control. The current position value of the motor can also be acquired when preset conditions are met. This embodiment does not specifically limit the triggering conditions for acquiring the current position value. It can be understood that the current position value of the motor can specifically be the position value corresponding to the currently executing motion trajectory of the PLC system, in order to perform accurate position comparisons and trigger control actions.
[0051] S102: Perform a matching operation between the current position value and the first candidate position value in the buffer; wherein, each buffer 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 sorted and stored in the corresponding buffer according to the rules corresponding to the position comparison type, and the candidate position value is the position value in the buffer that has not been matched.
[0052] S103: If the match fails, change the cache area and repeat the matching operation;
[0053] S104: If a match is successful, trigger the action signal corresponding to the position value of the successful match.
[0054] In this embodiment, before performing this step, the method further includes pre-creating multiple buffers that correspond one-to-one with multiple position comparison types. For example, assuming that the position comparison types include position advance, position lag, time advance, and time lag, the multiple buffers include a position advance buffer, a position lag buffer, a time advance buffer, and a time lag buffer. Multiple position comparison data along a motion trajectory are stored in their respective buffers. The position comparison data includes position values and position comparison types. For example, if position value A corresponds to the position advance type, then position value A is written to the position advance buffer. The position values in each buffer 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, sorting rules from largest to smallest (i.e., descending order) and sorting rules from smallest to largest (i.e., ascending order).
[0055] Taking three buffers as an example, the three buffers include buffer A, buffer B, and buffer C. Since each position value is stored in its corresponding buffer according to a preset rule based on its position comparison type, when performing position comparison, this embodiment first compares the current position value with the first candidate position value A in buffer A. P1 The matching operation is performed, and the candidate position value is the position value in cache A that has not yet been matched with the current position value. The first candidate position value is A. P1 This refers to the first position value stored in cache A according to a preset rule. If a match is found, the value at position A is triggered. P1 If the corresponding action signal fails to match, no operation is performed on the position value in buffer A. Instead, the position is directly moved to buffer B, and the current position value is compared with the first candidate position value B in buffer B. P1 Perform a matching operation; if the match is successful, trigger the value B at that position. P1 If the corresponding action signal fails to match, the process immediately moves to buffer C and continues matching the current position value with the first candidate position value in buffer C until a match is found. If all buffers fail to match, the matching can restart from buffer A, or other processing can be performed depending on the actual situation.
[0056] It is understandable that each position value is sorted and stored in its corresponding buffer according to preset rules based on its position comparison type. This makes the matching operation more efficient, allowing the PLC system to quickly locate potentially matching position values and avoiding the time wasted searching through unordered data. If the current buffer fails to match, the position comparison in that buffer can be stopped immediately, and the system can move to the next buffer. This reduces unnecessary data comparisons, improves real-time position comparison efficiency, and increases the response speed of the PLC system. For situations where multiple position comparison types are mixed in the same motion trajectory, the method changes from sequential comparison in a single buffer to sorting and comparing in multiple buffers, reducing sequential traversal and thus improving position comparison efficiency. Because the position values are stored in an ordered manner within the buffer, it is possible to more accurately determine whether a position comparison has been triggered, thus avoiding false or missed triggers and ensuring the accuracy and reliability of control actions.
[0057] As can be seen, in this embodiment, the position values on the same motion trajectory are sorted and stored according to the position comparison type rules corresponding to their respective buffers, which can reduce unnecessary matching operations. When a match fails, the system immediately switches to the next buffer instead of continuing to search in the same buffer, thus reducing matching time and improving matching efficiency. Since the position values are stored in an ordered manner in the buffers, it is possible to more accurately determine whether a position comparison has been triggered, 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 candidate position value in the buffer includes:
[0060] Determine the difference between the current position value and the first candidate position value in the buffer;
[0061] If the difference is less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer are successfully matched.
[0062] If the difference is not less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer area have failed to match.
[0063] In this embodiment, during the matching operation, the difference between the current position value and the first candidate position value in the buffer is first obtained. 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 a preset threshold, it means that the motor has approached or reached the target position, satisfying the triggering condition of the action signal corresponding to the first candidate position value. At this time, the matching is determined to be successful, and the action signal corresponding to the first candidate position value is triggered to execute the corresponding control action. If the difference is greater than or equal to the preset threshold, it is determined that the current position value and the first candidate position value in the buffer have failed to match. Considering that the position values in each buffer are stored in a preset order, the failure of the first candidate position value to match means that other position values will also fail to match. At this time, the buffer is directly changed for matching, avoiding the time consumption of continuing to search in the current buffer. The preset threshold can be set and adjusted according to actual engineering needs to adapt to different application scenarios. The preset threshold can also be adaptively set to consider the fault tolerance range of each position value or action signal for the motion trajectory.
[0064] In one exemplary embodiment, the motion control method further includes:
[0065] In response to the presence of a candidate position value in the current buffer where the successfully matched position value is located, the current position value is matched with the first candidate position value in the current buffer. If the match is successful, the 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 buffer or the match fails. Then, the buffer is changed and the matching operation is repeated.
[0066] In this embodiment, if a successfully matched position value exists in a certain buffer, after triggering the action signal corresponding to that position value, the buffer is determined as the current buffer. It is then determined whether there are any candidate position values in the current buffer that have not been matched with the current position value. If so, the current position value is matched with the first candidate position value in the current buffer. The first candidate position value is then the next candidate position value after the successfully matched position value. If the match is successful, it is then determined whether there are any candidate position values in the current buffer. The above steps are repeated until there are no candidate position values in the current buffer or the first candidate position value fails to match the current position value. At this point, the buffer is changed.
[0067] For example, suppose cache A contains position values A ordered sequentially. P1 A P2 A P3 None of the three position values have been matched, so position value A is currently unmatched. P1 This refers to the first candidate position value in buffer A. First, the current position value and position value A are set together. P1A matching process is performed. If the difference between the two values is less than a preset threshold, the match is successful, and position value A is triggered. P1 The corresponding action signal, due to A P1 It has already been matched once and is no longer a candidate position value. The current position value is A. P2 For the first candidate position value in buffer A, set the current position value and position value A. P2 A matching process is performed. If the difference between the two values is less than a preset threshold, the match is successful, and position value A is triggered. P2 The corresponding action signal, due to A P2 It has already been matched once and is no longer a candidate position value. The current position value is A. P3 For the first candidate position value in buffer A, set the current position value and position value A. P3 A matching process is performed. If the difference between the two values is not less than a preset threshold, the match fails, and the process is switched to cache B for the next matching operation. Alternatively, the current position value and position value A are compared. P3 A matching process is performed. If the difference between the two values is less than a preset threshold, the match is successful, and position value A is triggered. P3 After the action signal is received, there are no other candidate position values in buffer A, so the matching operation is performed in buffer B.
[0068] As is understandable, matching is performed sequentially according to the order of the position values in the buffer, ensuring the orderliness and logic of the matching process and avoiding chaos and duplicate matching. Once a match is successful, the corresponding position value's action signal is immediately triggered, ensuring the timeliness and accuracy of the control action and meeting the requirements of real-time control. When a position value fails to match or there is no candidate position value in the buffer, the system can quickly determine and switch to the next buffer for matching, reducing unnecessary matching operations and time consumption, and improving system efficiency.
[0069] In one exemplary embodiment, the motion control method further includes:
[0070] Remove the successfully matched position value from the current cache.
[0071] In this embodiment, if the current position value is different from a certain position value in the cache (such as A), P1 Once a match is successful, the position value is directly deleted from the current cache, thereby updating the list of candidate position values in the cache. This makes the next candidate position value the new first candidate position value. By deleting successfully matched position values, the amount of data stored in the cache can be reduced, thus reducing the storage burden on 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 one exemplary embodiment, the motion control method further includes adding a matching completion marker to the position value that was successfully matched in the current buffer.
[0073] In this embodiment, if the current position value is different from a certain position value in the cache (such as A), P1 Upon successful matching, a match completion flag is added to the position value. This flag can be a specific identifier or status indicator to signify that the position value has been successfully matched. By adding flags instead of deleting position values, complete information about the position values is preserved, facilitating subsequent recording, querying, and analysis. The matching process can be flexibly managed based on the flag status. For example, it's possible to view at any time which position values have been successfully matched and which have not, enabling dynamic adjustments and optimizations. Furthermore, adding flags does not alter the cache structure, making cache management 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 there are high requirements for storage space and no need to retain matching history information, the solution of deleting the position values of successful matches can be selected. If it is necessary to record the matching process or perform complex matching management, the solution of adding a matching completion mark to the position values of successful matches can be selected. This embodiment does not make specific limitations here.
[0075] In one exemplary embodiment, the motion control method further includes:
[0076] Multiple buffers are created one-to-one according to the multiple position comparison types included in the motion trajectory; the position comparison types include leading and lagging types, and the rules corresponding to the position comparison types include the rule from large to small corresponding to the leading type, and the rule from small to large corresponding to the lagging type.
[0077] For each cache, if the position comparison type corresponding to the cache is lookahead, the position values in the cache are stored in descending order; if the position comparison type corresponding to the cache is lag, the position values in the cache are stored in ascending order.
[0078] It is understood that motion control in a PLC system includes multiple motion trajectories. In this embodiment, a buffer is created for each motion trajectory based on the position comparison types it contains. For example, assuming motion trajectory L1 includes three position comparison types, three buffers can be created; motion trajectory L2 includes four position comparison types, so four buffers can be created. This creation method allows the position comparison data of each motion trajectory to be stored independently, reducing unnecessary buffer comparisons and improving position comparison efficiency when changing buffers. Of course, the same number of buffers can also be created for each motion trajectory based on the position comparison types they contain, such as creating four buffers for each motion trajectory.
[0079] In this embodiment, for each buffer, since it corresponds to a different position comparison type, and different position comparison types correspond to different rules, the rules for sorting position values in the buffer are defined. This embodiment divides position comparison types into two main categories: leading and lagging. Leading comparisons include, but are not limited to, time advance and position advance; the action signal for this type of position comparison needs to be triggered before reaching or passing a certain position or time point. Lagging comparisons include, but are not limited to, time lag and position lag; the action signal for this type of position comparison needs to be triggered after passing a certain position or time point. For leading buffers, the corresponding position comparison rule is a descending order rule; for lagging buffers, the corresponding position comparison rule is an ascending order rule. The specific sorting rules are as follows:
[0080] Position advance buffer: The position advance data for the same trajectory segment is stored in descending order from largest to smallest. In this way, when the motor approaches a certain set position, the larger position value can be matched first to ensure that the action signal is triggered in time before reaching the position.
[0081] Position lag buffer: The position lag data for the same trajectory segment are stored in ascending order from smallest to largest. When the motor passes through a certain set position, the smaller position value can be matched first to ensure that the action signal is triggered in time after passing through the position.
[0082] Advance time buffer: The advance time data for the same trajectory is stored in descending order from largest to smallest. 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: Data with time lag for the same trajectory segment are stored in ascending order from smallest to largest. 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 one exemplary embodiment, the motion control method further includes:
[0085] Obtain location comparison data for the user's selected motion trajectory; the location comparison data includes location values and location comparison types.
[0086] For each position comparison data, the position value in the position comparison data is written into the candidate buffer corresponding to the position comparison type in the position comparison data.
[0087] In this embodiment, both the motion trajectory and the position comparison data for that trajectory can be selected and input by the user. It can be understood that there are multiple points on a motion trajectory, and each time the control system moves to a corresponding point, a corresponding action needs to be performed. The user can input the position value on the motion trajectory and the corresponding position comparison type at once. Then, based on the user's input data and the position comparison type, the position value is written to the corresponding buffer and stored in sorted order. The user only needs to input the necessary data, and the solution in this embodiment can automatically complete the subsequent storage and sorting work, simplifying the configuration process and reducing the user's workload. (Refer to...) Figure 2 As shown, after the user inputs the target trajectory and the location comparison data, the location comparison data is stored in different buffers. In the location advance buffer, the location comparison data is sorted in descending order; in the location lag buffer, the location comparison data is sorted in ascending order; in the time advance buffer, the location comparison data is sorted in descending order; and in the time lag buffer, the location comparison data is sorted in ascending order.
[0088] As another optional embodiment, in addition to using position comparison data input by the user, position comparison data on the motion trajectory (such as key position points and the position comparison type of key position points) can be automatically determined according to task requirements, current environmental status, historical experience, etc., so as to improve the accuracy, efficiency and reliability of position control.
[0089] In one exemplary embodiment, the process of matching the current position value with the first candidate position value in the buffer, and if the match fails, changing the buffer and repeating the matching operation, includes:
[0090] Obtain the matching priority of each buffer corresponding to the motion trajectory;
[0091] The target cache is determined from all unmatched caches in descending order of matching priority. The current position value is matched with the first candidate position value in the target cache. If the match fails, this step is repeated.
[0092] This embodiment also sets the matching priority for each buffer zone corresponding to each motion trajectory. The matching priority is set according to actual application requirements and control logic, and is used to determine the matching order of each buffer zone in the current cycle. Assuming that the matching priority of each buffer zone is in descending order as follows: position advance buffer zone, position lag buffer zone, time advance buffer zone, and time lag buffer zone, 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 in the position advance buffer zone. If the match is successful, the comparison is cyclically performed in the position advance buffer zone. If the match fails, it is directly switched to the position lag buffer zone, and so on, until finally switching to the time lag buffer zone, and then waiting for the next cycle to process, as described above. Figure 3 As shown in the figure. In this embodiment, within each cycle, it is not necessary to traverse all position values to determine whether the corresponding action needs to be executed in the current cycle. When the first candidate position value in a buffer does not meet the requirements, the system directly switches to the next buffer. This avoids invalid matching operations in empty buffers, reduces unnecessary calculations and time consumption, and improves matching efficiency.
[0093] It's understandable that, due to the setting of matching priorities and the dynamic changes in the data in the cache (e.g., some actions have been completed, and the corresponding position value is deleted from the cache or marked as matched), checking the cache for data beforehand allows for flexible adaptation to these changes, ensuring the accuracy and effectiveness of the matching operation. Specifically, after obtaining the current position value, before performing a match, it can be checked whether there is data in the cache. If no data is found, the system directly switches to the next cache, further reducing unnecessary computation and time consumption, thus improving matching efficiency.
[0094] In this embodiment, by setting matching priorities and performing matching according to priority order, potentially matching buffers can be quickly located, reducing unnecessary matching operations and improving matching efficiency. For example, prioritizing matching the position advance buffer ensures that actions are triggered in time before the motor reaches the critical position, avoiding delays or errors caused by improper matching order. Furthermore, setting matching priorities allows the system to prioritize critical buffers based on actual control needs, thereby improving the accuracy and reliability of control actions. For example, in some application scenarios, actions with advanced positions may be more critical than those with delayed positions or time-related actions; prioritizing matching the position advance buffer ensures the timely execution of these critical actions.
[0095] In summary, the motion control method provided by this invention first classifies and stores different types of position comparison data, and then arranges them in ascending or descending order. In this way, each position comparison can be stopped immediately if the comparison condition is not met, thereby reducing unnecessary data comparison judgments and improving the efficiency of real-time position comparison.
[0096] Secondly, please refer to Figure 4 The present invention also provides a motion control system, comprising:
[0097] The 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 candidate position value in the buffer. If the match fails, the buffer is changed and the matching operation is repeated until the match is successful, and the action signal corresponding to the successfully matched position value is triggered.
[0099] Each buffer is used to store the position value of the corresponding position comparison type. The 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. The candidate position value is the position value in the buffer that has not been matched.
[0100] In an exemplary embodiment, the process of matching the current position value with the first candidate position value in the buffer includes:
[0101] Determine the difference between the current position value and the first candidate position value in the buffer;
[0102] If the difference is less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer are successfully matched.
[0103] If the difference is not less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer area have failed to match.
[0104] In one exemplary embodiment, the motion control system is further configured to:
[0105] In response to the presence of a candidate position value in the current buffer where the successfully matched position value is located, the current position value is matched with the first candidate position value in the current buffer. If the match is successful, the 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 buffer or the match fails. Then, the buffer is changed and the matching operation is repeated.
[0106] In one exemplary embodiment, the motion control system is further configured to:
[0107] Remove the successfully matched position value from the current cache.
[0108] In one exemplary embodiment, the motion control system is further configured to: add a matching completion marker to the position value that has been successfully matched in the current buffer.
[0109] In one exemplary embodiment, the motion control system is further configured to:
[0110] Multiple buffers are created one-to-one according to the multiple position comparison types included in the motion trajectory; the position comparison types include leading and lagging types, and the rules corresponding to the position comparison types include the rule from large to small corresponding to the leading type, and the rule from small to large corresponding to the lagging type.
[0111] For each cache, if the position comparison type corresponding to the cache is lookahead, the position values in the cache are stored in descending order; if the position comparison type corresponding to the cache is lag, the position values in the cache are stored in ascending order.
[0112] In one exemplary embodiment, the motion control system is further configured to:
[0113] Obtain location comparison data for the user's selected motion trajectory; the location comparison data includes location values and location comparison types.
[0114] For each position comparison data, the position value in the position comparison data is written into the candidate buffer corresponding to the position comparison type in the position comparison data.
[0115] In one exemplary embodiment, the process of matching the current position value with the first candidate position value in the buffer, and if the match fails, changing the buffer and repeating the matching operation, includes:
[0116] Obtain the matching priority of each buffer corresponding to the motion trajectory;
[0117] The target cache is determined from all unmatched caches in descending order of matching priority. The current position value is matched with the first candidate position value in the target cache. If the match fails, this step is repeated.
[0118] Thirdly, please refer to Figure 5 The present invention also provides an electronic device, comprising:
[0119] Memory 21 is used to store computer programs;
[0120] The processor 22 is configured to execute a computer program to implement the steps of the motion control method as described in any of the embodiments above.
[0121] The electronic device also includes:
[0122] Input interface 23, connected to processor 22 via communication bus 26, is used to acquire externally imported computer programs, parameters, and instructions, and save them to memory 21 under the control of processor 22. This input interface can be connected to an input device to receive parameters or instructions manually entered by the user. This input device can be a touch layer covering the display screen, or buttons, a trackball, or a touchpad mounted on the terminal casing.
[0123] Display unit 24 is connected to processor 22 via communication bus 26 and is used to display data sent by processor 22. This display unit can be a liquid crystal display screen or an electronic ink display screen, etc.
[0124] Network port 25 is connected to processor 22 via communication bus 26 and is used for communication with external terminal devices. The communication technology used for this connection can be wired or wireless communication technology, such as mobile high-definition link technology, universal serial bus, high-definition multimedia interface, wireless fidelity technology, Bluetooth communication technology, Bluetooth low power communication technology, and communication technology based on IEEE 802.11s.
[0125] For a description of the electronic device provided by the present invention, please refer to the above embodiments; the present invention will not be described again here.
[0126] The electronic device provided by this invention has the same beneficial effects as the motion control method described above.
[0127] Fourthly, please refer to Figure 6 The present invention also provides a computer-readable storage medium 30, on which a computer program 31 is stored, and when the computer program 31 is executed by a processor, it implements the steps of the motion control method as described in any of the embodiments above.
[0128] The computer-readable storage medium 30 may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0129] For a description of the computer-readable storage medium 30 provided by the present invention, please refer to the above embodiments; the present invention will not be described again here.
[0130] The computer-readable storage medium 30 provided by the present invention has the same beneficial effects as the motion control method described above.
[0131] Fifthly, the present invention also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the motion control method as described in any of the embodiments above.
[0132] For a description of the computer program product provided by this invention, please refer to the above embodiments; further details of this invention will not be repeated here.
[0133] The computer program product provided by this invention has the same beneficial effects as the motion control method described above.
[0134] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0135] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily 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 invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded 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; The current position value is matched with the first candidate position value in the buffer. If the match fails, the buffer is changed and the matching operation is repeated until the match is successful, and the action signal corresponding to the successfully matched position value is triggered. Each of the buffer areas is used to store position values of the corresponding position comparison type, and the position values of each of the position comparison types on the same motion trajectory are sorted and stored in the corresponding buffer area according to the rules corresponding to the position comparison type. The candidate position value is the position value in the buffer area that has not been matched.
2. The motion control method according to claim 1, characterized in that, The process of matching the current position value with the first candidate position value in the cache includes: Determine the difference between the current position value and the first candidate position value in the buffer; In response to the difference being less than a preset threshold, it is determined that the current position value and the first candidate position value in the buffer are successfully matched; In response to the difference being not less than the preset threshold, it is determined that the current position value and the first candidate position value in the cache area have failed to match.
3. The motion control method according to claim 1, characterized in that, The motion control method further includes: In response to the existence of a candidate position value in the current cache where the successfully matched position value is located, the current position value is matched with the first candidate position value in the current cache. If the match is successful, the 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 or the match fails. Then the cache is changed and the matching operation is repeated.
4. The motion control method according to claim 3, characterized in that, The motion control method further includes: Remove the successfully matched position value from the current cache. or, Add a match completion marker to the position value of a successful match in the current cache area.
5. The motion control method according to claim 1, characterized in that, The motion control method further includes: Multiple buffers are created one-to-one with the multiple position comparison types included in the motion trajectory; the position comparison types include leading and lagging types, and the rules corresponding to the position comparison types include rules from large to small corresponding to the leading type, and rules from small to large corresponding to the lagging type. For each cache region, if the position comparison type corresponding to the cache region is the ahead type, the position values in the cache region are stored in descending order; if the position comparison type corresponding to the cache region is the lag type, the position values in the cache region are stored in ascending order.
6. The motion control method according to claim 5, characterized in that, The motion control method further includes: Obtain location comparison data selected by the user for the motion trajectory; the location comparison data includes location values and location comparison types. For each location comparison data, the location value in the location comparison data is written into the candidate cache area corresponding to the location comparison type in the location comparison data.
7. The motion control method according to any one of claims 1-6, characterized in that, The process of matching the current position value with the first candidate position value in the cache, and if the match fails, changing the cache and repeating the matching operation includes: Obtain the matching priority of each of the buffer zones corresponding to the motion trajectory; The target cache is determined from all unmatched caches in descending order of matching priority. The current position value is matched with the first candidate position value in the target cache. If the match fails, this step is repeated.
8. A motion control system, characterized in that, include: The acquisition module is used to acquire the current position value of the motor; The matching control module is used to match the current position value with the first candidate position value in the buffer. If the matching fails, the buffer is changed and the matching operation is repeated until the matching is successful, and the action signal corresponding to the successfully matched position value is triggered. Each of the buffer areas is used to store position values of the corresponding position comparison type, and the position values of each of the position comparison types on the same motion trajectory are stored in the corresponding buffer area in an ordered manner according to the rules corresponding to the position comparison type. The candidate position value is the position value in the buffer area that has not been matched.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the motion control method as described in any one of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the motion control method as described in any one of claims 1-7.
Citation Information
Patent Citations
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