Initialization method and device for correlation point of electric angle and mechanical angle of stepping motor
By aligning the stepper motor rotor to the D-axis, calculating the theoretical and measured changes in the mechanical angle, and setting the number of successful follow-ups and the error threshold, the problem of mechanical angle jitter and error in stepper motors under unstable or heavy load conditions is solved. This achieves high-precision correlation between electrical and mechanical angles, improving the performance of the servo control system.
Patent Information
- Application Number
- CN202511539106.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-27
- Publication Date
- 2026-02-24
AI Technical Summary
In the existing technology, if the load is unstable or too heavy, the stepper motor is forced to align the D-axis during electrical angle changes, which can easily cause mechanical angle jitter and errors, affecting the initialization accuracy.
After achieving D-axis alignment with the stepper motor rotor, the electrical angle is adjusted at a constant speed. The following error of the theoretical and measured changes in the mechanical angle is calculated. The number of successful follow-ups and the error threshold are set, and a closed-loop confirmation mechanism is established to ensure a high-precision correlation between the electrical angle and the mechanical angle.
It effectively filters out mechanical jitter and minor step loss errors caused by load, ensuring high precision and high reliability of the initial correlation point between electrical angle and mechanical angle, and improving the performance and adaptability of the servo control system.
Smart Images

Figure CN121566972A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor control technology, and in particular to a method and apparatus for initializing the correlation point between the electrical angle and mechanical angle of a stepper motor. Background Technology
[0002] Stepper motors are widely used in the servo control industry. For cost-saving purposes, relative counting photoelectric encoders with ABZ signals are often used in high-precision control scenarios. Closed-loop control systems are generally employed to avoid issues like missed steps and stalling that occur in open-loop control, resulting in superior reliability, stability, and accuracy. In closed-loop control of stepper motors, parameter initialization requires finding the correlation point between the electrical and mechanical angles. Currently, the commonly used stepper motors in the industry are 50-pole pairs. Electrical angle alignment is achieved using a D-axis DC injection method, and changes in electrical angle forcefully pull the stepper motor to rotate synchronously by a certain displacement. This establishes a stable following relationship between the electrical and mechanical angles, which is then used to determine the initial correlation point between them.
[0003] This method is simple and effective, and can meet the requirements in typical application scenarios. However, during the process of forcibly aligning the D-axis by changing the electrical angle, if the load is unstable or too heavy, it can easily cause mechanical angle jitter, resulting in errors. Summary of the Invention
[0004] This invention provides a method and apparatus for initializing the correlation point between the electrical angle and the mechanical angle of a stepper motor, in order to solve the defect in the prior art that if the load is unstable or too heavy, mechanical angle jitter is easily caused during the process of forcibly aligning the D-axis when the electrical angle changes, thus generating errors.
[0005] This invention provides a method for initializing the correlation points between the electrical and mechanical angles of a stepper motor, comprising: Step S1: With the rotor of the stepper motor aligned to the D-axis, the electrical angle of the stepper motor is adjusted at a constant speed to obtain the current electrical angle change value and the mechanical angle change value corresponding to the electrical angle. Step S2: Calculate the theoretical change value of the mechanical angle based on the current electrical angle change value. Calculate the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, increment the number of successful following attempts by one. Step S3: Repeat steps S1 to S2 until the number of successful follow-ups reaches a preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
[0006] According to the present invention, an initialization method for the correlation point between the electrical angle and the mechanical angle of a stepper motor is provided, wherein the following step, based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle, calculates the following tracking error, and then further includes: If the following error exceeds a preset error threshold, the number of successful following attempts will be reset to zero. Repeat steps S1 to S2 until the number of successful follow-ups reaches the preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
[0007] According to the present invention, an initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor is provided, the method further includes: If the current electrical angle change value is greater than the preset electrical angle change threshold, the adjustment direction of the electrical angle is changed to obtain the current electrical angle change value when the electrical angle decreases or increases at a constant speed, and the mechanical angle measurement change value corresponding to the electrical angle.
[0008] According to the present invention, an initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor is provided, the method further includes: If the direction of adjustment of the electrical angle changes, the number of adjustment directions is incremented by one. If the number of adjustment directions exceeds a preset adjustment number threshold, the initialization of the electrical angle and mechanical angle association point is terminated.
[0009] According to the present invention, an initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor is provided, wherein the initial electrical angle of the stepper motor is 0.
[0010] According to the present invention, an initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor is provided, wherein the method includes the following steps before step S1: Injecting operating current into the D-axis of the rotor to achieve D-axis alignment of the rotor; The operating current gradually and smoothly increases to the maximum operating current of the rotor.
[0011] The present invention also provides an initialization device for the correlation point between the electrical angle and the mechanical angle of a stepper motor, comprising: The measuring unit, with the rotor of the stepper motor aligned to the D-axis, uniformly adjusts the electrical angle of the stepper motor to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value. The comparison unit calculates the theoretical change value of the mechanical angle based on the current electrical angle change value, and calculates the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, the number of successful following is incremented by one. The cyclic accumulation unit repeatedly executes the step measurement unit and comparison unit until the number of successful follow-ups reaches a preset follow-up threshold, and the last electrical angle and mechanical angle are used as the initial association point.
[0012] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the initialization method for the correlation point between the electrical angle and mechanical angle of the stepper motor as described above.
[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the initialization method for the correlation point between the electrical and mechanical angles of a stepper motor as described above.
[0014] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor as described above.
[0015] The method and apparatus for initializing the correlation point between the electrical and mechanical angles of a stepper motor provided by this invention establishes a closed-loop confirmation mechanism by setting dual thresholds for following error and the number of consecutive successful steps. This method effectively filters out errors caused by mechanical jitter and minor step loss during the motor startup phase under heavy or unstable loads, ensuring high precision and reliability of the established initial correlation point between the electrical and mechanical angles. Ultimately, this allows the stepper motor to obtain accurate initialization parameters even under harsh operating conditions, providing a solid foundation for its subsequent stable and powerful operation, and significantly improving the performance and adaptability of the entire servo control system. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the method for initializing the correlation points between the electrical and mechanical angles of a stepper motor provided by the present invention. Figure 2This is a schematic diagram of the structure of the initialization device for the correlation point between the electrical angle and mechanical angle of a stepper motor provided by the present invention; Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0019] To address the aforementioned issues, this invention provides an initialization method for the correlation points between the electrical and mechanical angles of a stepper motor, enabling high-precision alignment of the electrical and mechanical angles under scenarios with unstable or excessively heavy loads. Figure 1 This is a flowchart illustrating the initialization method for the correlation points between the electrical and mechanical angles of a stepper motor provided by the present invention. Figure 1 As shown, the method includes: Step S1: With the rotor of the stepper motor aligned with the D-axis, the electrical angle of the stepper motor is adjusted at a constant speed to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value.
[0020] Here, achieving D-axis alignment of the stepper motor rotor refers to generating a static, fixed-direction composite magnetic field by injecting a specific DC current into the stator windings. This magnetic field forcibly attracts and locks the stepper motor rotor to a stable position aligned with the stator magnetic field. The purpose of this process is to establish a known and stable relative state of initial electrical and mechanical angles for subsequent rotational control and to provide sufficient static holding torque to resist initial load disturbances. The D-axis here typically refers to the coordinate axis aligned with the rotor flux linkage direction.
[0021] Specifically, firstly, a DC current can be injected into the D-axis of the stepper motor. This current can be smoothly increased from zero until it reaches the motor's rated operating current or a preset value sufficient to overcome the static friction of the load. This process ensures that the motor rotor can stably align with the D-axis, completing the D-axis alignment. After alignment, the D-axis current is maintained, and the control system begins to adjust the electrical angle at a constant speed. For example, it can be set to drive the electrical angle to rotate in one direction at a constant angular velocity. During the rotation of the electrical angle, a fixed electrical angle increment can be used as a monitoring cycle. For example, the electrical angle increment is a change of 10 degrees.
[0022] At the beginning of a monitoring cycle, the current mechanical angle M1 is recorded by the encoder; at the end of the monitoring cycle, the mechanical angle is recorded again. Then, the change in mechanical angle measurement within that cycle is calculated. The change in electrical angle within that cycle is taken as the current electrical angle change value.
[0023] It should be noted that actively driving the motor to rotate and synchronously collecting data on changes in electrical and mechanical angles provides a foundation for real-time dynamic data input for subsequent accurate verification, which is a prerequisite for achieving closed-loop verification.
[0024] Step S2: Calculate the theoretical change value of the mechanical angle based on the current electrical angle change value. Calculate the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, increment the number of successful following attempts by one.
[0025] Here, the theoretical change in mechanical angle refers to the physical rotation angle that the motor rotor should exhibit when the electrical angle changes by a given value, under ideal conditions where the motor does not experience step loss or jitter. This value is determined by the inherent physical parameters of the stepper motor, particularly the number of pole pairs. The calculation relationship is: Theoretical change in mechanical angle = Current change in electrical angle / Number of pole pairs of the stepper motor. For example, for a 50-pole stepper motor, a 360-degree change in electrical angle should result in a mechanical angle change of 360 / 50 = 7.2 degrees.
[0026] Furthermore, the following error refers to the deviation between the measured change in mechanical angle and the theoretical change in mechanical angle, usually expressed as its absolute value. This error value directly reflects the difference between the actual movement of the motor rotor and the control command. The following error is a core indicator for judging whether a motor can stably and accurately follow changes in electrical angle.
[0027] The number of successful follow-ups here refers to a counter variable used to accumulate the number of monitoring cycles in which the motor continuously meets the error requirements.
[0028] Specifically, after obtaining the current electrical angle change value and the measured mechanical angle change value within a monitoring cycle in step S1, the theoretical mechanical angle change value can first be calculated based on the number of pole pairs of the stepper motor. Then, the absolute value of the difference between the measured mechanical angle change value and the theoretical mechanical angle change value is calculated to obtain the following error. Next, this following error is compared with a preset error threshold. If the following error is less than the preset error threshold, it indicates that the motor's mechanical rotation accurately follows the electrical angle change within that monitoring cycle, and the control system increments the number of successful following S1 by one.
[0029] It is important to note that if a tracking error is detected to be greater than or equal to a preset error threshold, it indicates that the motor may be experiencing jitter or loss of synchronization. In this case, the number of successful tracking attempts (S1) should be reset to zero. This ensures that subsequent success judgments must be based on continuous and stable tracking. This step establishes a dynamic and quantitative error verification mechanism by introducing a real-time comparison between theoretical and actual values. This mechanism can accurately capture minute loss of synchronization or jitter that may occur in the motor under heavy loads, thus providing a reliable basis for judging the stability of motor operation.
[0030] Step S3: Repeat steps S1 to S2 until the number of successful follow-ups reaches a preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
[0031] Here, the initial association point refers to the pairing of an electrical angle value and its precise corresponding mechanical angle value determined after successful initialization. This association point will serve as the reference point or zero point for the entire closed-loop servo control system, and all subsequent angle and position calculations will be based on this point.
[0032] Specifically, step S3 is the loop control and termination judgment stage of the entire initialization process. This is achieved by repeatedly executing the drive and data acquisition process of step S1, and the error calculation and verification process of step S2. After each monitoring cycle, it is checked whether the number of successful follow-ups has reached the preset follow-up threshold. As long as the number of successful follow-ups has not reached the preset follow-up threshold, the loop continues. Once the value of the number of successful follow-ups is detected to be equal to the preset follow-up threshold, it means that the motor has achieved high-precision stable following within the monitoring cycle for the preset follow-up threshold number of consecutive times. At this point, it can be determined that the motor is fully synchronized and the initialization conditions are met. Therefore, the loop is immediately stopped, and the current electrical angle value and the current mechanical angle value fed back by the encoder are recorded. This pair of values is formally established as the initial correlation point and stored for use by the subsequent closed-loop control algorithm. Thus, the entire initialization process is successfully completed.
[0033] The method provided in this invention establishes a closed-loop confirmation mechanism by setting dual thresholds for following error and the number of consecutive successful steps. This method effectively filters out errors caused by mechanical jitter and minor step loss during motor startup under heavy or unstable loads, ensuring high accuracy and reliability of the established initial correlation point between electrical and mechanical angles. Ultimately, this allows the stepper motor to obtain accurate initialization parameters even under harsh operating conditions, providing a solid foundation for its subsequent stable and powerful operation, and significantly improving the performance and adaptability of the entire servo control system.
[0034] Based on any of the above embodiments, the following steps are performed after calculating the following: based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error exceeds a preset error threshold, the number of successful following attempts will be reset to zero. Repeat steps S1 to S2 until the number of successful follow-ups reaches the preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
[0035] Here, resetting the number of successful follow-ups to zero is a crucial fault-tolerance and error-correction step in this embodiment. This step means that if, within any monitoring cycle, the deviation between the actual and theoretical motion of the motor rotor exceeds an acceptable range—that is, the following error exceeds a preset error threshold—then the motor following can be considered unstable, and any previously accumulated consecutive successful following records will be invalidated, and the counter will be immediately reset to zero.
[0036] It should be noted that the purpose of this operation is to ensure that the final successful determination is based on a completely continuous and uninterrupted stable following process, thereby eliminating the influence of any false stable state caused by factors such as load changes or transient interference on the final result.
[0037] Specifically, after calculating the tracking error, a conditional judgment is executed: if the tracking error is less than the preset error threshold, the tracking within this monitoring period is considered accurate, and the number of successful tracking attempts S1 is incremented by one; if the tracking error is greater than or equal to the preset error threshold, the tracking is determined to have failed. At this point, the number of successful tracking attempts is immediately reset to zero.
[0038] Subsequently, regardless of the outcome of this judgment, the next monitoring cycle will begin, and steps S1 and S2 will be repeated. Only if the judgment result is "successful following" within a monitoring cycle of a consecutive preset following count threshold number of times can the number of successful followings be prevented from being reset to zero and eventually accumulated to the preset following count threshold, thus satisfying the initialization success condition.
[0039] To more clearly illustrate the technical effects of this embodiment, the following example is given: Assume that the preset follow - up times threshold S = 5, and the preset error threshold E3 is 0.1 degree. In the first monitoring cycle, the calculated follow - up error is 0.05 degree, and the follow - up error < E3, so the follow - up success times S1 becomes 1. In the second monitoring cycle, the calculated follow - up error is 0.06 degree, and the follow - up error < E3, so the follow - up success times S1 becomes 2. In the third monitoring cycle, due to a sudden load fluctuation, the motor generates a slight jitter, and the calculated follow - up error is 0.2 degree, and the follow - up error >= E3. At this time, the system determines that the follow - up fails and immediately performs the operation of clearing the follow - up success times, and the follow - up success times S1 changes from 2 to 0. In the fourth monitoring cycle, the motor operation resumes stability, the calculated follow - up error is 0.04 degree, and the follow - up error < E3, so the follow - up success times S1 starts to be recounted from 0 and becomes 1. After that, it must follow successfully continuously for another 4 times to accumulate S1 from 1 to 5 before finally determining that the initialization is successful.
[0040] The method provided by the embodiment of the present invention, by introducing and clarifying the mechanism of clearing when failure occurs, the method of this embodiment establishes a more strict and reliable screening criterion. It ensures that only after the motor truly overcomes the load disturbance and enters a continuous and stable synchronous operation state can the initial correlation point be confirmed. This design greatly improves the robustness and anti - interference ability of the initialization process, can effectively avoid misjudgment caused by accidental and instantaneous system disturbances, and ensures that under various dynamically changing load conditions, this initialization method can obtain consistent and high - precision results, thus providing a strong guarantee for the reliable operation of the stepping motor in heavy - load and high - precision application scenarios.
[0041] Based on any of the above embodiments, the method further includes: When the current electrical angle change value is greater than the preset electrical angle change threshold, change the adjustment direction of the electrical angle to obtain the current electrical angle change value when the electrical angle decreases or increases uniformly, and the corresponding mechanical angle measurement change value of the electrical angle.
[0042] Here, the preset electrical angle change threshold refers to an upper limit value used to limit the one - way rotation range, specifically referring to the total cumulative change in the same direction since the start of adjusting the electrical angle. For example, it can be set to 720 electrical degrees. The function of this threshold is to be used as a basis for timeout judgment. It should be noted that if the motor still fails to meet the condition of continuous successful follow - up after rotating in one direction for a sufficient distance, it can be considered that there is little meaning in continuing to try in this direction, and it may encounter specific load resistance or be in an unfavorable initial position. At this time, triggering the commutation mechanism can avoid the motor from rotating endlessly or with excessive displacement, saving the initialization time and protecting the mechanical structure.
[0043] Specifically, initialization can be performed according to the method described in any of the above embodiments. For example, the electrical angle is set to increase uniformly from 0, and multi-point monitoring and verification are performed in real time. During the loop execution of steps S1 and S2, in addition to monitoring the number of successful follow-ups, the cumulative increase in electrical angle since the start of rotation is also monitored in parallel.
[0044] At the end of each monitoring cycle, the following judgments can be made: First, determine whether the number of successful follow-ups has reached the preset follow-up threshold. If it has, the initialization is successful and the process ends. If it has not, further determine whether the cumulative increase in electrical angle has exceeded the preset electrical angle change threshold. If it has not exceeded the preset electrical angle change threshold, continue executing the next round of steps S1 and S2 along the current direction of increase. If it has exceeded the preset electrical angle change threshold, it indicates that enough attempts have been made in the current direction but without success.
[0045] At this point, a reversal mechanism will be triggered, changing the direction of the electrical angle adjustment. For example, switching from a constant increase to a constant decrease. Simultaneously, the number of successful follow-ups can continue to accumulate. The subsequent process is similar; if a preset threshold of consecutive follow-ups is successfully accumulated in the direction of decreasing electrical angle, initialization is successful.
[0046] The method provided in this invention introduces an intelligent fault-tolerance and retry strategy to the stepper motor initialization method by adding a judgment mechanism between the current electrical angle change value and the preset electrical angle change threshold. This avoids prolonged invalid attempts under adverse conditions and significantly improves the probability of finding a stable correlation point by actively changing the adjustment direction of the electrical angle. This gives the initialization process basic adaptive adjustment capabilities, resulting in a higher initialization success rate and shorter average time when facing unknown or complex load characteristics, further enhancing the robustness and practical value of the method in actual industrial applications.
[0047] Based on any of the above embodiments, the method further includes: If the direction of adjustment of the electrical angle changes, the number of adjustment directions is incremented by one. If the number of adjustment directions exceeds a preset adjustment number threshold, the initialization of the electrical angle and mechanical angle association point is terminated.
[0048] Here, the number of direction adjustments quantifies the total number of reverse rotation attempts made during the entire initialization process to find a stable following point. Additionally, the preset adjustment threshold refers to a pre-defined integer value representing the maximum tolerable number of commutations. For example, the preset adjustment threshold can be set to 3. It should be noted that this threshold serves as a final circuit breaker mechanism for the entire initialization process. If the motor fails to achieve continuous and stable following after repeatedly attempting the preset adjustment threshold in both forward and reverse directions, it is reasonable to assume that there is a serious problem that the algorithm cannot overcome on its own. For example, severe load jamming, motor or encoder hardware failure, incorrect parameter settings, etc. In this case, initialization should be terminated decisively, and the fault reported.
[0049] Specifically, the initialization process begins and is performed according to the method described in any of the above embodiments. When it is necessary to change the adjustment direction of the electrical angle because the cumulative value of the electrical angle in a single direction exceeds a preset electrical angle change threshold, the adjustment direction count is immediately incremented by one while performing the reversal operation.
[0050] After accumulating the number of direction adjustments, the system does not immediately begin attempting a reverse rotation. Instead, a crucial check is performed first: the current number of direction adjustments is compared to a preset adjustment threshold. If the number of adjustments is less than or equal to the threshold, it indicates that the number of attempts has not been exhausted, and the multi-point monitoring and verification loop will restart in the new rotation direction, following the initialization method.
[0051] If the number of direction adjustments exceeds the preset adjustment threshold, it indicates that a sufficient number of attempts have been made, all of which have failed. At this point, it can be determined that the initialization cannot be successful, and the initialization of the electrical and mechanical angle correlation points should be terminated immediately. This means the entire process of finding the correlation points will be terminated, resulting in a clear failure status.
[0052] In one embodiment, assume the preset adjustment count threshold is 2. Initially, an attempt is made to initialize in the positive direction, but if the accumulated electrical angle value exceeds the preset electrical angle change threshold and the attempt is unsuccessful, then the adjustment direction of the electrical angle is prepared to be changed. At this time, the adjustment count is incremented from 0 to 1. Since 1 <= the preset adjustment count threshold (2), the attempt is switched to the opposite direction.
[0053] If the cumulative electrical angle value exceeds the preset electrical angle change threshold again and still fails to succeed in the opposite direction, then prepare to change direction again. At this time, the number of direction adjustments is incremented from 1 to 2. Since 2 <= the preset adjustment number threshold (2), switch back to the positive direction to continue trying. If the cumulative electrical angle value exceeds the preset electrical angle change threshold again and still fails to succeed in the positive direction, then prepare to change direction for the third time. At this time, the number of direction adjustments is incremented from 2 to 3. If it is found that 3 > the preset adjustment number threshold (2), the condition is met, so all actions are immediately terminated and an initialization failure is reported.
[0054] The method provided in this invention, by introducing a commutation count limit and a final failure determination mechanism, effectively prevents the system from getting stuck in an endless loop of forward and reverse attempts under extreme abnormal operating conditions, ensuring that the initialization process always ends within a finite time. Simultaneously, providing a definite failure exit point has significant practical implications, enabling timely feedback of problems to the upper-level control system or operators, prompting further hardware checks or parameter adjustments. This makes the entire initialization method not only perform excellently on the successful path but also possess determinism and predictability on the failure path, greatly improving the robustness, security, and engineering practicality of the entire system.
[0055] Based on any of the above embodiments, the initial electrical angle of the stepper motor is 0.
[0056] Based on any of the above embodiments, the steps preceding step S1 include: Injecting operating current into the D-axis of the rotor to achieve D-axis alignment of the rotor; The operating current gradually and smoothly increases to the maximum operating current of the rotor.
[0057] Specifically, firstly, a DC current can be injected into the D-axis of the stepper motor. This current can be smoothly increased from zero until it reaches the motor's rated operating current or a preset value sufficient to overcome the static friction of the load. This process ensures that the motor rotor can be stably aligned with the D-axis, thus completing the D-axis alignment.
[0058] Based on any of the above embodiments Figure 2 This is a schematic diagram of the structure of the initialization device for the correlation point between the electrical angle and mechanical angle of the stepper motor provided by the present invention, as shown in the figure. Figure 2 As shown, the device includes: The measuring unit 210, when the rotor of the stepper motor is aligned with the D-axis, uniformly adjusts the electrical angle of the stepper motor, obtains the current electrical angle change value and the corresponding mechanical angle measurement change value; The comparison unit 220 calculates the theoretical change value of the mechanical angle based on the current electrical angle change value, and calculates the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, the number of successful following is incremented by one. The cyclic accumulation unit 230 repeatedly executes the step measurement unit and comparison unit until the number of successful follow-ups reaches the preset follow-up threshold, and uses the last electrical angle and mechanical angle as the initial association point.
[0059] The device provided in this invention establishes a closed-loop confirmation mechanism by setting dual thresholds for following error and the number of consecutive successful steps. This method effectively filters out errors caused by mechanical jitter and minor step loss during motor startup under heavy or unstable loads, ensuring high accuracy and reliability of the established initial correlation point between electrical and mechanical angles. Ultimately, this allows the stepper motor to obtain accurate initialization parameters even under harsh operating conditions, providing a solid foundation for its subsequent stable and powerful operation, and significantly improving the performance and adaptability of the entire servo control system.
[0060] Based on any of the above embodiments, the comparison unit is further specifically used for: If the following error exceeds a preset error threshold, the number of successful following attempts will be reset to zero. Repeat steps S1 to S2 until the number of successful follow-ups reaches the preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
[0061] Based on any of the above embodiments, the measuring unit is further specifically used for: If the current electrical angle change value is greater than the preset electrical angle change threshold, the adjustment direction of the electrical angle is changed to obtain the current electrical angle change value when the electrical angle decreases or increases at a constant speed, and the mechanical angle measurement change value corresponding to the electrical angle.
[0062] Based on any of the above embodiments, the cyclic accumulation unit is further specifically used for: If the direction of adjustment of the electrical angle changes, the number of adjustment directions is incremented by one. If the number of adjustment directions exceeds a preset adjustment number threshold, the initialization of the electrical angle and mechanical angle association point is terminated.
[0063] Based on any of the above embodiments, the initial electrical angle of the stepper motor is 0.
[0064] Based on any of the above embodiments, an alignment unit is included before the measurement unit, and the alignment unit is specifically used for: Injecting operating current into the D-axis of the rotor to achieve D-axis alignment of the rotor; The operating current gradually and smoothly increases to the maximum operating current of the rotor.
[0065] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call the logic instructions in the memory 330 to execute an initialization method for the correlation point between the electrical angle and the mechanical angle of the stepper motor. The method includes: step S1, with the rotor of the stepper motor aligned to the D-axis, uniformly adjusting the electrical angle of the stepper motor to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value; step S2, calculating the theoretical mechanical angle change value based on the current electrical angle change value, calculating the following error based on the theoretical mechanical angle change value and the mechanical angle measurement change value, and accumulating the number of successful following once if the following error is less than a preset error threshold; step S3, repeating steps S1 to S2 until the number of successful following reaches a preset following number threshold, and using the last electrical angle and mechanical angle as the initial correlation point.
[0066] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0067] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the initialization method for the correlation point between the electrical angle and mechanical angle of the stepper motor provided by the above methods. The method includes: step S1, when the rotor of the stepper motor is aligned with the D-axis, uniformly adjusting the electrical angle of the stepper motor to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value; step S2, calculating the theoretical mechanical angle change value based on the current electrical angle change value, calculating the following error based on the theoretical mechanical angle change value and the mechanical angle measurement change value, and accumulating the number of successful following once when the following error is less than a preset error threshold; step S3, repeating steps S1 to S2 until the number of successful following reaches a preset following number threshold, and using the last electrical angle and mechanical angle as the initial correlation point.
[0068] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements an initialization method for the correlation point between the electrical angle and mechanical angle of a stepper motor provided by the methods described above. The method includes: step S1, with the rotor of the stepper motor aligned to the D-axis, uniformly adjusting the electrical angle of the stepper motor to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value; step S2, calculating the theoretical mechanical angle change value based on the current electrical angle change value, calculating the following error based on the theoretical mechanical angle change value and the mechanical angle measurement change value, and accumulating the number of successful following attempts once if the following error is less than a preset error threshold; step S3, repeating steps S1 to S2 until the number of successful following attempts reaches a preset following attempt threshold, and using the last electrical angle and mechanical angle as the initial correlation point.
[0069] The device embodiments described above are merely illustrative. 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0070] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0071] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention 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; and these 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 the present invention.
Claims
1. A method for initializing the correlation points between the electrical angle and mechanical angle of a stepper motor, characterized in that, include: Step S1: With the rotor of the stepper motor aligned to the D-axis, the electrical angle of the stepper motor is adjusted at a constant speed to obtain the current electrical angle change value and the mechanical angle change value corresponding to the electrical angle. Step S2: Calculate the theoretical change value of the mechanical angle based on the current electrical angle change value. Calculate the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, increment the number of successful following attempts by one. Step S3: Repeat steps S1 to S2 until the number of successful follow-ups reaches a preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
2. The method for initializing the correlation points between the electrical and mechanical angles of a stepper motor according to claim 1, characterized in that, The following steps further include calculating the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle: If the following error exceeds a preset error threshold, the number of successful following attempts will be reset to zero. Repeat steps S1 to S2 until the number of successful follow-ups reaches the preset follow-up threshold, and use the last electrical angle and mechanical angle as the initial association point.
3. The method for initializing the correlation points between the electrical and mechanical angles of a stepper motor according to claim 1, characterized in that, The method further includes: If the current electrical angle change value is greater than the preset electrical angle change threshold, the adjustment direction of the electrical angle is changed to obtain the current electrical angle change value when the electrical angle decreases or increases at a constant speed, and the mechanical angle measurement change value corresponding to the electrical angle.
4. The method for initializing the correlation points between the electrical and mechanical angles of a stepper motor according to claim 3, characterized in that, The method further includes: If the direction of adjustment of the electrical angle changes, the number of adjustment directions is incremented by one. If the number of adjustment directions exceeds a preset adjustment number threshold, the initialization of the electrical angle and mechanical angle association point is terminated.
5. The method for initializing the correlation point between the electrical angle and mechanical angle of a stepper motor according to any one of claims 1 to 4, characterized in that, The initial electrical angle of the stepper motor is 0.
6. The method for initializing the correlation point between the electrical angle and mechanical angle of a stepper motor according to any one of claims 1 to 4, characterized in that, Before step S1, the following is included: Injecting operating current into the D-axis of the rotor to achieve D-axis alignment of the rotor; The operating current gradually and smoothly increases to the maximum operating current of the rotor.
7. An initialization device for the correlation point between the electrical angle and mechanical angle of a stepper motor, characterized in that, include: The measuring unit, with the rotor of the stepper motor aligned to the D-axis, uniformly adjusts the electrical angle of the stepper motor to obtain the current electrical angle change value and the corresponding mechanical angle measurement change value. The comparison unit calculates the theoretical change value of the mechanical angle based on the current electrical angle change value, and calculates the following error based on the theoretical change value of the mechanical angle and the measured change value of the mechanical angle. If the following error is less than a preset error threshold, the number of successful following is incremented by one. The cyclic accumulation unit repeatedly executes the step measurement unit and comparison unit until the number of successful follow-ups reaches a preset follow-up threshold, and the last electrical angle and mechanical angle are used as the initial association point.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for initializing the stepper motor electrical angle and mechanical angle association point as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for initializing the correlation point between the electrical angle and mechanical angle of the stepper motor as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for initializing the correlation point between the electrical angle and mechanical angle of the stepper motor as described in any one of claims 1 to 6.