Motor motion control method, device, equipment and storage medium
Patent Information
- Application Number
- CN202311764017.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-12-19
AI Technical Summary
[0004]本发明的主要目的在于提供一种电机运动控制方法、装置、设备及存储介质,旨在解决电机运转不流畅,旋转动作生硬的问题
[0044] This invention constructs a motor control curve model based on a third-order Bézier curve according to control points. Parameter processing is performed on this model to obtain the functional relationships between intermediate variables and motor travel and motion time. Based on these relationships, the functional relationship between intermediate variables and motion speed is derived. Furthermore, the functional relationship between intermediate variables and motor frequency is obtained. This functional relationship is then evenly divided to obtain the motor control frequency corresponding to each motion time and motor travel. This achieves smoother motor motion using the variable acceleration of the third-order Bézier curve, while simultaneously reducing the system's computational load through an efficient motor control algorithm.
Smart Images

Figure CN117856670B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor control, and more particularly to a method, apparatus, device, and storage medium for controlling motor motion. Background Technology
[0002] Since the development of technology, stepper motors have been increasingly widely used in electronic products, transportation vehicles, and other fields, and the demand for them has also become more and more extensive. However, the motor control currently used on the market is mainly based on trapezoidal curve motion control. Although the calculation method is simple, the motor operation is not smooth and the rotational motion is stiff.
[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this invention is to provide a method, device, equipment, and storage medium for controlling motor motion, aiming to solve the problems of unsmooth motor operation and stiff rotational movements.
[0005] To achieve the above objectives, the present invention provides a motor motion control method, which constructs a motor control curve model based on a third-order Bézier curve according to the control points;
[0006] The parameters of the motor control curve model are processed to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time.
[0007] Based on the functional relationship between the intermediate variable and the motor stroke and the motion time, the functional relationship between the intermediate variable and the motion speed is obtained;
[0008] Based on the functional relationship between the intermediate variable and the speed of motion, the functional relationship between the intermediate variable and the frequency of the motor is obtained;
[0009] The functional relationship between the intermediate variable and the motor frequency is divided equally to obtain the control frequency of the motor corresponding to each motion time and motor stroke.
[0010] Optionally, the control points include a first control point, a second control point, a third control point, and a fourth control point, and the step of constructing a motor control curve model based on a third-order Bézier curve according to the control points includes:
[0011] Obtain the coordinate origin, motor running time, motor motion angle, first control point parameters, and second control point parameters;
[0012] The origin of the coordinate system is taken as the first control point;
[0013] The second control point is determined based on the parameters of the first control point.
[0014] The third control point is determined based on the parameters of the second control point and the motor motion angle.
[0015] The fourth control point is determined based on the motor running time and the motor motion angle.
[0016] A motor control curve model based on a third-order Bézier curve is constructed based on the first control point, the second control point, the third control point, and the fourth control point. The vectors formed by the first control point and the second control point, as well as the vectors formed by the third control point and the fourth control point, are parallel to the X-axis.
[0017] Optionally, the step of equally distributing the functional relationship between the intermediate variable and the motor frequency includes:
[0018] The number of equal divisions of the motor stroke is calculated based on the motor stroke and the motor step angle.
[0019] Based on the motor stroke of each equal part and the parameter equations of the motor control curve model, the motion time corresponding to each equal part stroke is obtained.
[0020] Optionally, obtaining the control frequency of the motor corresponding to each motion time and motor stroke includes:
[0021] The control frequency provided to the motor for the current average stroke is obtained by using the motor's step angle, downsampling factor, motion time corresponding to the current average stroke, and motion time corresponding to the next average stroke.
[0022] Based on the control frequency provided to the motor for each current equal-division stroke, the relationship between each motion time and the motor stroke and the motor control frequency is obtained.
[0023] Optionally, the step of parameter processing of the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time includes:
[0024] The intermediate variables corresponding to each evenly divided angle are obtained by solving the problem using Newton's iteration method based on the intermediate variables of the iteration number, the motor stroke, and the derivative of the motor stroke.
[0025] By substituting the intermediate variables corresponding to each equal division angle into the parametric equations of the motor control curve model of the third-order Bézier curve, the functional relationship between the intermediate variables and the motor stroke is obtained.
[0026] By substituting the intermediate variables corresponding to each equal division angle into the parametric equations of the motor control curve model of the third-order Bézier curve, the functional relationship between the intermediate variables and the motion time can be obtained.
[0027] Optionally, after performing equal division of the functional relationship between the intermediate variable and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke, the method further includes:
[0028] Obtain the downsampling factor;
[0029] When the downsampling factor is not equal to the preset value, obtain the current control frequency and the next control frequency;
[0030] The intermediate frequency for padding is determined based on the downsampling factor, the sampling points between the current sampling point and the next sampling point, the current control frequency, and the next control frequency.
[0031] The supplemented intermediate frequency is added to the control frequency to obtain the target control frequency.
[0032] Optionally, after performing equal division of the functional relationship between the intermediate variable and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke, the method further includes:
[0033] The pulse waveform period is obtained based on the control frequency;
[0034] The pulse waveform duty cycle is determined based on the pulse waveform period.
[0035] A pulse waveform signal is generated based on the pulse waveform duty cycle, and the pulse waveform signal is sent to the stepper driver so that the stepper driver controls the motor to rotate according to the pulse waveform signal.
[0036] Furthermore, to achieve the above objectives, the present invention also provides a motor motion control device, the device comprising:
[0037] The modeling module is used to construct a motor control curve model based on a third-order Bézier curve from the control points.
[0038] The acquisition module is used to process the parameters of the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time.
[0039] The acquisition module is also used to obtain the functional relationship between the intermediate variable and the movement speed based on the functional relationship between the intermediate variable and the motor stroke and the movement time;
[0040] The acquisition module is also used to obtain the functional relationship between the intermediate variable and the motor frequency based on the functional relationship between the intermediate variable and the motion speed;
[0041] The results module is used to equally divide the functional relationship between the intermediate variables and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke.
[0042] Furthermore, to achieve the above objectives, the present invention also provides a motor motion control device, the motor motion control device comprising: a memory, a processor, and a motor motion control program stored in the memory and executable on the processor, the motor motion control being configured to implement the steps of the motor motion control method described above.
[0043] In addition, to achieve the above objectives, the present invention also provides a storage medium storing a motor motion control program, wherein the motor motion control program, when executed by a processor, implements the steps of the motor motion control method.
[0044] This invention constructs a motor control curve model based on a third-order Bézier curve according to control points. Parameter processing is performed on this model to obtain the functional relationships between intermediate variables and motor travel and motion time. Based on these relationships, the functional relationship between intermediate variables and motion speed is derived. Furthermore, the functional relationship between intermediate variables and motor frequency is obtained. This functional relationship is then evenly divided to obtain the motor control frequency corresponding to each motion time and motor travel. This achieves smoother motor motion using the variable acceleration of the third-order Bézier curve, while simultaneously reducing the system's computational load through an efficient motor control algorithm. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the structure of the motor motion control device in the hardware operating environment involved in the embodiments of the present invention;
[0046] Figure 2 This is a flowchart illustrating the first embodiment of the motor motion control of the present invention;
[0047] Figure 3 A schematic diagram of the motor motion control curve for a third-order Bézier curve;
[0048] Figure 4 This is a flowchart illustrating the second embodiment of the motor motion control of the present invention;
[0049] Figure 5 This is a flowchart illustrating the third embodiment of the motor motion control of the present invention;
[0050] Figure 6 This is a schematic diagram of the stepper motor system of the present invention;
[0051] Figure 7 This is a structural block diagram of the first embodiment of the motor motion control device of the present invention.
[0052] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0053] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0054] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of the motor motion control device in the hardware operating environment involved in the embodiments of the present invention.
[0055] like Figure 1 As shown, the motor motion control device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0056] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the motor motion control device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0057] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a motor motion control device program.
[0058] exist Figure 1In the motor motion control device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the motor motion control device of the present invention can be set in the motor motion control device, and the motor motion control device calls the motor motion control program stored in the memory 1005 through the processor 1001 and executes the motor motion control method provided in the embodiment of the present invention.
[0059] This invention provides a method for controlling the motion of a motor, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of a motor motion control method according to the present invention.
[0060] In this embodiment, the motor motion control method includes:
[0061] Step S10: Construct a motor control curve model based on a third-order Bézier curve according to the control points.
[0062] It should be noted that the third-order Bézier curve implements a smoothing algorithm for both single-valued and two-dimensional time series data, which can meet most smoothing requirements. In order to determine the third-order Bézier curve, four points need to be found: two original data points and two control points. Then, the third-order Bézier curve formula is used to calculate any point on the smoothing curve between the two original data points.
[0063] Specifically, in this embodiment, the formula for the motor motion control curve based on the third-order Bézier curve is:
[0064] B(z)=P0(1-z) 3 +3P1z(1-z) 2 +3P2z 2 (1-z)+P3z 3 z∈[0,1]
[0065] The corresponding parametric equation is:
[0066]
[0067] Where z is an intermediate variable, and P0, P1, P2, P3 correspond to respectively Figure 3 The four points on the plane correspond to the positions of the motor as P(s) z ,t z ), s z t represents the current angle of the motor. z Indicates time.
[0068] Step S20: Perform parameter processing on the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time.
[0069] It should be noted that the motor control curve model can be a motor control curve model based on a third-order Bézier curve or a motor control curve model constructed based on other flat curves. This embodiment does not limit this. In this embodiment, a motor control curve model based on a third-order Bézier curve is used as an example for explanation.
[0070] Understandably, parameter processing of the motor control curve model yields the functional relationships between intermediate variables and motor travel and motion time. This includes: solving for intermediate variables corresponding to each equal-division angle using Newton's iteration method based on the intermediate variables of the iteration number, motor travel, and the derivative of the motor travel; substituting the intermediate variables corresponding to each equal-division angle into the parametric equations of the motor control curve model of the third-order Bézier curve to obtain the functional relationship between the intermediate variables and motor travel; and substituting the intermediate variables corresponding to each equal-division angle into the parametric equations of the motor control curve model of the third-order Bézier curve to obtain the functional relationship between the intermediate variables and motion time.
[0071] Furthermore, since the motor step angle is fixed, the motor stroke is divided equally into several parts:
[0072]
[0073] Where S represents the motor travel distance, step represents the motor step angle, and st coe To reduce the sampling rate, the intermediate variable corresponding to each evenly divided angle is obtained by solving the problem using Newton's iteration method based on the intermediate variable of the iteration number, the motor stroke, and the derivative of the motor stroke, as shown in the following formula:
[0074]
[0075] Among them, s(z) i The motor process is represented by s′(z) as an intermediate variable. i ) is s(z i By iterating through the derivative of , we can obtain the intermediate variable corresponding to each evenly divided angle.
[0076] Step S30: Obtain the functional relationship between the intermediate variable and the motion speed based on the functional relationship between the intermediate variable, the motor stroke, and the motion time.
[0077] It is understandable that the obtained third-order Bézier curve is used as the motion control curve of the motor. The independent variable is the intermediate variable, and the dependent variable is the motor rotation stroke. The intermediate variable is obtained by applying the curve parametric equation. Based on the derivative of the stroke and the derivative of the time, the functional relationship between the intermediate variable and the motion speed is obtained.
[0078] Step S40: Based on the functional relationship between the intermediate variable and the motion speed, obtain the functional relationship between the intermediate variable and the motor frequency.
[0079] It should be noted that frequency is the reciprocal of speed. Therefore, after obtaining the functional relationship between the intermediate variable and the motion speed, it is obvious that the functional relationship between the intermediate variable and the motor frequency can be obtained.
[0080] Step S50: The functional relationship between the intermediate variable and the motor frequency is divided equally to obtain the control frequency of the motor corresponding to each motion time and motor stroke.
[0081] It should be noted that the process of dividing the functional relationship between the intermediate variable and the motor frequency includes: calculating the number of divisions of the motor stroke based on the motor stroke and the motor step angle; and obtaining the motion time corresponding to each division of the motor stroke based on each division of the motor stroke and the parameter equation of the motor control curve model.
[0082] It is understandable that, since the distance the motor travels each time is fixed, and the motor runs at a constant speed within this distance, the number of equal parts is:
[0083]
[0084] Where S represents the motor travel distance and step represents the motor step angle.
[0085] It is important to understand that after obtaining the stroke of each equal-division motor, we can obtain the intermediate variables corresponding to each stroke. Then, by substituting the corresponding intermediate variables into the parameter equations of the motor control curve model, we can obtain the motion time corresponding to each equal-division equation.
[0086] The process of obtaining the control frequency of the motor corresponding to each motion time and motor stroke includes: obtaining the control frequency provided to the motor for the current average stroke by using the motor's step angle, downsampling factor, motion time corresponding to the current average stroke, and motion time corresponding to the next average stroke; and obtaining the relationship between each motion time, motor stroke, and motor control frequency based on the control frequency provided to the motor for each current average stroke.
[0087] Specifically, the control frequency provided to the motor for the current average stroke is obtained by using the motor's step angle, downsampling factor, motion time corresponding to the current average stroke, and motion time corresponding to the next average stroke. The formula is as follows:
[0088]
[0089] After obtaining the control frequency supplied to the motor corresponding to the evenly distributed stroke and the corresponding motion time, the formula can be used:
[0090]
[0091] The relationship between the motion time, motor stroke, and motor control frequency is obtained.
[0092] Further, after equally dividing the intermediate variables and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke, the following steps are taken: obtaining the downsampling factor.
[0093] When the downsampling factor is not equal to the preset value, obtain the current control frequency and the next control frequency;
[0094] The intermediate frequency to be supplemented is determined based on the downsampling factor, the sampling points between the current sampling point and the next sampling point, the current control frequency, and the next control frequency; the intermediate frequency to be supplemented is added to the control frequency to obtain the target control frequency.
[0095] It is important to understand that the motor control frequency corresponding to each motion time and motor stroke is obtained by reducing the number of sampling points through downsampling. Therefore, when the downsampling factor is not a preset value, linear interpolation will be used to fill in the intermediate data.
[0096] It is understandable that when the downsampling factor is not equal to 1, the current control frequency and the next control frequency are obtained, and then the intermediate data is padded. The reference formula is as follows:
[0097]
[0098] Where i is the current sampling point, i+1 is the next sampling point, j is the sampling point between the current sampling point and the next sampling point, and st coe To reduce the sampling rate, freq i+1 freq is the control frequency for the next sampling point. i freq is the control frequency for the current sampling point. ij This refers to the control frequency between the current sampling point and the next sampling point for all sampling points that were not collected due to downsampling.
[0099] This embodiment constructs a motor control curve model based on a third-order Bézier curve according to control points. Parameter processing is performed on the motor control curve model to obtain the functional relationships between intermediate variables and motor travel and motion time. Based on these relationships, the functional relationship between intermediate variables and motion speed is obtained. Furthermore, the functional relationship between intermediate variables and motor frequency is obtained. This functional relationship is then evenly divided to obtain the motor control frequency corresponding to each motion time and motor travel. This achieves smoother motor motion using the variable acceleration of the third-order Bézier curve, while employing an efficient motor control algorithm to reduce the system's computational load.
[0100] refer to Figure 4 , Figure 4 This is a flowchart illustrating the second embodiment of the motor motion control method of the present invention.
[0101] Based on the first embodiment described above, in step S10 of the motor motion control method of this embodiment, the control points include a first control point, a second control point, a third control point, and a fourth control point. The step of constructing a motor control curve model based on a third-order Bézier curve according to the control points includes:
[0102] Step S101: Obtain the coordinate origin, motor running time, motor motion angle, first control point parameters, and second control point parameters.
[0103] It is understandable that the origin of the coordinate system and the motor running time T are used as the coordinate system. usr The horizontal axis represents the motor's angle of motion, S. usr Using the points on the ordinate as two original data points, a motor control curve model based on a third-order Bézier curve is constructed based on the two original data points, the first control point parameter ω1, and the second control point parameter ω2.
[0104] Step S102: Use the origin of the coordinate system as the first control point.
[0105] Specifically, in this embodiment, P0(0,0) represents the first control point of the Bézier curve with the origin of the coordinate system as the first control point.
[0106] Step S103: Determine the second control point based on the parameters of the first control point.
[0107] Specifically, in this embodiment, the motor running time t is determined based on the first control point parameter ω1. ω1 , will t ω1 The second control point P1(t) is determined by using 0 as the x-coordinate and 0 as the y-coordinate. ω1 ,0).
[0108] Step S104: Determine the third control point based on the second control point parameters and the motor motion angle.
[0109] Specifically, in this embodiment, the motor running time t is determined based on the second control point parameter ω2. ω2 , will t ω2 The horizontal coordinate of the third control point is the motor motion angle S. usr The ordinate of the third control point is used to determine the third control point P2(t). ω2 ,S usr ).
[0110] Step S105: Determine the fourth control point based on the motor running time and the motor movement angle.
[0111] It is understandable that, based on the motor running time and the motor's angle of motion, the motor running time T is... usr The horizontal coordinate of the fourth control point is the motor motion angle S. usr The ordinate of the fourth control point, P3(T), was used to determine the fourth control point. usr ,S usr ).
[0112] Step S106: Construct a motor control curve model based on a third-order Bézier curve according to the first control point, the second control point, the third control point, and the fourth control point, wherein the vector formed by the first control point and the second control point, and the vector formed by the third control point and the fourth control point, are parallel to the X-axis.
[0113] It is important to understand that, in order to reduce parameter passing and computation, the vector formed by the first control point and the second control point is... and the vector formed by the third control point and the fourth control point. Parallel to the X-axis.
[0114] In this embodiment, the motor movement angle S usr Motor running time T usr The first control point parameter ω1 and the second control point parameter ω2 are used to obtain four control points. Based on the four control points, the control system setting curve is completed, thereby calculating and completing the control of the entire motor, reducing the amount of parameter transmission and calculation.
[0115] refer to Figure 5 , Figure 5 This is a flowchart illustrating the third embodiment of the motor motion control method of the present invention.
[0116] After step S50 of the first embodiment described above, the method further includes:
[0117] Step S501: Obtain the pulse waveform period based on the control frequency;
[0118] It should be noted that the main execution body of the motor motion control method in this embodiment is the MCU, which stands for Microcontroller Unit, also known as a single-chip microcomputer or microcontroller. It is a chip-level computer formed by appropriately reducing the frequency and specifications of the central processing unit and integrating peripheral interfaces such as memory, counter, USB, A / D conversion, UART, PLC, DMA, and even LCD driving circuits onto a single chip. It can perform different combinations of control for different applications, such as mobile phones, PC peripherals, remote controls, automotive electronics, stepper motors in industry, and robotic arms. This embodiment does not impose specific limitations on this.
[0119] like Figure 6 As shown, Figure 6 This is a schematic diagram of a stepper motor system. Figure 6 The stepper motor system includes an MCU and a motor driver connected to the MCU. The stepper motor system also includes a motor, which is connected to the motor driver. The MCU sends PWM pulse signals to the stepper driver, and the stepper driver guides the motor to rotate by controlling the current flow in the control coil.
[0120] Step S502: Determine the duty cycle of the pulse waveform based on the pulse waveform period;
[0121] In this embodiment, the duty cycle of the PWM pulse is specifically set to 50% according to the pulse waveform period.
[0122] Step S503: Generate a pulse waveform signal according to the duty cycle of the pulse waveform, and send the pulse waveform signal to the stepper driver so that the stepper driver controls the motor to rotate according to the pulse waveform signal.
[0123] It is understandable that the two-pole motor used in this embodiment, a bipolar stepper motor, has four wires and two coils, namely coil A and coil B in this embodiment. To make it rotate, current needs to be sent through the coils. Each wire needs to be able to be driven by high and low currents, and the order in which different coils are energized or the direction of the current inside the coils will affect the direction of rotation of the motor. For a stepper motor, each input pulse signal drives the motor to rotate by an angle or move forward one step.
[0124] In this embodiment, the relationship between the energization of coils A and B and the direction of motor rotation is shown in Table 1.
[0125] Table 1
[0126]
[0127] It's important to understand that CW indicates the motor rotates clockwise, while CCW indicates the motor rotates counterclockwise.
[0128] Furthermore, when the motor rotates clockwise, the initial state is that the current in coil A flows from the positive to the negative terminal, and coil B is not energized. Upon receiving the first pulse signal, the new state changes to coil A maintaining its original current flow direction, while coil B is also energized, with the current flowing from the positive to the negative terminal. Taking this state as the current state, upon receiving the second pulse signal, the new state changes to coil A being de-energized, and the current in coil B flowing from the positive to the negative terminal. Upon receiving the third pulse signal, the new state changes to coil A being energized, with the current flowing from the negative to the positive terminal, while coil B maintains its original current flow direction. Upon receiving the fourth pulse signal, the new state changes to coil A maintaining its original current flow direction, and coil B being de-energized. Upon receiving the fifth pulse signal, the new state changes to coil A maintaining its original current flow direction, and coil B being energized, with the current flowing from the negative to the positive terminal. Upon receiving the sixth pulse signal, the new state changes to coil A being de-energized, and the current in coil B maintaining its original current flow direction. Upon receiving the seventh pulse signal, the new state changes to coil A being energized, with current flowing from the positive to the negative terminal, while coil B maintains its original current flow direction. Upon receiving the eighth pulse signal, the new state changes again to coil A maintaining its original current flow direction, while coil B is de-energized. At this point, one PWM pulse cycle ends, and steps S201 to S203 are executed again.
[0129] Furthermore, considering the motor's counter-clockwise rotation, the initial state is that current in coil A flows from the positive to the negative terminal, while coil B is not energized. Upon receiving the first pulse signal, the new state changes to coil A maintaining its original current flow direction, while coil B is also energized, with current flowing from the negative to the positive terminal. Taking this state as the current state, upon receiving the second pulse signal, the new state changes to coil A being de-energized and current flowing from the negative to the positive terminal in coil B. Upon receiving the third pulse signal, the new state changes to coil A being energized, with current flowing from the negative to the positive terminal, while coil B maintains its original current flow direction. Upon receiving the fourth pulse signal, the new state changes to coil A maintaining its original current flow direction, while coil B is de-energized. Upon receiving the fifth pulse signal, the new state changes to coil A maintaining its original current flow direction, while coil B is energized, with current flowing from the positive to the negative terminal. Upon receiving the sixth pulse signal, the new state changes to coil A being de-energized, while current in coil B maintains its original current flow direction. Upon receiving the seventh pulse signal, the new state changes to coil A being energized, with current flowing from the positive to the negative terminal, while coil B maintains its original current flow direction. Upon receiving the eighth pulse signal, the new state changes again to coil A maintaining its original current flow direction, while coil B is de-energized. At this point, one PWM pulse cycle ends, and steps S201 to S203 are executed again.
[0130] In this embodiment, the pulse waveform period is obtained according to the control frequency, the pulse waveform duty cycle is determined according to the pulse waveform period, a pulse waveform signal is generated according to the pulse waveform duty cycle, and the pulse waveform signal is sent to the stepper driver so that the stepper driver controls the motor to rotate according to the pulse waveform signal. As illustrated by the table example, the pulse signal can make the stepper motor rotate faster.
[0131] refer to Figure 7 , Figure 7 This is a structural block diagram of the first embodiment of the motor motion control device of the present invention.
[0132] like Figure 7 As shown, the motor motion control device proposed in this embodiment of the invention includes:
[0133] Modeling module 10 is used to construct a motor control curve model based on a third-order Bézier curve according to the control points;
[0134] The acquisition module 20 is used to perform parameter processing on the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time.
[0135] The acquisition module 20 is also used to obtain the functional relationship between the intermediate variable and the movement speed based on the functional relationship between the intermediate variable and the motor stroke and the movement time;
[0136] The acquisition module 20 is also used to obtain the functional relationship between the intermediate variable and the motor frequency based on the functional relationship between the intermediate variable and the motion speed;
[0137] The result module 30 is used to perform equal distribution processing on the functional relationship between the intermediate variable and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke.
[0138] This embodiment constructs a motor control curve model based on a third-order Bézier curve according to control points. Parameter processing is performed on the motor control curve model to obtain the functional relationships between intermediate variables and motor travel and motion time. Based on these relationships, the functional relationship between intermediate variables and motion speed is obtained. Furthermore, the functional relationship between intermediate variables and motor frequency is obtained. This functional relationship is then evenly divided to obtain the motor control frequency corresponding to each motion time and motor travel. This achieves smoother motor motion using the variable acceleration of the third-order Bézier curve, while employing an efficient motor control algorithm to reduce the system's computational load.
[0139] In one embodiment, the modeling module 10 is further configured to acquire the coordinate origin, motor running time, motor motion angle, first control point parameters, and second control point parameters; use the coordinate origin as the first control point; determine the second control point based on the first control point parameters; determine the third control point based on the second control point parameters and the motor motion angle; determine the fourth control point based on the motor running time and the motor motion angle; and construct a motor control curve model based on a third-order Bézier curve based on the first control point, the second control point, the third control point, and the fourth control point, wherein the vectors formed by the first control point and the second control point, and the vectors formed by the third control point and the fourth control point, are parallel to the X-axis.
[0140] In one embodiment, the result module 30 is further configured to calculate the number of equal divisions of the motor stroke based on the motor stroke and the motor step angle; and to obtain the motion time corresponding to each equal division of the motor stroke based on each equal division of the motor stroke and the parameter equation of the motor control curve model.
[0141] In one embodiment, the result module 30 is further configured to obtain the control frequency provided to the motor for the current equal-segment stroke by means of the motor's step angle, downsampling factor, motion time corresponding to the current equal-segment stroke, and motion time corresponding to the next equal-segment stroke; and to obtain the relationship between each motion time and the motor stroke and the motor control frequency based on the control frequency provided to the motor for each current equal-segment stroke.
[0142] In one embodiment, the acquisition module 20 is further configured to solve for the intermediate variable corresponding to each equal-division angle by using Newton's iteration method based on the intermediate variable of the iteration number, the motor stroke, and the derivative of the motor stroke; substitute the intermediate variable corresponding to each equal-division angle into the parametric equation of the motor control curve model of the third-order Bézier curve to obtain the functional relationship between the intermediate variable and the motor stroke; and substitute the intermediate variable corresponding to each equal-division angle into the parametric equation of the motor control curve model of the third-order Bézier curve to obtain the functional relationship between the intermediate variable and the motion time.
[0143] In one embodiment, the result module 30 is further configured to obtain a downsampling factor; when the downsampling factor is not equal to a preset value, obtain the current control frequency and the next control frequency; determine the supplemented intermediate frequency based on the downsampling factor, the sampling points between the current sampling point and the next sampling point, the current control frequency, and the next control frequency; and add the supplemented intermediate frequency to the control frequency to obtain the target control frequency.
[0144] In one embodiment, the result module 30 is further configured to obtain the pulse waveform period according to the control frequency; determine the pulse waveform duty cycle according to the pulse waveform period; generate a pulse waveform signal according to the pulse waveform duty cycle; and send the pulse waveform signal to the stepper driver so that the stepper driver controls the motor to rotate according to the pulse waveform signal.
[0145] Furthermore, to achieve the above objectives, the present invention also proposes a motor motion control device, which includes: a memory, a processor, and a motor motion control program stored in the memory and executable on the processor, wherein the motor motion control program is configured to implement the steps of the motor motion control method described above.
[0146] Since this motor motion control device adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, which will not be repeated here.
[0147] Furthermore, this embodiment of the invention also proposes a storage medium storing a motor motion control program, which, when executed by a processor, implements the steps of the motor motion control method described above.
[0148] Since this storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, which will not be repeated here.
[0149] It should be understood that the above are merely illustrative examples and do not constitute any limitation on the technical solutions of the present invention. In specific applications, those skilled in the art can make settings as needed, and the present invention does not impose any restrictions on this.
[0150] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of this invention. In practical applications, those skilled in the art can select some or all of the workflow to achieve the purpose of this embodiment according to actual needs, and no restrictions are imposed here.
[0151] In addition, for technical details not described in detail in this embodiment, please refer to the engineering mode control method provided in any embodiment of the present invention, which will not be repeated here.
[0152] Furthermore, it should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system 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 system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0153] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0154] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0155] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A method for controlling the motion of a motor, characterized in that, A stepper motor system includes a microcontroller unit (MCU) and a stepper driver. The MCU calculates the frequency based on motor parameters, and the stepper driver receives the frequency information and controls the motor rotation. The method applied to the MCU includes: Construct a motor control curve model based on a third-order Bézier curve according to the control points; The parameters of the motor control curve model are processed to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time. Based on the functional relationship between the intermediate variable and the motor stroke and the motion time, the functional relationship between the intermediate variable and the motion speed is obtained; Based on the functional relationship between the intermediate variable and the speed of motion, the functional relationship between the intermediate variable and the frequency of the motor is obtained; The functional relationship between the intermediate variable and the motor frequency is divided equally to obtain the control frequency of the motor corresponding to each motion time and motor stroke. The control points include a first control point, a second control point, a third control point, and a fourth control point. The step of constructing a motor control curve model based on a third-order Bézier curve according to the control points includes: Obtain the coordinate origin, motor running time, motor motion angle, first control point parameters, and second control point parameters; The origin of the coordinate system is taken as the first control point; The second control point is determined based on the parameters of the first control point. The third control point is determined based on the parameters of the second control point and the motor motion angle. The fourth control point is determined based on the motor running time and the motor motion angle. A motor control curve model based on a third-order Bézier curve is constructed based on the first control point, the second control point, the third control point, and the fourth control point. The vectors formed by the first control point and the second control point, as well as the vectors formed by the third control point and the fourth control point, are parallel to the X-axis.
2. The method as described in claim 1, characterized in that, The process of equally dividing the functional relationship between the intermediate variable and the motor frequency includes: The number of equal divisions of the motor stroke is calculated based on the motor stroke and the motor step angle. Based on the motor stroke of each equal part and the parameter equations of the motor control curve model, the motion time corresponding to each equal part stroke is obtained.
3. The method as described in claim 2, characterized in that, The process of obtaining the control frequency of the motor corresponding to each motion time and motor stroke includes: The control frequency provided to the motor for the current average stroke is obtained by using the motor's step angle, downsampling factor, motion time corresponding to the current average stroke, and motion time corresponding to the next average stroke. Based on the control frequency provided to the motor for each current equal-division stroke, the relationship between each motion time and the motor stroke and the motor control frequency is obtained.
4. The method as described in claim 1, characterized in that, The parameter processing of the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time includes: The intermediate variables corresponding to each evenly divided angle are obtained by solving the problem using Newton's iteration method based on the intermediate variables of the iteration number, the motor stroke, and the derivative of the motor stroke. By substituting the intermediate variables corresponding to each equal division angle into the parametric equations of the motor control curve model of the third-order Bézier curve, the functional relationship between the intermediate variables and the motor stroke is obtained. By substituting the intermediate variables corresponding to each equal division angle into the parametric equations of the motor control curve model of the third-order Bézier curve, the functional relationship between the intermediate variables and the motion time can be obtained.
5. The method according to any one of claims 1 to 4, characterized in that, After dividing the functional relationship between the intermediate variable and the motor frequency into equal parts to obtain the control frequency of the motor corresponding to each motion time and motor stroke, the method further includes: Obtain the downsampling factor; When the downsampling rate is not equal to the preset value, obtain the current control frequency and the next control frequency; The intermediate frequency for padding is determined based on the downsampling factor, the sampling points between the current sampling point and the next sampling point, the current control frequency, and the next control frequency. The supplemented intermediate frequency is added between the current control frequency and the next control frequency to obtain the target control frequency.
6. The method according to any one of claims 1 to 4, characterized in that, After dividing the functional relationship between the intermediate variable and the motor frequency into equal parts to obtain the control frequency of the motor corresponding to each motion time and motor stroke, the method further includes: The pulse waveform period is obtained based on the control frequency; The pulse waveform duty cycle is determined based on the pulse waveform period. A pulse waveform signal is generated based on the pulse waveform duty cycle, and the pulse waveform signal is sent to the stepper driver so that the stepper driver controls the motor to rotate according to the pulse waveform signal.
7. A motor motion control device, characterized in that, The device includes: The modeling module is used to construct a motor control curve model based on a third-order Bézier curve according to the control points, which include a first control point, a second control point, a third control point, and a fourth control point. The acquisition module is used to process the parameters of the motor control curve model to obtain the functional relationship between the intermediate variables in the motor control curve model and the motor stroke and motion time. The acquisition module is further configured to obtain the functional relationship between the intermediate variable and the movement speed based on the functional relationship between the intermediate variable and the motor stroke and the movement time; The acquisition module is further configured to obtain the functional relationship between the intermediate variable and the motor frequency based on the functional relationship between the intermediate variable and the motion speed; The results module is used to equally divide the functional relationship between the intermediate variables and the motor frequency to obtain the control frequency of the motor corresponding to each motion time and motor stroke. The modeling module is further configured to acquire the coordinate origin, motor running time, motor motion angle, first control point parameters, and second control point parameters; use the coordinate origin as the first control point; determine the second control point based on the first control point parameters; determine the third control point based on the second control point parameters and the motor motion angle; determine the fourth control point based on the motor running time and the motor motion angle; and construct a motor control curve model based on a third-order Bézier curve based on the first, second, third, and fourth control points, wherein the vectors formed by the first and second control points and the vectors formed by the third and fourth control points are parallel to the X-axis.
8. A motor motion control device, characterized in that, The motor motion control device includes: a memory, a processor, and a motor motion control program stored in the memory and executable on the processor, the motor motion control program being configured to implement the steps of the motor motion control method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium stores a motor motion control program, which, when executed by a processor, implements the steps of the motor motion control method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method for quickly planning six-order S-shaped motion curve
CN111596543A
Methods for speed leveling of inhomogeneously parameterized trajectories - especially Bézier curves - for their dynamic use in CAM processes (Computer Aided Manufacturing) by reparameterization according to arc length
DE102022000530A1