Control method and control device of stepper motor, terminal device and storage medium
By determining the current stepper motor's current step count and input current, the current control mode is switched to solve the problem of poor flatness of the stepper motor drive current waveform, thereby achieving more precise rotation control and reducing energy consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2026-03-03
AI Technical Summary
The existing control method for stepper motors results in poor flatness of the drive current waveform, leading to significant stepping losses and affecting the stable motion control of electronic devices.
By determining the current number of steps and the input current of the stepper motor, the magnitude of the input current during the operation of the stepper motor is controlled, and the current control mode is switched to ensure the flatness of the current waveform and reduce step loss.
It improves the rotational accuracy of the stepper motor, reduces noise, lowers the energy consumption of the stepper motor, and achieves more stable motion control.
Smart Images

Figure CN114499298B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of stepper motor technology, and particularly relates to a stepper motor control method, control device, terminal equipment and storage medium. Background Technology
[0002] A stepper motor is an electric motor that converts electrical pulse signals into corresponding angular or linear displacement. Generally, stepper motors are used to support the motion control of electronic devices in order to make the motion control of these devices more accurate.
[0003] However, there are significant drawbacks in the current control methods for stepper motors. For example, when using existing on-chip integrated control methods to control stepper motors, although there are fewer and lower-cost peripheral control devices, the waveform flatness of the corresponding drive current is poor, resulting in greater stepping losses and making it difficult to stably control the movement of electronic devices. Summary of the Invention
[0004] This application provides a stepper motor control method, control device, terminal equipment, and storage medium to solve the problem of poor waveform flatness of the drive current when controlling a stepper motor, which results in a large step loss of the stepper motor.
[0005] In a first aspect, embodiments of this application provide a stepper motor control method, including:
[0006] Determine the current step number of the stepper motor, where the current step number is the number of steps corresponding to the current rotation angle of the rotor out of the total number of steps required for the rotor of the stepper motor to rotate one revolution;
[0007] Obtain the current first input current of the stepper motor;
[0008] The input current of the stepper motor is controlled based on the current number of steps and the current input current.
[0009] The stepper motor control method provided in this application determines the current step number corresponding to the current rotation angle of the rotor in the total number of steps required for the rotor to rotate one revolution, and obtains the current first input current of the stepper motor. Based on the current step number and the current input current, the input current of the stepper motor is controlled to increase or decrease. For example, when the current input current reaches the limit current corresponding to the current step number, the input current of the stepper motor is switched to increase or decrease, so that the rotor of the stepper motor can reach the appropriate position, with more precise rotation accuracy and less step loss.
[0010] Secondly, embodiments of this application provide a control device for a stepper motor, characterized in that it includes:
[0011] The determination module is used to determine the current number of steps of the stepper motor, wherein the current number of steps is the number of steps corresponding to the current rotation angle of the rotor out of the total number of steps required for the rotor of the stepper motor to rotate one revolution;
[0012] The acquisition module is used to acquire the current first input current of the stepper motor;
[0013] The control module is used to control the input current of the stepper motor during operation based on the current number of steps and the current input current.
[0014] Thirdly, embodiments of this application provide a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the control method when executing the computer program.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the control method described above.
[0016] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the terminal device to execute the control method described in any one of the first aspects.
[0017] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating a stepper motor control method provided in an embodiment of this application.
[0020] Figure 2 This is a schematic diagram illustrating the specific implementation of step S13 of the stepper motor control method provided in an embodiment of this application.
[0021] Figure 3 This is a schematic diagram illustrating an application scenario of the stepper motor control method provided in an embodiment of this application.
[0022] Figure 4This is a schematic diagram of a scenario where the current control mode is switched during the operation of a stepper motor, according to an embodiment of this application.
[0023] Figure 5 This is a waveform diagram of the input current of a stepper motor provided in another embodiment of this application.
[0024] Figure 6 This is a schematic diagram of the control device for a stepper motor provided in an embodiment of this application.
[0025] Figure 7 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application. Detailed Implementation
[0026] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limiting purposes, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details.
[0027] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0028] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0029] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0030] To illustrate the technical solution described in this application, specific embodiments are provided below.
[0031] Please see Figure 1 , Figure 1 This is a flowchart illustrating the implementation of a stepper motor control method according to an embodiment of this application. In this embodiment, the stepper motor control method is used to control the input current during stepper motor operation, and its execution entity is a terminal device. The terminal device includes at least a current sampling component, a processor, and a counter. The current sampling component is used to collect the input current of the stepper motor, the counter is used to record the number of steps of the stepper motor, and the processor is used to control the magnitude of the input current during stepper motor operation based on the number of steps and the input current recorded by the counter.
[0032] In order to drive the stepper motor, the processor is connected to an external microcontroller and receives pulse signals generated by the microcontroller to indicate the driving of the stepper motor. At the same time, the processor also controls the input current of the stepper motor according to the number of steps and the input current of the stepper motor.
[0033] When the microcontroller inputs a pulse signal to the processor, the counter is used to count the number of pulse signals. Since each pulse signal represents a stepper motor needing to move forward or backward one step, the number of pulse signals recorded by the counter can be used as the number of steps corresponding to the rotation angle of the stepper motor rotor.
[0034] Understandably, in order to better record steps, a counter includes up-counting and down-counting functions, and each count is represented in binary, quaternary, octal or other positional notation systems.
[0035] For example, a counter that can count both up and down steps is used to count each step of the stepper motor. Each step is represented by a seven-bit binary code, which makes it easy to locate each step and facilitate subsequent operations on a specific step to control the operation of the stepper motor.
[0036] In one embodiment, the terminal device may include, but is not limited to, one or more of a robot, a printer, and a POS machine.
[0037] like Figure 1 As shown, the stepper motor control method provided in this application includes the following steps:
[0038] S11: Determine the current step number of the stepper motor. The current step number is the number of steps that correspond to the current rotation angle of the rotor out of the total number of steps required for the rotor to rotate one revolution.
[0039] As an example of this application, the rotation angle refers to the rotation angle determined with respect to a preset angular reference point and the current position of the rotor.
[0040] For example, if the rotor rotates 360 degrees in one revolution, and the current angle of the rotor is determined by the rotor's position when the stepper motor is powered on as the angle reference point, then if the total number of steps required for the rotor to rotate one revolution is 128, then the number of steps corresponding to the current rotation angle of the rotor is the 96th step.
[0041] In this embodiment, in order to understand the current operating status of the stepper motor and provide an information basis for controlling the rotation of the stepper motor, the current number of steps of the stepper motor is first determined so that the corresponding current or voltage control information can be understood through the current number of steps, such as the limit drive current that should correspond to the current number of steps.
[0042] As for when to determine the current step number of the stepper motor, this includes, but is not limited to, the following scenarios:
[0043] Scenario 1: When a pulse signal is received, determine the current number of steps of the stepper motor.
[0044] Scenario 2: When it is detected that the currently executing task has not yet finished, determine the current step number of the stepper motor.
[0045] Understandably, in order for the task to be executed well, the total number of steps that the stepper motor will support to complete the task is predetermined for each task. Therefore, the current number of steps of the stepper motor can be determined based on the execution progress of the currently executing task.
[0046] For example, when executing task A, the total number of steps required for the stepper motor to support the completion of task A is 36,000. Since the progress of each task corresponds to each step of the stepper motor, when the execution progress of the currently executing task is 50%, the corresponding step number is 18,000. At the same time, the number of steps required for the stepper motor rotor to rotate one revolution is 128. Therefore, based on 18,000 and the number of steps required for the stepper motor rotor to rotate one revolution, it can be calculated that the stepper motor rotor has rotated 140 revolutions and the current step number is 80.
[0047] In applications, the current number of steps of the stepper motor can be determined by obtaining the current rotation angle of the rotor; or by determining the number of pulse signals recorded by the counter; or by determining the current number of steps of the stepper motor based on the task supported by the stepper motor.
[0048] In one embodiment, to more precisely control the rotation of the stepper motor, the total number of steps required for one revolution of the rotor is greater than 4. For example, the total number of steps is set to 128.
[0049] S12: Get the current first input current of the stepper motor.
[0050] As an example of this application, the first input current refers to the current currently used to drive the stepper motor.
[0051] For example, the first input current of the stepper motor can be acquired by using a pre-set current sampling resistor.
[0052] In this embodiment, in order to accurately control the operation of the stepper motor, after determining the current number of steps of the stepper motor, the current first input current of the stepper motor is also obtained, so as to understand the current driving status of the stepper motor, such as the current driving current, through the first input current, thereby providing an information basis for further controlling the operation of the stepper motor.
[0053] S13: Control the input current of the stepper motor during operation based on the current step number and the first input current.
[0054] In this embodiment, to better control the input current of the stepper motor, resulting in a smoother current waveform and more precise rotational control, the current or voltage control information is determined based on the current step number. Furthermore, the current driving status of the stepper motor is understood through the first input current. Based on the current step number and the first input current, the input current of the stepper motor is controlled to ensure smoother rotation and lower noise. For example, the maximum or minimum driving current corresponding to the current step number is compared with the first input current, and the comparison result determines whether to increase or decrease the input current during stepper motor operation.
[0055] Understandably, in the process of controlling a stepper motor, in order for the stepper motor to run, the magnitude of the drive current flowing through the two coils of the motor is controlled while maintaining the phase difference of the drive current setting degree to achieve the rotation of the stepper motor. Therefore, in order to better control the rotation of the stepper motor, based on the current control information corresponding to the current step and the first input current, it is determined whether to increase or decrease the magnitude of the input current when the stepper motor is running, and then control the magnitude of the input current of the stepper motor in the next step, so that the rotor of the stepper motor rotates to a specific position under the action of the magnetic field generated by the current flowing through the coils of the stepper motor, such as accelerating to position A or decelerating to position B.
[0056] Combination Figure 2 In one embodiment of this application, the specific implementation of controlling the magnitude of the input current during stepper motor operation based on the current step count and the first input current includes:
[0057] S21: Obtain the preset limit drive current corresponding to the current step number. The limit drive current is the maximum or minimum drive current when the stepper motor is running.
[0058] As an example in this application, the maximum drive current refers to the maximum input current of the stepper motor when it is running in the current increase mode corresponding to the current step number.
[0059] Minimum drive current refers to the minimum input current of a stepper motor when it is running in the current decay mode corresponding to the current step number.
[0060] In this embodiment, in order to better control the magnitude of the input current during the operation of the stepper motor, a preset limit drive current corresponding to the current step number is obtained to understand the minimum drive current and / or maximum drive current corresponding to the current rotation angle of the stepper motor rotor, so as to provide an information basis for determining the current control mode of the stepper motor in combination with the first input current.
[0061] It is understandable that the limiting drive current and the limiting drive voltage are different for each rotation angle required for one revolution of the stepper motor rotor. However, to effectively reduce stepper motor noise, step losses, and improve the flatness of the drive current waveform, the difference between the maximum and minimum drive current for each step is the same.
[0062] In one embodiment, to better control the operation of the stepper motor, after setting the total number of steps required for the stepper motor rotor to rotate one revolution as needed, the terminal device's counter records each step and inputs the recorded step number to the terminal device, including a digital-to-analog converter (DAC). This allows the DAC to output the maximum and minimum drive current (or voltage) corresponding to that step based on the input step number. Alternatively, the DAC can directly generate the maximum and minimum drive current (or voltage) for each step based on the set total number of steps.
[0063] S22: Compare the first input current and the limit drive current to obtain the current magnitude comparison result.
[0064] In this embodiment, in order to control the operation of the stepper motor, there is a process of increasing the control input current to accelerate the rotor rotation and a process of gradually decreasing the control input current to decelerate the rotor rotation at each step. Therefore, in order to control the operation of the stepper motor, it is necessary to understand the relationship between the first input current and the limit drive current corresponding to the current step, so as to provide an information basis for determining the specific control mode of the stepper motor.
[0065] Understandably, if the current current control mode of the stepper motor is to increase the input current during operation, the first input current is compared with the maximum drive current. Conversely, if the current current control mode of the stepper motor is to decrease the input current during operation, the first input current is compared with the minimum drive current.
[0066] S23: Determine the current control mode of the stepper motor based on the comparison results of the current magnitude.
[0067] As an example of this application, current control mode refers to a mode that controls the magnitude of increasing input current or controlling the magnitude of decreasing input current.
[0068] In this embodiment, after obtaining the comparison result of the current magnitude between the first input current and the limit drive current, since the comparison result can describe the relationship between the first input current and the maximum or minimum drive current, it can provide an information basis for whether to switch the current current control mode of the stepper motor. Therefore, the current control mode of the stepper motor can be determined based on the comparison result.
[0069] Understandably, if the current current control mode of the stepper motor is a control mode that increases the input current, and the comparison result of the current magnitude shows that the first input current is less than the maximum drive current, then it means that the current current control mode needs to be maintained. Conversely, if the comparison result of the current magnitude shows that the first input current is equal to the maximum drive current, it means that the limit of the stepper motor's drive current has been reached. In order to protect the stepper motor or to ensure that the stepper motor can operate well, it is necessary to switch the current control mode of the stepper motor, that is, to switch to a mode that can reduce the input current of the stepper motor, so as to improve the rotation accuracy of the stepper motor and reduce rotation noise.
[0070] Furthermore, if the current current control mode of the stepper motor is a control mode that reduces the input current, and the comparison result of the current magnitude shows that the first input current is less than the minimum drive current, it means that the rotor of the stepper motor has not yet rotated to the appropriate position. It is necessary to maintain the current current control mode so that the rotor can move to the appropriate position. Conversely, if the comparison result of the current magnitude shows that the first input current is equal to the minimum drive current, it means that the limit of the stepper motor's drive current has been reached. In order to protect the stepper motor or to ensure that the stepper motor can operate well, it is necessary to switch the current control mode of the stepper motor, that is, switch to a mode that increases the input current of the stepper motor, so as to improve the rotation accuracy of the stepper motor, reduce rotation noise, and reduce step loss.
[0071] S24: Controls the input current of the stepper motor during operation according to the current control mode.
[0072] In this embodiment, in order for the stepper motor to continue running to complete the task, after determining the current control mode, the input current of the stepper motor is controlled according to the determined current control mode.
[0073] As one possible implementation of this application, the limiting drive current is the maximum drive current, and the specific implementation of determining the current control mode of the stepper motor based on the comparison result of the current magnitude includes:
[0074] If the first input current is equal to the maximum drive current, then the current control mode of the stepper motor is determined to be the current decay mode; wherein, when the stepper motor is running in the current decay mode, the input current of the stepper motor gradually decreases.
[0075] In this embodiment, in order to reduce the stepper motor's step consumption, reduce operating noise, improve operating efficiency, and improve the flatness of the stepper motor's drive current waveform, if the first input current is determined to be equal to the maximum drive current, it means that the stepper motor's input current has reached the maximum drive current set for the current step number. Therefore, when the first input current is determined to be equal to the maximum drive current, it means that the stepper motor's torque value has reached the set value and will not increase further. It is necessary to switch the stepper motor's current control mode, that is, switch from the mode that gradually increases the stepper motor's input current to the current decay mode. In this mode, the stepper motor's input current gradually decreases, and the corresponding stepper motor torque value gradually decreases, allowing the rotor to rotate to the position required for the corresponding number of steps. This reduces the stepper motor's step consumption, reduces operating noise, improves operating efficiency, and improves the flatness of the stepper motor's drive current waveform.
[0076] In one embodiment, the maximum drive current corresponds to the maximum drive voltage, and the first input current is equal to the maximum drive current when the input voltage corresponding to the first input current is equal to the maximum drive voltage.
[0077] In one embodiment, the current decay mode includes a first decay mode and a second decay mode, wherein the current decrease rate corresponding to the first decay mode is less than the current decrease rate corresponding to the second decay mode.
[0078] In one embodiment of this application, if the current input current is equal to the maximum drive current, the specific implementation of determining the current control mode of the stepper motor as the current decay mode includes:
[0079] Obtain the inductance value of the stepper motor coil.
[0080] If the inductance value is greater than or equal to the preset threshold, the first input current is equal to the maximum drive current, and the first input current is greater than or equal to the input current of the stepper motor at the previous moment, then the current control mode of the stepper motor is determined to be the first attenuation mode.
[0081] If the inductance value is greater than or equal to the preset threshold, the first input current is equal to the maximum drive current, and the first input current is less than the input current of the stepper motor at the previous moment, then the current control mode of the stepper motor is determined to be a mode in which the first decay mode and the second decay mode alternate.
[0082] As an example of this application, the inductance value is determined by the coil condition of the stepper motor.
[0083] Understandably, the inductance value of a stepper motor can be determined in advance based on the corresponding coil.
[0084] The preset threshold can be determined in advance according to actual needs. For example, the preset threshold can be set to 30H.
[0085] In this embodiment, when the inductance value is greater than or equal to a preset threshold, it indicates that the waveform of the stepper motor's input current is prone to distortion, which makes the stepper motor prone to generating large noise or increasing step loss. Therefore, when the first input current is equal to the maximum drive current and the first input current is greater than or equal to the stepper motor's input current at the previous moment, it indicates that the stepper motor's input current is in a first attenuation mode with a smaller current reduction rate, which is determined as the stepper motor's current control mode. This makes the process of the stepper motor's input current changing more smoothly, that is, the change of the stepper motor's torque is smoother, resulting in less noise.
[0086] Furthermore, if the inductance value is greater than or equal to a preset threshold, the first input current equals the maximum drive current, and the first input current is less than the input current of the stepper motor at the previous moment. This indicates that the drive current of the stepper motor is decreasing, and correspondingly, the energy to drive the rotor of the stepper motor is decreasing. The difficulty of controlling the rotor of the stepper motor to run to the appropriate position is decreasing. Therefore, in order to better control the operation of the stepper motor and make the rotation of the stepper motor more precise, the alternation mode of the first attenuation mode and the second attenuation mode can be used as the current control mode of the stepper motor. This allows the first attenuation mode to be used to control the magnitude of the input current when the current is large, while the second attenuation mode is used to control the magnitude of the input current when the input current decreases to a certain level.
[0087] It is understandable that the input current of a stepper motor is either sinusoidal alternating current or cosine alternating current.
[0088] In one embodiment, combined with Figure 3The terminal device records the number of input pulse signals using a counter, and this recorded number is used as the current step number of the stepper motor. The preset limit drive current corresponding to the current step number is then obtained. This recorded current step number is input to the digital-to-analog converter (DAC), allowing the DAC to output the maximum drive voltage in the current increase mode and the minimum drive voltage in the current decrease mode corresponding to the current step number. Simultaneously, to understand the current drive current of the stepper motor, the current in the motor winding coil is sampled using sampling resistor 1 or 2 as the input current. Next, the input current is combined with the sampling resistor to be converted into a sampling voltage. The comparator compares the sampling voltage corresponding to the obtained input current with the maximum or minimum drive voltage output by the digital-to-analog converter, and inputs the comparison result to the logic drive module. The logic drive module determines the current control mode based on the comparison result. Then, based on the logic drive controller included in the terminal device, the input current of the stepper motor is controlled according to the determined current control mode. That is, logic drive module 1 controls the on and off of transistors 1, 2, 3, and 4 to control the input current of the stepper motor, and logic drive module 2 controls the on and off of transistors 5, 6, 7, and 8 to control the input current of the stepper motor.
[0089] When the stepper motor operates in current-increasing mode, switch S1 is connected to contact 1, and switch S2 is connected to contact 3. This allows the digital-to-analog converter (DAC) to output the maximum drive voltage to comparators 1 and 2. The sampled voltage corresponding to the input current of comparators 1 and 2 is compared with the maximum drive voltage. If the sampled voltage and the maximum drive voltage are equal, it indicates that the current input current equals the maximum drive current. Conversely, when the stepper motor operates in current-decreasing mode, switch S1 is connected to contact 2, and switch S2 is connected to contact 4. This allows the DAC to output the minimum drive voltage to comparators 1 and 2. The sampled voltage corresponding to the input current of comparators 1 and 2 is compared with the minimum drive voltage. If the sampled voltage and the minimum drive voltage are equal, it indicates that the current input current equals the minimum drive current.
[0090] In one embodiment, both logic driver module 1 and logic driver module 2 include at least a logic driver circuit.
[0091] In one embodiment, combined with Figure 4When current flows through transistor 1, the stepper motor coil, transistor 4, and sampling resistor 1, eventually reaching ground, this process represents the forward movement of the stepper motor. When NM1 and NM4 are turned off, transistors 3 and 2 are turned on. Since the equivalent model of a stepper motor is an inductor, based on the characteristics of inductance and current not changing abruptly, the current flows from ground to sampling resistor 1, transistor 3, the motor coil winding, and finally to the power supply via transistor 2. This process is the second attenuation mode. When transistors 3 and 4 are turned on, the change in the motor coil winding current during this process is defined as the first attenuation mode.
[0092] In one embodiment, combined with Figure 5 The current time corresponding to the first input current is T2, while the time corresponding to the input current of the stepper motor at the previous moment is T1. From the input current at these two moments, it can be seen that the overall current change trend of the stepper motor's input current is increasing. Therefore, in order to better control the rotation of the stepper motor, reduce noise and reduce step loss, the first decay mode with a smaller current reduction rate is used as the current control mode of the stepper motor, so that the torque value of the stepper motor gradually decreases.
[0093] In another specific implementation scenario, the current time corresponding to the first input current is T4, while the time corresponding to the input current of the stepper motor at the previous time is T3. It can be seen from the input current at these two times that the input current at time T4 is less than the input current at time T3. The overall current change trend of the stepper motor's input current is decreasing. Therefore, in order to better control the rotation of the stepper motor, reduce noise and step loss, a hybrid attenuation mode that alternates between the first attenuation mode and the second attenuation mode is used as the current control mode of the stepper motor, so that the torque value of the stepper motor gradually decreases.
[0094] In one embodiment of this application, the current decay mode includes a first decay mode and a second decay mode, wherein the current decrease rate corresponding to the first decay mode is less than the current decrease rate corresponding to the second decay mode.
[0095] If the first input current equals the maximum drive current, then the current control mode of the stepper motor is determined to be the current decay mode, including:
[0096] Obtain the inductance value of the stepper motor coil.
[0097] If the inductance value is less than the preset threshold and the first input current is equal to the maximum drive current, then the current control mode of the stepper motor is determined to be a mode that alternates between the first attenuation mode and the second attenuation mode.
[0098] In this embodiment, when the inductance of the stepper motor coil is less than a preset threshold, in order to make the waveform of the stepper motor's input current closer to the corresponding sine or cosine waveform, thereby controlling the magnitude of the stepper motor's input current to make the stepper motor run more smoothly, if the first input current is equal to the maximum drive current, then the current control mode of the stepper motor is determined to be an alternating mode of the first attenuation mode and the second attenuation mode. This ensures that when controlling the magnitude of the stepper motor's input current according to this current control mode, the current at different times will not change significantly, that is, the flatness of the sine or cosine waveform of the input current will be better. When the stepper motor is running, the magnetic field will not change significantly due to too much change in the current flowing through the coil, resulting in greater noise and vibration, increased step losses, and worse rotor rotation control.
[0099] It is understandable that the alternation between the first and second attenuation modes is a mixed attenuation mode.
[0100] In one embodiment, to better control the operation of the stepper motor, for a mode that alternates between a first attenuation mode and a second attenuation mode, a weight corresponding to each attenuation mode is preset. The weight describes the duration of the input current used to control the magnitude of the stepper motor's operation within a specified current attenuation time.
[0101] For example, if the ratio of the first attenuation mode to the second attenuation mode is set to 1:3, and the specified current attenuation time is 4 seconds, it means that the first attenuation mode controls the input current of the stepper motor for 1 second, and the second attenuation mode controls the input current of the stepper motor for 3 seconds.
[0102] In one embodiment of this application, after determining that the current control mode of the stepper motor is the current decay mode, the method further includes:
[0103] After the specified current decay time is reached, the current second input current of the stepper motor is obtained.
[0104] If the second input current is less than the minimum drive current of the stepper motor, the current control mode of the stepper motor is adjusted from the current decay mode to the current increase mode; wherein, when the stepper motor is running in the current increase mode, the input current of the stepper motor gradually increases.
[0105] As an example of this application, in order to make the stepper motor rotate more smoothly and with less noise, the specified current decay time can be preset according to actual needs.
[0106] In this embodiment, the stepper motor is controlled in current decay mode. This means that for the current step number, the input current of the stepper motor needs to be gradually reduced. Since the stepper motor may stop rotating or rotate very slowly when the input current decreases to a certain level, after reaching the specified current decay time, indicating that the set time difference for input current decay has been reached, the input current needs to be increased to continue driving the stepper motor rotor to accelerate. It is necessary to obtain the current second input current of the stepper motor in advance and compare it with the minimum drive current during stepper motor operation to determine whether the input current has decreased to the minimum drive current, thus determining the starting point for further current increase. Next, the current control mode of the stepper motor is adjusted from current decay mode to current increase mode to gradually increase the input current of the stepper motor, causing the rotor of the stepper motor to continue accelerating.
[0107] Understandably, if the second input current is equal to the minimum drive current of the stepper motor during operation, the current control mode of the stepper motor will also be adjusted from the current decay mode to the current increase mode.
[0108] In one embodiment, after determining that the current control mode of the stepper motor is the current decay mode, a timer is started, the timer duration is obtained, and the timer duration is compared with a preset specified current decay duration. If it is determined that the timer duration is equal to the preset specified current decay duration, then it is determined that the specified current decay duration has been reached.
[0109] In one embodiment of this application, the limiting drive current is the minimum drive current, and the specific implementation of determining the current control mode of the stepper motor based on the comparison result of the current magnitude includes:
[0110] If the first input current is equal to the minimum drive current, then the current control mode of the stepper motor is determined to be the current increase mode; wherein, when the stepper motor is running in the current increase mode, the input current of the stepper motor gradually increases.
[0111] In this embodiment, when the current control mode of the stepper motor is the current decay mode, the overall current change trend of the stepper motor's input current is decreasing. Since it is also necessary to control the continued rotation of the stepper motor to provide support for external devices, if the first input current is equal to the minimum drive current, the current control mode of the stepper motor is determined to be the current increase mode. This allows the stepper motor's input current to gradually increase when it is running in the current increase mode, causing the stepper motor's rotor to rotate faster. At the same time, it allows the waveform of the stepper motor's input current to fit better with a sine or cosine waveform, thus better controlling the operation of the stepper motor.
[0112] In one embodiment, the minimum drive current corresponds to the minimum drive voltage, and the first input current is equal to the minimum drive current when the input voltage corresponding to the first input current is equal to the minimum drive voltage.
[0113] In one embodiment, if the first input current is equal to the minimum drive current within a specified current decay time, the current control mode of the stepper motor is determined to be the current increase mode; wherein, when the stepper motor is running in the current increase mode, the input current of the stepper motor gradually increases.
[0114] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0115] The stepper motor control method provided in this application determines the current step number corresponding to the current rotation angle of the rotor in the total number of steps required for the rotor to rotate one revolution, and obtains the current first input current of the stepper motor. Based on the current step number and the current input current, the input current of the stepper motor is controlled to increase or decrease. For example, when the current input current reaches the limit current corresponding to the current step number, the input current of the stepper motor is switched to increase or decrease, so that the stepper motor can reach the appropriate position when the current reaches the limit value, resulting in more accurate rotation and less step loss.
[0116] Corresponding to the stepper motor control method in the above embodiments, Figure 6 A structural block diagram of a stepper motor control device provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiment of this application are shown.
[0117] Reference Figure 6 The control device 100 includes:
[0118] The determination module 101 is used to determine the current number of steps of the stepper motor. The current number of steps is the number of steps corresponding to the current rotation angle of the rotor out of the total number of steps required for the rotor of the stepper motor to rotate one revolution.
[0119] The acquisition module 102 is used to acquire the current first input current of the stepper motor;
[0120] The control module 103 is used to control the input current of the stepper motor during operation based on the current number of steps and the first input current.
[0121] In one embodiment, the control module 103 is further configured to acquire a preset limit drive current corresponding to the current step number, wherein the limit drive current is the maximum or minimum drive current when the stepper motor is running; compare the first input current and the limit drive current to obtain a current magnitude comparison result; determine the current control mode of the stepper motor according to the current magnitude comparison result; and control the input current magnitude of the stepper motor according to the current control mode.
[0122] In one embodiment, the control module 103 is further configured to determine that the current control mode of the stepper motor is a current decay mode if the first input current is equal to the maximum drive current; wherein, when the stepper motor is running in the current decay mode, the input current of the stepper motor gradually decreases.
[0123] In one embodiment, the current decay mode includes a first decay mode and a second decay mode, wherein the current decrease rate corresponding to the first decay mode is less than the current decrease rate corresponding to the second decay mode.
[0124] The control module 103 is also used to obtain the inductance value of the stepper motor's coil. If the inductance value is greater than or equal to a preset threshold, the first input current is equal to the maximum drive current, and the first input current is greater than or equal to the stepper motor's input current at the previous moment, then the current control mode of the stepper motor is determined to be the first attenuation mode; if the inductance value is greater than or equal to the preset threshold, the first input current is equal to the maximum drive current, and the first input current is less than the stepper motor's input current at the previous moment, then the current control mode of the stepper motor is determined to be a mode that alternates between the first attenuation mode and the second attenuation mode.
[0125] In one embodiment, the current decay mode includes a first decay mode and a second decay mode, wherein the current decrease rate corresponding to the first decay mode is less than the current decrease rate corresponding to the second decay mode.
[0126] The control module 103 is also used to obtain the inductance value of the stepper motor coil; if the inductance value is less than a preset threshold and the first input current is equal to the maximum drive current, then the current control mode of the stepper motor is determined to be a mode in which the first attenuation mode and the second attenuation mode alternate.
[0127] In one embodiment, the acquisition module 102 is further configured to acquire the current second input current of the stepper motor after a specified current decay time has been reached.
[0128] The control module 103 is also used to adjust the current control mode of the stepper motor from the current decay mode to the current increase mode if the second input current is less than the minimum drive current of the stepper motor during operation; wherein, when the stepper motor is running in the current increase mode, the input current of the stepper motor gradually increases.
[0129] In one embodiment, the control module 103 is further configured to determine that the current control mode of the stepper motor is the current increase mode if the first input current is equal to the minimum drive current; wherein, when the stepper motor is running in the current increase mode, the input current of the stepper motor gradually increases.
[0130] This embodiment provides a stepper motor control device for implementing any stepper motor control method in the method embodiment. The functions of each module can be referred to the corresponding descriptions in the method embodiment. Their implementation principles and technical effects are similar, and will not be repeated here.
[0131] The stepper motor control device provided in this application determines the current step number corresponding to the current rotation angle of the rotor in the total number of steps required for the rotor to rotate one revolution, and obtains the current first input current of the stepper motor. Based on the current step number and the current input current, the device controls the magnitude of the input current when the stepper motor is running. For example, when the current input current reaches the limit current corresponding to the current step number, the device switches to increase or decrease the input current of the stepper motor, so that the stepper motor can reach the appropriate position just when the current reaches the limit value, resulting in more accurate rotation and less step loss.
[0132] Figure 7 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Figure 7 As shown, the terminal device 7 of this embodiment includes: at least one processor 70 ( Figure 7 The diagram shows only one processor, a memory 71, and a computer program 72 stored in the memory 71 and executable on at least one processor 70. When the processor 70 executes the computer program 72, it implements the steps in any of the above-described stepper motor control method embodiments.
[0133] The terminal device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will understand that... Figure 7 The example of terminal device 7 is merely an illustration and does not constitute a limitation on terminal device 7. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0134] The processor 70 can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0135] In some embodiments, memory 71 may be an internal storage unit of terminal device 7, such as a hard disk or memory of terminal device 7. In other embodiments, memory 71 may be an external storage device of terminal device 7, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on terminal device 7. Furthermore, memory 71 may include both internal storage units and external storage devices of terminal device 7. Memory 71 is used to store operating system, application programs, bootloader, data, and other programs, such as program code of computer programs. Memory 71 can also be used to temporarily store data that has been output or will be output.
[0136] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0137] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0138] This application also provides a terminal device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor. When the processor executes the computer program, it implements the steps in any of the above method embodiments.
[0139] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method embodiments.
[0140] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps described in the various method embodiments.
[0141] If the integrated unit is implemented as 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, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0142] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0143] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0144] In the embodiments provided in this application, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0145] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0146] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A control method of a stepping motor, characterized by, The method comprises the following steps: determining a current step number of the stepper motor, the current step number being a step number corresponding to a current rotation angle of a rotor of the stepper motor in a total step number required for the rotor to rotate one round; obtaining a current first input current of the stepper motor; controlling a size of an input current of the stepper motor during operation according to the current step number and the first input current; the step of controlling the size of the input current of the stepper motor during operation according to the current step number and the first input current comprises the following steps: obtaining a preset limit driving current corresponding to the current step number, the limit driving current being a maximum driving current or a minimum driving current of the stepper motor during operation, a difference between the maximum driving current and the minimum driving current corresponding to each step number being the same; comparing the first input current and the limit driving current to obtain a current size comparison result; determining a current control mode of the stepper motor according to the current size comparison result; controlling the size of the input current of the stepper motor during operation according to the current control mode; the limit driving current is the maximum driving current, and the step of determining the current control mode of the stepper motor according to the current size comparison result comprises the following step: if the first input current is equal to the maximum driving current, determining that the current control mode of the stepper motor is a current decay mode; wherein the input current of the stepper motor gradually decreases when the stepper motor operates in the current decay mode; the current decay mode comprises a first decay mode and a second decay mode, and a current decrease rate corresponding to the first decay mode is smaller than a current decrease rate corresponding to the second decay mode; the step of determining that the current control mode of the stepper motor is the current decay mode if the first input current is equal to the maximum driving current comprises the following steps: obtaining an inductance value of a coil of the stepper motor; if the inductance value is greater than or equal to a preset threshold value, the first input current is equal to the maximum driving current, and the first input current is greater than or equal to an input current of the stepper motor at a previous moment, determining that the current control mode of the stepper motor is the first decay mode; if the inductance value is greater than or equal to the preset threshold value, the first input current is equal to the maximum driving current, and the first input current is smaller than the input current of the stepper motor at the previous moment, determining that the current control mode of the stepper motor is a mode in which the first decay mode and the second decay mode are alternately changed; the current decay mode comprises a first decay mode and a second decay mode, and a current decrease rate corresponding to the first decay mode is smaller than a current decrease rate corresponding to the second decay mode; the step of determining that the current control mode of the stepper motor is the current decay mode if the first input current is equal to the maximum driving current comprises the following steps: obtaining an inductance value of a coil of the stepper motor; if the inductance value is smaller than a preset threshold value, and the first input current is equal to the maximum driving current, determining that the current control mode of the stepper motor is a mode in which the first decay mode and the second decay mode are alternately changed. The first attenuation mode and the second attenuation mode are respectively corresponding to a preset proportion, and the proportion is used to describe a time length of an input current size for controlling the operation of the stepper motor in a specified current attenuation time length.
2. The control method according to claim 1, characterized by, After determining that the current control mode of the stepper motor is the current attenuation mode, the method further includes: After the specified current attenuation time length is reached, a current second input current of the stepper motor is obtained; If the second input current is less than the minimum driving current of the stepper motor, the current control mode of the stepper motor is adjusted from the current attenuation mode to a current increasing mode; when the stepper motor operates in the current increasing mode, the input current of the stepper motor gradually increases.
3. The control method according to claim 1, characterized by, The limit driving current is the minimum driving current, and the determination of the current control mode of the stepper motor according to the current size comparison result includes: If the first input current is equal to the minimum driving current, it is determined that the current control mode of the stepper motor is the current increasing mode; when the stepper motor operates in the current increasing mode, the input current of the stepper motor gradually increases.
4. A control device for a stepping motor, characterized by comprising: The method includes: A determination module is configured to determine a current step number of the stepper motor, the current step number being a step number corresponding to a current rotation angle of a rotor of the stepper motor in a total step number required for one rotation of the rotor; An acquisition module is configured to acquire a current first input current of the stepper motor; A control module is configured to control an input current size of the stepper motor during operation according to the current step number and the first input current; The control of the input current size of the stepper motor during operation according to the current step number and the first input current includes: A limit driving current corresponding to the current step number is acquired, the limit driving current being a maximum driving current or a minimum driving current of the stepper motor during operation, and a difference between the maximum driving current and the minimum driving current corresponding to each step number is the same; The first input current and the limit driving current are compared to obtain a current size comparison result; A current control mode of the stepper motor is determined according to the current size comparison result; An input current size of the stepper motor during operation is controlled according to the current control mode; The limit driving current is the maximum driving current, and the determination of the current control mode of the stepper motor according to the current size comparison result includes: If the first input current is equal to the maximum driving current, it is determined that the current control mode of the stepper motor is a current attenuation mode; when the stepper motor operates in the current attenuation mode, the input current of the stepper motor gradually decreases; The current attenuation mode includes a first attenuation mode and a second attenuation mode, and a current decrease rate corresponding to the first attenuation mode is less than a current decrease rate corresponding to the second attenuation mode; The determination of the current control mode of the stepper motor according to the first input current being equal to the maximum driving current includes: An inductance value of a coil of the stepper motor is acquired; If the inductance value is greater than or equal to the preset threshold value, the first input current is equal to the maximum driving current, and the first input current is greater than or equal to the input current of the stepper motor at the previous moment, it is determined that the current control mode of the stepper motor is the first decay mode. If the inductance value is greater than or equal to the preset threshold value, the first input current is equal to the maximum driving current, and the first input current is less than the input current of the stepper motor at the previous moment, it is determined that the current control mode of the stepper motor is a mode in which the first decay mode and the second decay mode are alternately changed. The current decay mode includes a first decay mode and a second decay mode, and the current reduction rate corresponding to the first decay mode is less than the current reduction rate corresponding to the second decay mode. If the first input current is equal to the maximum driving current, it is determined that the current control mode of the stepper motor is a current decay mode, including: obtaining an inductance value of a coil of the stepper motor; If the inductance value is less than a preset threshold value, and the first input current is equal to the maximum driving current, it is determined that the current control mode of the stepper motor is a mode in which the first decay mode and the second decay mode are alternately changed. The first decay mode and the second decay mode correspond to preset proportions, and the proportions are used to describe the time length of the input current for controlling the operation of the stepper motor within a specified current decay time.
5. A terminal device, characterized by, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the control method of any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the control method of any one of claims 1 to 3.
Citation Information
Patent Citations
Stepping motor driving system and motor system
CN113809962A