Method of determining a direction of rotation and valid transitions of quadrature pulses
10320594 ยท 2019-06-11
Assignee
Inventors
Cpc classification
International classification
Abstract
A method of determining a direction of rotation of a shaft is disclosed, as well as an integrated circuit chip that uses the disclosed method. The method includes receiving a first binary signal and a second binary signal from a transducer attached to the shaft, with the first and second binary signals being in quadrature. A present quadrant identification number, QID.sub.PRESENT, is determined as a two-digit binary number by left-shifting a value of the first signal and adding a value of the second signal. After a sampling interval has elapsed, the method sets a past quadrant identification number, QID.sub.PAST, to the value of said QID.sub.PRESENT, determines a new value of QID.sub.PRESENT and calculates a value of a transition code using an equation that operates on QID.sub.PRESENT and QID.sub.PAST. The method uses the transition code to determine a direction of rotation of the shaft.
Claims
1. A method of using a digital motor control system to control a motor driven by rotation of a shaft, the method comprising: receiving via one or more inputs of a processor of the digital motor control system, a first binary signal and a second binary signal from a transducer attached to the shaft, the first and second binary signals being in quadrature; and using the processor of the digital motor control system to: determine a present quadrant identification number, QID.sub.PRESENT, as a two-digit binary number by left-shifting a value of the first binary signal and adding a value of the second binary signal; after a sampling interval has elapsed, set a past quadrant identification number, QID.sub.PAST, to the value of the QID.sub.PRESENT, determine a new value of QID.sub.PRESENT, and calculate a value of a transition code using an equation that operates on QID.sub.PRESENT and QID.sub.PAST; and responsive to a determination that the transition code is valid, use the transition code to determine a direction of rotation of the shaft, produce a direction of rotation signal indicative of the determined direction of rotation, generate at least one control signal based at least partially upon the direction of rotation signal to control the motor.
2. The method of claim 1, further comprising using the processor to determine whether the transition code is invalid.
3. The method of claim 2, further comprising, responsive to determining that the transition code is invalid, using the processor to perform an invalid transition code routine.
4. The method of claim 3, wherein determining a direction of rotation of the shaft comprises determining whether the rotation of the shaft is clockwise.
5. The method of claim 4, further comprising, responsive to determining that the rotation of the shaft is clockwise, incrementing a counter.
6. The method of claim 1, wherein the value of the transition code is calculated as (2*QID.sub.PRESENT)QID.sub.PAST.
7. The method of claim 6, further comprising, after determining the new value of QID.sub.PRESENT and prior to calculating the value of the transition code, determining whether a transition has occurred.
8. The method of claim 7, further comprising, responsive to determining that no transition has occurred, waiting for a next sampling period to elapse.
9. The method of claim 1, wherein the value of the transition code is calculated as (QID.sub.PRESENT).sup.2(QID.sub.PAST).sup.2.
10. The method of claim 9, further comprising, responsive to determining that the transition code is valid, determining whether a transition has occurred.
11. The method of claim 10, further comprising, responsive to determining that no transition has occurred, waiting for a next sampling period to elapse.
12. The method of claim 1, wherein the value of the transition code as calculated using the equation that operates on QID.sub.PRESENT and QID.sub.PAST is: a value from a first set of values when the direction of rotation of the shaft is in a first direction; and a value from a second set of values when the direction of the rotation of the shaft is in a second direction opposite the first direction; wherein the values of the first set all differ from the values of the second set.
13. The method of claim 12, wherein the value of the transition code as calculated using the equation that operates on QID.sub.PRESENT and QID.sub.PAST is a value form a third set of values when the transition code is invalid, wherein the values of the third set all differ from the values of the first and second sets.
14. A motor control system comprising: a motor having a shaft; an inverter to supply power to the drive motor by rotation of the shaft; a transducer coupled to the shaft to provide a first binary signal and a second binary signal, the first and second binary signals being in quadrature; and a processor having inputs to receive the first and second binary signals and being configured to execute instructions to: determine a present quadrant identification number, QID.sub.PRESENT, as a two-digit binary number by left-shifting a value of the first binary signal and adding a value of the second binary signal; after a sampling interval has elapsed, set a past quadrant identification number, QID.sub.PAST, to the value of the QID.sub.PRESENT, determine a new value of QID.sub.PRESENT, and calculate a value of a transition code using an equation that operates on QID.sub.PRESENT and QID.sub.PAST; and responsive to a determination that the transition code is valid, use the transition code to determine a direction of rotation of the shaft, produce a direction of rotation signal indicative of the determined direction of rotation, output at least one control signal to the inverter to cause the inverter to drive the motor.
15. The motor control system of claim 14, wherein the value of the transition code as calculated using the equation that operates on QID.sub.PRESENT and QID.sub.PAST is: a value from a first set of values when the direction of rotation of the shaft is in a first direction; and a value from a second set of values when the direction of the rotation of the shaft is in a second direction opposite the first direction; wherein the values of the first set all differ from the values of the second set.
16. The motor control system of claim 15, wherein the value of the transition code as calculated using the equation that operates on QID.sub.PRESENT and QID.sub.PAST is a value form a third set of values when the transition code is invalid, wherein the values of the third set all differ from the values of the first and second sets.
17. The motor control system of claim 14, wherein the at least one control signal includes a plurality of pulse width modulation (PWM) signals.
18. The motor control system of claim 17, wherein the inverter is a three-phase inverter and the plurality of PWM signals includes six PWM signals.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that different references to an or one embodiment in this disclosure are not necessarily to the same embodiment, and such references may mean at least one. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.
(2) The accompanying drawings are incorporated into and form a part of the specification to illustrate one or more exemplary embodiments of the present disclosure. Various advantages and features of the disclosure will be understood from the following Detailed Description taken in connection with the appended claims and with reference to the attached drawing figures in which:
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
DETAILED DESCRIPTION OF THE DRAWINGS
(11) Specific embodiments of the invention will now be described in detail with reference to the accompanying figures. In the following detailed description of embodiments of the invention, numerous specific details are set forth in order to provide a more thorough understanding of the invention. However, it will be apparent to one of ordinary skill in the art that the invention may be practiced without these specific details. In other instances, well-known features have not been described in detail to avoid unnecessarily complicating the description.
(12) Turning first to
(13) Sinusoidal encoders, also known as sincos transducers, are another method of sensing rotation; their advantage is that with some computation, it is possible to detect the precise angle of the shaft being sensed. The angle calculation comprises a coarse part found by counting quadrature edges, and a fine part found using an arctan calculation on the sinusoids.
(14)
(15) Applicant has determined that rather than implementing a state machine in software, either of two simple calculations can provide the information in a timely manner. Applicant notes that the disclosed method is designed to be used whether or not the shaft whose rotation is being measured is powered or not. To ensure that all transitions are captured, the incoming signal should be sampled at least as often as the incoming signals can possibly have transitions or edges. If this is done, the method will capture all counts. The disclosed method requires that each time a sampling period has elapsed, a transition code is determined using current values of the signals. The current transition code and the immediate past transition code are then used in a simple mathematical formula that can determine the direction of travel, as well as invalid transitions, as will be explained below. In one embodiment, a transition code of zero indicates that no transition has occurred, i.e., that the shaft is either not turning or the shaft is turning slowly enough that a transition does not always occur during the sampling period.
(16) Turning next to
(17) The disclosed method uses the current QID (QID.sub.PRESENT), the immediate past QID (QID.sub.PAST), and a simple equation to determine the direction of rotation and can also identify invalid transitions. Applicants have found two simple equations that can provide the desired information, with each having their own advantages. In a first embodiment, a transition code is determined using Equation 1:
TCODE1=2*QID.sub.PRESENTQID.sub.PASTEquation 1
(18) Table 1 illustrates the valid TCODEs that can be produced using Equation 1. From this table, it can be seen that when the associated shaft is rotating in a clockwise manner, the values of TCODE1 proceed in the sequence 5, 1, 2, 2, 5, 1, 2, 2, etc. Similarly, if the associated shaft is rotating in a counter clockwise manner, the values of TCODE1 proceed in the sequence 4, 4, 1, 1, 4, 4, 1, 1, etc. Notably, the valid values in the clockwise direction do not overlap with the valid values in the counter clockwise direction, so the direction of rotation can be determined very quickly by noting the values of TCODE1.
(19) TABLE-US-00001 TABLE 1 QID 3 2 0 1 3 2 Clockwise TCODE1 5 1 2 2 5 1 Counter Clockwise 4 4 1 1 4 4 TCODE1
(20) As noted previously, the disclosed method is designed to be used whether or not the shaft is turning. Accordingly, it is possible to have QID.sub.PRESENT=QID.sub.PAST when the shaft is not turning. When Equation 1 is being used, this can result in TCODE values of 3, 2, 0 and 1, depending on the QID when the rotation stopped. These values overlap both valid clockwise TCODE values and illegal codes, so it is not possible to determine from the TCODE whether a transition has occurred. Accordingly, this determination must be made prior to applying Equation 1. Table 2 illustrates all of the possible transition codes using Equation 1:
(21) TABLE-US-00002 TABLE 2 Transition No code CW CCW Illegal Edge 6 Yes 5 Yes 4 Yes 3 Yes Yes 2 Yes Yes 1 Yes Yes 0 Yes Yes 1 Yes 2 Yes 3 Yes
(22) In a second embodiment, a transition code is determined using Equation 2:
TCODE2=(QID.sub.PRESENT).sup.2(QID.sub.PAST).sup.2Equation 2
Table 3 illustrates the valid TCODEs that can be produced using Equation 2:
(23) TABLE-US-00003 TABLE 3 QID 3 2 0 1 3 2 Clockwise TCODE2 8 5 4 1 8 5 Counter Clockwise 5 4 1 8 5 4 TCODE2
(24) It can be seen that if the associated shaft is rotating in a clockwise manner, the values of TCODE2 are produced in the sequence 8, 5, 4, 1, 8, 5, 4, 1, etc. Similarly, if the associated shaft is rotating in a counter clockwise manner, the values of TCODE2 are produced in the sequence 5, 4, 1, 8, 5, 4, 1, 8, etc. Using Equation 2, the valid values in the clockwise direction again do not overlap with the valid values in the counter clockwise direction, allowing the direction of rotation to be determined very quickly by noting the values of TCODE2. Additionally, however, if no transition has occurred because the shaft is not turning or is turning more slowly than the sampling interval, the resultant TCODE is always 0. As this is a unique code, overlapping with neither valid TCODES nor with invalid TCODES, calculating the TCODE using Equation 2 can identify when a transition has not occurred, so that there is no need to make this determination separately.
(25) Table 4 illustrates all of the possible values that can be calculated using Equation 2 and clearly shows that each possible code uniquely identifies whether that value represents clockwise rotation, counter clockwise rotation, illegal values or a lack of an edge. Applicant notes that although Equation 2 is more computationally complex than Equation 1, most processors have hardware multipliers that make the difference in calculations negligible.
(26) TABLE-US-00004 TABLE 4 Transition No code CW CCW Illegal edge 9 Yes 8 Yes 5 Yes 4 Yes 3 Yes 1 Yes 0 Yes 1 Yes 3 Yes 4 Yes 5 Yes 8 Yes 9 Yes
(27)
(28) DSP 208 includes a number of modules that act together to provide signals that will control motor 202 through three-way inverter 204. DSP 208 includes PWM driver 206, which generates switching waveforms PWM1-PWM6 that drive the switches in three-phase power inverter 204. Three connectors (not specifically shown) receive the inputs from quadrature encoder 212, which in this embodiment include quadrature signals QEP_A, QEP_B and QEP_INDEX. The remainder of DSP 208 utilizes the signals received from quadrature encoder 212, signals ADCIN.sub.X(Ia), ADCIN.sub.X(Ib), and ADCIN.sub.X(VDC) received from three-phase inverter 204, and programmable inputs for gain and offset received at ILEG2DRV 228 to provide a feedback loop to PWM driver 206. This feedback loop includes quadrature encoder pulse driver (QEP DRV) 214, ILEG2DRV 228, speed and frequency module 230, Clark module 218, Park module 220, Inverse Park module 222, SVGEN module 224, PID-REG modules 226, as well as a number of modules not specifically discussed. QEP 214 receives signals QEP_A and QEP_B, determines the rotor position, and generates a direction of rotation signal from the shaft position encoder pulses. QEP DRV 214 provides four outputs: motor electrical angle (ELEC_THETA), motor mechanical angle (THETA_MECH), motor rotation direction (DIRECTIONQEP) and index synchronous status (INDEXSYNCFLAG). ELEC_THETA is used to provide rotor angle 216 to other modules within DSP 208.
(29) Park transform module 220 and inverse Park transform module 222 convert vectors between a balanced two-phase orthogonal stationary frame and an orthogonal rotating reference frame. Clark transform module 218 converts balanced two phase quadrature quantities into balanced three phase quantities. Space vector with quadrature control (SVGEN) 224 calculates the appropriate duty ratios needed to generate a given stator reference voltage using space vector PWM technique. The stator reference voltage is described by (a, b) components, U.sub.ALPHA and U.sub.BETA. Proportional and Integral Regulators (PID-REG) 226 are software modules that implement two PI regulators with integral windup correction. Dual Inverter Leg Resistor Based Load Current Measurement Driver (ILEG2DRV) 228 is a driver module that converts two analog inputs into digital representations with programmable gains and offsets. The converted results represent load currents of a three-phase voltage source inverter for known conditions. DSP 208 uses obtained rotor angle 216 and the additional data that is derived from collected information to implement a control algorithm that controls motor 202. Further documentation on the system shown in
(30)
(31) As part of determining a direction of rotation of the shaft, it is desirable to determine whether a transition has occurred. However, as mentioned previously, the transition code can be used to make this determination when Equation 2 is utilized, but not when Equation 1 is used.
(32) On the other hand,
(33) Applicant has disclosed a method of determining a direction of rotation of a shaft with a simple computation that uses a present quadrant identification number and the past quadrant identification number to calculate a transition code. Use of the transition code also enables detection of an illegal transition in the received signals and in one embodiment also indicates when no transition has occurred in the signal. The direction of rotation can be used to increment or decrement a counter. The direction and speed of rotation, which are derived from the same signals, can then be used by a controller to control the speed and/or position of the shaft.
(34) Although various embodiments have been shown and described in detail, the claims are not limited to any particular embodiment or example. None of the above Detailed Description should be read as implying that any particular component, element, step, act, or function is essential such that it must be included in the scope of the claims. Reference to an element in the singular is not intended to mean one and only one unless explicitly so stated, but rather one or more. All structural and functional equivalents to the elements of the above-described embodiments that are known to those of ordinary skill in the art are expressly incorporated herein by reference and are intended to be encompassed by the present claims. Accordingly, those skilled in the art will recognize that the exemplary embodiments described herein can be practiced with various modifications and alterations within the spirit and scope of the claims appended below.