A trigonometric function acceleration / deceleration control method for stepper motors
By using a trigonometric function acceleration and deceleration control method, a continuous speed planning curve is generated by simulating the jerkness with a sine function and performing numerical integration and difference. This solves the problem of discontinuous acceleration of the stepper motor, achieves precise positioning of the motor and improves response speed, thereby enhancing system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU YAJIANG PHOTOELECTRIC EQUIP CO LTD
- Filing Date
- 2025-01-15
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional stepper motor control algorithms suffer from problems such as discontinuous acceleration, inaccurate positioning, and severe jitter, making them unable to meet the high stability requirements, especially in applications such as precision machining and robot joint control.
The trigonometric function acceleration and deceleration control method is adopted. The sine function is used to simulate the jerk, and numerical integration and difference are performed to generate a continuous speed planning curve. The acceleration is dynamically adjusted to adapt to different movement distances, ensuring that the motor accurately reaches the target point.
This achieves precise motor positioning and improved response speed, reduces vibration during operation, and enhances system efficiency and stability.
Smart Images

Figure CN120034049B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of stepper motor control, and in particular to a trigonometric function acceleration and deceleration control method for stepper motors. Background Technology
[0002] Traditional stepper motor control algorithms, such as trapezoidal acceleration / deceleration and S-curve acceleration / deceleration algorithms, mostly use fixed acceleration and deceleration for motion planning. However, this fixed acceleration / deceleration pattern has significant limitations: when moving a small distance, the motor may reach the target position too quickly due to excessive acceleration, leading to overshoot or inaccurate positioning; while when moving a large distance, the motor's response speed may not meet the requirements for rapid positioning. Furthermore, since the actual motion of a stepper motor is discrete, while traditional acceleration / deceleration algorithms are usually based on continuous mathematical models (such as integrals) for velocity planning, this can lead to a certain deviation between theoretical and actual motion, further affecting positioning accuracy.
[0003] More importantly, traditional acceleration and deceleration algorithms often neglect the continuity of jerk (i.e., the rate of change of acceleration). Discontinuity in jerk can cause motor vibration during movement, affecting the smoothness of motion. This vibration is unacceptable, especially in applications with extremely high requirements for motion smoothness, such as precision machining and robot joint control.
[0004] Therefore, there is an urgent need for a stepper motor acceleration / deceleration control algorithm that can dynamically adjust the acceleration curve based on the distance traveled while ensuring continuous abrupt changes. This algorithm would not only improve the motor's positioning accuracy and response speed but also effectively reduce jitter during motion, thereby enhancing the overall system's operating efficiency and stability. Summary of the Invention
[0005] This application provides a trigonometric function acceleration and deceleration control method for a stepper motor, which can dynamically adjust the response speed according to the distance to be moved by the stepper motor, and enable the motor to accurately reach the target point.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a trigonometric function acceleration / deceleration control method for a stepper motor, comprising:
[0008] Obtain the desired movement distance and expected response rate of the stepper motor, and initialize the acceleration and deceleration control parameters of the stepper motor;
[0009] Based on the aforementioned acceleration and deceleration control parameters, the jerk of the stepper motor is simulated as a sine curve using a sine function, resulting in a jerk equation describing the relationship between the rate of change of the stepper motor's acceleration and time.
[0010] The speed equation is obtained by numerical integration of the speed equation. The first difference of the speed equation is taken as the actual speed equation, which describes the relationship between the motor speed and time.
[0011] The constant values of the acceleration / deceleration control parameters in the actual velocity equation are calculated based on the distance to be traveled.
[0012] Based on the expected reaction rate, the slope of the actual velocity equation is set to obtain the velocity planning curve;
[0013] The stepper motor is controlled according to the speed planning curve.
[0014] In a preferred example of this application, it may further be configured to include:
[0015] Obtain a preset distance threshold; when the distance to be moved is greater than the preset distance threshold, calculate the constant speed movement time of the motor.
[0016] By combining the actual velocity equation, a velocity planning curve containing the uniform velocity time interval is obtained.
[0017] In a preferred embodiment of this application, the expression for the jerk equation can be further configured as follows: for:
[0018]
[0019] Δt1=t-t1;
[0020] Where t is the movement time of the stepper motor, a1 is the maximum acceleration during the actual acceleration process, a2 is the maximum acceleration during the actual deceleration process, and v max The maximum speed reached during actual operation, t0 = 0, t1 is the total acceleration time, t2 is the total deceleration time, and ω is the achievable speed. i To represent the intermediate parameters ω1 and ω2, a i They represent a1 and a2.
[0021] In a preferred example of this application, the expression for the actual velocity equation, v(t), can be further set as follows:
[0022]
[0023] In a preferred embodiment of this application, the acceleration / deceleration control parameters may be further configured to include constants and variables, wherein the constants include the maximum speed V of the motor. max The maximum acceleration A1 of the motor during its acceleration from rest to maximum speed, the total acceleration time T1, and the motor's speed from V maxThe acceleration A2 during deceleration to a stop, the total deceleration time T2, and the distance the motor travels during the entire acceleration and deceleration process S. max .
[0024] In a preferred example of this application, the expression v(t) for the velocity planning curve containing the uniform time interval can be further set as:
[0025]
[0026] Δt 1,c =t-T1-T c ;
[0027] Among them, T i Let T1, T2, and T be the values of T1, T2, and T2 respectively. c This indicates the time during which the motor moves at a constant speed.
[0028] Secondly, this application provides a trigonometric function acceleration / deceleration control device for a stepper motor, the device comprising:
[0029] The data acquisition module is used to obtain the expected movement distance and expected response rate of the stepper motor, and to initialize the acceleration and deceleration control parameters of the stepper motor.
[0030] The jerkness module is used to simulate the jerkness of the stepper motor as a sine curve using a sine function based on the acceleration and deceleration control parameters, and obtain the jerkness equation describing the relationship between the rate of change of the stepper motor acceleration and time.
[0031] The speed module is used to numerically integrate the speed equation to obtain the speed equation, and take the first difference of the speed equation as the actual speed equation, which describes the relationship between the motor speed and time.
[0032] The control module is used to calculate the values of the acceleration / deceleration control parameters in the actual speed equation based on the distance to be moved; to set the slope of the actual speed equation based on the expected response rate to obtain a speed planning curve; and to control the stepper motor based on the speed planning curve.
[0033] Thirdly, this application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the trigonometric function acceleration and deceleration control method for a stepper motor as described in any of the preceding claims.
[0034] Fourthly, this application provides a computer-readable storage medium storing a program, wherein when the program is executed by a processor, it implements the trigonometric function acceleration / deceleration control method for a stepper motor as described in any of the preceding claims.
[0035] Fifthly, this application provides a computer program product, including computer instructions that, when executed by a processor, implement the steps of the trigonometric function acceleration / deceleration control method for a stepper motor as described in any of the preceding claims.
[0036] In summary, compared with the prior art, the beneficial effects of the technical solution provided in this application include at least the following:
[0037] The method presented in this application boasts strong real-time performance, simple calculation, continuous jerk, and varying response speeds for different distances, enabling the stepper motor to accurately reach the target point. It can be applied to the acceleration and deceleration movements of devices such as moving head lights, improving the motion control performance of stepper motors. Furthermore, the velocity planning curve obtained through differential calculations not only meets the limits for maximum acceleration and continuous jerk but also ensures accurate target point arrival, guaranteeing the precision of acceleration and deceleration planning. Moreover, by selecting different slope functions, the control method of this application can achieve control over the response rate at different distances, making it adaptable to the needs of various application scenarios. Attached Figure Description
[0038] Figure 1 This is a flowchart illustrating a trigonometric function acceleration / deceleration control method for a stepper motor, as provided in one embodiment of this application.
[0039] Figure 2 This is a structural diagram of a trigonometric function acceleration / deceleration control device for a stepper motor, provided in one embodiment of this application. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0041] In one embodiment of this application, a trigonometric function acceleration / deceleration control method for a stepper motor is provided. Please refer to [link to relevant documentation]. Figure 1 As shown, the method includes:
[0042] S100: Obtain the desired movement distance and expected response rate of the stepper motor, and initialize the acceleration and deceleration control parameters of the stepper motor.
[0043] Specifically, the distance to be moved is the distance that the user wants the stepper motor to accelerate or decelerate. The acceleration / deceleration control parameters include constant parameters and variables. The constants include at least the maximum motor speed V. max The motor accelerates from a standstill to V. maxThe maximum acceleration during the process is A1, and the total time taken is T1; the motor starts from its highest speed V. max The acceleration from deceleration to a stop is A2, and the total time taken is T2; the distance the motor travels during the entire acceleration and deceleration process is S. max The variables include: the maximum speed v that the motor actually accelerates to during operation. max The actual acceleration during acceleration is a1, the actual deceleration during deceleration is a2, the actual total acceleration time is t1, the actual total deceleration time is t2, and the actual motor travel distance is s during acceleration and deceleration.
[0044] The distance to be moved is taken as the actual motor running distance s during the acceleration and deceleration process.
[0045] S200: Based on the acceleration and deceleration control parameters, the jerk of the stepper motor is simulated as a sine curve using a sine function, and the jerk equation describing the relationship between the rate of change of the stepper motor acceleration and time is obtained.
[0046] Specifically, if the simulated jerk is a sine curve, then the jerk equation is... for:
[0047]
[0048] Where, Δt1=t-t1, t0 = 0, t1 is the total acceleration time, and t2 is the total deceleration time;
[0049] S300: Numerical integration is performed on the speed equation to obtain the velocity equation. The first difference of the velocity equation is taken as the actual velocity equation, which describes the relationship between the motor speed and time.
[0050] Specifically, by integrating it successively, we obtain for:
[0051]
[0052] At time t1, the acceleration process ends, and the motor speed will reach v. max , points for:
[0053]
[0054] At time t1, the motor has traveled a distance of s1. Integrating again, we get s(t) as:
[0055]
[0056] In formulas (3) and (4), we have s(t1) = s1, s max=s(t1+t2), combining the equations, we get:
[0057]
[0058] In addition, for constants A1, A2, V max T1 and T2 also have:
[0059]
[0060] All the above calculations are integral results. The actual operation of the motor is a discrete process. Using integrals to replace the discrete process will introduce errors. In order to ensure that the motor travels the specified distance accurately, the first difference of s(t) is taken as the actual velocity equation, denoted as v(t):
[0061] (7)
[0062] v(t) is the velocity planning curve under acceleration smoothing. The velocity curve v(t) obtained by difference can not only meet the continuous constraints of maximum acceleration and jerk, but also reach the target point accurately.
[0063] S400: Calculate the constant value of the acceleration / deceleration control parameter in the actual velocity equation based on the distance to be moved;
[0064] Specifically, in order to obtain the velocity planning curve v(t), it is necessary to calculate v based on the given distance s. max And a1 and a2.
[0065] For any distance s max For short distances, where slow and stable operation is required, simply stretching and transforming the velocity curve is sufficient. And for any trigonometric function... As long as the product of amplitude A and frequency w is constant, the curve shape will be consistent, therefore... Define slope The shape of the curve can be adjusted by adjusting the slope k. It is known that at S... max Acceleration time T1, T2, A1, A2, V max ,definition Solve the following equations simultaneously:
[0066]
[0067] We can obtain:
[0068]
[0069] S500: Based on the expected reaction rate, set the slope of the actual velocity equation to obtain the velocity planning curve;
[0070] Furthermore, a preset distance threshold is obtained. When the distance to be moved is greater than the preset distance threshold, the uniform motion time of the motor is calculated. Combined with the actual speed equation, a speed planning curve containing the uniform motion time period is obtained.
[0071] Specifically, S max As a preset distance threshold, when the distance to be moved is s max When, take the slope k i =f(s,S) max ,K i The actual v can then be calculated. max ,Pick For example calculations, we can obtain:
[0072]
[0073] From (6), it can be seen that when the motor reaches its highest speed V max Acceleration / deceleration time T i Given, the maximum acceleration A during the acceleration / deceleration phase. i Slope K i (i = 1, 2), S max All can be determined, that is Let the constant term be denoted as:
[0074]
[0075] Combining (5), (8), and (10), all the unknowns of the velocity curve v(t) are obtained as follows:
[0076]
[0077] in
[0078] Based on the motor's speed requirements for different distances in practical applications, i.e., the expected response rate, the slope function f(s,S) is defined. max ,K i ).
[0079] When the slope function When, for distance s max It will arrive at any distance in a fixed time. In fact, if we take...
[0080]
[0081] Similar calculations can be obtained By selecting different slope functions, the reaction rate at different distances can be controlled. This is based on s max The discussion.
[0082] If s>S max Then there exists a uniform speed segment, and obviously the uniform speed time is... Combining (7), we can obtain:
[0083]
[0084] Where Δt 1,c =t-T1-T c ,
[0085] S600: Control the stepper motor according to the speed planning curve.
[0086] Specifically, the control program sets the speed of the stepper motor in each operating cycle according to the speed planning curve, eventually reaching the target. During control, the target position of the motor is issued by the control console, the real-time position of the motor is measured by the (Hall) position sensor, and the motor speed is specified by the method described in S100-S600 above. The purpose of this method is to control the motor to reach the target position smoothly, without losing steps or overshoot, and it has been used in the point-to-point movement of moving head lights.
[0087] In this embodiment, the method features strong real-time performance, simple calculation, continuous abrupt change, different response speeds for different distances, and precise target point reach of the stepper motor. It can be applied to the acceleration and deceleration movements of devices such as moving head lights, improving the motion control performance of the stepper motor. Furthermore, the velocity planning curve obtained through differential calculation not only meets the limits of maximum acceleration and continuous abrupt change but also ensures accurate target point reach, guaranteeing the precision of acceleration and deceleration planning. Moreover, by selecting different slope functions, the control method of this application can achieve control over the response rate at different distances, making the method adaptable to the needs of various application scenarios.
[0088] This application also provides a trigonometric function acceleration / deceleration control device for a stepper motor; please refer to [link to relevant documentation]. Figure 2 As shown, the device includes:
[0089] The data acquisition module 100 is used to acquire the expected movement distance and expected response rate of the stepper motor, and to initialize the acceleration and deceleration control parameters of the stepper motor.
[0090] The swiftness module 200 is used to simulate the swiftness of the stepper motor as a sine curve using a sine function based on the acceleration and deceleration control parameters, and obtain a swiftness equation describing the relationship between the rate of change of the stepper motor acceleration and time.
[0091] The speed module 300 is used to numerically integrate the speed equation to obtain the speed equation, and take the first difference of the speed equation as the actual speed equation, which describes the relationship between the motor speed and time.
[0092] The control module 400 is used to calculate the values of the acceleration / deceleration control parameters in the actual speed equation based on the distance to be moved; to set the slope of the actual speed equation based on the expected response rate to obtain a speed planning curve; and to control the stepper motor based on the speed planning curve.
[0093] The functions of each module in the above-mentioned trigonometric function acceleration and deceleration control device for stepper motors correspond to the steps in the above-mentioned trigonometric function acceleration and deceleration control method embodiment for stepper motors. Their functions and implementation processes will not be described in detail here.
[0094] This application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the trigonometric function acceleration and deceleration control method for a stepper motor as described in any of the above embodiments.
[0095] This application also provides a computer-readable storage medium storing a program. The computer-readable storage medium refers to a data storage medium, which may include, but is not limited to, floppy disks, optical disks, hard disks, flash memory, USB flash drives, and / or Memory Sticks. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The working process, details, and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment regarding a trigonometric function acceleration / deceleration control method for a stepper motor, and will not be repeated here.
[0096] The application also provides a computer program product, including computer instructions that, when executed by a processor, implement the steps of the trigonometric function acceleration / deceleration control method for a stepper motor as described in any of the above embodiments.
[0097] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).
[0098] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. The above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those skilled in the art, several modifications and improvements can be made without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A trigonometric function acceleration / deceleration control method for a stepper motor, characterized in that, include: Obtain the desired movement distance and expected response rate of the stepper motor, and initialize the acceleration and deceleration control parameters of the stepper motor; Based on the aforementioned acceleration and deceleration control parameters, the jerk of the stepper motor is simulated as a sine curve using a sine function, resulting in a jerk equation describing the relationship between the rate of change of the stepper motor's acceleration and time. The expression for this jerk equation is... for: ; ; ; in, The motion time of the stepper motor. This represents the maximum acceleration during the actual acceleration process. This represents the maximum acceleration during the actual deceleration process. This is the maximum speed achieved during actual operation. , To speed up the overall time, To reduce the total deceleration time, For intermediate parameters, Represented as and Corresponding to the acceleration phase, Corresponding to the deceleration phase, express and ; Numerical integration of the jerk equation yields the acceleration equation, and integration of the acceleration equation yields the velocity equation, which in turn yields the distance equation. The first difference of the distance equation is taken as the actual speed equation, which describes the relationship between the motor speed and time. The constant values of the acceleration / deceleration control parameters in the actual velocity equation are calculated based on the distance to be traveled. Based on the expected reaction rate, the slope of the actual velocity equation is set to obtain the velocity planning curve; The stepper motor is controlled according to the speed planning curve. Obtain a preset distance threshold; when the distance to be moved is greater than the preset distance threshold, calculate the constant speed movement time of the motor. By combining the actual velocity equation, a velocity planning curve containing the uniform velocity time interval is obtained.
2. The trigonometric function acceleration / deceleration control method for a stepper motor according to claim 1, characterized in that, The expression of the actual velocity equation for: 。 3. The trigonometric function acceleration / deceleration control method for a stepper motor according to claim 2, characterized in that, The acceleration / deceleration control parameters include constants and variables, where the constants include the maximum speed of the motor. The maximum acceleration of the motor during the process of accelerating from a standstill to its maximum speed. Total time during acceleration The motor from Acceleration from deceleration to stop The total time for deceleration is The distance the motor travels during the entire acceleration and deceleration process .
4. The trigonometric function acceleration / deceleration control method for a stepper motor according to claim 3, characterized in that, Expression for velocity planning curves containing uniform time intervals for: ; ; ; ; ; in, This represents the total time for acceleration or deceleration; when i=1, it represents the total time for acceleration. When i=2, it represents the total time during deceleration. , This indicates the time during which the motor moves at a constant speed. express and ,in, , express and ; Indicates the distance to be traveled.
5. A trigonometric function acceleration / deceleration control device for a stepper motor, characterized in that, include: The data acquisition module is used to obtain the expected movement distance and expected response rate of the stepper motor, and to initialize the acceleration and deceleration control parameters of the stepper motor. The jerkiness module is used to simulate the jerkiness of the stepper motor as a sine curve using a sine function based on the acceleration / deceleration control parameters, thereby obtaining a jerkiness equation describing the relationship between the rate of change of the stepper motor's acceleration and time. The expression for the jerkiness equation is... for: ; ; ; in, The motion time of the stepper motor. This represents the maximum acceleration during the actual acceleration process. This represents the maximum acceleration during the actual deceleration process. This is the maximum speed achieved during actual operation. , To speed up the overall time, To reduce the total deceleration time, For intermediate parameters, Represented as and Corresponding to the acceleration phase, Corresponding to the deceleration phase, express and ; The speed module is used to numerically integrate the abruptness equation to obtain the acceleration equation, integrate the acceleration equation to obtain the speed equation, and integrate the speed equation to obtain the distance equation; the first difference of the distance equation is taken as the actual speed equation, which describes the relationship between the motor speed and time. The control module is used to calculate the values of the acceleration / deceleration control parameters in the actual speed equation based on the distance to be moved; set the slope of the actual speed equation according to the expected response rate to obtain a speed planning curve; control the stepper motor according to the speed planning curve; obtain a preset distance threshold; when the distance to be moved is greater than the preset distance threshold, calculate the uniform motion time of the motor; and combine the actual speed equation to obtain a speed planning curve containing the uniform motion time period.
6. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the trigonometric function acceleration / deceleration control method for the stepper motor as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program, wherein when the program is executed by a processor, it implements the trigonometric function acceleration and deceleration control method for a stepper motor as described in any one of claims 1 to 4.
8. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the trigonometric function acceleration / deceleration control method for a stepper motor as described in any one of claims 1 to 4.