Motor speed measurement method, device, terminal equipment and storage medium

By calculating the counting direction change of the orthogonal pulse signal output by the encoder, obtaining the compensation amount, and correcting the abnormal level jump, the motor speed measurement error caused by the encoder signal error is solved, and high-precision measurement of the motor speed is achieved.

CN116338231BActive Publication Date: 2025-10-14CHIAPHUA COMPONENTS SHENZHEN
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211583755.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-09
Publication Date
2025-10-14
Estimated Expiration
2042-12-09

AI Technical Summary

Technical Problem

In the prior art, abnormal level fluctuations in the pulse signal output by the encoder lead to errors in measuring the motor speed, thus affecting the system's control over the motor.

Method used

By obtaining the orthogonal pulse signal output by the encoder, calculating the counting direction of the pulse edge, and calculating the compensation amount according to the change of the counting direction of adjacent pulse edges, the influence of abnormal level jump on the motor speed measurement is corrected.

Benefits of technology

The accuracy of motor speed measurement is improved, the interference of abnormal level jump on motor speed measurement is eliminated, and accurate measurement in a wide speed range is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116338231B_ABST
    Figure CN116338231B_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of electric machines, and provides a motor rotating speed measurement method, device, terminal equipment and storage medium, the method comprising: acquiring a pulse signal output by an encoder when a motor rotor rotates, the pulse signal comprising a first signal and a second signal, the first signal and the second signal being orthogonal pulses; obtaining a counting direction of a pulse edge according to a phase difference between the first signal and the second signal; obtaining a compensation amount according to the counting direction of adjacent pulse edges, the compensation amount being used to compensate for abnormal level jumps of the pulse signal; and obtaining the rotating speed of the motor according to the compensation amount and the pulse signal. By using the method, the problem that the motor rotating speed measured finally exists errors due to the existence of abnormal level jumps of the acquired pulse signal is solved, and accurate measurement of the motor rotating speed is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of motor technology, and in particular to a method, apparatus, terminal device, and storage medium for measuring motor speed. Background Art

[0002] In the field of motor control, accurate measurement of the motor's real-time speed is fundamental to achieving high-precision speed control. Encoders are commonly used in existing technologies to detect rotor position and calculate motor speed. However, in actual measurements, factors such as encoder installation, electromagnetic interference, and mechanical vibration can affect the encoder's output pulse signal, causing occasional level fluctuations (abnormal level fluctuations) at the edges of the encoder's output pulse signal. Sometimes, the encoder output signal's level will fluctuate several times in a short period of time before returning to normal. The occurrence of abnormal level fluctuations can cause errors in the pulse edge count during that period, resulting in a discrepancy between the final measured pulse number and the actual number. This can cause errors in the motor speed measurement and affect the system's control of the motor.

[0003] The purpose of this application is to provide a method for accurately measuring the speed of a motor and eliminating the influence of abnormal level jumps on the speed measurement of the motor. Summary of the Invention

[0004] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for measuring motor speed, which can solve the problem of errors in the motor speed finally measured due to abnormal level jumps in the acquired pulse signal.

[0005] In a first aspect, an embodiment of the present application provides a method for measuring motor speed, comprising:

[0006] Acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;

[0007] Obtaining a counting direction of a pulse edge according to a phase difference between the first signal and the second signal;

[0008] Obtaining a compensation amount according to the counting direction of adjacent pulse edges, wherein the compensation amount is used to compensate for abnormal level jumps of the pulse signal;

[0009] The rotational speed of the motor is obtained according to the compensation amount and the pulse signal.

[0010] The above method calculates a compensation amount based on the change in the counting direction of adjacent pulse edges, compensating for the erroneous pulse signals generated by the encoder when an abnormal level jump occurs, thereby correcting the erroneous counting of pulse edges. The encoder's erroneous count is corrected using the compensation amount, and the motor speed is calculated based on the compensation amount and the pulse signal. This improves the accuracy of motor speed measurement and eliminates interference from abnormal level jumps on motor speed measurement.

[0011] In a possible implementation manner of the first aspect, the step of obtaining a counting direction of pulse edges according to a phase difference between the first signal and the second signal includes:

[0012] If it is determined that the phase of the first edge lags behind that of the second edge, the counting direction of the first edge is recorded as forward counting; if it is determined that the phase of the first edge leads that of the second edge, the counting direction of the first edge is recorded as reverse counting;

[0013] Of the first edge and the second edge, one is a pulse edge on the first signal, and the other is a pulse edge on the second signal; the first edge and the second edge are both rising edges, or both falling edges; the second edge is the pulse edge with the smallest absolute value of the phase difference relative to the first edge.

[0014] This method links abnormal level transitions to the counting direction of pulse edges and defines this direction, providing a standard for calculating compensation based on changes in the counting direction. Furthermore, defining the counting direction of pulse edges through the phase difference method allows this difficult-to-obtain physical quantity to be calculated, further enhancing the method's feasibility.

[0015] In a possible implementation manner of the first aspect, the step of obtaining the compensation amount according to the counting direction of adjacent pulse edges includes:

[0016] When the i-th pulse edge is counted in the positive direction, the direction value of the i-th pulse edge is recorded as 1, where i is a positive integer and i≥2;

[0017] When the i-th pulse edge is counted in reverse, the direction value of the i-th pulse edge is recorded as 0;

[0018] The compensation amount is calculated based on the difference between the direction value of the (i-1)th pulse edge and the direction value of the (i)th pulse edge;

[0019] The compensation amount is used to compensate the count value of the pulse edge to obtain an effective count value, and the effective count value is used to determine whether an abnormal level jump occurs.

[0020] The method quantizes the counting direction by taking the direction value of the counting direction of the pulse edge as 1 and the direction value of the other counting direction as 0, and calculates the compensation amount in the form of the direction value. On the other hand, the method calculates the compensation amount by the difference between the direction values of two adjacent pulse edges, and links the compensation amount to the change of the counting direction of the adjacent pulse edges when the abnormal level jump occurs, so that the compensation amount can more accurately compensate for the error counting caused by the abnormal level jump in the motor speed measurement process.

[0021] In a possible implementation of the first aspect, the step of obtaining the motor speed according to the compensation amount and the pulse signal comprises:

[0022] determining a first time period and a second time period with a common starting time, and the first time period is shorter than the second time period;

[0023] determining that the number of valid edges in the first time period is at least two, and then calculating the motor speed according to the number of valid edges; the number of valid edges is the number of pulse edges without abnormal level jump;

[0024] determining that the number of valid edges in the first time period is less than two, and the number of valid edges in the second time period is not less than two, and then calculating the motor speed according to the time interval between adjacent pulse edges without abnormal level jump.

[0025] The method measures the motor speed in two adjacent time periods, and distinguishes between high and low motor speeds according to whether at least two valid edges can be detected in the first time period and the second time period. When at least two valid edges are detected in the first time period, it indicates that the motor speed is high at this time, and the method of determining the number of pulses in a period is used to measure the motor speed, which can avoid the problem that the time of a single pulse is too short at high speed, and the measurement error of the time of a single pulse has a relatively large impact. At low speed, the measurement error of the time of a single pulse is relatively small. This method realizes accurate measurement of a wide range of motor speeds and smooth transition between high speed and low speed. In addition, the method determines whether the measurement condition is met according to the number of valid edges in a period, which solves the problem that the number of pulse edges in a period is too large due to abnormal level jump, resulting in incorrect determination of the two conditions during measurement and the use of an unsuitable method to measure the motor speed.

[0026] In a possible implementation of the first aspect, the step of calculating the motor speed according to the number of valid edges comprises:

[0027] Obtaining the number of valid edges in the first time period;

[0028] Calculating the effective pulse time according to the time difference between the pulse edge of the first non-abnormal level jump and the pulse edge of the last non-abnormal level jump in the first time period;

[0029] The motor speed is calculated based on the number of valid edges and the valid pulse time in the first time period.

[0030] The above method calculates the time difference between the first non-abnormal level jump pulse edge and the last non-abnormal level jump pulse edge in the first time period, thereby solving the problem that when measuring the high speed of the motor in the past, half a pulse may not be counted at the beginning and end of the measurement time, resulting in two pulse edge errors in the final calculation, making the measurement of the motor speed more accurate.

[0031] In a possible implementation manner of the first aspect, the step of obtaining the compensation amount according to the counting direction of adjacent pulse edges includes:

[0032] Determine that the i-th pulse edge is the first pulse edge in the first time period, then use formula C i =(D i-1 -D i )*2 calculates the compensation amount;

[0033] Determine that the i-th pulse edge is not the first pulse edge in the first time period, then use the formula C i =C i-1 +(D i-1 -D i ) calculating the compensation amount;

[0034] Wherein, C is the compensation amount, C i is the compensation amount of the i-th pulse edge, C i-1 is the compensation amount calculated for the i-1th pulse edge, D is the direction value of the pulse edge, D i-1 is the direction value of the i-1th pulse edge, D i is the direction value of the i-th pulse edge.

[0035] The above method defines the above compensation amount and calculates the compensation amount for different pulse edges by accumulating the variables in the counting direction, so that the compensation amount can be continuously updated and corrected according to the change of the counting direction, thereby better generating a counting value for the continuously updated counting value and eliminating the influence of abnormal level jumps on the counting value.

[0036] In a possible implementation of the first aspect, the pulse edge of the non-abnormal level jump is a pulse edge whose Delta value is not zero;

[0037] The Delta value is calculated according to the formula Delta i =Z i -Past i-1 +C i Calculated;

[0038] The Past value is calculated according to the formula i =Past i-1 +Delta i It is calculated that when the i-th pulse edge is the first pulse edge in the first time period, Past i-1 =Z i-1 ;

[0039] Among them, Delta is the change of the effective count value, Delta i is the change in the effective count value of the i-th pulse edge; Z is the count value of the pulse edge, when the pulse edge counts in the positive direction, the count value of the pulse edge is increased by one, when the pulse edge counts in the reverse direction, the count value of the pulse edge is decreased by one; Z i is the count value of the i-th pulse edge, Z i-1 is the count value of the i-1th pulse edge, Z0=0; Past is the effective count value, Past i-1 is the effective count value of the i-1th pulse edge, Past i is the effective count value of the i-th pulse edge.

[0040] The above method uses Z i +C i Indicates the count value obtained after compensating the pulse edge according to the compensation amount, through Z i -Past i-1 +C i Calculate the difference between the two valid count values ​​to determine whether the pulse edge is a valid edge. If the difference between the two valid count values ​​is zero, it means that the count is invalid. i =Past i-1 +Delta i , update the last valid count value, and distinguish whether it is a valid count value from the count value read by the encoder, so as to facilitate the next judgment on whether the pulse edge is a valid edge.

[0041] At the same time, the above method defines the pulse edge of non-abnormal level jump in this way, calculates the change of the effective count value through the compensated pulse edge count value, and judges whether an abnormal level jump has occurred based on whether the change of the effective count value is zero, so that the method can better count the effective edges and record the time of the effective edges during execution.

[0042] In a possible implementation of the first aspect, calculating the motor speed according to the number of valid edges includes:

[0043] pass Calculating the motor speed;

[0044] Wherein, Speed ​​is the motor speed; rpm is the unit of the motor speed, indicating revolutions per minute; EncoderLines is the number of encoder lines; T1 is the duration of the first time period; ΔT1 is the time interval from the start time to the pulse edge of the first non-abnormal level jump in the first time period; ΔT2 is the time interval from the pulse edge of the last non-abnormal level jump in the first time period to the end of the first time period; Y is the count value of the pulse edges at the end of the first time period; and X is the count value of the pulse edges at the first time node.

[0045] The above method calculates the effective pulse time by T1-ΔT1-ΔT2, compensates the number of pulses in the first time period by |-X+C|-1, calculates the effective pulse number, and provides a calculation method for measuring the motor speed when the motor is rotating at high speed.

[0046] In a possible implementation of the first aspect, calculating the motor speed according to the time interval between adjacent pulse edges of non-abnormal level transitions includes:

[0047] pass Calculating the motor speed;

[0048] Among them, Speed ​​is the motor speed; rpm is the unit of the motor speed, which represents revolutions per minute; EncoderLines is the number of lines of the encoder; and T is the time interval between two adjacent pulse edges of non-abnormal level jumps in the second time period.

[0049] The above method measures the time interval between two adjacent pulse edges of non-abnormal level jumps in the second time period, and provides a calculation method for measuring the motor speed when the motor is rotating at a low speed.

[0050] In a second aspect, an embodiment of the present application provides a device for measuring motor speed, comprising:

[0051] an acquisition module, configured to acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;

[0052] a processing module, configured to obtain a counting direction of a pulse edge according to a phase difference between the first signal and the second signal;

[0053] a calculation module, configured to obtain a compensation amount according to the counting direction of adjacent pulse edges, wherein the compensation amount is used to compensate for abnormal level jumps of the pulse signal;

[0054] A rotation speed module is used to obtain the rotation speed of the motor according to the compensation amount and the pulse signal.

[0055] In a third aspect, an embodiment of the present application provides a terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for measuring the motor speed described in any one of the first aspects above is implemented.

[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the motor speed measurement method described in any one of the first aspects above is implemented.

[0057] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the motor speed measurement method described in any one of the above-mentioned first aspects.

[0058] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0060] Figure 1 1 is a flow chart of a method for measuring motor speed provided in an embodiment of the present application;

[0061] Figure 2 This is a flow chart of a method for measuring motor speed provided by one embodiment of the present application;

[0062] Figure 3 Schematic diagram of the structure of the motor speed measuring device provided in an embodiment of the present application;

[0063] Figure 4 This is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application;

[0064] Figure 5 A schematic diagram of an example of a first pulse signal provided in one embodiment of the present application;

[0065] Figure 6 is a schematic diagram of an example of a second pulse signal provided by an embodiment of the present application;

[0066] Figure 7 is a schematic diagram of an example of a third pulse signal provided by an embodiment of the present application;

[0067] Figure 8 is a schematic diagram of an example of a fourth pulse signal provided by an embodiment of the present application;

[0068] Figure 9 is a schematic diagram of an example of a fifth pulse signal provided by an embodiment of the present application;

[0069] Figure 10 is a schematic diagram of an example of a sixth pulse signal provided by an embodiment of the present application;

[0070] Figure 11 This is a schematic diagram of an example of a seventh pulse signal provided in an embodiment of the present application.

[0071] Reference numerals:

[0072] Terminal device 40;

[0073] Processor 401;

[0074] Memory 402;

[0075] Computer program 403. DETAILED DESCRIPTION

[0076] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.

[0077] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0078] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0079] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0080] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0081] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in 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 "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0082] In the field of motor control, the motor speed is often measured through an encoder. The encoder outputs a pulse signal during measurement. The system calculates the motor speed based on the frequency of the pulse signal output by the encoder over a period of time or the time of a single pulse, and then controls the motor.

[0083] However, in the actual measurement process, factors such as encoder installation, electromagnetic interference, and mechanical vibration may cause abnormal level jumps at the edges of the pulse signal output by the encoder, causing the system to miscalculate the pulse edges generated by the abnormal level jumps during calculation, resulting in errors in the motor speed measurement and affecting the system's control over the motor.

[0084] See also Figure 1 , an embodiment of the present application provides a method for measuring the speed of a motor.

[0085] The execution subject of the motor speed measurement method in this embodiment can be a computer program or a speed measurement device, and the speed measurement device can be implemented by hardware and / or software. Figure 1 The motor speed measurement methods shown include:

[0086] Step S102: Acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses.

[0087] Step S104: Obtain the counting direction of the pulse edge according to the phase difference between the first signal and the second signal.

[0088] Among them, the pulse edge is the jump edge of the pulse signal obtained by the encoder, including the rising edge and the falling edge. The execution entity obtains the pulse signal output by the encoder when the motor rotor rotates according to the orthogonal encoding module of the encoder. The encoder is an orthogonal encoder. The first signal and the second signal, one corresponds to the A signal in the orthogonal pulse, and the other corresponds to the B signal in the orthogonal pulse.

[0089] The phase difference between the first signal and the second signal can be determined based on the timing advance or lag of the rising edge or falling edge of the first signal and the rising edge or falling edge of the second signal, or based on the reading order of the high and low levels of the first signal and the second signal.

[0090] When a counting direction is determined to be forward, the execution entity increments the encoder value upon the arrival of a pulse edge. When a counting direction is determined to be reverse, the execution entity decrements the encoder value upon the arrival of an encoder edge. However, in the prior art, when counting pulse edges, pulse edges with abnormal level transitions are often incremented or decremented, resulting in errors in the measured count value and, consequently, inaccuracies in the motor speed calculation.

[0091] Step S106: Obtain a compensation amount according to the counting direction of adjacent pulse edges, and the compensation amount is used to compensate for abnormal level jumps of the pulse signal.

[0092] Wherein, when the abnormal level jump occurs, the counting direction of the generated pulse edge changes relative to the counting direction in normal condition, and the compensation amount can compensate the error of the counting value caused by the abnormal level jump, or compensate the number of pulses measured in a period of time, or correct the pulse edge generated by the abnormal level jump read to be invalid pulse edge, to compensate the abnormal level jump of the pulse signal.

[0093] Step S108: obtaining the rotation speed of the motor according to the compensation amount and the pulse signal.

[0094] Wherein, obtaining the rotation speed of the motor according to the compensation amount and the pulse signal can be:

[0095] The pulse signal with abnormal level jump is compensated by the compensation amount, the pulse edge generated by the abnormal level jump read is corrected to be invalid pulse edge, the time interval of two valid edges is calculated to obtain the rotation speed of the motor.

[0096] It can also be:

[0097] The pulse edge counting value in a period of time is compensated by the compensation amount, so that the compensated counting value is consistent with the counting value when the abnormal level jump does not occur, and then the number of pulses in a period of time is calculated by the compensated counting value to obtain the rotation speed of the motor.

[0098] The beneficial effects of the embodiment are that: the compensation amount is calculated according to the change of the counting direction of adjacent pulse edges, when the abnormal level jump occurs, in addition to the counting value of the pulse edge being counted incorrectly, the counting direction of the pulse edge will also change relative to the counting direction of adjacent pulse edges. The error pulse generated by the encoder when the abnormal level jump occurs is compensated by the compensation amount, and the incorrect counting of the pulse edge is corrected. The error counting of the encoder is corrected by the compensation amount, and the rotation speed of the motor is calculated according to the compensation amount and the pulse signal, which improves the accuracy of the motor speed measurement and eliminates the interference of the abnormal level jump on the motor speed measurement.

[0099] According to the above embodiment, in another embodiment:

[0100] According to the phase difference between the first signal and the second signal, the step of obtaining the counting direction of the pulse edge includes: determining that the phase of the first edge lags behind the second edge, and recording the counting direction of the first edge as positive counting; determining that the phase of the first edge leads the second edge, and recording the counting direction of the first edge as negative counting.

[0101] Among them, one of the first edge and the second edge is a pulse edge on the first signal, and the other is a pulse edge on the second signal; the first edge and the second edge are both rising edges, or both falling edges; the second edge is the pulse edge with the smallest absolute value of the phase difference relative to the first edge.

[0102] It should be noted that the positive counting of the pulse edges can correspond to clockwise or counterclockwise rotation of the motor. The above definition of the pulse edge counting direction is only one implementation method. It is easy to imagine that when the phase of the first edge leads the second edge, the counting direction of the first edge can also be recorded as reverse counting. Conversely, when the phase of the first edge leads the second edge, the counting direction of the first edge can also be recorded as forward counting.

[0103] The beneficial effects of this embodiment are as follows: By linking the abnormal level jump phenomenon with the counting direction of the pulse edge and defining the counting direction of the pulse edge, a standard is provided for calculating the compensation amount based on the change in the counting direction. Furthermore, by defining the counting direction of the pulse edge using the phase difference method, the counting direction of the pulse edge, a physical quantity that is difficult to obtain directly, can be obtained through calculation, thereby increasing the feasibility of the method.

[0104] According to the above embodiment, in yet another embodiment:

[0105] Obtaining the compensation amount according to the counting direction of adjacent pulse edges includes: when the i-th pulse edge is counted in the forward direction, recording the direction value of the i-th pulse edge as 1, where i is a positive integer and i≥2; when the i-th pulse edge is counted in the reverse direction, recording the direction value of the i-th pulse edge as 0; and calculating the compensation amount based on the difference between the direction value of the i-1-th pulse edge and the direction value of the i-th pulse edge.

[0106] The compensation amount is used to compensate the count value of the pulse edge to obtain a valid count value, and the valid count value is used to determine whether an abnormal level jump occurs.

[0107] When an abnormal level jump occurs in the pulse signal, two pulse edges are generated. The count values ​​of these two pulse edges vary by ±1 relative to the preceding pulse edge. In this embodiment, by recording the direction value of one counting direction as 1 and the direction value of the other counting direction as 0, the direction values ​​of these two pulse edges and the adjacent pulse edges also vary by ±1. Therefore, the compensation calculated based on the direction value can better compensate for the count value of the pulse edge, eliminating the impact of the abnormal level jump on the motor speed measurement in subsequent calculations.

[0108] The beneficial effect of this embodiment is that: this embodiment calculates the compensation amount by the difference in the direction values ​​of two adjacent pulse edges, and links the compensation amount with the change in the counting direction of adjacent pulse edges when an abnormal level jump occurs, so that the compensation amount can more accurately compensate for the erroneous counts caused by abnormal level jumps during the motor speed measurement process.

[0109] According to the above embodiment, in yet another embodiment:

[0110] See also Figure 2 The step of obtaining the rotational speed of the motor according to the compensation amount and the pulse signal includes: determining a first time period and a second time period having a common starting time, and the first time period is shorter than the second time period; determining that the number of valid edges in the first time period is at least two, and then calculating the motor rotational speed based on the number of valid edges; the number of valid edges is the number of pulse edges with non-abnormal level jumps; determining that the number of valid edges in the first time period is less than two, and the number of valid edges in the second time period is not less than two, and then calculating the motor rotational speed based on the time interval between adjacent pulse edges with non-abnormal level jumps.

[0111] In this embodiment, the determination of the common starting moment of the first time period and the second time period can be taken at any moment during the rotation of the motor. The effective edge is the pulse edge corresponding to the non-abnormal level jump, wherein the judgment of the effective edge can be determined by whether the counting direction of the pulse edge changes, and can also be reflected by the change of the effective count value. In practical applications, the second time period should be much larger than the first time period. When the number of effective edges in the first time period is at least 2, the conditions required for calculating the motor speed are met, and the motor speed can be calculated based on the number of effective edge pulses. Similarly, for the second time period, when the number of effective edges in the second time period is at least 2, the conditions for measuring the speed of the motor are met, and the motor speed can be calculated.

[0112] This embodiment determines whether the motor speed measurement condition is met by determining the number of valid edges within a time period. When at least two valid edges are detected within the first time period, the motor speed is relatively high. Detecting the number of valid edges within the first time period can avoid situations where a single pulse duration is too short, resulting in large errors in time measurement.

[0113] The beneficial effects of this embodiment are as follows: by detecting the motor in the first time period or the second time period, this embodiment can accurately measure the motor's rotational speed at both high and low speeds, achieving smooth switching between the two rotational speed measurement methods and enabling measurement over a wide rotational speed range. Furthermore, by determining whether measurement conditions are met based on the number of valid edges within a period, the problem of abnormal level fluctuations causing an excessive number of pulse edges within that period, leading to incorrect judgment of the two conditions during the measurement process and the use of an inappropriate method for measuring motor rotational speed, is resolved.

[0114] According to the above embodiment, in yet another embodiment:

[0115] Optionally, when it is determined that the number of valid edges in the first time period is at least two, after the motor speed is calculated based on the number of valid edges, the number of valid edges in the second time period may no longer be judged, and the next measurement of the motor speed may be performed directly; when it is determined that the number of valid edges in the first time period is less than two, and the number of valid edges in the second time period is not less than two, after two valid edges are detected and the motor speed is calculated based on the time interval between the pulse edges of adjacent non-abnormal level jumps, the current measurement is ended and the next measurement of the motor speed is performed.

[0116] The beneficial effect of this embodiment is that: under the condition that the measurement conditions are met, after obtaining the motor speed within a period of time, the next measurement of the motor speed is directly performed, thereby realizing rapid measurement of the motor speed, which is beneficial to achieving real-time control of the motor speed.

[0117] In a possible implementation, when the number of valid edges in the second time period is less than two, it is considered that the motor speed is zero at this time.

[0118] According to the above embodiment, in yet another embodiment:

[0119] The steps of calculating the motor speed based on the number of valid edges include: obtaining the number of valid edges in the first time period; calculating the effective pulse time based on the time difference between the pulse edge of the first non-abnormal level jump and the pulse edge of the last non-abnormal level jump in the first time period; and calculating the motor speed based on the number of valid edges in the first time period and the effective pulse time.

[0120] The beneficial effect of this embodiment is that: this embodiment calculates the time difference between the first non-abnormal level jump pulse edge and the last non-abnormal level jump pulse edge in the first time period, thereby solving the problem of two pulse edge errors in the final calculation due to the possibility that half a pulse may not be counted at the beginning and end of the measurement time when measuring the motor at high speed in the past.

[0121] According to the above embodiment, in yet another embodiment:

[0122] The step of obtaining the compensation amount according to the counting direction of the adjacent pulse edges includes:

[0123] Determine that the i-th pulse edge is the first pulse edge in the first time period, then use formula C i =(D i-1 -D i )*2 calculates the compensation amount;

[0124] Determine that the i-th pulse edge is not the first pulse edge in the first time period, then use the formula C i =C i-1 +(D i-1 -D i ) calculating the compensation amount;

[0125] Wherein, C is the compensation amount, C i is the compensation amount of the i-th pulse edge, C i-1 is the compensation amount calculated for the i-1th pulse edge, D is the direction value of the pulse edge, D i-1 is the direction value of the i-1th pulse edge, D i is the direction value of the i-th pulse edge.

[0126] The above method defines the above compensation amount and obtains the compensation amount of the i-th pulse edge by accumulating the compensation amount to eliminate the influence of the abnormal level jump on the count value. If a complete abnormal level jump occurs, the count value read by the encoder is the same as the count value of the actual valid pulse. If the abnormal level jump occurs at the beginning or end of the first time period or at the end of the second time period, the compensation amount can be used to compensate for the abnormal level.

[0127] (D i-1 -D i ) represents the change in the direction of two adjacent pulse edges, through C i =C i-1 +(D i-1 -D i ) accumulates the variables in the pulse edge counting direction, eliminates the influence of the pulse edges caused by multiple abnormal level jumps on the counting value, and can continuously correct the counting value.

[0128] The beneficial effect of this embodiment is that: this embodiment defines the above-mentioned compensation amount, and calculates the compensation amount corresponding to different pulse edges by accumulating the variables in the counting direction, so that the compensation amount can be continuously updated and corrected according to the change of the counting direction, thereby being able to better count the continuously updated count value and eliminate the influence of abnormal level jumps on the count value.

[0129] According to the above embodiment, in yet another embodiment:

[0130] The pulse edge of the non-abnormal level jump is a pulse edge whose Delta value is not zero;

[0131] The Delta value is calculated according to the formula Delta i =Z i -Past i-1 +C i Calculated;

[0132] The Past value is calculated according to the formula i =Past i-1 +Delta i It is calculated that when the i-th pulse edge is the first pulse edge in the first time period, Past i-1 =Z i-1 ;

[0133] Among them, Delta is the change of the effective count value, Delta i is the change in the effective count value of the i-th pulse edge; Z is the count value of the pulse edge, when the pulse edge counts in the positive direction, the count value of the pulse edge is increased by one, when the pulse edge counts in the reverse direction, the count value of the pulse edge is decreased by one; Z i is the count value of the i-th pulse edge, Z i-1 is the count value of the i-1th pulse edge, Z0=0; Past is the effective count value, Past i-1 is the effective count value of the i-1th pulse edge, Past iis the effective count value of the i-th pulse edge.

[0134] where Z i +C i It means the count value obtained after compensating the pulse edge by the compensation amount, that is, the effective count value. i -Past i-1 +C i Calculate the difference between the two valid count values ​​to determine whether the pulse edge is a valid edge. If the difference between the two valid count values ​​is zero, it means that the count is invalid. i =Past i-1 +Delta i , update the last valid count value, and distinguish whether it is a valid count value from the count value read by the encoder, so as to facilitate the next judgment on whether the pulse edge is a valid edge.

[0135] Optionally, when the Delta value is calculated, the pulse edge with a Delta value that is not zero is determined to be a valid edge, and the time count of the pulse edge is recorded; the pulse edge with a Delta value of zero is determined to be a pulse edge generated by an abnormal level jump, and the time count of the pulse edge is recorded.

[0136] The beneficial effect of this embodiment is that: this embodiment defines the pulse edge of non-abnormal level jump in this way, calculates the change of the effective count value through the compensated pulse edge count value, and judges whether an abnormal level jump has occurred based on whether the change of the effective count value is zero, so that the execution subject can better count the effective edges and record the time of the effective edges.

[0137] According to the above embodiment, in yet another embodiment:

[0138] The calculating of the motor speed according to the number of valid edges includes:

[0139] pass The motor speed is obtained by calculation.

[0140] Wherein, Speed ​​is the motor speed; rpm is the unit of the motor speed, indicating revolutions per minute; EncoderLines is the number of encoder lines; T1 is the duration of the first time period; ΔT1 is the time interval from the start time to the pulse edge of the first non-abnormal level jump in the first time period; ΔT2 is the time interval from the pulse edge of the last non-abnormal level jump in the first time period to the end of the first time period; Y is the count value of the pulse edges at the end of the first time period; and X is the count value of the pulse edges at the first time node.

[0141] T1-ΔT1-ΔT2 is the time difference between the pulse edge of the first non-abnormal level transition and the pulse edge of the last non-abnormal level transition in the first time period, |Y-+| is the number of valid edges in the first time period, and |Y-+|-1 is the number of valid pulses in the first time period. This method compensates for abnormal level transitions and simultaneously calculates the time difference between the pulse edge of the first non-abnormal level transition and the pulse edge of the last non-abnormal level transition in the first time period. These two time errors are eliminated to accurately calculate the motor speed.

[0142] According to the above embodiment, in yet another embodiment:

[0143] The calculating of the motor speed according to the time interval of the pulse edges of adjacent non-abnormal level jumps includes:

[0144] pass Calculating the motor speed;

[0145] Where Speed ​​is the motor speed; rpm is the unit of the motor speed, indicating revolutions per minute; EncoderLines is the number of encoder lines; and T is the time interval between two adjacent pulse edges with no abnormal level transitions within the second time period. By calculating the time interval between two adjacent pulse edges with no abnormal level transitions within the second time period with a longer time interval, the time taken for a pulse within that period is calculated, and thus the motor speed within that period is calculated.

[0146] According to the above embodiment, in yet another embodiment:

[0147] After determining the common starting time of the first and second time periods, a first timer and a second timer are started. The first timer is used to determine the first time period, and the second timer is used to determine the second time period. At the end of the first time period, the first timer stops timing, and the second timer continues timing until the end of the second time period. Simultaneously, the encoder count value X is read while the timers are started. When the pulse signal reaches a rising or falling edge, the current pulse edge count value Z is obtained, the counting direction of the pulse edge is determined, and a compensation amount C is calculated. A Delta value is calculated based on the compensation amount to determine whether it is a valid edge. The time counted by the second timer when the pulse edge is a valid edge is recorded to calculate the motor speed. At the end of a measurement, the first and second timers are reset to prepare for the next measurement.

[0148] As an example and not a limitation, this embodiment provides a method for implementing motor speed measurement. By recording the time count of the valid edge in the first time period and / or the second time period by the second timer, the valid pulse time and the time interval between two valid edges can be calculated more accurately and conveniently.

[0149] The following will target Figure 5 The pulse signal shown provides an optional motor speed measurement embodiment. In this embodiment:

[0150] When no abnormal level jump occurs in the first time period, the starting time a of the first time period is determined, and the count value of the pulse edge at this time is Z0=X.

[0151] For edge 501, D0=1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; edge 501 is judged to be a valid edge, the time count of edge 501 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0152] For edge 502, D1=1, D2=1, C1=0, C2=C1+(D1-D2)*2=0, Z2=X+2, Past1=X+1, Delta2=Z2-Past1+C2=1, Past2=Past1+Delta2=X+2; edge 502 is determined to be a valid edge, the time count of edge 502 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0153] For edge 503, D2=1, D3=1, C2=0, C3=C2+(D2-D3)*2=0, Z3=X+3, Past2=X+2, Delta3=Z3-Past2+C3=1, Past3=Past2+Delta3=X+3; edge 503 is judged to be a valid edge, the time count of edge 503 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0154] At this time, the motor speed is ΔT1 is the time interval from edge 501 to the beginning of the first time period, ΔT2 is the time interval from edge 503 to the end of the first time period b, and |Z3-X+C|-1=3 is consistent with the actual number of pulses in this period.

[0155] The following will target Figure 6 The pulse signal shown provides an optional motor speed measurement embodiment. In this embodiment:

[0156] When an abnormal level jump occurs after the first time period begins, at the starting time a of the first time period, the count value of the pulse edge is Z0=X.

[0157] For edge 601, D o =1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; edge 601 is determined to be a valid edge, the time count of edge 601 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0158] For edge 602, D1=1, D2=0, C1=0, C2=C1+(D1-D2)*2=1, Z2=X, Past1=X+1, Delta2=Z2-Past1+C2=0, Past2=Past1+Delta2=X+1; edge 602 is determined to be a pulse edge generated by an abnormal level jump, the time count of edge 602 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 1, and the compensation for the effective count value is 1.

[0159] For edge 603, D2=0, D3=1, C2=1, C3=C2+(D2-D3)*2=0, Z3=X+1, Past2=X+1, Delta3=Z3-Past2+C3=0, Past3=Past2+Delta3=X+1; edge 602 is judged to be a pulse edge caused by an abnormal level jump, the time count of edge 603 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation for the effective count value is 0.

[0160] For edge 604, D3=1, D4=1, C4=C3+(D3-D4)*2=0, Z4=X+2, Past3=X+1, Delta4=Z4-Past3+C3=1, Past4=Past3+Delta4=X+1; edge 604 is judged to be a valid edge, the time count of edge 604 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0161] At this time, the motor speed is ΔT1 is the time interval from edge 601 to the beginning of the first time period, ΔT2 is the time interval from edge 604 to the end of the first time period b, and |Z4-X+C|-1=2 is consistent with the actual number of pulses.

[0162] The following will target Figure 7 The pulse signal shown provides an optional motor speed measurement embodiment. In this embodiment:

[0163] When an abnormal level jump occurs during the first time period, at the starting time a of the first time period, the count value of the pulse edge is Z0=X.

[0164] For edge 701, D0=1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; edge 701 is determined to be a valid edge, the time count of edge 701 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0165] For edge 702, D1=1, D2=1, C1=0, C2=C1+(D1-D2)=0, Z2=X+2, Past1=X+1, Delta2=Z2-Past1+C2=1, Past2=Past1+Delta2=X+2; edge 702 is determined to be a valid edge, the time count of edge 702 is recorded, the valid count value is consistent with the actual valid edge value, the compensation amount is calculated to be 0, and the compensation for the valid count value is 0.

[0166] For edge 703, D2=1, D3=0, C2=0, C3=C2+(D2-D3)=1, Z3=X+1, Past2=X+2, Delta3=Z3-Past2+C3=0, Past3=Past2+Delta3=X+2; edge 703 is judged to be a pulse edge caused by an abnormal level jump, the time count of edge 703 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation for the effective count value is 1.

[0167] For edge 704, D3=0, D4=1, C4=C3+(D3-D4)=0, Z4=X+2, Past3=X+2, Delta4=Z4-Past3+C3=0, Past4=Past3+Delta4=X+2; edge 704 is judged to be a pulse edge caused by an abnormal level jump, the time count of edge 704 is not recorded, the compensation amount is calculated as zero, and the compensation for the effective count value is 0.

[0168] At this time, the motor speed is ΔT1 is the time interval from edge 701 to the beginning of the first time period, and ΔT2 is the time interval from edge 702 to the end of the first time period. |Z4-X+C|-1=2 is consistent with the actual number of pulses.

[0169] The following will target Figure 8The pulse signal shown gives an alternative embodiment of motor speed measurement, in which embodiment:

[0170] When an abnormal level jump occurs at the end of the first time period, for the starting time a of the first time period, the count value of the pulse edge at this time is Z0=X.

[0171] For edge 801, D0=1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; edge 801 is judged as a valid edge, the time count of edge 801 is recorded, the compensation amount is calculated as zero, and the compensation for the valid count value is 0.

[0172] For edge 802, D1=1, D2=1, C1=0, C2=C1+(D1-D2)=0, Z2=X+2, Past1=X+1, Delta2=Z2-Past1+C2=1, Past2=Past1+Delta2=X+2; edge 802 is judged as a valid edge, the time count of edge 802 is recorded, the valid count value is consistent with the actual valid edge value, the compensation amount is calculated as 0, and the compensation for the valid count value is 0.

[0173] For edge 803, D2=1, D3=0, C2=0, C3=C2+(D2-D3)=1, Z3=X+1, Past2=X+2, Delta3=Z3-Past2+C3=0, Past3=Past2+Delta3=X+2; edge 803 is judged as a pulse edge generated by an abnormal level jump, the time count of edge 803 is not recorded, the valid count value is consistent with the actual valid edge value, the compensation amount is calculated as 0, and the compensation for the valid count value is 1.

[0174] At this time, the motor speed is ΔT1 takes the time interval from edge 801 to the start of the first time period, ΔT2 takes the time interval from edge 802 to the end of the first time period, |Z3-X+C|-1=2 is consistent with the actual pulse quantity.

[0175] The following will be described for Figure 9 The pulse signal shown gives an alternative embodiment of motor speed measurement, in which embodiment:

[0176] When an abnormal level jump occurs at the end of the first time period, for the starting time a of the first time period, the count value of the pulse edge at this time is Z0=X.

[0177] For edge 901, D0=1, D1=0, C1=(D0-D1)*2=2, Z1=X-1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; judging edge 901 as a valid edge, recording the time count of edge 901.

[0178] For edge 902, D1=0, D2=1, C1=0, C2=C1+(D1-D2)=1, Z2=X, Past1=X+1, Delta2=Z2-Past1+C2=0, Past2=Past1+Delta2=X+1; judging edge 902 as a pulse edge generated by abnormal level jump, not recording the time count of edge 902.

[0179] For edge 903, D2=1, D3=1, C2=1, C3=C2+(D2-D3)=1, Z3=X+1, Past2=X+1, Delta3=Z3-Past2+C3=1, Past3=Past2+Delta3=X+2; judging edge 903 as a valid edge, recording the time count of edge 903, the valid count value is consistent with the actual valid edge value, the compensation amount is 0, and the compensation for the valid count value is 1.

[0180] At this time, the motor speed is ΔT1 takes the time interval from edge 901 to the start of the first time period, ΔT2 takes the time interval from edge 902 to the end b of the first time period, and |Z3-X+C|-1=1.

[0181] The following will be described with respect to Figure 10 The pulse signal shown in the figure, an optional motor speed measurement embodiment will be given, in this embodiment:

[0182] When it is determined that the number of valid edges in the first time period a to b is less than two, and the number of valid edges in the second time period a to c is not less than two, when an abnormal level jump occurs in the second time period, for the starting time a of the first time period, the count value of the pulse edge at this time is Z0=X.

[0183] For edge 1001, D0=1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; judging edge 1001 as a valid edge, recording the time count of edge 1001, the compensation amount is calculated as zero, and the compensation for the valid count value is 0.

[0184] For edge 1002, D1=1, D2=0, C1=0, C2=C1+(D1-D2)*2=1, Z2=X, Past1=X+1, Delta2=Z2-Past1+C2=0, Past2=Past1+Delta2=X+1; edge 1002 is judged to be a pulse edge generated by an abnormal level jump, the time count of edge 1002 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 1, and the compensation for the effective count value is 1.

[0185] For edge 1003, D2=0, D3=1, C2=1, C3=C2+(D2-D3)*2=0, Z3=X+1, Past2=X+1, Delta3=Z3-Past2+C3=0, Past3=Past2+Delta3=X+1; edge 1003 is judged to be a pulse edge generated by an abnormal level jump, the time count of edge 1003 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation for the effective count value is 0.

[0186] For edge 1004, D3=1, D4=1, C4=C3+(D3-D4)*2=0, Z4=X+2, Past3=X+1, Delta4=Z4-Past3+C3=1, Past4=Past3+Delta4=X+1; edge 1004 is judged to be a valid edge, the time count of edge 1004 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0187] At this time, the motor speed is Wherein, T is the time interval between two valid edges from edge 1001 to edge 1004.

[0188] The following will target Figure 11 The pulse signal shown provides an optional motor speed measurement embodiment. In this embodiment:

[0189] When it is determined that the number of valid edges in the first time period a to b is less than two, and the number of valid edges in the second time period a to c is not less than two, when an abnormal level jump occurs at the end of the second time period, for the starting time a of the first time period, the count value of the pulse edge at this time is Z0=X.

[0190] For edge 1101, D0=1, D1=1, C1=(D0-D1)*2=0, Z1=X+1, Past0=Z0=X, Delta1=Z1-Past0+C1=1, Past1=Past0+Delta1=X+1; edge 1101 is judged to be a valid edge, the time count of edge 1101 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.

[0191] For edge 1102, D1=1, D2=1, C1=0, C2=C1+(D1-D2)=0, Z2=X+2, Past1=X+1, Delta2=Z2-Past1+C2=1, Past2=Past1+Delta2=X+2; edge 1102 is determined to be a valid edge, and the time count of edge 1102 is recorded.

[0192] At this time, the motor speed is Wherein, T is the time interval between two valid edges from edge 1101 to edge 1102.

[0193] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean 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.

[0194] Corresponding to the motor speed method described in the above embodiment, Figure 2 A structural block diagram of the device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0195] Reference Figure 3 , the device comprises:

[0196] An acquisition module 301 is configured to acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;

[0197] A processing module 302 is configured to obtain a counting direction of pulse edges according to a phase difference between the first signal and the second signal;

[0198] A calculation module 303 is configured to obtain a compensation amount according to the counting direction of adjacent pulse edges, wherein the compensation amount is used to compensate for abnormal level jumps of the pulse signal;

[0199] The speed module 304 is configured to obtain the speed of the motor according to the compensation amount and the pulse signal.

[0200] Specifically, the processing module 302 includes:

[0201] a direction determination submodule, configured to determine the counting direction of the first edge after determining the phase difference between the first edge and the second edge; when it is determined that the phase of the first edge lags behind the second edge, the counting direction of the first edge is recorded as forward counting; when it is determined that the phase of the first edge leads the second edge, the counting direction of the first edge is recorded as reverse counting;

[0202] Of the first edge and the second edge, one is a pulse edge on the first signal, and the other is a pulse edge on the second signal; the first edge and the second edge are both rising edges, or both falling edges; the second edge is the pulse edge with the smallest absolute value of the phase difference relative to the first edge.

[0203] The calculation module 303 includes:

[0204] An assignment submodule is used to assign a direction value to the i-th pulse edge after determining the counting direction of the i-th pulse edge; when the i-th pulse edge is counted in the forward direction, the direction value of the i-th pulse edge is recorded as 1, where i is a positive integer and i≥2; when the i-th pulse edge is counted in the reverse direction, the direction value of the i-th pulse edge is recorded as 0;

[0205] a compensation amount calculation submodule, which calculates the compensation amount according to the difference between the direction value of the (i-1)th pulse edge and the direction value of the (i)th pulse edge;

[0206] The compensation amount is used to compensate the count value of the pulse edge to obtain an effective count value, and the effective count value is used to determine whether an abnormal level jump occurs.

[0207] Furthermore, after determining that the i-th pulse edge is the first pulse edge in the first time period, the compensation amount calculation submodule uses formula C i =(D i-1 -D i )*2 calculates the compensation amount; when it is determined that the i-th pulse edge is not the first pulse edge in the first time period, the formula is C i = i-1 +(D i-1 -D i ) calculating the compensation amount;

[0208] The speed module 304 includes:

[0209] an edge timing submodule, configured to determine a first time period and a second time period having a common starting time, wherein the first time period is shorter than the second time period;

[0210] a first speed calculation submodule, configured to calculate the motor speed according to the number of valid edges after determining that the number of valid edges in the first time period is at least two;

[0211] The second speed calculation submodule is used to calculate the motor speed based on the time interval between adjacent pulse edges of non-abnormal level jumps after determining that the number of valid edges in the first time period is less than two and the number of valid edges in the second time period is not less than two.

[0212] Specifically, the edge timing submodule includes an edge timing unit, and the subunit is used to record the timing time of the valid edge;

[0213] The first speed calculation submodule includes:

[0214] An effective edge acquisition unit, configured to acquire the number of effective edges in the first time period;

[0215] The first speed calculation unit is used to calculate the effective pulse time based on the time difference between the pulse edge of the first non-abnormal level jump and the pulse edge of the last non-abnormal level jump in the first time period; the first calculation unit is also used to calculate the motor speed based on the number of valid edges in the first time period and the effective pulse time.

[0216] Furthermore, the effective edge acquisition unit acquires the number of effective edges by acquiring a change Delta of an effective count value of a pulse edge.

[0217] The Delta value is calculated according to the formula Delta i = i -ast i-1 + i Calculated;

[0218] The Past value is calculated according to the formula i =ast i-1 +elta i It is calculated that when the i-th pulse edge is the first pulse edge in the first time period, Past i-1 =Z i-1 ;

[0219] The first speed calculation unit is Calculating the motor speed;

[0220] The second speed calculation submodule is The motor speed is obtained by calculation.

[0221] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.

[0222] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by 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 embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0223] The present application also provides a terminal device, such as Figure 4 As shown, the terminal device 40 includes: at least one processor 401, a memory 402, and a computer program 403 stored in the memory and executable on the at least one processor, and the processor implements the steps of any of the above method embodiments when executing the computer program.

[0224] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned various method embodiments can be implemented.

[0225] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned various method embodiments when executing the computer program product.

[0226] 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, the present application implements all or part of the process of the above-mentioned method embodiment by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can at least include: any entity or device capable of carrying computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, mobile hard drive, magnetic disk, or optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals or telecommunication signals.

[0227] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0228] Those skilled in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0229] In the embodiments provided in this application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0230] The units described as separate components may or may not be physically separate, and 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0231] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A method for measuring motor speed, characterized in that: include: Acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses; If it is determined that the phase of the first edge lags behind that of the second edge, the counting direction of the first edge is recorded as forward counting; if it is determined that the phase of the first edge leads that of the second edge, the counting direction of the first edge is recorded as reverse counting; One of the first edge and the second edge is a pulse edge on the first signal, and the other is a pulse edge on the second signal; the first edge and the second edge are both rising edges, or both falling edges; and the second edge is a pulse edge having a minimum absolute phase difference with respect to the first edge; When the i-th pulse edge is counted in the positive direction, the direction value of the i-th pulse edge is recorded as 1, where i is a positive integer, and i ; When the i-th pulse edge is counted in reverse, the direction value of the i-th pulse edge is recorded as 0; The compensation amount is calculated based on the difference between the direction value of the (i-1)th pulse edge and the direction value of the (i)th pulse edge; The compensation amount is used to compensate the count value of the pulse edge to obtain an effective count value, and the effective count value is used to determine whether an abnormal level jump occurs; determining a first time period and a second time period having a common starting time, wherein the first time period is shorter than the second time period; Determining that the number of valid edges in the first time period is at least two, then calculating the motor speed based on the number of valid edges; the number of valid edges is the number of pulse edges with non-abnormal level jumps; If it is determined that the number of valid edges in the first time period is less than two and the number of valid edges in the second time period is not less than two, the motor speed is calculated based on the time interval between adjacent pulse edges of non-abnormal level jumps.

2. The method for measuring motor speed according to claim 1, wherein: The step of calculating the motor speed according to the number of valid edges comprises: Obtaining the number of valid edges in the first time period; Calculating the effective pulse time according to the time difference between the pulse edge of the first non-abnormal level jump and the pulse edge of the last non-abnormal level jump in the first time period; The motor speed is calculated based on the number of valid edges and the valid pulse time in the first time period.

3. The method for measuring motor speed according to claim 1, wherein: The step of obtaining a compensation amount according to the counting direction of adjacent pulse edges comprises: Determine that the i-th pulse edge is the first pulse edge in the first time period, then use the formula *2 Calculate the compensation amount; Determine that the i-th pulse edge is not the first pulse edge in the first time period, then use the formula: Calculating the compensation amount; in, is the compensation amount, is the compensation amount of the i-th pulse edge, is the compensation amount calculated for the i-1th pulse edge, is the direction value of the pulse edge, is the direction value of the i-1th pulse edge, is the direction value of the i-th pulse edge.

4. The method for measuring motor speed according to claim 3, wherein: The pulse edge of the non-abnormal level jump is Pulse edges with non-zero values; described Value according to the formula Calculated; Value according to the formula It is calculated that when the i-th pulse edge is the first pulse edge in the first time period, = ; in, is the change in the effective count value, The change in the effective count value of the i-th pulse edge; is the count value of the pulse edge, when the pulse edge is counted in the positive direction, the count value of the pulse edge is increased by one, and when the pulse edge is counted in the negative direction, the count value of the pulse edge is decreased by one; is the count value of the i-th pulse edge, is the count value of the i-1th pulse edge, ; is the effective count value, is the effective count value of the i-1th pulse edge, is the effective count value of the i-th pulse edge.

5. A device for measuring motor speed, characterized in that: include: an acquisition module, configured to acquire a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal includes a first signal and a second signal, and the first signal and the second signal are orthogonal pulses; a processing module, configured to: determine that if the phase of a first edge lags behind that of a second edge, then record the counting direction of the first edge as forward counting; determine that if the phase of the first edge leads that of the second edge, then record the counting direction of the first edge as reverse counting; one of the first edge and the second edge is a pulse edge on the first signal, and the other is a pulse edge on the second signal; the first edge and the second edge are both rising edges or both falling edges; and the second edge is a pulse edge having the smallest absolute value of a phase difference with respect to the first edge; The calculation module is used to record the direction value of the i-th pulse edge as 1 when the i-th pulse edge is counted in the positive direction, where i is a positive integer and i When the i-th pulse edge is counted in reverse, the direction value of the i-th pulse edge is recorded as 0; the compensation amount is calculated based on the difference between the direction value of the i-1-th pulse edge and the direction value of the i-th pulse edge; The compensation amount is used to compensate the count value of the pulse edge to obtain an effective count value, and the effective count value is used to determine whether an abnormal level jump occurs; A speed module is used to determine a first time period and a second time period having a common starting time, and the first time period is shorter than the second time period; if it is determined that the number of valid edges in the first time period is at least two, the motor speed is calculated based on the number of valid edges; the valid edge number is the number of pulse edges with non-abnormal level jumps; if it is determined that the number of valid edges in the first time period is less than two, and the number of valid edges in the second time period is not less than two, the motor speed is calculated based on the time interval between adjacent pulse edges with non-abnormal level jumps.

6. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method and device for obtaining low-rotating-speed angular speed of motor

    CN108226560A

  • Method and device for controlling operation of motor, terminal equipment and storage medium

    CN113131826A