A control method and device for a stepping motor

By dynamically adjusting the PWM signal output of the stepper motor and comparing the actual current value with the reference current value, the problems of high software overhead and electromagnetic interference in the existing technology are solved, and the control efficiency and motor reliability are improved.

CN118523671BActive Publication Date: 2024-10-11TINYCHIP MICROELECTRONICS (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410992743.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-10-11
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

In the existing stepper motor control method, the software overhead is large, the control efficiency is low, and the fixed-frequency PWM signal will produce strong electromagnetic interference, affecting the reliability of the motor.

Method used

By outputting a PWM signal with a duty cycle of 1 at the initial moment of the PWM cycle, the coil driving current of the stepper motor gradually increases, and the actual current value is collected in real time and compared with the reference current value. If the actual current value is greater than or equal to the reference current value, then Stop outputting the PWM signal, control the current to gradually decrease, and start the next PWM cycle to dynamically adjust the frequency of the PWM signal.

Benefits of technology

It reduces the adjustment of the PWM signal duty cycle, reduces software overhead, improves control efficiency, and by dynamically adjusting the PWM signal frequency, reduces electromagnetic interference and improves the reliability of the stepper motor.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118523671B_ABST
    Figure CN118523671B_ABST
Patent Text Reader

Abstract

The present application provides a control method for a stepper motor, comprising: at the initial moment of a PWM cycle, outputting a PWM signal with a duty cycle of 1 to a motor drive circuit, so that the driving current in the coil of the stepper motor gradually increases; collecting the actual current value in the coil of the stepper motor, and comparing the actual current value with a preset reference current value; if the actual current value is greater than or equal to the reference current value, then stopping outputting the PWM signal to the motor drive circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a preset time, entering the next PWM cycle. Since the duty cycle of the PWM signal is always 1, the duty cycle of the PWM signal does not need to be adjusted during the control process of the stepper motor, thereby reducing software overhead and improving control efficiency; and the frequency of the PWM signal is dynamically changing, thereby reducing the electromagnetic interference generated by the PWM signal and improving the reliability of the stepper motor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a control method and device for a stepping motor, and belongs to the technical field of stepping motors. Background Art

[0002] A stepper motor is a discrete value control motor that converts an electrical pulse excitation signal into a corresponding angular displacement or linear displacement. This type of motor moves one step each time an electrical pulse is input, so it is also called a pulse motor. With the development of new energy vehicles, stepper motors are widely used in automobiles.

[0003] In practical applications, the speed of a stepper motor is usually controlled by the duty cycle of a PWM (Pulse Width Modulation) signal. Specifically, an initial reference current value is set, an initial PWM signal duty cycle is generated based on the initial reference current value, and the stepper motor is driven to operate based on the initial PWM signal duty cycle. During the operation of the stepper motor, the actual current value of the stepper motor is collected in real time, and the reference current value is adjusted based on the actual current value, thereby adjusting the PWM signal duty cycle.

[0004] That is to say, the reference current value and the PWM signal duty cycle need to be adjusted continuously during the process, resulting in large software overhead and low control efficiency.

[0005] In addition, in the prior art, the frequency of the PWM signal is usually fixed, and the fixed-frequency PWM signal will generate strong electromagnetic interference, thereby affecting the reliability of the stepper motor. Summary of the invention

[0006] In order to overcome the problems in the prior art of large software overhead, low control efficiency, and strong electromagnetic interference generated by PWM signals, the present invention proposes a control method, device and controller for a stepper motor.

[0007] In order to achieve the above object, the present invention adopts the following technical solutions:

[0008] In a first aspect, an embodiment of the present application provides a method for controlling a stepper motor, comprising:

[0009] At the initial moment of the PWM cycle, a PWM signal with a duty cycle of 1 is output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually increases;

[0010] Collecting an actual current value in the coil of the stepper motor, and comparing the actual current value with a preset reference current value;

[0011] If the actual current value is greater than or equal to the reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after the PWM signal is stopped from being output for a preset time, the next PWM cycle is entered.

[0012] In a possible implementation, the reference current value includes a first reference current value and a second reference current value, the first reference current value is less than the second reference current value, and if the actual current value is greater than or equal to the reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after the PWM signal is continuously stopped from being output for a preset time, the next PWM cycle is entered, including:

[0013] If the actual current value is greater than or equal to the first reference current value and less than the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a first preset time, enter the next PWM cycle;

[0014] If the actual current value is greater than or equal to the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a second preset time, enter the next PWM cycle;

[0015] Wherein, the first preset time is less than the second preset time. In a possible implementation, at the initial moment of the PWM cycle, outputting a PWM signal with a duty cycle of 1 to the motor drive circuit so that the drive current in the coil of the stepper motor gradually increases, includes: at the initial moment of the PWM cycle, outputting a plurality of PWM signals with a duty cycle of 1 to a plurality of motor drive circuits respectively so that the drive current in the plurality of coils of the stepper motor gradually increases, wherein the i-th PWM signal with a duty cycle of 1 is used to be output to the i-th motor drive circuit so that the drive current in the i-th coil of the stepper motor gradually increases;

[0016] The collecting of the actual current value in the coil of the stepper motor and comparing the actual current value with a preset reference current value comprises: collecting the actual current value in each coil of the stepper motor respectively, and comparing the actual current value in each coil with each preset reference current value respectively;

[0017] If the actual current value is greater than or equal to the reference current value, then stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a preset time, enter the next PWM cycle, including: if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, then stop outputting the i-th PWM signal to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually decreases, and after continuously stopping outputting the i-th PWM signal for a preset time, enter the next PWM cycle;

[0018] Among them, 1≤i≤N, N≥2.

[0019] In a possible implementation, the motor drive circuit includes:

[0020] A first transistor, wherein a drain of the first transistor is used to connect a high level;

[0021] a second transistor, wherein a drain of the second transistor is used to connect to a high level;

[0022] a third transistor, wherein a drain of the third transistor is electrically connected to a source of the first transistor, and the source of the third transistor is used to connect to a low level;

[0023] a fourth transistor, wherein a drain of the fourth transistor is electrically connected to a source of the third transistor, and the source of the fourth transistor is used to connect to a low level;

[0024] The node between the first transistor and the third transistor is used to connect the first end of the coil, and the node between the second transistor and the fourth transistor is used to connect the second end of the coil.

[0025] In a possible implementation, the control method further includes:

[0026] Controlling the gates of the first transistor and the fourth transistor to input the PWM signal, and connecting the gates of the second transistor and the third transistor to a low level, so that the driving current in the coil flows from the first end to the second end;

[0027] or,

[0028] The gates of the first transistor and the fourth transistor are controlled to be connected to a low level, and the gates of the second transistor and the third transistor are input with the PWM signal, so that the driving current in the coil flows from the second end to the first end.

[0029] In a possible implementation, the method further includes:

[0030] The reference current value is set according to the number of operation steps and the expected rotation speed of the stepper motor.

[0031] In a second aspect, an embodiment of the present application provides a control device for a stepper motor, comprising:

[0032] A PWM controller, used for outputting a PWM signal with a duty cycle of 1 to a motor drive circuit at an initial moment of a PWM cycle, so that a drive current in the coil of the stepper motor gradually increases;

[0033] A comparator, used to collect an actual current value in the coil of the stepper motor, and compare the actual current value with a preset reference current value;

[0034] The PWM controller is also used to stop outputting the PWM signal to the motor drive circuit if the actual current value is greater than or equal to the reference current value, so that the driving current in the coil of the stepper motor gradually decreases, and after continuously stopping the output of the PWM signal for a preset time, enter the next PWM cycle.

[0035] In a possible implementation, the reference current value includes a first reference current value and a second reference current value, the first reference current value is less than the second reference current value, and the PWM controller is specifically configured to:

[0036] If the actual current value is greater than or equal to the first reference current value and less than the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a first preset time, enter the next PWM cycle;

[0037] If the actual current value is greater than or equal to the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a second preset time, enter the next PWM cycle;

[0038] Wherein, the first preset time is shorter than the second preset time.

[0039] In a possible implementation, the PWM controller is specifically used to output a plurality of PWM signals with a duty cycle of 1 to a plurality of motor drive circuits at the initial moment of a PWM cycle, so that the drive current in the plurality of coils of the stepper motor gradually increases, wherein the i-th PWM signal with a duty cycle of 1 is used to be output to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually increases;

[0040] The number of the comparators is N, and the N comparators are respectively used to collect the actual current value in each coil of the stepper motor, and compare the actual current value in each coil with each preset reference current value;

[0041] The PWM controller is further configured to stop outputting the i-th PWM signal to the i-th motor drive circuit if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, so that the drive current in the i-th coil of the stepper motor gradually decreases, and after continuously stopping outputting the i-th PWM signal for a preset time, enter the next PWM cycle;

[0042] Among them, 1≤i≤N, N≥2.

[0043] In a possible implementation, the motor drive circuit includes:

[0044] A first transistor, wherein a drain of the first transistor is used to connect a high level;

[0045] a second transistor, wherein a drain of the second transistor is used to connect to a high level;

[0046] a third transistor, wherein a drain of the third transistor is electrically connected to a source of the first transistor, and the source of the third transistor is used to connect to a low level;

[0047] a fourth transistor, wherein a drain of the fourth transistor is electrically connected to a source of the third transistor, and the source of the fourth transistor is used to connect to a low level;

[0048] The node between the first transistor and the third transistor is used to connect the first end of the coil, and the node between the second transistor and the fourth transistor is used to connect the second end of the coil.

[0049] In a possible implementation, when it is necessary to control the driving current in the coil to flow from the first end to the second end, the gates of the first transistor and the fourth transistor are controlled to input the PWM signal, and the gates of the second transistor and the third transistor are connected to a low level;

[0050] When it is necessary to control the driving current in the coil to flow from the second end to the first end, the gates of the first transistor and the fourth transistor are controlled to be connected to a low level, and the gates of the second transistor and the third transistor are input with the PWM signal.

[0051] In a possible implementation, the method further includes:

[0052] The reference current value setting module is used to set the reference current value according to the number of operation steps and the expected rotation speed of the stepper motor.

[0053] In a third aspect, an embodiment of the present application provides a controller, wherein the controller is configured to execute any method described in the first aspect.

[0054] In the embodiment of the present application, the output of the PWM signal is controlled according to the comparison result between the actual current value and the reference current value to achieve precise control of the stepper motor. Since the duty cycle of the PWM signal is always 1, it is not necessary to adjust the duty cycle of the PWM signal during the control of the stepper motor, thereby reducing software overhead and improving control efficiency.

[0055] It can be understood that the duration of outputting the PWM signal and the duration of stopping outputting the PWM signal constitute a PWM cycle. In the embodiment of the present application, since the duration of outputting the PWM signal is not a fixed value, and the duration of stopping outputting the PWM signal is a fixed value, the PWM cycle is not a fixed value, that is, the frequency of the PWM signal is dynamically changing, thereby reducing the electromagnetic interference generated by the PWM signal and improving the reliability of the stepper motor. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 A schematic diagram of the structure of a stepper motor provided in an embodiment of the present application;

[0057] Figure 2 A schematic flow chart of a stepper motor control method provided in an embodiment of the present application;

[0058] Figure 3 A waveform diagram of a PWM signal provided in an embodiment of the present application;

[0059] Figure 4 A schematic diagram of the structure of a motor drive circuit provided in an embodiment of the present application;

[0060] Figure 5 A structural block diagram of a stepper motor control device provided in an embodiment of the present application;

[0061] Figure 6 A structural block diagram of another stepper motor control device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0063] See also Figure 1 , is a schematic diagram of the structure of a stepper motor provided in an embodiment of the present application. Figure 1As shown, the stepper motor includes a first coil L1 and a second coil L2, wherein the first coil L1 and the second coil L2 are respectively used to input a driving current, and by changing the magnitude and direction of the driving current, the magnetic field and torque can be changed, thereby causing the stepper motor to rotate. Usually, the two driving currents in the first coil L1 and the second coil L2 change according to a sinusoidal waveform, and the phase difference between the two is 90°.

[0064] It should be pointed out that Figure 1 This is only an exemplary description of the stepper motor in the embodiment of the present application, and should not be used as a limitation on the protection scope of the present application. For example, in some application scenarios, the stepper motor may contain only one coil, or contain a larger number of coils (3 or 4, etc.), and the embodiment of the present application does not make specific limitations on this.

[0065] See also Figure 2 , is a schematic flow chart of a control method for a stepper motor provided in an embodiment of the present application. Figure 2 As shown, it mainly includes the following steps.

[0066] Step S201: at the initial moment of the PWM cycle, output a PWM signal with a duty cycle of 1 to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually increases.

[0067] See also Figure 3 , is a waveform diagram of a PWM signal provided in an embodiment of the present application. Figure 3 As shown, at the initial moment t1 of the PWM cycle, a PWM signal with a duty cycle of 1 is output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually increases. Since the duty cycle of the PWM signal is 1, when the PWM signal is output, the first level, that is, the high level, is always output.

[0068] In some possible implementations, a stepper motor may include multiple coils. When the stepper motor includes N coils, at the initial moment of the PWM cycle, each PWM signal with a duty cycle of 1 is output to each corresponding motor drive circuit, thereby gradually increasing the drive current in the corresponding coil. Among them, the i-th PWM signal with a duty cycle of 1 is used to output to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually increases, 1≤i≤N, N≥2.

[0069] For example, in Figure 1In the application scenario shown, the stepper motor includes a first coil L1 and a second coil L2. At the initial moment of the PWM cycle, the first (also called the "first") PWM signal is output to the first motor drive circuit, so that the drive current in the first coil L1 gradually increases; the second (also called the "second") PWM signal is output to the second motor drive circuit, so that the drive current in the second coil L2 gradually increases. The duty cycle of the first PWM signal and the second PWM signal are both 1.

[0070] Step S202: collecting the actual current value in the coil of the stepper motor, and comparing the actual current value with a preset reference current value.

[0071] In an embodiment of the present application, the reference current value can be set according to the number of steps and the expected speed of the stepper motor. During the operation of the stepper motor, the actual current value in the coil of the stepper motor is collected in real time, and the actual current value is compared with the preset reference current value, and the corresponding comparison result is output. Among them, if the actual current value is less than the reference current value, the first comparison result is output (for example, output "0"); if the actual current value is greater than or equal to the reference current value, the second comparison result is output (for example, output "1").

[0072] For example, in Figure 3 In the application scenario shown, at time t2, the actual current value is compared with the preset reference current value, and if it is determined that the actual current value is less than the reference current value, a first comparison result is output; at time t3, the actual current value is compared with the preset reference current value, and if it is determined that the actual current value is greater than or equal to the reference current value, a second comparison result is output.

[0073] In some possible implementations, the stepper motor may include multiple coils. When the stepper motor includes multiple coils, the actual current value in each coil of the stepper motor is collected respectively, and the actual current value in each coil is compared with each preset reference current value respectively, and the comparison result corresponding to each coil is output. It can be understood that each coil corresponds to a reference current value.

[0074] For example, in Figure 1 In the application scenario shown, the stepper motor includes a first coil L1 and a second coil L2. The actual current values ​​in the first coil L1 and the second coil L2 are collected respectively, the actual current value in the first coil L1 is compared with a preset first reference current value, and the comparison result corresponding to the first coil L1 is output; the actual current value in the second coil L2 is compared with a preset second reference current value, and the comparison result corresponding to the second coil L2 is output.

[0075] Step S203: If the actual current value is greater than or equal to the reference current value, stop outputting the PWM signal to the motor driving circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a preset time, enter the next PWM cycle.

[0076] Specifically, if the actual current value is less than the reference current value, that is, the first comparison result is received, the PWM signal is output, that is, the first level is maintained, so that the driving current in the coil of the stepper motor continues to increase; if the actual current value is greater than or equal to the reference current value, the PWM signal is stopped from being output to the motor drive circuit. Since the PWM signal stops being output, the input level of the motor drive circuit is adjusted to the second level, that is, the low level. It can be understood that the low level cannot drive the motor drive circuit to work, thereby gradually reducing the driving current in the coil of the stepper motor.

[0077] Furthermore, after the output of the PWM signal is stopped for a preset time, the current PWM cycle ends, and the next PWM cycle begins, and the process returns to step S201.

[0078] For example, in Figure 3 In the application scenario shown, at time t2, the actual current value is less than the reference current value, and the PWM signal is output, that is, the first level is maintained, so that the drive current in the coil of the stepper motor continues to increase; at time t3, the actual current value is greater than or equal to the reference current value, and the PWM signal is stopped from being output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases. At time t4, after the PWM signal output is stopped for a preset time, the current PWM cycle ends and the next PWM cycle begins.

[0079] It can be understood that the duration of outputting the PWM signal (t1-t3) and the duration of stopping outputting the PWM signal (t3-t4) constitute a PWM cycle. In the embodiment of the present application, since the duration of outputting the PWM signal is not a fixed value, and the duration of stopping outputting the PWM signal is a fixed value, the PWM cycle is not a fixed value, that is, the frequency of the PWM signal is dynamically changing, thereby reducing the electromagnetic interference generated by the PWM signal and improving the reliability of the stepper motor.

[0080] In some possible implementations, the reference current value includes a first reference current value and a second reference current value. If the actual current value is greater than or equal to the first reference current value and less than the second reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after the PWM signal is continuously stopped for a first preset time, the next PWM cycle is entered; if the actual current value is greater than or equal to the second reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after the PWM signal is continuously stopped for a second preset time, the next PWM cycle is entered; wherein the first preset time is less than the second preset time. That is, the time to stop outputting the PWM signal is determined according to the size of the actual current value. When the actual current value is small, the time to stop outputting the PWM signal is short; when the actual current value is small, the time to stop outputting the PWM signal is long. In the embodiment of the present application, the PWM cycle can be further adjusted by setting different preset times, the dynamic change degree of the frequency of the PWM signal is increased, and the electromagnetic interference generated by the PWM signal is further reduced.

[0081] In some possible implementations, the stepper motor may include multiple coils. When the stepper motor includes N coils, if the actual current value in the i-th coil is less than the i-th reference current value, the i-th PWM signal is controlled to be output to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually increases; if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, the i-th PWM signal is stopped from being output to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually decreases, and after the i-th PWM signal is stopped from being output for a preset time, the next PWM cycle is entered, 1≤i≤N, N≥2.

[0082] For example, in Figure 1In the application scenario shown, the stepper motor includes a first coil L1 and a second coil L2. If the actual current value of the first coil L1 is less than the first reference current value, the first PWM signal is controlled to be output to the first motor drive circuit, so that the drive current in the first coil L1 gradually increases; if the actual current value of the first coil L1 is greater than or equal to the first reference current value, the first PWM signal is stopped from being output to the first motor drive circuit, so that the drive current in the first coil L1 gradually decreases. After the first PWM signal is continuously stopped from being output for a preset time, the current PWM cycle ends and the next PWM cycle begins. If the actual current value of the second coil L2 is less than the second reference current value, the second PWM signal is controlled to be output to the second motor drive circuit, so that the drive current in the second coil L2 gradually increases; if the actual current value of the second coil L2 is greater than or equal to the second reference current value, the second PWM signal is stopped from being output to the second motor drive circuit, so that the drive current in the second coil L2 gradually decreases. After the second PWM signal is continuously stopped from being output for a preset time, the current PWM cycle ends and the next PWM cycle begins.

[0083] In the embodiment of the present application, the output of the PWM signal is controlled according to the comparison result between the actual current value and the reference current value to achieve precise control of the stepper motor. Since the duty cycle of the PWM signal is always 1, it is not necessary to adjust the duty cycle of the PWM signal during the control of the stepper motor, thereby reducing software overhead and improving control efficiency.

[0084] See also Figure 4 , is a schematic diagram of a motor drive circuit provided in an embodiment of the present application. Figure 4 As shown, the motor drive circuit includes a first transistor, a second transistor, a third transistor and a fourth transistor. The drain of the first transistor is used to connect to a high level VBAT; the drain of the second transistor is used to connect to a high level VBAT; the drain of the third transistor is electrically connected to the source of the first transistor, and the source of the third transistor is used to connect to a low level GND; the drain of the fourth transistor is electrically connected to the source of the third transistor, and the source of the fourth transistor is used to connect to a low level GND. The node between the first transistor and the third transistor is used to connect to the first end of the coil (for example, Figure 4 The node between the second transistor and the fourth transistor is used to connect the second end of the coil (eg, Figure 4 The second end A' of the first coil L1 is shown in FIG.

[0085] In a specific implementation, the control logic of the motor drive circuit is as follows: when it is necessary to control the driving current in the coil to flow from the first end to the second end, HQ_U=PWM, LQ_U=0, HQ_V=0, LQ_V=PWM, that is, the gate HQ_U of the first transistor and the gate LQ_U of the fourth transistor are controlled to input a PWM signal, and the gate HQ_V of the second transistor and the gate LQ_U of the third transistor are connected to a low level; when it is necessary to control the driving current in the coil to flow from the second end to the first end, HQ_U=0, LQ_U=PWM, HQ_V=PWM, LQ_V=0, that is, the gate HQ_U of the first transistor and the gate LQ_V of the fourth transistor are controlled to connect to a low level, and the gate HQ_V of the second transistor and the gate LQ_U of the third transistor are controlled to input a PWM signal.

[0086] In the embodiment of the present application, the first transistor, the second transistor, the third transistor and the fourth transistor are NMOS transistors. It is understandable that those skilled in the art can also use other types of transistors to implement the above functions of the motor drive circuit according to actual needs, and the embodiment of the present application does not make specific restrictions on this.

[0087] Corresponding to the above embodiment, the embodiment of the present application further provides a control device for a stepper motor.

[0088] See also Figure 5 , is a structural block diagram of a control device for a stepping motor provided in an embodiment of the present application. Figure 5 As shown, the control device includes: a comparator and a PWM controller. The PWM controller is used to output a PWM signal with a duty cycle of 1 to the motor drive circuit at the initial moment of the PWM cycle, so that the drive current in the coil of the stepper motor gradually increases. The comparator is used to collect the actual current value in the coil of the stepper motor and compare the actual current value with the preset reference current value. Furthermore, the PWM controller is also used to stop outputting the PWM signal to the motor drive circuit if the actual current value is greater than or equal to the reference current value, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a preset time, enter the next PWM cycle.

[0089] It should be noted that in actual applications, the reference current value can be configured through the "DAC" parameter in the software. Specifically, the reference current value can be configured according to the number of steps and the expected speed of the stepper motor.

[0090] In some possible implementations, the reference current value includes a first reference current value and a second reference current value, the first reference current value is less than the second reference current value, and the PWM controller is specifically used to: if the actual current value is greater than or equal to the first reference current value and less than the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after continuously stopping the output of the PWM signal for a first preset time, enter the next PWM cycle; if the actual current value is greater than or equal to the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the driving current in the coil of the stepper motor gradually decreases, and after continuously stopping the output of the PWM signal for a second preset time, enter the next PWM cycle; wherein the first preset time is less than the second preset time.

[0091] In some possible implementations, a stepper motor may include multiple coils. When the stepper motor includes N coils, the PWM controller is specifically used to output multiple PWM signals with a duty cycle of 1 to multiple motor drive circuits at the initial moment of the PWM cycle, so that the driving current in the multiple coils of the stepper motor gradually increases, wherein the i-th PWM signal with a duty cycle of 1 is used to output to the i-th motor drive circuit, so that the driving current in the i-th coil of the stepper motor gradually increases. The number of comparators is N, and the N comparators are used to collect the actual current value in each coil of the stepper motor, and compare the actual current value in each coil with each preset reference current value. The PWM controller is also used to stop outputting the i-th PWM signal to the i-th motor drive circuit if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, so that the driving current in the i-th coil of the stepper motor gradually decreases, and after continuously stopping outputting the i-th PWM signal for a preset time, enter the next PWM cycle. Wherein, 1≤i≤N, N≥2.

[0092] For example, in Figure 6In the implementation shown, N=2. Accordingly, the PWM controller is specifically used to output the first PWM signal "PWM0" to the first motor drive circuit at the initial moment of the PWM cycle, so that the drive current in the first coil L1 gradually increases; and output the second PWM signal "PWM1" to the second motor drive circuit, so that the drive current in the second coil L2 gradually increases. The first comparator "Comparator 0" is used to collect the actual current value "actual current value 0" in the first coil L1, compare the "actual current value 0" with the preset first reference current value "reference current value 0", and output the comparison result "comparison result 0" corresponding to the first coil L1. The second comparator "Comparator 1" is used to collect the actual current value "actual current value 1" in the second coil L2, compare the "actual current value 1" with the preset second reference current value "reference current value 1", and output the comparison result "comparison result 1" corresponding to the second coil L2. The PWM controller is also used to control the first PWM signal "PWM0" to be output to the first motor drive circuit if the actual current value "actual current value 0" of the first coil L1 is less than the first reference current value "reference current value 0"; if the actual current value "actual current value 0" of the first coil L1 is greater than or equal to the first reference current value "reference current value 0", then stop outputting the first PWM signal "PWM0" to the first motor drive circuit, and continue to stop outputting the first PWM signal "PWM0" for a preset time before entering the next PWM cycle. If the actual current value "actual current value 1" of the second coil L2 is less than the second reference current value "reference current value 1", then control the second PWM signal "PWM1" to be output to the second motor drive circuit; if the actual current value "actual current value 1" of the second coil L2 is greater than or equal to the second reference current value "reference current value 1", then stop outputting the second PWM signal "PWM1" to the second motor drive circuit, and continue to stop outputting the second PWM signal "PWM1" for a preset time before entering the next PWM cycle.

[0093] In the embodiment of the present application, the output of the PWM signal is controlled according to the comparison result between the actual current value and the reference current value to achieve precise control of the stepper motor. Since the duty cycle of the PWM signal is always 1, it is not necessary to adjust the duty cycle of the PWM signal during the control of the stepper motor, thereby reducing software overhead and improving control efficiency.

[0094] In a possible implementation, the motor drive circuit includes a first transistor, a second transistor, a third transistor, and a fourth transistor. The drain of the first transistor is used to connect to a high level VBAT; the drain of the second transistor is used to connect to a high level VBAT; the drain of the third transistor is electrically connected to the source of the first transistor, and the source of the third transistor is used to connect to a low level GND; the drain of the fourth transistor is electrically connected to the source of the third transistor, and the source of the fourth transistor is used to connect to a low level GND. The node between the first transistor and the third transistor is used to connect to the first end of the coil (for example, Figure 4 The node between the second transistor and the fourth transistor is used to connect the second end of the coil (eg, Figure 4 The second end A' of the first coil L1 is shown in FIG.

[0095] In a specific implementation, the control logic of the motor drive circuit is as follows: when it is necessary to control the driving current in the coil to flow from the first end to the second end, HQ_U=PWM, LQ_U=0, HQ_V=0, LQ_V=PWM, that is, the gate HQ_U of the first transistor and the gate LQ_V of the fourth transistor are controlled to input a PWM signal, and the gate HQ_V of the second transistor and the gate LQ_U of the third transistor are connected to a low level; when it is necessary to control the driving current in the coil to flow from the second end to the first end, HQ_U=0, LQ_U=PWM, HQ_V=PWM, LQ_V=0, that is, the gate HQ_U of the first transistor and the gate LQ_U of the fourth transistor are controlled to connect to a low level, and the gate HQ_V of the second transistor and the gate LQ_U of the third transistor are controlled to input a PWM signal.

[0096] In the embodiment of the present application, the first transistor, the second transistor, the third transistor and the fourth transistor are NMOS transistors. It is understandable that those skilled in the art can also use other types of transistors to implement the above functions of the motor drive circuit according to actual needs, and the embodiment of the present application does not make specific restrictions on this.

[0097] Corresponding to the above embodiment, the embodiment of the present application further provides a controller, which is configured to execute the above stepper motor control method. Specifically, the controller can be an MCU, and of course can also be other types of controllers, which are not specifically limited in the embodiment of the present application.

[0098] It should be pointed out that the specific content of the control method of the stepper motor can be found in the above description, and for the sake of brevity, it will not be repeated here.

[0099] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0100] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0102] In several embodiments provided in the present application, if any function 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 this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0103] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A control method for a stepping motor, characterized in that: include: At the initial moment of the PWM cycle, a PWM signal with a duty cycle of 1 is output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually increases; Collecting an actual current value in the coil of the stepper motor, and comparing the actual current value with a preset reference current value; If the actual current value is greater than or equal to the reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after the PWM signal is stopped from being output for a preset time, the next PWM cycle is entered, and the PWM cycle is not a fixed value; The reference current value includes a first reference current value and a second reference current value, the first reference current value is less than the second reference current value, and if the actual current value is greater than or equal to the reference current value, the PWM signal is stopped from being output to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after the PWM signal is continuously stopped for a preset time, the next PWM cycle is entered, including: If the actual current value is greater than or equal to the first reference current value and less than the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a first preset time, enter the next PWM cycle; If the actual current value is greater than or equal to the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a second preset time, enter the next PWM cycle; Wherein, the first preset time is shorter than the second preset time.

2. The control method according to claim 1, characterized in that: The step of outputting a PWM signal with a duty cycle of 1 to a motor drive circuit at the initial moment of a PWM cycle so that the drive current in the coil of the stepper motor gradually increases comprises: at the initial moment of a PWM cycle, outputting a plurality of PWM signals with a duty cycle of 1 to a plurality of motor drive circuits respectively so that the drive current in the plurality of coils of the stepper motor gradually increases, wherein the ith PWM signal with a duty cycle of 1 is used to be output to the ith motor drive circuit so that the drive current in the ith coil of the stepper motor gradually increases; The collecting of the actual current value in the coil of the stepper motor and comparing the actual current value with a preset reference current value comprises: collecting the actual current value in each coil of the stepper motor respectively, and comparing the actual current value in each coil with each preset reference current value respectively; If the actual current value is greater than or equal to the reference current value, then stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a preset time, enter the next PWM cycle, including: if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, then stop outputting the i-th PWM signal to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually decreases, and after continuously stopping outputting the i-th PWM signal for a preset time, enter the next PWM cycle; Among them, 1≤i≤N, N≥2.

3. The control method according to any one of claims 1 to 2, characterized in that: The motor drive circuit comprises: A first transistor, wherein a drain of the first transistor is used to connect a high level; a second transistor, wherein a drain of the second transistor is used to connect to a high level; a third transistor, wherein the drain of the third transistor is electrically connected to the source of the first transistor, and the source of the third transistor is used to connect to a low level; a fourth transistor, wherein a drain of the fourth transistor is electrically connected to a source of the third transistor, and the source of the fourth transistor is used to connect to a low level; The node between the first transistor and the third transistor is used to connect the first end of the coil, and the node between the second transistor and the fourth transistor is used to connect the second end of the coil.

4. The control method according to claim 3, characterized in that: The control method further comprises: Controlling the gates of the first transistor and the fourth transistor to input the PWM signal, and connecting the gates of the second transistor and the third transistor to a low level, so that the driving current in the coil flows from the first end to the second end; or, The gates of the first transistor and the fourth transistor are controlled to be connected to a low level, and the gates of the second transistor and the third transistor are input with the PWM signal, so that the driving current in the coil flows from the second end to the first end.

5. The control method according to claim 1, characterized in that: Also includes: The reference current value is set according to the number of operation steps and the expected rotation speed of the stepper motor.

6. A control device for a stepping motor, characterized in that: include: A PWM controller, used for outputting a PWM signal with a duty cycle of 1 to a motor drive circuit at an initial moment of a PWM cycle, so that a drive current in the coil of the stepper motor gradually increases; A comparator, used to collect an actual current value in the coil of the stepper motor, and compare the actual current value with a preset reference current value, wherein the reference current value is set according to the number of operation steps and the expected rotation speed of the stepper motor; The PWM controller is further configured to stop outputting the PWM signal to the motor drive circuit if the actual current value is greater than or equal to the reference current value, so that the drive current in the coil of the stepper motor gradually decreases, and enter the next PWM cycle after continuously stopping outputting the PWM signal for a preset time, wherein the PWM cycle is not a fixed value; The reference current value includes a first reference current value and a second reference current value, the first reference current value is less than the second reference current value, and the PWM controller is specifically used to: If the actual current value is greater than or equal to the first reference current value and less than the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a first preset time, enter the next PWM cycle; If the actual current value is greater than or equal to the second reference current value, stop outputting the PWM signal to the motor drive circuit, so that the drive current in the coil of the stepper motor gradually decreases, and after continuously stopping outputting the PWM signal for a second preset time, enter the next PWM cycle; Wherein, the first preset time is shorter than the second preset time.

7. The control device according to claim 6, characterized in that: The PWM controller is specifically used to output a plurality of PWM signals with a duty cycle of 1 to a plurality of motor drive circuits at the initial moment of a PWM cycle, so that the drive current in the plurality of coils of the stepper motor gradually increases, wherein the i-th PWM signal with a duty cycle of 1 is used to output to the i-th motor drive circuit, so that the drive current in the i-th coil of the stepper motor gradually increases; The number of the comparators is N, and the N comparators are respectively used to collect the actual current value in each coil of the stepper motor, and compare the actual current value in each coil with each preset reference current value; The PWM controller is further configured to stop outputting the i-th PWM signal to the i-th motor drive circuit if the actual current value in the i-th coil is greater than or equal to the i-th reference current value, so that the drive current in the i-th coil of the stepper motor gradually decreases, and after continuously stopping outputting the i-th PWM signal for a preset time, enter the next PWM cycle; Among them, 1≤i≤N, N≥2.

8. The control device according to any one of claims 6 to 7, characterized in that: The motor drive circuit comprises: A first transistor, wherein a drain of the first transistor is used to connect a high level; a second transistor, wherein a drain of the second transistor is used to connect to a high level; a third transistor, wherein the drain of the third transistor is electrically connected to the source of the first transistor, and the source of the third transistor is used to connect to a low level; a fourth transistor, wherein a drain of the fourth transistor is electrically connected to a source of the third transistor, and the source of the fourth transistor is used to connect to a low level; Among them, the node between the first transistor and the third transistor is used to connect the first end of the coil, and the node between the second transistor and the fourth transistor is used to connect the second end of the coil; when it is necessary to control the driving current in the coil to flow from the first end to the second end, the gates of the first transistor and the fourth transistor are controlled to input the PWM signal, and the gates of the second transistor and the third transistor are connected to a low level; when it is necessary to control the driving current in the coil to flow from the second end to the first end, the gates of the first transistor and the fourth transistor are controlled to connect to a low level, and the gates of the second transistor and the third transistor are input to the PWM signal.