CN116338231A - Motor rotation speed measuring method and device, terminal equipment and storage medium - Google Patents
Motor rotation speed measuring method and device, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN116338231A CN116338231A CN202211583755.XA CN202211583755A CN116338231A CN 116338231 A CN116338231 A CN 116338231A CN 202211583755 A CN202211583755 A CN 202211583755A CN 116338231 A CN116338231 A CN 116338231A
- Authority
- CN
- China
- Prior art keywords
- edge
- pulse
- signal
- pulse edge
- effective
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 80
- 230000002159 abnormal effect Effects 0.000 claims abstract description 107
- 238000004364 calculation method Methods 0.000 claims description 25
- 238000004590 computer program Methods 0.000 claims description 20
- 230000000630 rising effect Effects 0.000 claims description 8
- 238000012545 processing Methods 0.000 claims description 5
- 230000007704 transition Effects 0.000 claims description 5
- 230000003247 decreasing effect Effects 0.000 claims 1
- 238000005259 measurement Methods 0.000 abstract description 37
- 230000008859 change Effects 0.000 description 17
- 230000008569 process Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 10
- 230000009286 beneficial effect Effects 0.000 description 8
- 230000004044 response Effects 0.000 description 4
- 238000009825 accumulation Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 238000009434 installation Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01P—MEASURING LINEAR OR ANGULAR SPEED, ACCELERATION, DECELERATION, OR SHOCK; INDICATING PRESENCE, ABSENCE, OR DIRECTION, OF MOVEMENT
- G01P3/00—Measuring linear or angular speed; Measuring differences of linear or angular speeds
- G01P3/42—Devices characterised by the use of electric or magnetic means
- G01P3/44—Devices characterised by the use of electric or magnetic means for measuring angular speed
- G01P3/48—Devices characterised by the use of electric or magnetic means for measuring angular speed by measuring frequency of generated current or voltage
- G01P3/481—Devices characterised by the use of electric or magnetic means for measuring angular speed by measuring frequency of generated current or voltage of pulse signals
-
- H—ELECTRICITY
- H02—GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
- H02P—CONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
- H02P23/00—Arrangements or methods for the control of AC motors characterised by a control method other than vector control
- H02P23/14—Estimation or adaptation of motor parameters, e.g. rotor time constant, flux, speed, current or voltage
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Power Engineering (AREA)
- Control Of Electric Motors In General (AREA)
Abstract
The application is applicable to the technical field of motors, and provides a motor rotation speed measuring method, a motor rotation speed measuring device, terminal equipment and a storage medium, wherein the motor rotation speed measuring method comprises the following steps: acquiring a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses; obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal; obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, wherein the compensation quantity is used for compensating abnormal level jump of the pulse signals; and obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal. By adopting the method, the problem that the finally measured motor rotating speed has errors due to the fact that the acquired pulse signal has abnormal level jump is solved, and accurate measurement of the motor rotating speed is realized.
Description
Technical Field
The application belongs to the technical field of motors, and particularly relates to a motor rotation speed measuring method, a motor rotation speed measuring device, terminal equipment and a storage medium.
Background
Accurate measurement of motor real-time rotational speed in the field of motor control is the basis for achieving high-precision speed control, and encoders are often used in the prior art to detect rotor position and calculate motor rotational speed. However, in actual measurement, the factors such as the installation of the encoder, electromagnetic interference, mechanical vibration and the like all affect the pulse signal output by the encoder, so that sporadic level jump (abnormal level jump) occurs at the edge of the pulse signal output by the encoder, and sometimes the level of the signal output by the encoder continuously jumps for several times in a very short time to be normal. The occurrence of abnormal level jump can cause the pulse edge counting in the period of time to be wrong, so that the pulse quantity obtained by final measurement is inconsistent with the actual pulse quantity, the motor rotating speed measurement is error, and the control of the system on the motor is affected.
The application aims to provide a method capable of accurately measuring the motor rotating speed, and eliminating the influence of abnormal level runout on motor rotating speed measurement.
Disclosure of Invention
The embodiment of the application provides a method, a device, terminal equipment and a storage medium for measuring the motor rotation speed, which can solve the problem that the finally measured motor rotation speed has errors due to abnormal level jump of an acquired pulse signal.
In a first aspect, an embodiment of the present application provides a method for measuring a rotational speed of a motor, including:
acquiring a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;
obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal;
obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, wherein the compensation quantity is used for compensating abnormal level jump of the pulse signals;
and obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
The method calculates the compensation quantity according to the change of the counting direction of the adjacent pulse edges, compensates the error pulse signals generated by the encoder when the abnormal level jump occurs, and corrects the error counting of the pulse edges. The error count of the encoder is corrected through the compensation quantity, and the motor rotating speed is obtained through calculation according to the compensation quantity and the pulse signal, so that the accuracy of motor rotating speed measurement is improved, and the interference of abnormal level jump on motor rotating speed measurement is eliminated.
In a possible implementation manner of the first aspect, the step of obtaining a counting direction of the pulse edge according to a phase difference between the first signal and the second signal includes:
Determining that the phase of the first edge is behind the second edge, and recording the counting direction of the first edge as forward counting; determining that the phase of the first edge leads the second edge, and recording the counting direction of the first edge as backward 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; the second edge is a pulse edge with the minimum absolute value of phase difference relative to the first edge.
The method provides a standard for calculating the compensation quantity according to the change of the counting direction by relating the phenomenon of abnormal level jump with the counting direction of the pulse edge and defining the counting direction of the pulse edge. Meanwhile, the counting direction of the pulse edge is defined by a phase difference method, so that the physical quantity which is difficult to directly obtain the counting direction of the pulse edge can be obtained by calculation, and the method has further increased performability.
In a possible implementation manner of the first aspect, the step of obtaining the compensation amount according to the counting direction of the adjacent pulse edges includes:
When the ith pulse edge is counted in the forward direction, the direction value of the ith pulse edge is recorded as 1, wherein i is a positive integer, and i is more than or equal to 2;
when the ith pulse edge is counted reversely, the direction value of the ith pulse edge is recorded as 0;
calculating the compensation quantity according to the difference value between the direction value of the ith pulse edge and the direction value of the ith pulse edge;
the compensation quantity is used for compensating the counting value of the pulse edge to obtain an effective counting value, and the effective counting value is used for judging whether abnormal level jump occurs or not.
The method quantifies the counting direction in the form of a direction value by marking the direction value of the counting direction of the pulse edge as 1 and marking the direction value of the other counting direction as 0, and calculates the compensation quantity. On the other hand, the method calculates the compensation quantity through the difference of the direction values of the two adjacent pulse edges, and the compensation quantity is related to the change of the counting direction of the adjacent pulse edges when the abnormal level jump occurs, so that the compensation quantity can more accurately compensate the error count generated by the abnormal level jump in the motor rotating speed measuring process.
In a possible implementation manner of the first aspect, the step of obtaining the rotation 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 start time, and the first time period is shorter than the second time period;
determining that the number of the effective edges in the first time period is at least two, and calculating the motor rotating speed according to the number of the effective edges; the number of the effective edges is the number of pulse edges which are not abnormal level jumps;
and determining that the number of the effective edges in the first time period is smaller than two, and if the number of the effective edges in the second time period is not smaller than two, calculating to obtain the motor rotating speed according to the time interval of the pulse edges of adjacent non-abnormal level jump.
According to the method, the motor is measured in two adjacent time periods, and the high and low rotational speeds of the motor are distinguished according to whether at least two effective edges can be detected in the first time period and the second time period. When at least two effective edges exist in the first time period, the motor rotating speed is higher, the motor rotating speed is measured by adopting a method for determining the pulse number in a period of time, the problem that the error influence of measuring single pulse time is relatively large under the condition of high speed can be avoided, and the error influence of measuring single pulse time is relatively small under the condition of low speed. By the method, accurate measurement of a wide rotating speed range of the motor is realized, and automatic and stable transition of a high-speed method and a low-speed method is realized. Meanwhile, whether the measurement condition is met or not is judged according to the number of the effective edges in a period of time, and the problem that the two conditions are judged to be wrong in the measurement process and the motor rotating speed is measured by adopting an unsuitable method due to the fact that the number of the pulse edges in the period of time is too large due to abnormal level jitter is solved.
In a possible implementation manner of the first aspect, the step of calculating the motor rotation speed according to the number of effective edges includes:
acquiring the number of effective edges in the first time period;
calculating 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;
and calculating the motor rotating speed according to the number of the effective edges in the first time period and the effective pulse time.
According to the method, 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 is calculated, so that the problem that half pulses are not counted from beginning to end in the measurement time when the motor is measured at high speed in the past, and two pulse edge errors can occur in the final calculation is solved, and the motor rotating speed is measured more accurately.
In a possible implementation manner of the first aspect, the step of obtaining the compensation amount according to the counting direction of the adjacent pulse edges includes:
determining the ith pulse edge as the first pulse edge in the first time period, and passing through formula C i =(D i-1 -D i ) 2, calculating to obtain the compensation quantity;
determining that the ith pulse edge is not the first pulse edge in the first time period, and determining that the ith pulse edge is C by a formula i =C i-1 +(D i-1 -D i ) Calculating to obtain the compensation quantity;
wherein C is the compensation amount, C i C for the compensation amount of the ith pulse edge i-1 The compensation quantity calculated for the i-1 th pulse edge is D, which is the direction value of the pulse edge i-1 D is the direction value of the i-1 th pulse edge i Is the direction value of the ith pulse edge.
According to the method, the compensation quantity is defined, and the compensation quantity obtained by different pulse edges is calculated through accumulation of variables in the counting direction, so that the compensation quantity can be continuously updated and corrected according to the change of the counting direction, the count value can be better generated for the continuously updated count value, and the influence of abnormal level jump on the count value is eliminated.
In a possible implementation manner of the first aspect, the pulse edge of the non-abnormal level jump is a pulse edge with a Delta value not being zero;
the Delta value is Delta according to the formula i =Z i -Past i-1 +C i Calculating to obtain;
the Past value is according to the formula Past i =Past i-1 +Delta i Calculated, when the ith pulse edge is the first pulse edge in the first time period, past i-1 =Z i-1 ;
Wherein Delta is the variation of the effective count value i A variation of the effective count value for the ith pulse edge; z is the count value of the pulse edge, when the pulse edge counts forward, the count value of the pulse edge is increased by one, when the pulse edge counts backward, the pulse edge counts backwardThe count value of the pulse edge is reduced by one; z is Z i Z is the count value of the ith pulse edge i-1 Z is the count value of the i-1 th pulse edge 0 =0; past is the effective count value i-1 For the count value valid for the i-1 th pulse edge, past i A count value valid for the ith pulse edge.
The method is carried out by Z i +C i Representing the count value obtained by compensating the pulse edge according to the compensation quantity, and passing Z i -Past i-1 +C i Calculating the change of the effective count value of the two times to judge whether the pulse edge is the effective edge, if the change of the effective count value of the two times is zero, the counting is invalid, and the method passes through the formula Past i =Past i-1 +Delta i And updating the last effective count value, distinguishing the effective count value from the count value read by the encoder by judging whether the effective count value is the effective count value or not, and facilitating the next judgment of whether the pulse edge is the effective edge or not.
Meanwhile, the method defines the pulse edge of non-abnormal level jump, calculates the variation of the effective counting value through the compensated pulse edge counting value, and judges whether abnormal level jump occurs or not according to whether the variation of the effective counting value is zero, so that the method can count the effective edge and record the time of the effective edge better in the executing process.
In a possible implementation manner of the first aspect, the calculating the motor rotation speed according to the number of effective edges includes:
wherein Speed is the motor Speed; rpm is the motor rotation speed unit and represents revolutions per minute; encoerLines is the number of lines of the encoder; t (T) 1 A duration of the first time period; delta T 1 For the starting time to the first time periodA time interval of the pulse edge of the first non-abnormal level jump; delta T 2 A 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 edge at the end of the first time period; x is the count of the pulse edges at the first time node.
The method is carried out by T 1 -ΔT 1 -ΔT 2 Calculating effective pulse time, and compensating the pulse number in the first time period by using I-X+C-1, and calculating the effective pulse number, thereby providing a calculation method for measuring the motor rotation speed under the condition that the motor rotates at a high speed.
In a possible implementation manner of the first aspect, the calculating the motor rotation speed according to the time interval of the pulse edge of the adjacent non-abnormal level transition includes:
wherein Speed is the motor Speed; rpm is the motor rotation speed unit and represents revolutions per minute; encoerLines is the number of lines of the encoder; and T is the time interval of the pulse edges of two adjacent non-abnormal level jumps in the second time period.
The method measures the time interval of the pulse edges of the two adjacent non-abnormal level jumps in the second time period, and provides a calculation method for measuring the motor rotation speed under the condition that the motor rotates at a low speed.
In a second aspect, an embodiment of the present application provides a device for measuring a rotational speed of a motor, including:
the acquisition module is used for acquiring a pulse signal output by the encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;
The processing module is used for obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal;
the calculation module is used for obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, and the compensation quantity is used for compensating abnormal level jump of the pulse signals;
and the rotating speed module is used for obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the method for measuring the rotational speed of the motor according to any one of the first aspects when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program which, when executed by a processor, implements the method for measuring a rotational speed of a motor according to any one of the first aspects.
In a fifth aspect, embodiments of the present application provide a computer program product, which, when run on a terminal device, causes the terminal device to perform the method for measuring a rotational speed of a motor according to any one of the first aspects above.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for measuring a motor rotation speed according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for measuring motor speed according to one embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a motor rotation speed measurement device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a terminal device provided in an embodiment of the present application;
FIG. 5 is a schematic diagram of a first pulse signal example provided in one embodiment of the present application;
FIG. 6 is a schematic diagram of an example of a second pulse signal provided by one embodiment of the present application;
FIG. 7 is a schematic diagram of a third pulse signal example provided by an embodiment of the present application;
FIG. 8 is a schematic diagram of a fourth pulse signal example provided by an embodiment of the present application;
FIG. 9 is a schematic diagram of a fifth pulse signal example provided by an embodiment of the present application;
FIG. 10 is a schematic diagram of a sixth pulse signal example provided by an embodiment of the present application;
fig. 11 is a schematic diagram of a seventh pulse signal example provided in an embodiment of the present application.
Reference numerals:
a terminal device 40;
a processor 401;
a memory 402;
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
In the field of motor control, the motor rotation speed is usually measured by an encoder, the encoder outputs a pulse signal during measurement, and the system calculates the motor rotation speed according to the frequency of the pulse signal output by the encoder or the time of a single pulse in a period of time, so as to control the motor.
However, in the actual measurement process, due to factors such as installation of an encoder, electromagnetic interference, mechanical vibration and the like, abnormal level jump occurs at the edge of a pulse signal of an output signal of the encoder, so that a system performs error counting on the pulse edge generated by the abnormal level jump during calculation, and the motor rotation speed measurement is caused to have errors, so that the control of the system on a motor is affected.
Referring to fig. 1, an embodiment of the present application provides a method for measuring a rotational speed of a motor.
The main execution body of the method for measuring the rotational speed of the motor in this embodiment may be a computer program or a rotational speed measuring device, which may be implemented by hardware and/or software. The motor rotation speed measuring method shown in fig. 1 includes:
step S102, acquiring a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses.
Step S104, according to the phase difference between the first signal and the second signal, the counting direction of the pulse edge is obtained.
The pulse edge is a jump edge of a pulse signal obtained through an encoder and comprises a rising edge and a falling edge, the execution body obtains the pulse signal output by the encoder when the motor rotor rotates according to an orthogonal encoding module of the encoder, the encoder is an orthogonal encoder, one of the first signal and the second signal corresponds to an A signal in the orthogonal pulse, and the other corresponds to a B signal in the orthogonal pulse.
The phase difference between the first signal and the second signal may be determined according to the timing advance and the timing lag of the rising edge or the falling edge of the first signal and the rising edge or the falling edge of the second signal, or may be determined according to the reading order of the high level and the low level of the first signal and the second signal.
When a certain counting direction is determined to be forward counting, the execution body can count up the value of the encoder when the pulse edge arrives, and when a certain counting direction is determined to be backward counting, the execution body can count down the value of the encoder when the encoder edge arrives. In the prior art, when counting pulse edges, the pulse edges with abnormal level jump are often counted up or down, so that the measured count value is wrong, and the problem of error in motor rotation speed calculation is caused.
And step S106, obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, wherein the compensation quantity is used for compensating abnormal level jump of the pulse signal.
When abnormal level jump occurs, the counting direction of the generated pulse edge is changed relative to the counting direction under normal condition, the compensation quantity can compensate the abnormal level jump of the pulse signal by compensating the error of the counting value caused by the abnormal level jump, or compensating the pulse quantity measured in a period of time, or correcting the pulse edge generated by the read abnormal level jump to be judged as an invalid pulse edge.
And S108, obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
The rotating speed of the motor obtained according to the compensation amount and the pulse signal may be:
and compensating the pulse signal with the abnormal level jump through the compensation quantity, correcting the pulse edge generated by the read abnormal level jump to ensure that the pulse edge is judged to be an invalid pulse edge, and calculating single pulse time according to the time interval of the two valid edges to further obtain the motor rotating speed.
It may also be:
and compensating the pulse edge count value in a period of time through the compensation quantity, so that the compensated count value is consistent with the count value when no abnormal level jump occurs, and further calculating the pulse number in a period of time through the compensated count value to obtain the motor rotating speed.
The beneficial effects of this embodiment lie in: in this embodiment, the compensation amount is calculated according to the change of the counting direction of the adjacent pulse edges, and when the abnormal level jump occurs, the counting direction of the pulse edges is changed relative to the counting direction of the adjacent pulse edges, except that the counting value of the pulse edges is wrongly counted. Error pulses generated by the encoder when the abnormal level jump occurs are compensated by the compensation amount, and error counts for the pulse edges are corrected. The error count of the encoder is corrected through the compensation quantity, and the motor rotating speed is obtained through calculation according to the compensation quantity and the pulse signal, so that the accuracy of motor rotating speed measurement is improved, and the interference of abnormal level jump on motor rotating speed measurement is eliminated.
According to the above embodiment, in yet another embodiment:
the step of obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal comprises the following steps: determining that the phase of the first edge is behind the second edge, and recording the counting direction of the first edge as forward counting; and if the phase of the first edge is determined to be ahead of the second edge, recording the counting direction of the first edge as a reverse counting.
Wherein 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 a pulse edge with the minimum absolute value of phase difference relative to the first edge.
It should be noted that, the pulse edge positive counting may be rotated clockwise with respect to the motor, or rotated counterclockwise with respect to the motor, and the above definition of the pulse edge counting direction is only an implementation manner. It is easy to think that when the phase of the first edge is advanced from the second edge, the counting direction of the first edge may be recorded as a counter, whereas when the phase of the first edge is advanced from the second edge, the counting direction of the first edge may be recorded as a positive counter.
The beneficial effects of this embodiment lie in: in this embodiment, by associating the phenomenon of abnormal level jump 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 according to the change of the counting direction. Meanwhile, the counting direction of the pulse edge is defined by a phase difference method, so that the physical quantity which is difficult to directly obtain the counting direction of the pulse edge can be obtained by calculation, and the method has increased performability.
According to the above embodiment, in yet another embodiment:
obtaining the compensation amount according to the counting direction of the adjacent pulse edges comprises: when the ith pulse edge is counted in the forward direction, the direction value of the ith pulse edge is recorded as 1, wherein i is a positive integer, and i is more than or equal to 2; when the ith pulse edge is counted reversely, the direction value of the ith pulse edge is recorded as 0; and calculating the compensation quantity according to the difference value between the direction value of the ith pulse edge and the direction value of the ith pulse edge.
The compensation quantity is used for compensating the count value of the pulse edge to obtain an effective count value, and the effective count value is used for judging whether abnormal level jump occurs or not.
When the pulse signal makes an abnormal level jump phenomenon, two pulse edges are generated, and the count value of the two pulse edges is changed by +/-1 relative to the pulse edge before the pulse edges. In this embodiment, by marking the direction value of one counting direction as 1 and the direction value of the other counting direction as 0, the two pulse edges and the direction value of the pulse edge adjacent to the two pulse edges can also change by ±1, so that the count value of the pulse edge can be better compensated according to the compensation amount obtained by calculating the direction value, and the influence of abnormal level jump on the motor rotation speed measurement is eliminated in the following calculation.
The beneficial effects of this embodiment lie in: according to the embodiment, the compensation quantity is obtained through calculation of the difference of the direction values of the two adjacent pulse edges, and the compensation quantity is related to the change of the counting direction of the adjacent pulse edges when the abnormal level jump occurs, so that the compensation quantity can more accurately compensate the error count generated by the abnormal level jump in the motor rotating speed measuring process.
According to the above embodiment, in yet another embodiment:
referring to fig. 2, the step of obtaining the rotation 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 start time, and the first time period is shorter than the second time period; determining that the number of the effective edges in the first time period is at least two, and calculating the motor rotating speed according to the number of the effective edges; the number of the effective edges is the number of pulse edges which are not abnormal level jumps; and determining that the number of the effective edges in the first time period is smaller than two, and if the number of the effective edges in the second time period is not smaller than two, calculating to obtain the motor rotating speed according to the time interval of the pulse edges of adjacent non-abnormal level jump.
In this embodiment, the determination of the common start time of the first time period and the second time period may take any time in the rotation process of the motor. The effective edge is a pulse edge generated by non-abnormal level jump, wherein the judgment of the effective edge can be determined by whether the counting direction of the pulse edge changes or not, and can also be embodied by the change of an effective counting value. In practical applications, the second period of time should be much longer than the first period of time. When the number of the effective edges in the first time period is at least 2, the condition required by the calculation of the motor rotating speed is met, and the motor rotating speed can be calculated according to the number of the effective edge pulses. Likewise, for the second period, when the number of effective edges in the second period is at least 2, the condition of measuring the speed of the motor is satisfied, and the motor rotation speed can be calculated.
The present embodiment determines whether the condition for measuring the speed of the motor is satisfied by determining the number of effective edges in a period of time. When the number of the effective edges is detected to be at least 2 in the first time period, the motor rotating speed is higher, and the situation that errors caused by measuring time are larger due to the fact that the single pulse time is too short can be avoided by detecting the number of the effective edges in the first time period.
The beneficial effects of this embodiment lie in: according to the embodiment, the motor is detected in the first time period or the second time period, so that the rotating speeds of the motor at high speed and low speed can be accurately measured, stable switching of two rotating speed measuring methods is realized, and measurement of a wide rotating speed range is realized. Meanwhile, whether the measurement condition is met is judged according to the number of the effective edges in a period of time, and the problem that the two conditions are misjudged in the measurement process and the motor rotating speed is measured by adopting an unsuitable method due to the fact that the number of the pulse edges in the period of time is too large caused by abnormal level jitter is solved.
According to the above embodiment, in yet another embodiment:
optionally, when the number of the effective edges in the first period is at least two, after the motor rotation speed is calculated according to the number of the effective edges, the number of the effective edges in the second period can be not judged any more, and the next measurement of the motor rotation speed can be directly performed; when the number of the effective edges in the first time period is determined to be smaller than two and the number of the effective edges in the second time period is determined to be not smaller than two, after the effective edges are detected twice and the motor rotating speed is calculated according to the time interval of the pulse edges of adjacent non-abnormal level jump, the current measurement is ended, and the next measurement of the motor rotating speed is carried out.
The beneficial effects of this embodiment lie in: according to the embodiment, under the condition that the measurement condition is met, after the motor rotating speed in a period of time is obtained, the next measurement of the motor rotating speed is directly carried out, so that the motor rotating speed is rapidly measured, and the real-time control of the motor rotating speed is facilitated.
In one possible embodiment, the motor speed is considered to be zero when the number of edges active during said second period of time is less than two.
According to the above embodiment, in yet another embodiment:
the step of calculating the motor rotation speed according to the number of the effective edges comprises the following steps: acquiring the number of effective edges in the first time period; calculating 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; and calculating the motor rotating speed according to the number of the effective edges in the first time period and the effective pulse time.
The beneficial effects of this embodiment lie in: according to the method and the device for measuring the motor at high speed, 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 is calculated, so that the problem that two pulse edge errors can exist in the final calculation due to the fact that half pulses are not counted in the head and tail of the measuring time in the past is solved.
According to the above embodiment, in yet another embodiment:
the step of obtaining the compensation amount according to the counting direction of the adjacent pulse edges comprises the following steps:
determining the ith pulse edge as the first pulse edge in the first time period, and passing through formula C i =(D i-1 -D i ) 2, calculating to obtain the compensation quantity;
determining that the ith pulse edge is not the first pulse edge in the first time period, and determining that the ith pulse edge is C by a formula i =C i-1 +(D i-1 -D i ) Calculating to obtain the compensation quantity;
wherein C is the compensation amount, C i C for the compensation amount of the ith pulse edge i-1 The compensation quantity calculated for the i-1 th pulse edge is D, which is the direction value of the pulse edge i-1 D is the direction value of the i-1 th pulse edge i Is the direction value of the ith pulse edge.
The method is characterized in that the compensation quantity is defined, the i-th compensation quantity of the pulse edge is obtained through accumulation of the compensation quantity, the influence of abnormal level jump on the count value is eliminated, if a complete abnormal level jump occurs, the count value read by the encoder is identical to the count value of an actual effective pulse, and if the abnormal level jump occurs at the beginning or the end of the first time period or the end of the second time period, the compensation quantity can be used for compensating the abnormal level.
(D i-1 -D i ) Representing the change of the edge direction value of two adjacent pulses through C i =C i-1 +(D i-1 -D i ) And accumulating the variables in the counting direction of the pulse edge, eliminating the influence of the pulse edge generated by the abnormal level jump on the counting value for a plurality of times, and continuously correcting the counting value.
The beneficial effects of this embodiment lie in: according to the embodiment, the compensation quantity is defined, and the compensation quantity obtained by different pulse edges is calculated through accumulation of variables in the counting direction, so that the compensation quantity can be continuously updated and corrected according to the change of the counting direction, the continuously updated counting value can be better counted, and the influence of abnormal level jump on the counting value is eliminated.
According to the above embodiment, in yet another embodiment:
the pulse edge of the non-abnormal level jump is a pulse edge with a Delta value not being zero;
the Delta value is Delta according to the formula i =Z i -Past i-1 +C i Calculating to obtain;
the Past value is according to the formula Past i =Past i-1 +Delta i Calculated, when the ith pulse edge is the first pulse edge in the first time period, past i-1 =Z i-1 ;
Wherein Delta is the variation of the effective count value i A variation of the effective count value for the ith pulse edge; z is the count value of the pulse edge, and when the pulse edge counts forward, the pulse edge The count value of the pulse edge is decremented by one when the pulse edge is counted back; z is Z i Z is the count value of the ith pulse edge i-1 Z is the count value of the i-1 th pulse edge 0 =0; past is the effective count value i-1 For the count value valid for the i-1 th pulse edge, past i A count value valid for the ith pulse edge.
Wherein Z is i +C i Representing the count value obtained by compensating the pulse edge by the compensation quantity, namely the effective count value, and passing Z i -Past i-1 +C i Calculating the change of the effective count value of the two times to judge whether the pulse edge is the effective edge, if the change of the effective count value of the two times is zero, the counting is invalid, and the method passes through the formula Past i =Past i-1 +Delta i And updating the last effective count value, distinguishing the effective count value from the count value read by the encoder by judging whether the effective count value is the effective count value or not, and facilitating the next judgment of whether the pulse edge is the effective edge or not.
Optionally, when the Delta value is obtained by calculation, determining that the pulse edge with the Delta value not being zero is a valid edge, recording the time count of the pulse edge, determining that the pulse edge with the Delta value being zero is a pulse edge generated by abnormal level jump, and recording the time count of the pulse edge.
The beneficial effects of this embodiment lie in: according to the method, the pulse edge which is not abnormal in level jump is defined, the change amount of the effective count value is calculated through the compensated pulse edge count value, whether abnormal level jump occurs is judged according to whether the change amount of the effective count value is zero, and therefore an executing main body can count the effective edge better and record the time of the effective edge better.
According to the above embodiment, in yet another embodiment:
the calculating the motor rotating speed according to the number of the effective edges comprises the following steps:
Wherein Speed is the motor Speed; rpm is the motor rotation speed unit and represents revolutions per minute; encoerLines is the number of lines of the encoder; t (T) 1 A duration of the first time period; delta T 1 The time interval from the starting moment to the pulse edge of the first non-abnormal level jump in the first time period is set; delta T 2 A 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 edge at the end of the first time period; x is the count of the pulse edges at the first time node.
T 1 -ΔT 1 -ΔT 2 And (3) 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 is the effective edge number in the first time period, and the Y-plus-1 is the effective pulse number in the first time period. The abnormal level jump is compensated in the mode, 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 is calculated, the two error times are eliminated, and the accurate motor rotating speed is calculated.
According to the above embodiment, in yet another embodiment:
the calculating the motor rotation speed according to the time interval of the pulse edge of the adjacent non-abnormal level jump comprises the following steps:
wherein Speed is the motor Speed; rpm is the motor rotation speed unit and represents revolutions per minute; encoerLines is the number of lines of the encoder; and T is the time interval of the pulse edges of two adjacent non-abnormal level jumps in the second time period. And calculating the time used by one pulse in the time period by calculating the time interval of the pulse edges of two adjacent non-abnormal level jumps in the second time period with longer time interval, and further calculating the rotating speed of the motor in the time period.
According to the above embodiment, in yet another embodiment:
after the common starting time of the first time period and the second time period is determined, a first timer and a second timer are started, wherein the first timer is used for determining the first time period, and the second timer is used for determining the second time period. When the first time period is over, the first timer stops counting, and the second timer continues counting until the second time period is over; the count value X of the encoder is read while the timer is started. When the pulse signal reaches the rising edge or the falling edge, the counting value Z of the current pulse edge is obtained, meanwhile, the counting direction of the pulse edge is judged, the compensation quantity C is calculated, whether the pulse edge is an effective edge is judged according to the compensation quantity Delta, and when the pulse edge is the effective edge, the time count of the second timer is calculated, and the motor rotating speed is obtained. At the end of one measurement, the first timer and the second timer are cleared for the next measurement.
As an example and not by way of limitation, the present embodiment provides a method for implementing motor rotation speed measurement, where the second timer counts the time of the effective edge in the first time period and/or the second time period, so that the effective pulse time and the time interval between the two effective edges can be more accurately and conveniently calculated.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 5, in which:
when no abnormal level jump occurs in the first time period, determining the starting time a of the first time period, wherein the counted value of the pulse edge is Z 0 =X。
For edge 501, D 0 =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 501 is judged to be a valid edge, the time count of the edge 501 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
For edge 502, D 1 =1,D 2 =1,C 1 =0,C 2 =C 1 +(D 1 -D 2 )*2=0,Z 2 =X+2,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =1,Past 2 =Past 1 +Delta 2 =x+2; the edge 502 is judged to be a valid edge, the time count of the edge 502 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
For edge 503, D 2 =1,D 3 =1,C 2 =0,C 3 =C 2 +(D 2 -D 3 )*2=0,Z 3 =X+3,Past 2 =X+2,Delta 3 =Z 3 -Past 2 +C 3 =1,Past 3 =Past 2 +Delta 3 =x+3; the edge 503 is judged to be a valid edge, the time count of the edge 503 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
At this time, the motor rotation speed isΔT 1 Taking the time interval from the edge 501 to the beginning of the first period, deltaT 2 Taking the time interval of edge 503 to b at the end of the first time period, |z 3 -x+c| -1=3 corresponds to the actual number of pulses in the period.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 6, in which:
When the first time period starts and an abnormal level jump occurs, the starting time a of the first time period is the counting value of the pulse edge is Z 0 =X,
For edge 601, D o =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 601 is judged to be a valid edge, the time count of the edge 601 is recorded, the compensation amount is calculated to be zero, and the compensation of the valid count value is 0.
For edge 602, D 1 =1,D 2 =0,C 1 =0,C 2 =C 1 +(D 1 -D 2 )*2=1,Z 2 =X,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =0,Past 2 =Past 1 +Delta 2 =x+1; the edge 602 is judged to be a pulse edge generated by abnormal level jump, the time count of the edge 602 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated as 1, and the compensation of the effective count value is 1.
For edge 603, D 2 =0,D 3 =1,C 2 =1,C 3 =C 2 +(D 2 -D 3 )*2=0,Z 3 =X+1,Past 2 =X+1,Delta 3 =Z 3 -Past 2 +C 3 =0,Past 3 =Past 2 +Delta 3 =x+1; the edge 602 is judged to be a pulse edge generated by abnormal level jump, the time count of the 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 to the effective count value is calculated to be 0.
For edge 604, D 3 =1,D 4 =1,C 4 =C 3 +(D 3 -D 4 )*2=0,Z 4 =X+2,Past 3 =X+1,Delta 4 =Z 4 -Past 3 +C 3 =1,Past 4 =Past 3 +Delta 4 =x+1; the edge 604 is judged to be a valid edge, the time count of the edge 604 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
At this time, the motor rotation speed isΔT 1 Taking the time interval from the edge 601 to the beginning of the first period, deltaT 2 Taking the time interval from edge 604 to the end b of the first time period, |Z 4 -x+c| -1=2 corresponds to the actual number of pulses.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 7, in which:
when the first time period is in progress and abnormal level jump occurs, for the starting time a of the first time period, the counted value of the pulse edge is Z 0 =X,
For edge 701, D 0 =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 701 is judged to be a valid edge, the time count of the edge 701 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
For edge 702, D 1 =1,D 2 =1,C 1 =0,C 2 =C 1 +(D 1 -D 2 )=0,Z 2 =X+2,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =1,Past 2 =Past 1 +Delta 2 =x+2; the edge 702 is judged to be an effective edge, the time count of the edge 702 is recorded, the effective count value accords with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation to the effective count value is 0.
For edge 703, D 2 =1,D 3 =0,C 2 =0,C 3 =C 2 +(D 2 -D 3 )=1,Z 3 =X+1,Past 2 =X+2,Delta 3 =Z 3 -Past 2 +C 3 =0,Past 3 =Past 2 +Delta 3 =x+2; the edge 703 is judged to be a pulse edge generated by an abnormal level jump, the time count of the edge 703 is not recorded, the effective count value coincides with the actual effective edge value, the compensation amount is calculated as 0, and the compensation for the effective count value is 1.
For edge 704, D 3 =0,D 4 =1,C 4 =C 3 +(D 3 -D 4 )=0,Z 4 =X+2,Past 3 =X+2,Delta 4 =Z 4 -Past 3 +C 3 =0,Past 4 =Past 3 +Delta 4 =x+2; the edge 704 is judged to be a pulse edge generated by abnormal level jump, the time count of the edge 704 is not recorded, the compensation amount is calculated to be zero, and the compensation of the effective count value is calculated to be 0.
At this time, the motor rotation speed isΔT 1 Taking the time interval from the edge 701 to the beginning of the first period, Δt 2 Taking the time interval from edge 702 to the end of the first time period, |Z 4 -x+c| -1=2 corresponds to the actual number of pulses.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 8, in which:
when the first time period is over, abnormal level jump occurs, and for the starting time a of the first time period, the counting value of the pulse edge is Z 0 =X,
For edge 801, D 0 =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 801 is judged to be a valid edge, the time count of the edge 801 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
For edge 802, D 1 =1,D 2 =1,C 1 =0,C 2 =C 1 +(D 1 -D 2 )=0,Z 2 =X+2,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =1,Past 2 =Past 1 +Delta 2 =x+2; the edge 802 is judged to be an effective edge, the time count of the edge 802 is recorded, the effective count value accords with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation to the effective count value is 0.
For edge 803, D 2 =1,D 3 =0,C 2 =0,C 3 =C 2 +(D 2 -D 3 )=1,Z 3 =X+1,Past 2 =X+2,Delta 3 =Z 3 -Past 2 +C 3 =0,Past 3 =Past 2 +Delta 3 =x+2; the edge 803 is judged to be a pulse edge generated by abnormal level jump, the time count of the edge 803 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 to the effective count value is 1.
At this time, the motor rotation speed isΔT 1 Taking the time interval from edge 801 to the beginning of the first time period, ΔT 2 Taking the time interval from edge 802 to the end of the first time period, |Z 3 -x+c| -1=2 corresponds to the actual number of pulses.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 9, in which:
when the first time period is over, abnormal level jump occurs, and for the starting time a of the first time period, the counting value of the pulse edge is Z 0 =X。
For edge 901, D 0 =1,D 1 =0,C 1 =(D 0 -D 1 )*2=2,Z 1 =X-1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 901 is judged to be a valid edge, and the time count of the edge 901 is recorded.
For edge 902, D 1 =0,D 2 =1,C 1 =0,C 2 =C 1 +(D 1 -D 2 )=1,Z 2 =X,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =0,Past 2 =Past 1 +Delta 2 =x+1; the edge 902 is determined to be a pulse edge generated by an abnormal level transition, and the time count of the edge 902 is not recorded.
For edge 903, D 2 =1,D 3 =1,C 2 =1,C 3 =C 2 +(D 2 -D 3 )=1,Z 3 =X+1,Past 2 =X+1,Delta 3 =Z 3 -Past 2 +C 3 =1,Past 3 =Past 2 +Delta 3 =x+2; the edge 903 is judged to be an effective edge, the time count of the edge 903 is recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated to be 0, and the compensation of the effective count value is 1.
At this time, the motor rotation speed isΔT 1 Taking the time interval from the edge 901 to the beginning of the first period, ΔT 2 Taking the time interval from edge 902 to the end b of the first period, |z 3 -X+C|-1=1。
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 10, in which:
when the number of effective edges in the first time periods a to b is determined to be less than two and the number of effective edges in the second time periods a to c is determined to be not less than two, when 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 edges is Z 0 =X。
For edge 1001, D 0 =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 1001 is judged to be a valid edge, the time count of the edge 1001 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
For edge 1002, D 1 =1,D 2 =0,C 1 =0,C 2 =C 1 +(D 1 -D 2 )*2=1,Z 2 =X,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =0,Past 2 =Past 1 +Delta 2 =x+1; the edge 1002 is judged to be a pulse edge generated by abnormal level jump, the time count of the edge 1002 is not recorded, the effective count value is consistent with the actual effective edge value, the compensation amount is calculated as 1, and the compensation of the effective count value is 1.
For edge 1003, D 2 =0,D 3 =1,C 2 =1,C 3 =C 2 +(D 2 -D 3 )*2=0,Z 3 =X+1,Past 2 =X+1,Delta 3 =Z 3 -Past 2 +C 3 =0,Past 3 =Past 2 +Delta 3 =x+1; the edge 1003 is judged to be a pulse edge generated by abnormal level jump, the time count of the edge 1003 is not recorded, the effective count value coincides with the actual effective edge value, the compensation amount is calculated as 0, and the compensation to the effective count value is 0.
For edge 1004, D 3 =1,D 4 =1,C 4 =C 3 +(D 3 -D 4 )*2=0,Z 4 =X+2,Past 3 =X+1,Delta 4 =Z 4 -Past 3 +C 3 =1,Past 4 =Past 3 +Delta 4 =x+1; the edge 1004 is judged to be a valid edge, the time count of the edge 1004 is recorded, the compensation amount is calculated to be zero, and the compensation to the valid count value is 0.
At this time, the motor rotation speed isWhere T is the time interval of two valid edges of edge 1001 to edge 1004.
An alternative motor speed measurement embodiment will be given below with respect to the pulse signal shown in fig. 11, in which:
when the number of effective edges in the first time periods a to b is determined to be less than two and the number of effective edges in the second time periods a to c is determined to be not less than two, when abnormal level jump occurs at the end of the second time periods, for the starting time a of the first time periods, the count value of the pulse edges is Z 0 =X。
For edge 1101, D 0 =1,D 1 =1,C 1 =(D 0 -D 1 )*2=0,Z 1 =X+1,Past 0 =Z 0 =X,Delta 1 =Z 1 -Past 0 +C 1 =1,Past 1 =Past 0 +Delta 1 =x+1; the edge 1101 is judged to be a valid edge, the time count of the edge 1101 is recorded, the compensation amount is calculated to be zero, and the compensation for the valid count value is 0.
For edge 1102, D 1 =1,D 2 =1,C 1 =0,C 2 =C 1 +(D 1 -D 2 )=0,Z 2 =X+2,Past 1 =X+1,Delta 2 =Z 2 -Past 1 +C 2 =1,Past 2 =Past 1 +Delta 2 =x+2; the edge 1102 is judged to be a valid edge and the time count of the edge 1102 is recorded.
At this time, the motor rotation speed isWhere T is the time interval of two valid edges of edge 1101 to edge 1102.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Corresponding to the motor rotation speed method described in the above embodiments, fig. 2 shows a block diagram of the apparatus provided in the embodiment of the present application, and for convenience of explanation, only the portions relevant to the embodiment of the present application are shown.
Referring to fig. 3, the apparatus includes:
the acquisition module 301 is configured to acquire a pulse signal output by the encoder when the motor rotor rotates, where 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 302, configured to obtain a counting direction of a pulse edge according to a phase difference between the first signal and the second signal;
a calculation module 303, configured to obtain a compensation amount according to the counting directions of the adjacent pulse edges, where the compensation amount is used to compensate for abnormal level transitions of the pulse signal;
and the rotating speed module 304 is used for obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
Specifically, the processing module 302 includes:
a direction judging sub-module, configured to determine a counting direction of the first edge after determining a phase difference between the first edge and the second edge; when the phase of the first edge is determined to be behind the second edge, the counting direction of the first edge is recorded as positive counting; when the phase of the first edge is determined to be ahead of the second edge, the counting direction of the first edge is recorded as backward 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; the second edge is a pulse edge with the minimum absolute value of phase difference relative to the first edge.
The calculation module 303 includes:
an assignment sub-module, configured to assign a direction value of the ith pulse edge after determining a counting direction of the ith pulse edge; when the ith pulse edge is counted in the forward direction, the direction value of the ith pulse edge is recorded as 1, wherein i is a positive integer, and i is more than or equal to 2; when the ith pulse edge is counted reversely, the direction value of the ith pulse edge is recorded as 0;
the compensation calculation operator module calculates the compensation according to the difference value between the direction value of the ith pulse edge and the direction value of the ith pulse edge;
the compensation quantity is used for compensating the counting value of the pulse edge to obtain an effective counting value, and the effective counting value is used for judging whether abnormal level jump occurs or not.
Further, the compensation calculation operator module, after determining the ith pulse edge as the first pulse edge in the first time period, passes through formula C i =(D i-1 -D i ) 2, calculating to obtain the compensation quantity; when it is determined that the ith pulse edge is not the first pulse edge in the first period of time, the pulse edge is represented by formula C i = i-1 +(D i-1 -D i ) Calculating to obtain the compensation quantity;
the rotational speed module 304 includes:
an edge timing sub-module for determining a first time period and a second time period having a common start time, and the first time period is shorter than the second time period;
the first rotational speed calculation sub-module is used for calculating the rotational speed of the motor according to the number of the effective edges after determining that the number of the effective edges in the first time period is at least two;
and the second rotating speed calculation sub-module is used for calculating the rotating speed of the motor according to the time interval of the pulse edges of adjacent non-abnormal level jump after the number of the effective edges in the first time period is determined to be smaller than two and the number of the effective edges in the second time period is determined to be not smaller than two.
Specifically, the edge timing submodule comprises an edge timing unit, wherein the subunit is used for recording the timing time of the effective edge;
the first rotational speed calculation sub-module includes:
an effective edge obtaining unit, configured to obtain the number of effective edges in the first period;
The first rotation speed calculation unit is used for calculating 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 first calculating unit is further used for calculating the motor rotating speed according to the number of effective edges in the first time period and the effective pulse time.
Further, the effective edge acquisition unit acquires the effective edge number by acquiring the variation Delta of the effective count value of the pulse edge.
The Delta value is Delta according to the formula i = i -ast i-1 + i Calculating to obtain;
the Past value is according to the formula Past i =ast i-1 +elta i Calculated, when the ith pulse edge is the first pulse edge in the first time period, past i-1 =Z i-1 ;
The first rotational speed calculating unit calculates the rotational speed of the motor byCalculating to obtain the motor rotation speed;
the second rotational speed calculation sub-module is used for calculating the rotational speed of the motor byAnd calculating to obtain the motor rotating speed.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the present application further provides a terminal device, as shown in fig. 4, where 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, which processor implements the steps of any of the various method embodiments described above when it executes the computer program.
Embodiments of the present application also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements steps that may implement the various method embodiments described above.
Embodiments of the present application provide a computer program product which, when run on a mobile terminal, causes the mobile terminal to perform steps that may be performed in the various method embodiments described above.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing device/terminal apparatus, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (10)
1. A method of measuring a rotational speed of a motor, comprising:
acquiring a pulse signal output by an encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;
Obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal;
obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, wherein the compensation quantity is used for compensating abnormal level jump of the pulse signals;
and obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
2. A method of measuring a rotational speed of a motor as defined in claim 1, wherein the step of obtaining a counting direction of pulse edges based on a phase difference between the first signal and the second signal comprises:
determining that the phase of the first edge is behind the second edge, and recording the counting direction of the first edge as forward counting; determining that the phase of the first edge leads the second edge, and recording the counting direction of the first edge as backward 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; the second edge is a pulse edge with the minimum absolute value of phase difference relative to the first edge.
3. A method of measuring a rotational speed of a motor according to claim 2, wherein said step of deriving the compensation amount based on said counting direction of adjacent pulse edges comprises:
when the ith pulse edge is counted in the forward direction, the direction value of the ith pulse edge is recorded as 1, wherein i is a positive integer, and i is more than or equal to 2;
when the ith pulse edge is counted reversely, the direction value of the ith pulse edge is recorded as 0;
calculating the compensation quantity according to the difference value between the direction value of the ith pulse edge and the direction value of the ith pulse edge;
the compensation quantity is used for compensating the counting value of the pulse edge to obtain an effective counting value, and the effective counting value is used for judging whether abnormal level jump occurs or not.
4. A method of measuring a rotational speed of a motor according to any one of claim 3, wherein the step of obtaining the rotational speed of the motor based on the compensation amount and the pulse signal comprises:
determining a first time period and a second time period having a common start time, and the first time period is shorter than the second time period;
determining that the number of the effective edges in the first time period is at least two, and calculating the motor rotating speed according to the number of the effective edges; the number of the effective edges is the number of pulse edges which are not abnormal level jumps;
And determining that the number of the effective edges in the first time period is smaller than two, and if the number of the effective edges in the second time period is not smaller than two, calculating to obtain the motor rotating speed according to the time interval of the pulse edges of adjacent non-abnormal level jump.
5. The method of claim 4, wherein said step of calculating said motor speed from said number of active edges comprises:
acquiring the number of effective edges in the first time period;
calculating 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;
and calculating the motor rotating speed according to the number of the effective edges in the first time period and the effective pulse time.
6. The method of claim 4, wherein said step of obtaining the compensation amount according to the counting direction of the adjacent pulse edges comprises:
determining the ith pulse edge as the first pulse edge in the first time period, and passing through formula C i =(D i-1 -D i ) 2, calculating to obtain the compensation quantity;
Determining that the ith pulse edge is not the first pulse edge in the first time period, and determining that the ith pulse edge is C by a formula i =C i-1 +(D i-1 -D i ) Calculating to obtain the compensation quantity;
wherein C is the compensation amount, C i C for the compensation amount of the ith pulse edge i-1 For the i-1 th pulse edgeThe calculated compensation quantity D is the direction value of the pulse edge and D i-1 D is the direction value of the i-1 th pulse edge i Is the direction value of the ith pulse edge.
7. The method of claim 6, wherein the pulse edge of the non-abnormal level transition is a pulse edge with Delta value not being zero;
the Delta value is Delta according to the formula i = i -ast i-1 + i Calculating to obtain;
past values according to the formula Past i =ast i-1 +elta i Calculated, when the ith pulse edge is the first pulse edge in the first time period, past i-1 =Z i-1 ;
Wherein Delta is the variation of the effective count value i A variation of the effective count value for the ith pulse edge; z is the count value of the pulse edge, when the pulse edge counts forward, the count value of the pulse edge is increased by one, and when the pulse edge counts backward, the count value of the pulse edge is decreased by one; z is Z i Z is the count value of the ith pulse edge i-1 Z is the count value of the i-1 th pulse edge 0 =0; past is the effective count value i-1 For the count value valid for the i-1 th pulse edge, past i A count value valid for the ith pulse edge.
8. A motor speed measuring device, comprising:
the acquisition module is used for acquiring a pulse signal output by the encoder when the motor rotor rotates, wherein the pulse signal comprises a first signal and a second signal, and the first signal and the second signal are orthogonal pulses;
the processing module is used for obtaining the counting direction of the pulse edge according to the phase difference of the first signal and the second signal;
the calculation module is used for obtaining a compensation quantity according to the counting direction of the adjacent pulse edges, and the compensation quantity is used for compensating abnormal level jump of the pulse signals;
and the rotating speed module is used for obtaining the rotating speed of the motor according to the compensation quantity and the pulse signal.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211583755.XA CN116338231A (en) | 2022-12-09 | 2022-12-09 | Motor rotation speed measuring method and device, terminal equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211583755.XA CN116338231A (en) | 2022-12-09 | 2022-12-09 | Motor rotation speed measuring method and device, terminal equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116338231A true CN116338231A (en) | 2023-06-27 |
Family
ID=86884683
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211583755.XA Pending CN116338231A (en) | 2022-12-09 | 2022-12-09 | Motor rotation speed measuring method and device, terminal equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116338231A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116460321A (en) * | 2023-04-12 | 2023-07-21 | 阿帕斯数控机床制造(上海)有限公司 | Compensation method and device for elongation of spindle of numerical control machine tool and numerical control machine tool |
-
2022
- 2022-12-09 CN CN202211583755.XA patent/CN116338231A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116460321A (en) * | 2023-04-12 | 2023-07-21 | 阿帕斯数控机床制造(上海)有限公司 | Compensation method and device for elongation of spindle of numerical control machine tool and numerical control machine tool |
CN116460321B (en) * | 2023-04-12 | 2024-02-09 | 阿帕斯数控机床制造(上海)有限公司 | Compensation method and device for elongation of spindle of numerical control machine tool and numerical control machine tool |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20060119348A1 (en) | Technique for sensing the rotational speed and angular position of a rotating wheel using a variable threshold | |
JP2003254785A (en) | Signal processor for encoder | |
CN116338231A (en) | Motor rotation speed measuring method and device, terminal equipment and storage medium | |
KR20060047859A (en) | Method for measuring the rotation speed of an ec-motor | |
US4329645A (en) | Rotational speed measuring system having a circuit for increasing the accuracy thereof | |
US10921767B2 (en) | Encoder system | |
CN106645780B (en) | DSP-based rotating speed detection method and system | |
CN108549024B (en) | Predictive M/T speed measurement system and method | |
US5703283A (en) | Detrending engine positional data for rotating position encoders | |
US20010013775A1 (en) | Technique for sensing the rotational speed and angular position of a rotating wheel | |
US10352957B2 (en) | Method for generating a speed signal of an electric motor | |
JPH06147922A (en) | Displacement measuring device | |
CN116183954A (en) | Motor speed measuring method, system, device, electronic equipment and storage medium | |
CN111146979A (en) | Initial angle correction method and device of motor rotor and electric vehicle | |
GB2374150A (en) | Method of Determining Engine Speed | |
CN117222866A (en) | Method for adapting tolerances of a system comprising a position sensor and a rotating target | |
US6246343B1 (en) | Increment encoder failure detection | |
CN107425759B (en) | Method and device for eliminating MT method speed measurement error of incremental photoelectric encoder | |
JP3320454B2 (en) | Motor position control device and motor position control method | |
CN117782187B (en) | Nonlinear error correction method of encoder and encoder | |
JP3860324B2 (en) | Motor speed control device | |
CN114778884B (en) | Speed measurement method and device based on incremental encoder and electronic equipment | |
JP3201238B2 (en) | Speed detector | |
CN113632370B (en) | Control device for motor | |
JPH0725698Y2 (en) | Rotating machine speed detector |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |