Motor variable speed regulation and control method, electronic equipment and computer program product

By subdividing the speed change process of the drive motor, dynamically determining the speed regulation mode and speed, the jitter problem during the speed change process of the motor is solved, and the stability and picture quality of the camera are improved.

CN120357779APending Publication Date: 2025-07-22TP-LINK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510502377.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In the prior art, there is obvious jitter during the motor speed change, resulting in a decrease in the quality of the picture collected by the camera.

Method used

By dividing the entire speed change process of the motor into multiple subdivided steps, the speed regulation mode and motor speed are dynamically determined, the smooth change of motor speed is achieved, and the motor speed is controlled by the subdivided driving method.

Benefits of technology

It reduces the jitter of the motor during acceleration or deceleration, and improves the stability and picture quality of the camera during rotation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120357779A_ABST
    Figure CN120357779A_ABST
Patent Text Reader

Abstract

The invention provides a motor speed change regulation and control method, electronic equipment and a computer program product. Relates to the technical field of motor control. The invention provides a motor speed change regulation and control method, which comprises the following steps: in the operation process of a holder, obtaining the current position and the current speed of a motor and a control instruction for the motor, the control instruction comprising the target speed and the target position of the motor; according to the current position, the current speed, the target speed and the target position, determining a speed regulation mode of the motor in the next subdivision step; and determining the motor speed of the next subdivision step according to the speed regulation mode, and controlling the motor to rotate based on the motor speed. Through the embodiment of the invention, the jitter phenomenon in the speed change process of the motor can be slowed down, the image collection stability of the camera in the rotation process is improved, and the quality of the collected image is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of motor control, and particularly to a motor speed regulation method, an electronic device, and a computer program product. Background Art

[0002] A camera with a pan-tilt head, such as a speed dome camera, integrates a camera and a pan-tilt head. By rotating the pan-tilt head, the camera is driven to rotate, realizing large-range and multi-angle monitoring, and is widely used in the fields of security, transportation, industry, etc.

[0003] Currently, by driving the rotation of the pan-tilt head through a motor, the speed of the motor is usually controlled in a full-step speed change manner. However, during the acceleration or deceleration drive process of the pan-tilt head, the full-step speed change causes the motor to generate obvious jitter, resulting in a jitter phenomenon in the captured image of the camera and affecting the image quality. Summary of the Invention

[0004] According to various embodiments of the present application, a motor speed regulation method, an electronic device, and a computer program product are provided; the jitter phenomenon during the motor speed change process can be reduced, the stability of the camera rotation for image capture can be improved, and the image quality can be improved.

[0005] In a first aspect, the present application provides a motor speed regulation method, and the method includes:

[0006] During the operation of the pan-tilt head, obtain the current position, current speed of the motor, and the control command for the motor, where the control command includes the target speed and target position of the motor; determine the speed regulation mode of the motor in the next sub-step according to the current position, current speed, target speed, and target position; determine the motor speed in the next sub-step according to the speed regulation mode, and control the rotation of the motor based on the motor speed.

[0007] In the above manner, by dividing a full step into multiple sub-steps, based on the obtained current position, current speed of the motor, and the target speed and target position in the control command, dynamically determine the speed regulation mode of the next sub-step, determine the motor speed of the next sub-step according to the speed regulation mode, ensure that the motor speed changes smoothly based on sub-drive, sub-drive the motor speed change process based on the control command, realize the precise control and stable operation of the motor, reduce the jitter of the motor during acceleration or deceleration, improve the stability during the rotation of the camera, and improve the quality of the captured image; it has strong usability and practicability.

[0008] In a possible implementation manner of the first aspect, determining the speed regulation mode of the motor in the next sub-step according to the current position, current speed, target speed, and target position includes:

[0009] Determine the number of steps to be rotated according to the current position and the target position; determine the first deceleration buffer steps according to the current speed and the preset stop rotation speed; determine the speed regulation mode of the motor in the next microstep according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer steps, and / or, the magnitude relationship between the current speed and the target speed.

[0010] In a possible implementation manner of the first aspect, determining the speed regulation mode of the motor in the next microstep according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer steps, and the magnitude relationship between the current speed and the target speed, includes:

[0011] When the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is less than the target speed, determine that the speed regulation mode is the microstep acceleration mode; when the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is greater than the target speed, determine that the speed regulation mode is the microstep deceleration mode.

[0012] In a possible implementation manner of the first aspect, determining the speed regulation mode of the motor in the next microstep according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer steps, includes:

[0013] When the number of steps to be rotated is less than or equal to the first deceleration buffer steps, determine that the speed regulation mode is the microstep deceleration mode.

[0014] In a possible implementation manner of the first aspect, when the directions of the target speed and the current speed are opposite, the method further includes:

[0015] When the current speed is greater than the preset reverse speed, determine that the speed regulation mode is the microstep deceleration mode.

[0016] In a possible implementation manner of the first aspect, the speed regulation mode includes the microstep acceleration mode; determining the motor speed of the next microstep according to the speed regulation mode, includes:

[0017] In the microstep acceleration mode, when the current speed is less than the first microstep target speed, calculate the first new speed based on the current speed and the acceleration corresponding to the current speed; the first microstep target speed is the microstep target speed for one acceleration during the microstep acceleration process; calculate the second deceleration buffer steps corresponding to the first new speed based on the first new speed and the preset stop rotation speed; when the number of steps to be rotated is greater than the second deceleration buffer steps, determine the first microstep number corresponding to the first new speed; when the microstep index corresponding to the next microstep is an integer multiple of the first microstep factor, use the first new speed as the motor speed of the next microstep; wherein, the first microstep factor is determined based on the first microstep number and the maximum microstep number of the motor.

[0018] In a possible implementation of the first aspect, before calculating the first new speed based on the current speed and the acceleration corresponding to the current speed, the method further includes:

[0019] When the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is less than the target speed, update the first sub-target speed to the target speed.

[0020] In a possible implementation of the first aspect, the speed regulation mode includes a sub-deceleration mode; determining the motor speed of the next sub-step according to the speed regulation mode includes:

[0021] In the sub-deceleration mode, when the current speed is greater than the second sub-target speed, calculate the second new speed according to the current speed and the deceleration corresponding to the current speed; the second sub-target speed is the sub-target speed for one deceleration in the sub-deceleration process; query the second sub-division number corresponding to the second new speed, and when the sub-division index corresponding to the next sub-step is an integer multiple of the second sub-division factor, use the second new speed as the motor speed of the next sub-step; or, when the sub-division index corresponding to the next sub-step is an integer multiple of the second sub-division factor, the direction of the current speed is opposite to the target speed, and the second new speed is not greater than the second sub-target speed, reverse the direction of the current speed and then use the second new speed as the motor speed of the next sub-step; wherein, the second sub-division factor is determined based on the second sub-division number and the maximum sub-division number of the motor.

[0022] In a possible implementation of the first aspect, before calculating the second new speed according to the current speed and the deceleration corresponding to the current speed, the method further includes:

[0023] When the direction of the target speed is the same as the current speed, when the number of steps to be rotated is less than or equal to the first deceleration buffer steps, update the second sub-target speed to the stop speed; the stop speed is the speed at which the motor stops rotating; or, when the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is greater than the target speed, update the second sub-target speed to the target speed; or, when the direction of the target speed is opposite to the current speed and the current speed is greater than the reverse speed, update the second sub-target speed to the reverse speed.

[0024] In a possible implementation of the first aspect, when the direction of the target speed is opposite to the current speed, the method further includes:

[0025] When the current speed is less than or equal to the reverse speed and the target speed is greater than the reverse speed, update the sub-target speed of the next subdivision step to the target speed, update the magnitude of the current speed to the reverse speed, and reverse the direction of the current speed; or, when the current speed is less than or equal to the reverse speed and the target speed is less than or equal to the reverse speed, update the sub-target speed of the next subdivision step to the target speed, update the magnitude of the current speed to the target speed, and reverse the direction of the current speed; wherein, the sub-target speed of the next subdivision step is the sub-target speed of the motor during a speed change process.

[0026] In a possible implementation manner of the first aspect, controlling the rotation of the motor based on the motor speed includes:

[0027] Determine the timer timing period according to the motor speed and the number of subdivisions corresponding to the motor speed; determine the timer target count value based on the timer timing period and the timer clock frequency; control the rotation of the motor based on the timer target count value.

[0028] In a possible implementation manner of the first aspect, the method further includes:

[0029] When the operating mode corresponding to the control instruction is continuous rotation, the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions, and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed; or, when the operating mode corresponding to the control instruction is non-continuous rotation and the current speed is opposite to the target speed, increase the number of steps to be rotated to the first number of steps, and when the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed; or, when the operating mode corresponding to the control instruction is non-continuous rotation and the current speed is the same as the target speed, reduce the number of steps to be rotated to the second number of steps, and when the current speed is greater than the stop speed, the number of steps to be rotated is greater than zero, and when the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed; wherein, the number of steps to be rotated is determined based on the current position and the target position; the current speed corresponds to the current number of subdivisions, and the new motor speed corresponds to the new number of subdivisions; adjusting the motor speed of the motor includes adjusting the current speed to the new motor speed.

[0030] In a second aspect, the present application provides a motor speed change control device, and the device includes:

[0031] A monitoring unit, configured to obtain the current position, current speed of the motor and the control instruction for the motor during the operation of the pan-tilt head, where the control instruction includes the target speed and target position of the motor;

[0032] A planning unit, configured to determine the speed regulation mode of the motor in the next sub-step according to the current position, the current speed, the target speed and the target position;

[0033] An adjustment and control unit, configured to determine the motor speed in the next sub-step according to the speed regulation mode, and control the rotation of the motor based on the motor speed.

[0034] In a third aspect, the present application provides an electronic device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the method described in any one of the first aspect is implemented.

[0035] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the first aspect is implemented.

[0036] In a fifth aspect, the present application provides a computer program product, and when the computer program product runs on a device, the device is enabled to execute the method described in any one of the first aspect above.

[0037] It can be understood that the beneficial effects of the above second aspect to fifth aspect can refer to the relevant descriptions in the above first aspect, and will not be elaborated here. Description of the Drawings

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0039] Figure 1 It is a schematic structural diagram of the motor provided by the embodiment of the present application;

[0040] Figure 2 It is a schematic diagram of dividing sub-steps provided by the embodiment of the present application;

[0041] Figure 3 It is a schematic implementation flowchart of controlling the operation process of the motor provided by the embodiment of the present application;

[0042] Figure 4 It is a schematic implementation flowchart of the motor speed regulation and control method provided by the embodiment of the present application;

[0043] Figure 5 Schematic diagram of the implementation process of the same-direction speed planning provided by the embodiment of the present application;

[0044] Figure 6 Schematic diagram of the implementation process of the reverse speed planning provided by the embodiment of the present application;

[0045] Figure 7 Schematic diagram of the implementation process of the fine acceleration control provided by the embodiment of the present application;

[0046] Figure 8 Schematic diagram of the implementation process of the fine deceleration control provided by the embodiment of the present application;

[0047] Figure 9 Schematic diagram of the structure of the motor speed regulation device provided by the embodiment of the present application;

[0048] Figure 10 Schematic diagram of the structure of the electronic device provided by the embodiment of the present application. Detailed implementation manners

[0049] The embodiments of the technical solutions of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solutions of the present application more clearly, and therefore are only examples and cannot be used to limit the protection scope of the present application.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion.

[0051] In the description of the embodiments of the present application, technical terms such as "first" and "second" are only used to distinguish different objects and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity, specific order or primary-secondary relationship of the indicated technical features. In the description of the embodiments of the present application, "a plurality" means more than two unless otherwise specifically defined.

[0052] Referring to "embodiment" herein means that a specific feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0053] In the description of the embodiments of the present application, the term "and / or" is merely an association relationship describing associated objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. Additionally, in this article, the character " / " generally represents an "or" relationship between the associated objects before and after.

[0054] Currently, in the speed regulation control process of a stepper motor, the method of integral step speed change is usually adopted; for example, for the sine wave drive signal of a stepper motor, one sine wave period corresponds to 4 integral steps, that is, 1 / 4 sine wave. The speed is only changed at integral steps. When switching between one 1 / 4 sine wave and the next 1 / 4 sine wave, the situation of uneven slopes will occur, resulting in zero-crossing distortion, and the speed change granularity is large, leading to motor jitter during the speed change process; moreover, the speed can only be changed at integral steps, making the motor speed up slowly and it is difficult to track a fast-moving target object.

[0055] In view of the above technical problems, the embodiments of the present application provide a method for motor speed regulation and control. By dividing one integral step into multiple sub-steps, based on the current position, current speed of the motor, and the target speed and target position in the control instruction, the speed regulation mode of the next sub-step is dynamically determined. Based on the speed regulation mode, the motor speed of the next sub-step is determined, ensuring that the motor speed changes smoothly based on sub-step drive. The motor speed change process is subdivided based on the control instruction to achieve precise control and stable operation of the motor, reduce the jitter of the motor during acceleration, deceleration, and startup processes, improve the stability during the rotation of the camera, and improve the quality of the captured image.

[0056] The architecture of the motor applicable to the present application is introduced below through embodiments.

[0057] Please refer to Figure 1 , Figure 1 which is a schematic structural diagram of the motor provided by the embodiments of the present application. This motor is applied to a pan-tilt control system; among them, the pan-tilt control system may include a stepper motor (hereinafter simply referred to as the motor), at least one timer, and a controller. As Figure 1 shown, the stepper motor includes a stator 101 and a rotor 102; among them, the stator 101 has orthogonal A ends (A+ and A-) and B ends (B+ and B-); the controller continuously outputs a pulse modulation signal and converts the pulse modulation signal into an approximate sine wave signal as the drive signal; the controller can control the drive signals (such as drive current or drive voltage) input to the A ends and B ends. By changing the current in the A ends and B ends, different magnetic fields are generated to drive the rotor 102 to rotate; the controller realizes the division of each integral step of the sine wave drive signal into sub-steps by adjusting the duty cycle of the pulse modulation signal within one timer interruption.

[0058] AsFigure 2 As shown, it is a schematic diagram of the change of the current y of phase A with time t during the rotation of the stepping motor. Taking the example of dividing each full step into 4 sub-steps, the changes from the origin to (t0, y0), from (t0, y0) to (t1, y1), from (t1, y1) to (t2, y2), and from (t2, y2) to (t3, y3) respectively correspond to one sub-step. The controller can control the continuous change of the current between 0, y0, y1, y2, and y3, thereby driving the stepping motor to rotate continuously; adjusting the time intervals of t0 to 0, t1 to t0, t2 to t1, and t3 to t2, that is, the duration of the sub-steps, to adjust the speed of the motor.

[0059] Among them, when the phase difference of the drive signals of phase A and phase B of the motor remains at 90°, a rotating magnetic field is generated inside the motor, and this magnetic field attracts the rotor 102 to rotate accordingly, realizing the stepping rotation of the motor. By dividing the sine wave into sub-steps, more precise angle control can be achieved; for example, dividing a complete sine wave period into 256 sub-steps makes the stepping angle of the motor smaller and the movement smoother.

[0060] It should be noted that in the way of full-step speed change, the duration of the sub-steps within each full step is a constant value. Due to the full-step speed change, the duration of the sub-steps between different full steps may be different. In this application, the sub-step speed change method is adopted, and the speed is planned for each sub-step, and the duration of each sub-step may be different. The above Figure 1 shown motor structure and Figure 2 the number of subdivisions shown are only for illustrative purposes. There can be other numbers of subdivisions during the subdivision drive process, and during the speed planning process for each sub-step, it can be dynamically adjusted based on the current speed of the motor.

[0061] Based on the above implementation principle, the following further introduces each control process during the operation of the motor through embodiments.

[0062] Please refer to Figure 3 , Figure 3 which is a schematic diagram of the implementation process for controlling the operation of the motor provided by the embodiment of this application. During one interruption of the timer, the direction of the motor rotation is controlled by modifying the polarities (such as positive and negative) of the currents of phase A and phase B; and the magnitude of the currents input to phase A and phase B is controlled by modifying the PWM duty cycles of phase A and phase B, thereby driving the motor to rotate one sub-step. During the process of adjusting the speed of the motor, based on the planned speed of the motor for the next sub-step, the timing period of the timer is modified to achieve the speed adjustment of the motor.

[0063] Such as Figure 3As shown, in a single interrupt handling process of the timer, the control process of the controller for the motor may include: driving the motor to rotate (such as S301 to S302), updating the motor state (such as S311 to S316), adjusting the motor speed (such as S321 to S326), and stopping the motor (such as S331 to S332).

[0064] Among them, the control process of driving the motor to rotate may include the following steps:

[0065] S301, calculate and set the polarities of phases A and B.

[0066] S302, update the PWM duty cycles of phases A and B by looking up a table according to the calculation results.

[0067] During the operation of the motor or after the motor starts, based on the control instructions issued by the user or the control algorithm, calculate the rotation direction, speed, and the number of steps to be rotated of the motor; then determine the current (including direction and magnitude) used to drive the motor to rotate according to the foregoing calculation results; set the polarities of phases A and B of the motor based on the direction of the motor, and the corresponding PWM duty cycle can be determined by looking up a table based on the speed of the motor.

[0068] Exemplarily, in an actual application scenario, the pan-tilt control system stores the correspondence between the motor speed and the microstep division number, and the correspondence between the microstep division number and the PWM duty cycle, and solidifies the above correspondences into the memory in the form of a discrete table. Thus, after determining the motor speed, the corresponding PWM duty cycle can be directly determined by looking up a table, and the drive signal is controlled based on the duty cycle to drive the motor to rotate.

[0069] The control process of updating the motor state may include the following steps:

[0070] S311, after determining the PWM duty cycle, drive the motor to rotate and update the state of the motor. The state of the motor includes the microstep index recorded by software and the position of the motor. For example, the motor moves from the position corresponding to the microstep index 20 of the microstep to the position corresponding to the microstep index 21.

[0071] S312, determine whether the motor rotates continuously. If yes, execute S313; if not, execute S314.

[0072] In an actual application scenario, the actual operation process of the motor depends on the trigger of the external user or the control of the algorithm, and determines that the motor operates in the corresponding rotation mode. For example, for pan-tilt functions such as user manual control of the pan-tilt, automatic scanning, frame scanning, and panoramic scanning, the motor needs to rotate continuously; in pan-tilt functions such as setting preset points, cruise scanning, pattern scanning, and 3D positioning, the motor rotates discontinuously. Based on the functions currently implemented by the pan-tilt, determine the scenario where the motor rotates continuously.

[0073] S313. Determine whether the current subdivision index is divisible by the subdivision factor. If so, execute S321; if not, end.

[0074] Exemplarily, the subdivision factor in S313 can be the current subdivision factor corresponding to the current subdivision number, and the corresponding current subdivision number is determined based on the current speed. During the operation of the motor, when receiving a control instruction issued by a user or an algorithm and needing to perform speed planning for the rotation process of the motor in the subdivision step, it is necessary to first determine whether the subdivision index corresponding to the subdivision step for which the speed needs to be adjusted is divisible by the current subdivision factor. When it is determined that it is divisible, speed change adjustment is performed in the current subdivision step, thereby avoiding the motor losing steps due to incorrect update of the subdivision index.

[0075] S314. Determine whether the direction of the current speed is the same as that of the target speed. If so, execute S315; if not, execute S316.

[0076] During the operation of the motor, in the functional scenario of non - continuous rotation, the controller drives the motor to rotate by further determining whether the direction of the current speed is the same as that of the target speed based on the target position and the target speed in the control instruction issued by the user or the control algorithm.

[0077] S315. Reduce the number of steps to be rotated to the second number of steps.

[0078] S316. Increase the number of steps to be rotated to the first number of steps.

[0079] When the direction of the current speed of the motor is the same as that of the target speed, reduce the number of steps to be rotated to the second number of steps. The number of steps to be rotated refers to the remaining number of steps that need to be rotated in the current rotation process. For the application scenario of non - continuous rotation, the initial value of the number of steps to be rotated is obtained by converting the rotation angle expected by the user or the control algorithm, such as calculated by the following formula:

[0080] Number of steps to be rotated = Rotation angle to be rotated * Housing transmission ratio * Maximum subdivision number / Motor step angle;

[0081] Rotation angle to be rotated = Target angle - Current angle;

[0082] Among them, the housing transmission ratio depends on the structural design of the motor, the motor step angle depends on the motor model, the maximum subdivision number is the maximum value of the subdivision numbers supported by the motor (depending on software configuration), and the housing transmission ratio, the motor step angle, and the maximum subdivision number are all constants.

[0083] For a non - continuous rotation scenario, if the current speed is in the same direction as the target speed (the target speed direction can be determined based on the current position and the target position), the motor is approaching the target position, and the number of steps to be rotated should be subtracted by the number of micro - steps taken during this interruption, that is, the number of steps to be rotated is reduced to the second number of steps; conversely, if the current speed is in the opposite direction to the target speed (for example, the user or the control algorithm may issue a new rotation instruction during a rotation process, resulting in a situation where the current speed direction is opposite to the target speed direction), the motor is moving away from the target position, and the number of steps to be rotated should be added by the number of micro - steps taken during this interruption.

[0084] For a continuous rotation scenario, before the user issues a stop rotation instruction, the number of steps to be rotated is constantly 0. After the stop rotation instruction is issued, the number of steps to be rotated is updated to a negative number.

[0085] Correspondingly, after increasing the number of steps to be rotated to the first number of steps, when speed adjustment is required, continue to execute S313 to determine whether the micro - step index after increasing the number of steps to be rotated is divisible by the current micro - step factor, and when variable speed control is required, acceleration or deceleration adjustment can be performed at the micro - step index divisible by the current micro - step factor.

[0086] Among them, the first number of steps and the second number of steps can be determined based on the current state and the target state of the motor in the actual application scenario.

[0087] The control process of adjusting the motor speed may include the following steps:

[0088] S321, calculate the first deceleration buffer number of steps. During the operation of the motor, when receiving a control instruction issued by the user or the control algorithm and needing to adjust the motor speed, calculate the deceleration buffer number of steps of the control instruction relative to the current state of the motor; among them, the deceleration buffer number of steps refers to the number of steps required to decelerate from the current speed to a stop. If the current speed is greater than the stop speed, the deceleration buffer number of steps is the number of steps required for the current speed to decelerate along the deceleration curve to the stop speed. If the current speed is less than or equal to the stop speed, the motor can directly stop at the current speed, so the deceleration buffer number of steps is 0.

[0089] S322, perform speed planning. When the motor speed needs to be adjusted, the controller determines the speed of the motor in the next micro - step according to the current speed, the target speed, the number of steps to be rotated, and the deceleration buffer number of steps. Through the speed planning of the next micro - step, the motor speed is restricted to change along the established acceleration curve and deceleration curve, reducing the probability of the motor overshooting or losing steps.

[0090] S323. Determine whether speed change is possible. If yes, execute S324; if no, end. In the case where speed change is possible, for example, when the current subdivision index corresponding to the current subdivision step is an integral multiple of the subdivision factor corresponding to the new number of subdivisions, update the motor speed to adjust the motor speed; for example, adjust the current speed of the motor to a new motor speed, where the new motor speed corresponds to the new number of subdivisions.

[0091] S324. Update the software speed. The software speed is the value that records the current motor speed for calculating the duration of the subdivision step and is also used for the next speed planning. The software speed is not equivalent to the actual speed of the motor during rotation. The actual speed of the motor depends on the number of subdivisions and the duration of the subdivision step (i.e., the timer timing period).

[0092] S325. Update the number of subdivisions. Different motor speeds correspond to different numbers of subdivisions. For example, use a high number of subdivisions at low speeds to reduce the jitter of the prototype, while at relatively high motor speeds, due to CPU resource limitations, select a relatively low number of subdivisions, so different numbers of subdivisions are used in different speed ranges. After calculating the motor speed, in the pre-defined speed-number of subdivisions table (referred to as the subdivision configuration table), query the corresponding number of subdivisions according to the motor speed.

[0093] S326. Update the timer timing period. The frequency of the timer interrupt determines the rotation speed of the motor. By adjusting the frequency of the timer interrupt, the rotation speed of the motor can be controlled. For example, a high-frequency interrupt corresponds to high-speed operation of the motor, and a low-frequency interrupt corresponds to low-speed operation of the motor. During the motor speed change control process, the frequency of the timer interrupt is dynamically adjusted to achieve acceleration or deceleration of the motor; accordingly, each time the interrupt is triggered, the timer target count value gradually changes, thus changing the interrupt frequency. After determining the motor speed and the number of subdivisions, the duration of the subdivision step and the timer timing period are determined by the following formulas:

[0094] Duration of a full step = 1 / motor speed;

[0095] Duration of a subdivision step = Duration of a full step / Number of subdivisions;

[0096] Timer timing period = Duration of a subdivision step;

[0097] Timer target count value = Timer timing period * Timer clock frequency;

[0098] Among them, the unit of the motor speed is pps (steps rotated per second), the unit of time is s (seconds), and the unit of the clock frequency is Hz (Hertz), which is a constant related to the single-chip microcomputer specification and software configuration. Determine the timer target count value based on the updated timer timing period, and control the interval time of the timer interrupt based on the timer target count value to adjust the motor speed.

[0099] The control process for motor stop may include the following steps:

[0100] S331. Determine whether the current speed is not greater than the stopping speed and the number of steps to be rotated is not greater than 0. If so, execute S332; if not, execute S313.

[0101] S332. Set the motor to stop.

[0102] By gradually reducing the number of steps to be rotated to the second number through the aforementioned S315, the motor is gradually decelerated, avoiding the impact or vibration caused by sudden stop, ensuring the smooth stop of the motor, and reducing system instability; furthermore, the magnitude of the current speed and the stopping speed is judged to ensure that the motor has been decelerated to a low enough speed before stopping (before the number of steps to be rotated is non-zero), avoiding the impact or inaccurate positioning caused by too high speed, ensuring the motor stops at a low speed, improving the stopping accuracy and system stability; when the conditions of S331 are met, the timer is turned off, and the phase A and phase B currents of the motor do not change, causing the motor to stop rotating, ensuring that the motor accurately stops at the target position, and avoiding overshoot or positioning misalignment.

[0103] Based on the above overall process of motor control, the control process for adjusting the motor speed will be described in detail below through embodiments.

[0104] Please refer to Figure 4 , the schematic implementation flowchart of the motor speed regulation method provided by the embodiment of the present application; the execution subject of the motor speed regulation method may be the controller of the above-mentioned pan-tilt system, such as Figure 4 shown, and the method may include the following steps:

[0105] S401. During the operation of the pan-tilt, obtain the current position, current speed of the motor, and the control instruction for the motor. The control instruction includes the target speed and target position of the motor.

[0106] In some embodiments, during the operation of the pan-tilt after power-on, control instructions sent by users or control algorithms will be received, such as application scenarios where the pan-tilt function is switched or it is found that a tracking target needs to be continuously tracked. When a new control instruction is received, the controller can monitor the current position and current speed recorded in the system, or the controller can monitor the current position and current speed of the motor through sensors (such as encoders). For example, the current stepping position of the motor is obtained in real time through the sensor, and the current running speed of the motor is obtained in real time by calculating the change in the number of steps of the motor per unit time.

[0107] Exemplarily, the control instruction includes the target speed and target position of the motor; when the pan-tilt receives a control signal, the control signal for the pan-tilt can be converted into a control instruction for the motor, for example, converting the movement of the pan-tilt in the control signal into the actual rotation amount of the motor; the target position can be the position that the motor needs to reach, and the target speed can be the speed that the motor needs to reach at the target position.

[0108] For example, the control information received by the pan-tilt includes that the pan-tilt rotates horizontally to the position of 30°, and the speed is 10° / second. By parsing the control information, the control instruction for the motor is obtained. For example, according to the reduction ratio between the pan-tilt and the motor, it is calculated that the target position for the motor to rotate to is 300 steps, and according to the speed requirement, the target speed for the motor is calculated to be 30 steps / second.

[0109] Another example is that the current position of the motor is 500 steps, the target position is 1000 steps, the current speed is 50 steps / second, and the target speed is 100 steps / second.

[0110] It should be noted that the process of converting the control signal for the pan-tilt into the control instruction for the motor is only exemplarily described above. For example, the angular position of the motor can also be obtained based on the position of the pan-tilt. The specific conversion method can be determined based on the connection structure between the pan-tilt and the motor in the pan-tilt system, and no specific limitation is provided here.

[0111] S402. Determine the speed regulation mode of the motor in the next sub-step according to the current position, current speed, target speed, and target position.

[0112] In some embodiments, when the controller of the pan-tilt system receives a new control instruction, based on the current state and target state of the motor, the operating state of the motor in the next sub-step can be planned; and after one sub-step, the operating state of the next sub-step is planned again according to the current state of the motor and the target speed and target position.

[0113] Exemplarily, in order to avoid the motor losing steps, when adjusting the speed of the motor, the sub-step index of the sub-step where the motor is currently located needs to satisfy being an integer multiple of the current sub-division factor of the motor; where the current sub-division factor is determined based on the current sub-division number corresponding to the planned current motor speed and the maximum sub-division number supported by the motor. For example, the ratio of the maximum sub-division number to the current sub-division number is used as this sub-division factor; correspondingly, the new sub-division factor is the ratio of the maximum sub-division number to the new sub-division number.

[0114] Exemplarily, the speed regulation mode may include a sub - division acceleration mode, a sub - division deceleration mode, and a constant speed mode. For example, when the motor is far from the target position and the current speed is lower than the target speed, the determined speed regulation mode is the sub - division acceleration mode; when the motor is close to the target position and the current speed is higher than the target speed, the determined speed regulation mode is the sub - division deceleration mode; when the current speed of the motor is equal to the target speed and the distance from the target position is moderate, such as the distance from the target position satisfies a preset threshold range (this threshold range can be set based on the motor structure and motor state), the determined speed regulation mode is the constant speed mode.

[0115] In the gimbal system according to the embodiments of the present application, by acquiring the motor state and control instructions, the running state of the motor is dynamically adjusted for each variable - speed sub - division step to ensure the smooth running of the motor; by adjusting the running state of the sub - division step (such as the motor speed and the time interval of the sub - division step), smooth acceleration or deceleration of the motor is achieved, reducing motor jitter and shock; and based on the speed regulation mode of the sub - division step, it is ensured that the motor can accurately reach the target position.

[0116] In some embodiments, determining the speed regulation mode of the motor in the next sub - division step according to the current position, current speed, target speed, and target position includes:

[0117] Determining the number of steps to be rotated according to the current position and the target position; determining the first deceleration buffer number of steps according to the current speed and a preset stop - rotation speed; determining the speed regulation mode of the motor in the next sub - division step according to the size relationship between the number of steps to be rotated and the first deceleration buffer number of steps, and / or, the size relationship between the current speed and the target speed.

[0118] Exemplarily, the number of steps to be rotated is the difference between the target position and the current position. For example, if the current position of the motor is 500 steps and the target position is 1000 steps, then the number of steps to be rotated is 500 steps. In addition, when converting the control information for the gimbal into the control instruction for the motor, the determined target position can also be the position represented by the angle of the motor. For example, the target position is 300°, and the current position can also be the current angle of the motor. Based on the current angle and the target angle, the angle to be rotated by the motor can be calculated, and thus the number of steps to be rotated can be determined based on the angle to be rotated; for example, the number of steps to be rotated = the angle to be rotated * housing transmission ratio * maximum number of sub - divisions / motor step angle.

[0119] Exemplarily, the first acceleration buffer step count is the number of steps required for the motor to decelerate from the current speed to a stop. For example, if the current speed is greater than the stall speed of the motor, the deceleration buffer step count is the number of steps required to decelerate the current speed to the stall speed; if the current speed is less than or equal to the stall speed, the motor can stop directly at the current speed, and the deceleration buffer step count is 0. Based on the deceleration buffer step count, it can also be determined whether the motor needs to start decelerating. For example, if the number of steps to be rotated is less than or equal to the deceleration buffer step count, the motor needs to start decelerating; if the number of steps to be rotated is greater than the deceleration buffer step count, the motor can continue to accelerate or run at a constant speed.

[0120] In some embodiments, when planning the speed for the next microstep of the motor, including scenarios where the motor decelerates to a stop, accelerates to the target speed, decelerates to the target speed, and runs at a constant speed, the process of determining the speed adjustment mode for the next microstep is introduced below for the foregoing scenarios and for the direction relationship between the current speed and the target speed.

[0121] As Figure 5 shown, when the direction of the current speed of the motor is the same as the target speed, the process of determining the speed adjustment mode for the next microstep may include:

[0122] The first scenario: The motor decelerates to a stop

[0123] S501, determine whether the number of steps to be rotated is less than or equal to the first deceleration buffer step count. If so, execute S502; if not, execute 503.

[0124] Exemplarily, based on the number of steps to be rotated and the deceleration buffer step count, it is determined whether the motor needs to start decelerating, thereby determining that the speed adjustment mode is the microstep deceleration mode.

[0125] S502, update the second microstep target speed to the stall speed; the stall speed is the speed at which the motor stops rotating.

[0126] Exemplarily, the second microstep target speed is the microstep target speed corresponding to the microstep deceleration mode; the microstep target speed is the target speed during the microstep acceleration or deceleration process, that is, the target speed corresponding to the microstep.

[0127] Among them, in the case where the number of steps to be rotated is less than or equal to the first deceleration buffer step count, it indicates that the motor is already close to the target position and needs to start decelerating; the motor is currently in the scenario of decelerating to a stop, the motor starts to decelerate, and finally stops at the target position. Updating the second microstep target speed to the stall speed (such as 0 steps / second) indicates that the motor needs to decelerate and stop.

[0128] By updating the microstep target speed to the stall speed, it can ensure that the subsequent motor decelerates smoothly and finally stops accurately at the target position, avoiding jitter or loss of steps caused by sudden stops.

[0129] Second scenario: The motor accelerates to the target speed

[0130] S503. Determine whether the current speed is less than the target speed. If so, execute S504; if not, execute S505.

[0131] Exemplarily, when the number of steps to be rotated is greater than the first deceleration buffer steps, it indicates that the motor is far from the target position and the motor does not need to decelerate. Then, it is determined whether the current speed has reached the target speed. If not, that is, the current speed is less than the target speed, the motor needs to continue to accelerate. Thus, the speed regulation mode for the next microstep is determined as the microstep acceleration mode, avoiding premature deceleration of the motor and resulting in reduced motor operation efficiency.

[0132] S504. Update the first microstep target speed to the target speed.

[0133] Exemplarily, the first microstep target speed is the target speed corresponding to the microstep during the microstep acceleration of the motor. When the current speed is less than the target speed, the first microstep target speed is updated to the target speed, and the motor needs to gradually increase the operating speed in the subsequent steps.

[0134] By updating the first microstep target speed to the target speed and gradually increasing the motor operating speed in the next microstep, it is ensured that the motor can stably accelerate to the target speed during the subsequent acceleration process, avoiding jitter or out-of-step caused by speed mutation.

[0135] Third scenario: The motor decelerates to the target speed

[0136] S505. When the current speed is not less than the target speed, further determine whether the current speed is greater than the target speed. If so, execute S506; if not, execute S507.

[0137] Exemplarily, when the current speed is greater than or equal to the target speed, it indicates that the motor has reached or exceeded the target speed, and it can maintain a constant speed or start to decelerate.

[0138] Correspondingly, when the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed has exceeded the target speed, the motor operating speed is too fast and needs to start decelerating to the target speed. The speed regulation mode for the next microstep is determined as the microstep deceleration mode, so as to reach the target speed as much as possible without overshoot.

[0139] S506. Update the second microstep target speed to the target speed.

[0140] Exemplarily, update the second microstep target speed to the target speed. Based on the microstep deceleration mode, gradually reduce the current speed of the motor to ensure that the motor can smoothly decelerate to the target speed.

[0141] In the microstepping deceleration mode, by updating the second microstepping target speed to the target speed, the speed of each step (microstep) of the motor will gradually decrease until the target speed is reached, ensuring that the target speed is achieved as much as possible without overshooting.

[0142] Fourth scenario: The motor runs at a constant speed

[0143] S507, update the microstepping target speed to the current speed. When the number of steps to be rotated is greater than the first deceleration buffer steps and there is still a certain distance between the motor and the target position and the current speed is equal to the target speed, the motor can continue to run at a constant speed for a period of time, and no speed change adjustment is required in the next microstep, ensuring the stable and efficient operation of the motor.

[0144] Such as Figure 6 As shown, when the current speed of the motor is opposite to the target speed, the process of determining the speed regulation mode of the next microstep may include:

[0145] Fifth scenario: Decelerate first and then turn

[0146] S601, determine whether the current speed is greater than the reverse speed. If so, execute S602; if not, execute S603.

[0147] Exemplarily, the reverse speed refers to the maximum speed allowed for the motor when changing the rotation direction. The controller can dynamically adjust the magnitude of the reverse speed according to the current state of the motor (such as speed and position); for example, when running at a high speed, the reverse speed is set lower, and when running at a low speed, the reverse speed is set higher. When the current speed of the motor is greater than the reverse speed, it is necessary to first decelerate to the reverse speed or below, otherwise directly reversing the direction will cause the motor to lose steps or mechanical shock; thus, the speed regulation mode of the next microstep is determined as the microstepping deceleration mode.

[0148] S602, update the second microstepping target speed to the reverse speed.

[0149] Exemplarily, updating the second microstep target speed to the reverse speed, based on the microstepping deceleration mode, gradually reduces the current speed of the motor first to ensure that the motor can smoothly decelerate to the reverse speed and avoid motor step loss or mechanical shock caused by direct turning.

[0150] S403, determine the motor speed of the next microstep according to the speed regulation mode, and control the rotation of the motor based on the motor speed.

[0151] In some embodiments, the speed control mode may include a segmented acceleration mode, a segmented deceleration mode, and a constant speed mode. When determining that the speed control mode is the segmented acceleration mode, based on the current speed and the acceleration corresponding to the current speed, determine the motor speed of the next segmentation step; when determining that the speed control mode is the segmented deceleration mode, based on the current speed and the deceleration corresponding to the current speed, determine the motor speed of the next segmentation step; when at a constant speed, use the current speed as the motor speed of the next segmentation step.

[0152] Exemplarily, after determining the motor speed of the next segmentation step, when the segmentation index corresponding to the next segmentation step is an integer multiple of the segmentation factor, variable speed control can be performed to avoid missing steps.

[0153] Among them, the acceleration and deceleration corresponding to the current speed can be obtained based on looking up a table; for example, in the pan-tilt system, there is a pre-set acceleration table corresponding to each speed interval stored, and the acceleration table corresponding to each speed interval can be determined based on the performance requirements of the tracking algorithm configured in the pan-tilt system and the motor torque, etc.

[0154] The following introduces the specific implementation process of determining the motor speed of the next segmentation step based on the segmented acceleration mode through embodiments. Please refer to Figure 7 , the schematic diagram of the implementation process of the segmented acceleration mode provided by the embodiments of the present application, and this process may include:

[0155] S701, determine whether the current speed is less than the first segmentation target speed.

[0156] Exemplarily, when determining the speed control mode above, the first segmentation target speed is updated based on the target speed; in the segmented acceleration mode, the corresponding prerequisite is that the current speed is less than the target speed. Therefore, after updating the first segmentation target speed to the target speed, it is determined that the current speed is less than the first segmentation target speed.

[0157] S702, determine the first new speed based on the current speed and the acceleration.

[0158] Exemplarily, in the case where the current speed is less than the first segmentation target speed, calculate the first new speed based on the current speed and the acceleration corresponding to the current speed; the first segmentation target speed is the segmentation target speed for one acceleration during the segmented acceleration process. For example, the first new speed is equal to the sum of the current speed and the acceleration.

[0159] S703, calculate the second deceleration buffer steps corresponding to the first new speed based on the first new speed and the preset stall speed.

[0160] Exemplarily, after calculating the first new speed, in order to avoid receiving a stop instruction again, it is necessary to further calculate the second deceleration buffer steps corresponding to the first new speed to avoid overshoot of the motor and ensure the safe and stable operation of the motor. The second deceleration buffer steps can be calculated based on the first new speed of the motor, the stop speed, and the deceleration corresponding to the first new speed; for example, the second deceleration buffer steps are calculated by the following formula:

[0161]

[0162] Among them, in the acceleration table, there is also the deceleration corresponding to the current speed, and the deceleration can be obtained by looking up the table.

[0163] S704, determine whether the number of steps to be rotated is greater than the second deceleration buffer steps. If so, execute S705; if not, end.

[0164] Exemplarily, only when the number of steps to be rotated is greater than the second deceleration buffer steps can the motor be controlled to continue to accelerate, otherwise the first new speed after acceleration adjustment is likely to cause overshoot of the motor.

[0165] S705, query the first subdivision number corresponding to the first new speed.

[0166] Exemplarily, the subdivision number is the number of subdivisions of each whole step into multiple small steps. For example, if the subdivision number is 4, it means that each whole step is divided into 4 small steps, as Figure 2 shown.

[0167] Among them, different motor speeds can correspond to different subdivision numbers. Since the motor speed changes, when the number of steps to be rotated is greater than the second deceleration buffer steps, the first subdivision number corresponding to the first new speed is re-determined.

[0168] For example, a high subdivision number is used at low speeds to reduce the jitter of the prototype, while at relatively high motor speeds, a relatively low subdivision number is selected due to CPU resource limitations, so different subdivision numbers are used in different speed ranges. After calculating the first new speed, in the pre-defined speed-subdivision number table (abbreviated as the subdivision configuration table), the first subdivision number corresponding to the first new speed is queried according to the first new speed.

[0169] S706, determine whether the subdivision index corresponding to the next subdivision step is divisible by the first subdivision factor. If so, execute S707; if not, end. Among them, the first subdivision factor is determined based on the first subdivision number and the maximum subdivision number of the motor, such as the first subdivision factor is the ratio of the maximum subdivision number to the first subdivision number; the first subdivision number is the new subdivision number corresponding to the new motor speed (i.e., the first new speed) in the subdivision acceleration mode.

[0170] S707. Update the current speed of the next subdivision step of the motor to the first new speed.

[0171] Exemplarily, the subdivision factor is the ratio of the maximum number of subdivisions of the motor to the re-determined first number of subdivisions. The subdivision index is the number of the subdivision step, which is used to identify the specific subdivision position of the motor in the current full step. For example, one full step of the motor is divided into multiple small steps (subdivision steps), such as being divided into 4 subdivision steps. The subdivision index then identifies the number of the current subdivision step. When the number of subdivisions is 4, the range of the subdivision index can be from 0 to 3 (or from 1 to 4).

[0172] Correspondingly, in order to avoid the motor from losing steps, when the subdivision index corresponding to the next subdivision step is an integer multiple of the first subdivision factor, the speed of the motor is adjusted. For example, the maximum number of subdivisions of the motor is 256, and the current number of subdivisions corresponding to the first new speed is 32, then the subdivision factor is 256 / 32 = 8. If the subdivision index of the next subdivision step is 16, it means that the subdivision index of the next subdivision step corresponds to a certain subdivision step under the current number of subdivisions. The speed of the motor can be regulated in the next subdivision step; that is, taking the first new speed as the speed of the motor in the next subdivision step to achieve variable speed of the motor based on subdivision drive.

[0173] Correspondingly, in the next subdivision step, update the current speed to the first new speed and drive the motor to rotate based on the first new speed.

[0174] The following introduces the specific implementation process of determining the speed of the motor in the next subdivision step based on the subdivision deceleration mode through an embodiment. Please refer to Figure 8 , the schematic diagram of the implementation process of the subdivision deceleration mode provided by the embodiment of the present application. This process may include:

[0175] S801. Determine whether the current speed is greater than the second subdivision target speed.

[0176] Exemplarily, when determining the speed regulation mode above, the second subdivision target speed is updated based on the stop speed, the target speed or the reverse speed; in the subdivision deceleration mode, further determine the magnitude relationship between the current speed and the updated second subdivision target speed; since the corresponding determined mode is the subdivision deceleration mode, after updating the second subdivision target speed to the stop speed, the target speed or the reverse speed, it is determined that the current speed is less than the second subdivision target speed.

[0177] S802. Determine the second new speed based on the current speed and the deceleration.

[0178] Exemplarily, based on the same implementation principle as the subdivision acceleration mode, in the subdivision deceleration mode, when the current speed is greater than the second subdivision target speed, query the deceleration corresponding to the current speed, and calculate the second new speed according to the current speed and the deceleration corresponding to the current speed; the second subdivision target speed is the subdivision target speed for one deceleration during the subdivision deceleration process; take the difference between the current speed and the deceleration as the second new speed.

[0179] S803. Query the second subdivision number corresponding to the second new speed.

[0180] S804. Determine whether the subdivision index corresponding to the next subdivision step is divisible by the second subdivision factor. If so, execute S805; if not, end. Among them, the second subdivision factor is determined based on the second subdivision number and the maximum subdivision number of the motor. For example, the second subdivision factor is the ratio of the maximum subdivision number to the second subdivision number; the second subdivision number is the new subdivision number corresponding to the new motor speed (i.e., the second new speed) in the subdivision deceleration mode.

[0181] Exemplarily, based on the same implementation principle as the above-mentioned subdivision acceleration mode, determine whether the subdivision index of the next subdivision step is divisible by the second subdivision factor, and the second subdivision factor is the ratio of the maximum subdivision number of the motor to the second subdivision number.

[0182] S805. Determine whether the current speed is in the opposite direction to the target speed and the second new speed is not greater than the second subdivision target speed. If so, execute S806; if not, execute S807.

[0183] Exemplarily, when the second new speed is less than or equal to the second subdivision target speed, it is determined that during the deceleration process of the next subdivision step, deceleration can be performed according to the standard of reaching the planned subdivision target speed, that is, it can be decelerated to the second subdivision target speed corresponding to the next subdivision step or below.

[0184] S806. Reverse the direction of the current speed.

[0185] S807. Update the current speed of the motor for the next subdivision step to the second new speed.

[0186] In the first case, the current speed is in the same direction as the target speed. Based on the same implementation principle as the above-mentioned subdivision acceleration mode, by querying the second subdivision number corresponding to the second new speed, when the subdivision index corresponding to the next subdivision step is an integer multiple of the second subdivision factor, take the second new speed as the motor speed for the next subdivision step.

[0187] In the second case, when the current speed is opposite to the target speed, and the subdivision index corresponding to the next subdivision step is an integer multiple of the second subdivision factor, and the second new speed is not greater than the second subdivision target speed, after reversing the direction of the current speed, the second new speed is used as the motor speed for the next subdivision step.

[0188] It should be noted that after determining that the second new speed after decelerating and adjusting the current speed can be reduced to the second subdivision target speed or below, it is judged whether the current speed is opposite to the target speed; when the current speed is opposite to the target speed, when adjusting the speed in the next subdivision step, it is necessary to reverse the direction of the current speed to achieve deceleration first and then reverse.

[0189] Among them, since for the fifth scenario where the current speed is opposite to the target speed, the second subdivision target speed has been updated to the reverse speed, when reversing the direction of the current speed, mechanical shock and jitter can be avoided. The second new speed is used as the current speed for the next subdivision step of the motor to determine the rotation of the motor.

[0190] In some embodiments, as Figure 6 shown, when the target speed is opposite to the direction of the current speed, the process of planning the motor speed for the next subdivision step further includes:

[0191] S603, judge whether the target speed is greater than the reverse speed. If so, execute S604; if not, execute S606.

[0192] S604, update the subdivision target speed to the target speed.

[0193] S605, update the magnitude of the current speed to the reverse speed.

[0194] Exemplarily, when the current speed is less than or equal to the reverse speed and the target speed is greater than the reverse speed, the subdivision target speed for the next subdivision step is updated to the target speed, and the magnitude of the current speed is updated to the reverse speed. That is, when the target speed is greater than the reverse speed and the reverse speed is greater than the current speed, when adjusting the speed in the next subdivision step, the magnitude of the current speed for the next subdivision step is accelerated to the reverse speed, and then the direction of the speed is reversed; then the motor can be controlled to accelerate to the target speed in the subsequent subdivision steps based on the above-mentioned subdivision acceleration mode.

[0195] S606, update the subdivision target speed to the target speed.

[0196] S607, update the magnitude of the current speed to the target speed.

[0197] Exemplarily, when the current speed is less than or equal to the reverse speed and the target speed is less than or equal to the reverse speed, update the subdivision target speed of the next subdivision step to the target speed, and update the magnitude of the current speed to the target speed. That is, when the current speed is less than or equal to the reverse speed and the target speed is also less than or equal to the reverse speed, update the subdivision target speed to the target speed. When adjusting the speed in the next subdivision step, update the current speed of the next subdivision step to the target speed by accelerating or decelerating (depending on the magnitude relationship between the current speed and the target speed), and then reverse the speed direction.

[0198] S608, reverse the direction of the updated current speed.

[0199] Wherein, the subdivision target speed of the next subdivision step is the subdivision target speed of the motor during one speed change process.

[0200] In some embodiments, after determining the motor speed of the next subdivision step, control the rotation of the motor based on the motor speed, including:

[0201] Determine the timer timing period according to the motor speed and the number of subdivisions corresponding to the motor speed; determine the timer target count value based on the timer timing period and the timer clock frequency; control the rotation of the motor based on the timer target count value.

[0202] Exemplarily, based on the same implementation principle as the part of adjusting the motor speed in the corresponding embodiment above, determine the timer target count value according to the following formula: Figure 2 The duration of one full step = 1 / motor speed;

[0203] The duration of one full step = 1 / motor speed;

[0204] The duration of one subdivision step = the duration of one full step / the number of subdivisions;

[0205] The timer timing period = the duration of one subdivision step;

[0206] The timer target count value = the timer timing period * the timer clock frequency;

[0207] Drive the rotation of the motor based on the timer target count value.

[0208] In some embodiments, as Figure 3 shown, the embodiments of the present application further include a control process for updating the motor state. Based on the same implementation principle as the corresponding embodiment, it will not be elaborated here; this control process may include: Figure 3 The embodiments of the present application further include a control process for updating the motor state. Based on the same implementation principle as the corresponding embodiment, it will not be elaborated here; this control process may include:

[0209] When the operating mode corresponding to the control instruction is continuous rotation, the current subdivision index corresponding to the current subdivision step is an integral multiple of the subdivision factor corresponding to the current number of subdivisions, and the current subdivision index is an integral multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed of the motor.

[0210] When the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is in the opposite direction to the target speed, increase the number of steps to be rotated to the first number of steps, and when the current subdivision index corresponding to the current subdivision step is an integral multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integral multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed of the motor.

[0211] When the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is in the same direction as the target speed, reduce the number of steps to be rotated to the second number of steps, and when the current speed is greater than the stopping speed, the number of steps to be rotated is greater than zero, and when the current subdivision index corresponding to the current subdivision step is an integral multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integral multiple of the subdivision factor corresponding to the new number of subdivisions, adjust the motor speed of the motor.

[0212] Among them, the number of steps to be rotated is determined based on the current position and the target position; the current speed corresponds to the current number of subdivisions, and the new motor speed corresponds to the new number of subdivisions; adjusting the motor speed of the motor includes adjusting the current speed to the new motor speed.

[0213] In the embodiments of the present application, by adopting the subdivision drive method, the defect of zero-crossing distortion existing in the motor drive waveform is corrected, the granularity of the speed change of the motor during acceleration or deceleration is reduced, and the jitter of the pan-tilt camera during the speed change process is slowed down; based on the division and drive of the subdivision steps, the curves of the acceleration and deceleration processes can be accurately controlled; by adjusting the speed of the motor through subdivision drive, the speed and the acceleration / deceleration can be continuously changed, and the acceleration / deceleration can be gradually decreased to zero, effectively reducing the inertial mechanical impact during the stop process and significantly suppressing the jitter generated by the pan-tilt at the stop moment; based on the subdivision drive, the acceleration process has a faster response, can be quickly started, and can track fast-moving objects; and there is no need to accelerate after the whole-step cycle is completed.

[0214] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0215] Corresponding to the motor speed regulation method provided in the above embodiments, the motor speed regulation device provided in the embodiments of the present application, as Figure 9 shown, for the sake of convenience of description, only the parts related to the embodiments of the present application are shown.

[0216] The motor speed regulation device includes:

[0217] A monitoring unit 91, configured to obtain the current position, current speed of the motor, and a control instruction for the motor during the operation of the pan-tilt, where the control instruction includes the target speed and target position of the motor;

[0218] A planning unit 92, configured to determine a speed regulation mode of the motor in the next sub-step according to the current position, the current speed, the target speed, and the target position;

[0219] A regulation unit, configured to determine the motor speed in the next sub-step according to the speed regulation mode, and control the rotation of the motor based on the motor speed.

[0220] In a possible implementation manner, the planning unit is further configured to determine the number of steps to be rotated according to the current position and the target position; determine the first deceleration buffer number of steps according to the current speed and the target speed; and determine the speed regulation mode of the motor in the next sub-step according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer number of steps, and / or, the magnitude relationship between the current speed and the target speed.

[0221] In a possible implementation manner, the planning unit is further configured to determine that the speed regulation mode is a sub-step acceleration mode when the number of steps to be rotated is greater than the first deceleration buffer number of steps and the current speed is less than the target speed; and determine that the speed regulation mode is a sub-step deceleration mode when the number of steps to be rotated is greater than the first deceleration buffer number of steps and the current speed is greater than the target speed.

[0222] In a possible implementation manner, the planning unit is further configured to determine that the speed regulation mode is a sub-step deceleration mode when the number of steps to be rotated is less than or equal to the first deceleration buffer number of steps.

[0223] In a possible implementation manner, the planning unit is further configured to determine that the speed regulation mode is a sub-step deceleration mode when the directions of the target speed and the current speed are opposite and the current speed is greater than a preset reverse speed.

[0224] In a possible implementation, the control unit is further configured to, in the micro-stepping acceleration mode, when the current speed is less than the first micro-stepping target speed, calculate a first new speed based on the current speed and the acceleration corresponding to the current speed; the first micro-stepping target speed is the micro-stepping target speed for one acceleration during the micro-stepping acceleration process; calculate the number of second deceleration buffer steps corresponding to the first new speed; when the number of steps to be rotated is greater than the number of second deceleration buffer steps, determine the first micro-stepping number corresponding to the first new speed; when the micro-stepping index corresponding to the next micro-stepping step is an integer multiple of the first micro-stepping factor, use the first new speed as the motor speed of the next micro-stepping step; wherein, the first micro-stepping factor is determined based on the first micro-stepping number and the maximum micro-stepping number of the motor.

[0225] In a possible implementation, the control unit is further configured to, when the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is less than the target speed, update the first micro-stepping target speed to the target speed.

[0226] In a possible implementation, the control unit is further configured to, in the micro-stepping deceleration mode, when the current speed is greater than the second micro-stepping target speed, calculate a second new speed according to the current speed and the deceleration corresponding to the current speed; the second micro-stepping target speed is the micro-stepping target speed for one deceleration during the micro-stepping deceleration process; query the second micro-stepping number corresponding to the second new speed, and when the micro-stepping index corresponding to the next micro-stepping step is an integer multiple of the second micro-stepping factor, use the second new speed as the motor speed of the next micro-stepping step; or, when the micro-stepping index corresponding to the next micro-stepping step is an integer multiple of the second micro-stepping factor, the direction of the current speed is opposite to that of the target speed, and the second new speed is not greater than the second micro-stepping target speed, reverse the direction of the current speed and then use the second new speed as the motor speed of the next micro-stepping step; wherein, the second micro-stepping factor is determined based on the second micro-stepping number and the maximum micro-stepping number of the motor.

[0227] In a possible implementation, the control unit is further configured to, when the direction of the target speed is the same as that of the current speed, update the second micro-stepping target speed to the stop speed when the number of steps to be rotated is less than or equal to the first deceleration buffer steps; the stop speed is the speed at which the motor stops rotating; or, update the second micro-stepping target speed to the target speed when the number of steps to be rotated is greater than the first deceleration buffer steps and the current speed is greater than the target speed; or, update the second micro-stepping target speed to the reverse speed when the direction of the target speed is opposite to that of the current speed and the current speed is greater than the reverse speed.

[0228] In a possible implementation, the control unit is further configured to, when the current speed is less than or equal to the reverse speed and the target speed is greater than the reverse speed, update the subdivision target speed of the next subdivision step to the target speed, update the magnitude of the current speed to the reverse speed, and reverse the direction of the current speed; or, when the current speed is less than or equal to the reverse speed and the target speed is less than or equal to the reverse speed, update the subdivision target speed of the next subdivision step to the target speed, update the magnitude of the current speed to the target speed, and reverse the direction of the current speed; wherein, the subdivision target speed of the next subdivision step is the subdivision target speed of the motor during a speed change process.

[0229] In a possible implementation, the control unit is further configured to determine a timer timing period according to the motor speed and the number of subdivisions corresponding to the motor speed; determine a timer target count value based on the timer timing period and the timer clock frequency; and control the rotation of the motor based on the timer target count value.

[0230] In a possible implementation, the control unit is further configured to adjust the motor speed when the operating mode corresponding to the control instruction is continuous rotation and the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions; or, when the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is in the opposite direction to the target speed, increase the number of steps to be rotated to the first number of steps, and adjust the motor speed when the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new number of subdivisions; or, when the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is in the same direction as the target speed, reduce the number of steps to be rotated to the second number of steps, and adjust the motor speed when the current speed is greater than the stop rotation speed, the number of steps to be rotated is greater than zero, and the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current number of subdivisions and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new number of subdivisions; wherein, the number of steps to be rotated is determined based on the current position and the target position; the current speed corresponds to the current number of subdivisions, and the new motor speed corresponds to the new number of subdivisions; adjusting the motor speed includes adjusting the current speed to the new motor speed.

[0231] Through the embodiments of the present application, by adopting the method of microstep drive, the defect of zero-crossing distortion existing in the motor drive waveform is corrected, the granularity of the speed change of the motor during acceleration or deceleration is reduced, and the jitter of the pan-tilt camera during the speed change process is slowed down; based on the division and drive of microsteps, the curves of acceleration and deceleration can be accurately controlled; by adjusting the speed of the motor through microstep drive, the speed and acceleration / deceleration can be continuously changed, and the acceleration / deceleration can be gradually decreased to zero, effectively reducing the inertial mechanical impact during the stop process and significantly suppressing the jitter generated by the pan-tilt at the stop moment; based on microstep drive, the acceleration process has a faster response, can be quickly started, and can track fast-moving objects; and there is no need to wait until the whole step period is completed before accelerating.

[0232] Figure 10 FIG. shows the schematic hardware structure of the electronic device 10. The electronic device 10 may be the above-mentioned pan-tilt system.

[0233] As Figure 10 shown, the electronic device 10 of this embodiment includes: at least one processor 1001 ( Figure 10 only one is shown in the figure), a memory 1002, and a computer program 1003 that can run on the processor 1001 is stored in the memory 1002. When the processor 1001 executes the computer program 1003, it implements the steps in the above method embodiments, such as Figure 4 S401 to S403 shown in the figure. Alternatively, when the processor 1001 executes the computer program 1003, it implements the functions of each module / unit in the above device embodiments.

[0234] It can be understood that the structure schematically shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 10. In other embodiments of the present application, the electronic device 10 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0235] The electronic device 10 may include, but is not limited to, a processor 1001 and a memory 1002. Those skilled in the art can understand that Figure 10 this is only an example of the electronic device 10 and does not constitute a limitation on the electronic device 10. It may include more or fewer components than those shown in the figure, or combine certain components, or have different components. For example, the server may further include an input and sending device, a network access device, a bus, etc.

[0236] The processor 1001 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0237] The processor 1001 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 1001 is a cache memory. The memory may store instructions or data that the processor 1001 has just used or cyclically used. If the processor 1001 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 1001, and thus improves the efficiency of the system.

[0238] In some embodiments, the memory 1002 may be an internal storage unit of the electronic device 10, such as a hard disk or memory of the electronic device 10. The memory 1002 may also be an external storage device of the electronic device 10, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 10. Further, the memory 1002 may also include both an internal storage unit of the electronic device 10 and an external storage device. The memory 1002 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of a computer program. The memory 1002 may also be used to temporarily store data that has been sent or is to be sent.

[0239] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0240] It should be noted that the structure of the above-mentioned electronic device is only illustrative, and based on different application scenarios, it may also include other physical structures, and the physical structure of the electronic device is not limited here.

[0241] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not described or recorded in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

[0242] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0243] The embodiments of the present application provide a computer program product. When the computer program product runs on a server, the server can execute the steps in the above-mentioned method embodiments.

[0244] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, all or part of the processes in the method of the above embodiments of the present application can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc.

[0245] The electronic device, computer storage medium, and computer program product provided in the above embodiments of the present application are all used to execute the method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects corresponding to the method provided above, and will not be elaborated here.

[0246] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0247] It should be understood that the above is only to help those skilled in the art better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. Those skilled in the art can obviously make various equivalent modifications or changes according to the above examples. For example, in each of the embodiments of the above detection method, some steps may not be necessary, or some steps may be newly added, etc. Or any combination of any two or any more of the above embodiments. The solutions after such modifications, changes or combinations also fall within the scope of the embodiments of the present application.

[0248] It should also be understood that the classification of the manners, situations, categories and embodiments in the embodiments of the present application is only for the convenience of description and should not constitute a special limitation. The features in various manners, categories, situations and embodiments can be combined with each other without conflict.

[0249] It should also be understood that in each of the embodiments of the present application, if there is no special description and logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other. The technical features in different embodiments can be combined to form new embodiments according to their internal logical relationships.

[0250] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0251] In the embodiments provided in the present application, it should be understood that the disclosed device / network device and method can be implemented in other ways. For example, the device / network device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.

[0252] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0253] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the protection scope of the present application.

[0254] Finally, it should be noted that the above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or replacements within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the said claims.

Claims

1. A method for motor speed regulation and control, characterized in that, The method includes: During the operation of the pan-tilt, obtaining the current position, current speed of the motor, and the control command for the motor, where the control command includes the target speed and target position of the motor; Determining the speed regulation mode of the motor in the next sub-step according to the current position, the current speed, the target speed, and the target position; Determining the motor speed in the next sub-step according to the speed regulation mode, and controlling the rotation of the motor based on the motor speed.

2. The method according to claim 1, characterized in that The determining the speed regulation mode of the motor in the next sub-step according to the current position, the current speed, the target speed, and the target position includes: Determining the number of steps to be rotated according to the current position and the target position; Determining the first deceleration buffer number of steps according to the current speed and a preset stop rotation speed; Determining the speed regulation mode of the motor in the next sub-step according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer number of steps, and / or, the magnitude relationship between the current speed and the target speed.

3. The method according to claim 2, wherein The determining the speed regulation mode of the motor in the next sub-step according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer number of steps, and the magnitude relationship between the current speed and the target speed includes: When the number of steps to be rotated is greater than the first deceleration buffer number of steps and the current speed is less than the target speed, determining that the speed regulation mode is the sub-step acceleration mode; When the number of steps to be rotated is greater than the first deceleration buffer number of steps and the current speed is greater than the target speed, determining that the speed regulation mode is the sub-step deceleration mode.

4. The method according to claim 2, wherein The determining the speed regulation mode of the motor in the next sub-step according to the magnitude relationship between the number of steps to be rotated and the first deceleration buffer number of steps includes: When the number of steps to be rotated is less than or equal to the first deceleration buffer number of steps, determining that the speed regulation mode is the sub-step deceleration mode.

5. The method according to claim 1, characterized in that When the direction of the target speed is opposite to the current speed, the method further includes: When the current speed is greater than a preset reverse speed, determining that the speed regulation mode is the sub-step deceleration mode.

6. The method according to claim 2, characterized in that, The speed regulation mode includes the sub-step acceleration mode; the determining the motor speed in the next sub-step according to the speed regulation mode includes: In the sub-step acceleration mode, when the current speed is less than the first sub-step target speed, calculating a first new speed based on the current speed and the acceleration corresponding to the current speed; the first sub-step target speed is the sub-step target speed for one acceleration during the sub-step acceleration process; Calculating the second deceleration buffer number of steps corresponding to the first new speed based on the first new speed and a preset stop rotation speed; When the number of steps to be rotated is greater than the second deceleration buffer number of steps, determining the first sub-step number corresponding to the first new speed; When the sub-step index corresponding to the next sub-step is an integer multiple of the first sub-step factor, taking the first new speed as the motor speed in the next sub-step; Wherein, the first sub-step factor is determined based on the first sub-step number and the maximum sub-step number of the motor.

7. The method according to claim 6, characterized in that Before calculating the first new speed based on the current speed and the acceleration corresponding to the current speed, the method further includes: When the number of steps to be rotated is greater than the first deceleration buffer step number and the current speed is less than the target speed, updating the first sub-target speed to the target speed.

8. The method according to claim 2, wherein The speed regulation mode includes a sub-deceleration mode; determining the motor speed of the next sub-step according to the speed regulation mode includes: In the sub-deceleration mode, when the current speed is greater than the second sub-target speed, calculating a second new speed according to the current speed and the deceleration corresponding to the current speed; the second sub-target speed is the sub-target speed for one deceleration during the sub-deceleration process. Querying the second sub-division number corresponding to the second new speed, and when the sub-division index corresponding to the next sub-step is an integer multiple of the second sub-division factor, using the second new speed as the motor speed of the next sub-step; or, When the sub-division index corresponding to the next sub-step is an integer multiple of the second sub-division factor, the direction of the current speed is opposite to that of the target speed, and the second new speed is not greater than the second sub-target speed, after reversing the direction of the current speed, using the second new speed as the motor speed of the next sub-step; Wherein, the second sub-division factor is determined based on the second sub-division number and the maximum sub-division number of the motor.

9. The method according to claim 8, characterized in that, Before calculating the second new speed according to the current speed and the deceleration corresponding to the current speed, the method further includes: When the direction of the target speed is the same as that of the current speed, and when the number of steps to be rotated is less than or equal to the first deceleration buffer step number, updating the second sub-target speed to the stop speed; the stop speed is the speed at which the motor stops rotating; or, When the number of steps to be rotated is greater than the first deceleration buffer step number and the current speed is greater than the target speed, updating the second sub-target speed to the target speed; or, When the direction of the target speed is opposite to that of the current speed and the current speed is greater than the reverse speed, updating the second sub-target speed to the reverse speed.

10. The method according to claim 5, characterized in that, When the direction of the target speed is opposite to that of the current speed, the method further includes: When the current speed is less than or equal to the reverse speed and the target speed is greater than the reverse speed, updating the sub-target speed of the next sub-step to the target speed, updating the magnitude of the current speed to the reverse speed, and reversing the direction of the current speed; or, When the current speed is less than or equal to the reverse speed and the target speed is less than or equal to the reverse speed, updating the sub-target speed of the next sub-step to the target speed, updating the magnitude of the current speed to the target speed, and reversing the direction of the current speed; Wherein, the sub-target speed of the next sub-step is the sub-target speed of the motor during one speed change process.

11. The method according to any one of claims 1 to 10, characterized in that, Controlling the rotation of the motor based on the motor speed includes: Determining the timer timing period according to the motor speed and the subdivision number corresponding to the motor speed; Determining the timer target count value based on the timer timing period and the timer clock frequency; Controlling the rotation of the motor based on the timer target count value.

12. The method according to any one of claims 1 to 10, characterized in that, The method further includes: Adjusting the motor speed when the operating mode corresponding to the control instruction is continuous rotation, the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current subdivision number, and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new subdivision number; or, When the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is opposite to the target speed, increasing the number of steps to be rotated to the first number of steps, and adjusting the motor speed when the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current subdivision number and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new subdivision number; or, When the operating mode corresponding to the control instruction is discontinuous rotation and the current speed is the same as the target speed, reducing the number of steps to be rotated to the second number of steps, and adjusting the motor speed when the current speed is greater than the stop speed, the number of steps to be rotated is greater than zero, and the current subdivision index corresponding to the current subdivision step is an integer multiple of the subdivision factor corresponding to the current subdivision number and the current subdivision index is an integer multiple of the subdivision factor corresponding to the new subdivision number; Wherein, the number of steps to be rotated is determined based on the current position and the target position; the current speed corresponds to the current subdivision number, and the new motor speed corresponds to the new subdivision number; adjusting the motor speed includes adjusting the current speed to the new motor speed.

13. An electronic device, characterized in that, It includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the method according to any one of claims 1 to 12.

14. A computer program product, characterized in that, When the computer program product runs on the device, the device is caused to execute the method according to any one of claims 1 to 12 above.