Spectrum and Cepstrum Based
Speed Determination of Stepper Motors
Topic: Sensors, Measurement and Observation Techniques
Abstract-Accurate rotational speed determination for rotary machines tends to be allocated high priority in technical applications. It is not easy to measure shaft speed directly in some cases. Vibration diagnostic tools can offer an alternative solution to the problem posed by direct rotational speed measurement. Using calculated spectra and cepstra can help to determine rotational speed of stepper motor driven systems easily and accurately. This paper summarizes the theoretical background of discrete spectrum and cepstrum based methodologies and also shows results of practical experiments. Equations for each method to calculate the possible speed estimation error are also shown. A novel vibration based hybrid spectral speed estimation logic can be defined, which uses the presented equations to decide which spectral method results in the most accurate output. Numerous vibration measurements were made to test the hybrid methods reliability. It was successfully applied on various type of electromotive drives, as well as spark- and compression-ignition internal combustion engines with different cylinder numbers and arrangements.
I. INTRODUCTION
It is often a critically important task to define an accurate, and measurement based method for estimating the operational state of the examined device. Rotational speed should ideally be measured for a high number of diagnostic algorithms, control or regulation processes. Incorrect values could cause serious disturbances in the operation of machines.
There are plenty of common rotational speed measuring solutions to solve this problem. One can easily use electrical, optical, magnetic or combined techniques as well. Mounting sensors into a device is usually not an easy task, in particular if doing so requires the modification of a rotating component. The difficulty is mainly caused by the compactness of modern devices. These parts are usually not directly accessible to users and there tends to be insufficient free space near the drive. In these instances vibration diagnostics that uses additional acceleration sensor and spectral analysis methods can be the best alternative solution. Vibration analysis is nowadays the most commonly used tool for troubleshooting and condition monitoring of rotary machines [1].
This paper presents the development of a spectrum and cepstrum based hybrid calculation method. This method is capable of calculating the rotational speed of rotary machines more accurately than any of the aforementioned methods when used alone.
In the last few decades, spectrum [2-3] and cepstrum [2, 4] based methods used for rotational speed and malfunction analysis have attracted much attention from research teams. However, to the authors’ best knowledge, there are very few publications available that discuss and compare the reliability of these two calculation methods [2, 4]. In the case of data acquisition systems, most of the settings are usually constant during a single measurement process. The two most relevant parameters are the sampling frequency and the buffer size of the data acquisition. It is possible to create equations based on these parameters which show whether the spectra or the cepstra calculation method produces a lower level of possible speed estimation error. The analyzed error originates from the resolution of output data series produced by each the two methods. This article explains how to calculate the applicable ranges, as well as the main decision levels which will assist in determining to use the preferable methodology.
II. ROTATIONAL SPEED DETERMINATION USING SPECTRUM AND CEPSTRUM CALCULATION
A. Spectrum and cepstrum calculation
Traditional spectral analysis is concerned with the study of how the power of a signal is distributed in the frequency domain. After decomposing the original data series into sinusoidal components, it is relatively easy to detect a power content that corresponds to the rotational frequency [1]. The x coordinate of this peak represents the main operational frequency. In the case of a rotating excentric shaft the most powerful spectral peak usually show directly the rotational frequency of the shaft. In the case of stepper systems, the rotating frequency is much lower then the operational or the coil switching frequency. As further example, in the case of internal combustion engines the periodic activity of the cylinders provides the dominant frequency [3].
The so-called APS (Auto Power Spectrum) is perhaps the most commonly used method in spectrum calculations. To estimate the APS, the DFT (Discrete Fourier Transformation) of the signal is computed and then multiplied by its complex conjugate [2]. Hence the magnitude of an APS is equal to the square magnitude of a DFT.
The discrete equations are as follows:
(1)
(2)
where P[k] is the discrete APS, X[k] is the DFT of the x[n] discrete source signal.
Cepstrum was originally defined as the power spectrum of the power spectrum’s logarithm. Later, a newer definition was coined; cepstrum being the inverse transform of the power spectrum’s logarithm [4], expressed mathematically as:
(3)
A detailed study of the calculation methodology used for discrete data series and the particulars of the cepstral results can be found at Ref. [5]. For a number of further studies on the history and the application of cepstrum analysis please see the following references [2, 4, 6].
This method converts the signal into so-called quefrency components. One of the earliest applications of cepstrum theory can be found in the study of signals containing echoes and in the study of speech analysis. The application discussed in these studies was aimed at detecting the harmonic structure of measured sound. Such harmonic structures, so-called harmonic families, can be detected by gearbox analysis or, alternatively by any kind of analysis of rotary machines. The cepstrum calculation of a signal will only result in an evaluable output if its spectrum contains harmonic families as it searches for periodic changes in the spectrum. For example, a clear one component sinusoidal signal can be examined well by power spectrum; however, its cepstrum produces much less useful information. The latter is due to the cepstra’s behavior being similar to autocorrelation. This is to be expected in the light of the previously introduced definition of cepstrum, and when comparing Eq. (7) with the following mathematical definition, where Rxx[n] is the autocorrelation of x[n] signal [4]:
(4)
Similarly to autocorrelation cepstrum output reveals nothing about absolute frequency only about the spacing of spectral peaks. The cepstrum data series’ variable possesses the dimensions of time, but is mostly referred to as quefrency. Usually the most dominant peak after the noisy fraction, belongs to the rotational speed or the so-called main harmonic component. The quefrency value of this peak shows the main time period in seconds. The distance between two data points of the resulting data series equals to the sampling period of the source signal. By the time the lowest quefrencies are reached, the result is usually much noisier. This is the reason why the rotational speed estimation method becomes unreliable at very high speeds (i.e. at small rotating periods). The cepstral output can be improved by using zero padded windowed signals. This treatment minimalizes the aliasing effect of cepstra [5].
B. Parameters which have an effect on the output
In the case of numerous rotary machines, searching upper or sub-harmonic component instead of the main frequency makes signal processing automation much easier and more reliable. For the purpose of these calculations we have to extend the aforementioned theory with two new parameters. These parameters depend on the structure of the analyzed device and the measurement’s layout (measured property, sensor position, orientation).
One of the new parameters has been named p. The abbreviation originates in the ‘Number of Poles’ phrase. It shows the number of main parts in a structure that cause periodical vibration. Usually these are the driving parts of the machine that keep the shaft rotating. Most drives cannot grant an absolutely even torque and they cause pulsation in other parts too. If the torque has a really small deviation over time, we can usually find eccentric parts or cogwheels causing a certain, periodically changing effect.
The other new parameter has been named r and originates in the ‘Number of Revolutions’ phrase. It shows how many revolutions are made by the main shaft during one whole period of the machine’s functionality. This parameter carries great importance, for example, for stepper motors.
Most data evaluation systems are configured with fixed parameters. It is useful to consider the following parameters as given properties of the sampling setup. Nt is the number of samples, equals to length of the window, which is used for spectral calculation. FS specifies the sampling rate in samples per second. dt is the sample period of the time-domain signal in seconds. T is the duration of the time-domain signal in seconds which equals to the window size.
(5)
(6)
f”1 is the rotational frequency of the device’s main shaft in Hertz. This is the wanted parameter that had been examined in every instance discussed throughout this paper. When dealing with stepper motor driven systems it is useful to search for the upper- or sub-harmonics of this rotational frequency. Direct detectable component during spectral and cepstral analysis is f” SpectMain and T” CepsMain respectively.
(7)
(8)
(9)
n”1 is the rotational speed expressed in rpm (revolutions per minute). In many cases shaft speed is expressed in this form. f”1 is easily convertible to rpm using the following expression [3]:
(10)
df is the sample period of the frequency-domain signal in Hertz.
(11)
Nf is the number of data points in the result. In this paper authors defined this parameter for one-sided spectral output.
(12)
fSpect min is the lowest frequency after the DC component that has a corresponding value in the spectral output. fSpect max is the highest frequency that has a corresponding value in the spectral output. It is now the last frequency point before Nyquist frequency.
(13)
(14)
dq is the sample period of the quefrency-domain signal in seconds. Nq is the number of elements in the cepstrum result.
(15)
(16)
fCeps min and fCeps max are the lowest and highest frequencies that has a corresponding value in the quefrency domain.
(17)
(18)
III. HYBRID SPEED DETERMINATION METHOD
The speed determination method is called hybrid method because it uses the calculated spectrum as well as the cepstrum if needed. The decision logic is based on calculating the possible error. This paper solely analyses the error which arises from the resolution of the discrete data series. Naturally, the described results can be improved by several methods. Improvements to the most well-known approaches, as well as new methods, are published every year [7]. These fall outside the scope of this article. In the experiment described herein, the authors used solely a simple highest peak searching method for frequency estimation.
Both the spectrum and cepstrum calculations result in an output with linear resolution. The problem begins with the different domain of the outputs. One of them has linear resolution in frequency domain, while the other one has linear resolution in quefrency domain. If we convert the x-axis values to the same unit ‘ for example, both to rpm ‘ the spectrum result remains in linear resolution because of the linear operation described in Eq. (12). On the other hand, in the case of cepstrum output, transformed values along the x-axis have a continuously increasing distance from each other as we move in the direction of higher values. The exponential scale is caused by the reciprocal operation that is to be used when changing the quefrency values (sec) to frequency (Hz) or also to rotational speed (rpm). If we convert both data series to the function of frequency, a new notion, Relative Step Size (RSS) must be introduced. The RSS is a certain function of frequency. This value can be defined as the ratio of the location of a point along the frequency axis and its distance to the nearest point. The relative error level in the frequency determination will decreases with spectral analysis and will increases with cepstral analysis in the direction of the higher values on the frequency or rotational speed axis.
One of the questions is how to calculate the location of the intersection point of these two curves. This information will ? in turn provide the basis for the hybrid estimation method. Although cepstrum based analysis can provide us with the more accurate result, we will have to start the calculation with a spectrum calculation as can be seen from Eq. (7). As a side note, the experiment shows that when evaluating cepstrum results a simple search for the highest peak is insufficient for arriving at a reliable result. For an automated evaluation, we need to set search ranges because often the highest peak is not the queried one. However, the spectrum shows a much more stable output. If the analyzed process is well-known, it is usually not a major challenge to define the main frequency that will provide most of the power in the spectral result. If we can detect this main frequency peak and several harmonics, we can also detect the queried cepstrum peak in the close proximity of its corresponding quefrency. Therefore, we can determine an estimated frequency from the calculated spectrum, which can hitherto be compared to the decision level of the hybrid method. If the estimated value is below the decision level, we can use the readily available two sided spectrum data series for cepstrum calculation. If the estimated value is bigger than the decision level, we can save a lot of computational capacity without having to perform the cepstrum calculation. If we have to use the cepstrum, it could?may be practicable to limit the quefrency range of the peak search proportional to the spectral RSS (e.g. multiplied by 1 to 3).
The following subsections show how to calculate the RSS in the function of the wanted frequency and the measurement’s main parameters. The paper also shows the calculation method for the spectrum and cepstrum based instances. In the followings equations the function of the RSS values is assigned as E(f). Based on the earlier introduced definition Eq. (21) represents the way of calculating RSS for the spectral output.
(19)
(20)
The graphical representation of this function typically shows the shape of the falling curve in Fig. 1.
We can derive the function for the cepstrum based calculation analogously to the spectral instance of the quefrency domain, as shown in Eq. (22).
(21)
In Eqs. (21) and (22) the RSS is defined as the function of different variables. To make these comparable we have to convert the argument of ECeps(T) to frequency. We shall define the above as Eq. (23).
(22)
The typical shape of this function can be seen as the rising curve in Fig. 1.
A. RSS comparison of the methods
The above subsections show how to form equations for RSS calculation. Now, we can use Eq. (24) to determine the intersection point of the error functions. Cepstrum can give the lower level of RSS value if ECeps(f”1)<ESpect(f”1).
(23)
The decision logic of the hybrid speed determination method is summarized in Eqs. (28) to (32), based on the previous calculations.
(24)
(25)
(26)
(27)
(28)
The graphical representation of the corresponding RSS error curves and the resulting error of the hybrid method is illustrated by Fig. 1.
IV. USING THE HYBRID CALCULATION METHOD IN PRACTICE
The hybrid speed determination method’s reliability was successfully tested on several rotary machines. This paper shows only the results of the stepper motor vibration measurements. The vibration acceleration was measured by a PCB356A33 accelerometer, which was fastened onto the surface of the analyzed motor using neodymium magnet. The high precision sampling procedure was ensured by the application of the NI 9234 data acquisition card. The measurement assembly also contained a high precision encoder, which gave 1024 pulses per revolution. Fig. 2. shows the analyzed measurement assembly. The stepper motor controller device was a NI myRIO 1900 embedded system, which was connected to the coils of the stepper motor through a simple amplifier electronic.
The NI Linux Real Time OS operating system, which is running on the embedded controller, ensures the deterministic real-time functionality of the controller software. The coil switching logic was implemented via FPGA (Field-Programmable Gate Array) chip, which can switch the coils with 25 ns (40 MHz clock) timing accuracy. The myRIO based controller is able to handle the connected stepper motor using full-step mode with one or two active phases and also half-step control mode, which is the combination of the previous two methods.
By spectral evaluation of vibration signals, first step must be always the analysis of the examined mechanical structure and the methodology of coil control. In our case the stepper motor has got four electromagnetic coils with unipolar winding arrangement. Both of the most common drive methods ‘ the single-coil full-step and half-stepping modes ‘ are shown in this paper. The rotor has 50 teeth, which is a typical value in the case of stepper motors. This 50 teeth combined with the four phases means that the motor can take a full revolution within 200 full steps. One full step is equal to 1.8” rotation of the shaft.
A. Full-step drive of the stepper motor
Fig. 3. shows the results of the shaft’s angular measurement when the stepper motor was driven with full-step one-phase mode at 1, 5, 15 and 90 rpm rotational speeds. The shape of the curves are totallyvery different. At lower speeds (1-5 rpm) the transient sections can be clearly separated from each other. The shaft has enough time to get its steady-state after transient oscillation. When taking a look at Fig. 3(c), it can be seen that the oscillating sections have reached each other. There is not enough time to get a temporary steady-state of the rotor. In the case of higher rotational speed just several waves can be seen in the angular measurement data series. Over 90 rpm the individual steps can be hardly separated. At higher speed the stepper motor produces much more balanced output torque and the power of measured vibration is usually lower.
The applied piezoelectric acceleration sensor can solve three dimensional acceleration measurements. This way the orientation of the fixed sensor is almost irrelevant. One can measure the vibration acceleration in all directions parallel with simultaneous sampling techniques of the NI 9234 data acquisition card. At early stages of the experiment it can be useful to acquire and evaluate all directions and choose just one, which shows the clearest results. In our case the Y channel, which corresponds to the radial vibration components of the motor, seemed to be the most informative direction. In the followings only the radial component appears in this paper.
In Fig. 4(a) the lower frequency range of the power spectrum of the measured radial vibration can be seen at 5 rpm rotational speed. When analyzing e.g. internal combustion engine vibration, the highest peak in the spectrum usually appears at the burning frequency, which is proportional to the main shaft speed. In such cases searching the maximum value in the spectra can solve the rotational speed estimation problem. As we see in Fig. 4(a) the harmonic structure of the 16.7 Hz phase switching frequency appears in the whole spectrum, and the most interesting main peak can notcannot be detected. The hybrid spectral speed determination method uses parallel the spectral and cepstral output as well. Even if the decision logic shows that the spectrum can give the most accurate output, the spectral output can be improved using cepstrum calculation. Without the detailed mathematical background, the so called liftering procedure filters the spectrum in the quefrency domain, as a classic filter filters the time domain signal in the frequency domain. The result of the liftered spectrum can be seen in Fig. 4(b). In this case, the main frequency component at 16.7 Hz can be localized, and the upper harmonic family of the base component can be analyzed easier. In the case of stepper motors liftering is usually not necessary. The strong upper harmonic content in the vibration signal causes that the cepstrum give extremely sharp peaks. Based on the above equations, spectrum produces the result with better resolution only by very small sampling frequencies when a relatively long window is applied.
If cepstrum calculation of vibration signals is used to determine the analyzed device’s rotational frequency, the key parameter is the applied window length. As the autocorrelation function indicates repeating components’ periodicity in the time signal, a peak in cepstrum data series shows the average distance between corresponding frequency peaks. The x coordinate of the detected peak shows directly the period time of the repeating time signal component. When choosing the parameters for evaluation, the applied window size must be greater than the longest period in the source signal, expressed in seconds. It means that for reliable output the algorithm needs to use huge windows at lower speeds, which causes much bigger memory usage of the computation and longer delay of the estimated value in real-time applications. Longer window can also minimize the aliasing effect of cepstrum calculation. The usage of long window is causeless at higher rotational speeds. The algorithm do not produce the result with better resolution or higher accuracy, if the sampling frequency of the source signal remains the same.
If the stepper motor has a rotational speed of 1 rpm, the rotor takes one rotation in 60 seconds, which is the period time of the motor functionality. In this case, a window with a length bigger than 60 seconds should be used for cepstrum evaluation, which needs unreasoning amount of computational resource and causes more than 60 seconds delay of the result. In Fig. 5. the cepstral results are shown at low rotational speeds, but shorter window size has been used. It can be practical, to use shorter window size and search for faster periodicities in the motor functionality when needed. In the case of Fig. 5(a) the coil switching period appears at 0.3 s and the peak of full control period for the four phases can be found at 1.2 s. In the case of Fig. 5(b) the same two peaks appear at 0.06 and 0.24 s. The cepstrum usually shows coil switching and the whole control period as dominant peaks. They are usually followed by a series of rahmonic components with sinking peak values.
To apply the hybrid spectral method, or to calculate the methods’ applicable ranges the p and r parameters must be chosen for the measurement setup. At extremely low rotational speed or when using very small window sizes, searching for the effect of coil switching frequency seems to be practical with the parameters of p=1 and r=0.005. When using the parameters of p=4 and r=0.02, one can evaluate the full control period of the four phases.
When the rotor has a really high rotational speed, as in the case of Fig. 6., the transient oscillations has no effect on the spectral output, that’s why the data series gives much better overview of the controlling frequencies. In the presented results a constant frequency component is always present near to 100 Hz. It can be some kind of electric noise from the environment. When such components are present, and the usage of the spectrum is needed for speed estimation, custom rules must be used by evaluation to left this peak out of consideration. The peak of coil switching frequency and its harmonics follow the anomalous peak at 100 Hz.
The discrete cepstrum of the measured vibration can be seen in Fig. 7. at relatively high rotational speeds. Density of the cepstral peaks seems to be much higher and a new absolute maximum, and its rahmonics appeared in the cepstrum. This new peak shows the periodicity of full revolutions of the rotor. Between the zero quefrency and the highest peak 50 smaller peak appeared which shows the controlling cycles within one turn. In Fig. 7(a) the quefrency peak at 0.2 s shows 300 rpm, as in the case of Fig. 7(b), 0.12 s corresponds to the 500 rpm rotational speed of the stepper motor.
Based on the presented results it can be stated for the case of high rotational speeds or extremely long window sizes, that the parameter combination of p=200 and r=1 can be practical for hybrid spectral rotational speed estimation of a stepper motor in full-step control mode.
B. Half-stepping drive of the stepper motor
Full-step control mode for a four-phase stepper motor means that the number of active phases remains constant? during the operation. One or two coils are on, and one step happens when the next coil will be active and one of the previously active coils turns off at the same time. The half-stepping mode is the combination of the steps of the one and two phases full-step modes. First, only one phase is active. When the next coil turns off, two coils are active and half of the full-step mode’s angular change can be observed. The next half step happens, when the first coil turns off and only the second phase remains active. In half-stepping control mode the stepper motor’s holding torque changes between discrete positions because of the changing number of electromagnetic coils. Even so, the motor has smoother rotational speed and generates lower vibration level.
Comparing the results to the previously demonstrated full-step mode, the first difference can be seen on the Fig. 8.. In Fig. 8(a) the effect of the inserted half steps can be clearly seen. The angular change caused by one step (0.9”) is half of the size of the step in full-step mode (1.8”), and two type of the transients can be distinguish. It is because of the different number of active phases and holding torque. When take a look at Fig. 8(b-d), it can be stated, that the half step mode has one clear advantage, that it causes smoother rotational speed when compared to the full-step mode.
In the previous chapter of this paper Fig. 4. showed the vibration spectrum of the stepper motor at low rotational speed. The main frequency did not appear at 16.7 Hz because of the attenuation of the mechanical structure at this lower frequency range. The stepping frequency in half-stepping control mode would be 8.3 Hz at the same rotational speed, which has no chance to appear with the same input parameters. Of course the spectra can be more representative if longer window size is used or if lifter is applied before spectral evaluation.
In the case of high rotational speeds the full step control produces an absolutely smooth shaft speed and constant torque as well as the half-stepping mode does. At high frequencies the effect of the half steps in the spectrum is negligible. Because of the slightly difference from illustrations of full-step mode, these spectrogram are not presented in this paper.
When analyzing the cepstral content of the measured vibration for the case of half-stepping drive, the effect of the half steps clearly appears as sharp peaks between the full step signing peaks. Fig. 9(a) shows the vibration cepstra at extremely low 1 rpm rotational speed. The same peak as in Fig. 5(a) signs at 1.2 s that the motor has this period as the full control period of the four phases. In the half-stepping mode this peak is the 8th peak in order, which shows that the four coils are switched in 8 steps. Every second peak has lower value as it’s neighbors, because the power of the vibration is much less in the case of every second half step (See the encoder measurement in Fig. 8(a)). When applying an extremely short window size at such low speed states, the extra peak at 0.15 s can be used for speed determination with the parameters of p=1 and r=0.0025, but longer window size is much more preferred. When using longer windows for calculation, the same parameter combinations of p and r are suggested as for the case of full-step mode.
In the case of the half-stepping mode cepstra at high speeds, no relevant changes can be observed compared to Fig. 7.. The highest peaks show the full turn periods of the shaft in seconds, and the 50 control cycle signing lower peak appears between zero quefrency and the 1.2 s (time of full turn) peak.
7. CONCLUSIONS
This article lays out a hybrid technique which improves common spectrum and cepstrum based rotating speed determination methods. This study discusses the way to calculate the representations’ RSS error parametrically. Based on that, a hybrid method has been developed which makes use of both methods. First, it calculates the applicable ranges of both methods and also a decision level to give the final result with the best resolution. Second, it calculates the spectrum of the sampled time series and searches the peak which corresponds to the rotational speed. Third, the algorithm compares the peak location to the calculated decision level, which is proportional to the ratio of the sampling frequency to the square root of used FFT size. Fourth, the discrete cepstrum must be calculated, if the spectrum based estimation shows that the rotational frequency is under the decision level. The equations have been extended with the p and r parameters for generalization and for a more efficient analysis of rotary machines. The hybrid method, with its background theory was tested on stepper motor driven systems and on several other types of rotary machines as well. The main conclusions about the measurement results were as follows:
– The spectrum and cepstrum based methods can be easily used for stepper motor analysis in full- and in half-stepping mode as well.
– There are more p and r parameter combination to get the same result about the estimated rotational speed. The applied window size, the sampling frequency and the actual rotational speed help to find out, which combination of p and r is needed.
– The hybrid spectral methodology can be used for post processing and also for real time analysis.
References
[1] M.L. Adams, Rotating Machinery Vibration: From Analysis to Troubleshooting, New York: Marcel Dekker, 2001.
[2] B. Liang, S.D. Iwnicki and Y. Zhao, ‘Application of power spectrum, cepstrum, higher order spectrum and neural network analyses for induction motor fault diagnosis’, Mechanical Systems and Signal Processing, Vol. 39, 2013, pp. 342’360.
[3] H. Lin and K. Ding, ‘A new method for measuring engine rotational speed based on the vibration and discrete spectrum correction technique’, Measurement, Vol. 46, 2013, pp. 2056’2064.
[4] R.B. Randall, ‘A History of Cepstrum Analysis and Its Application to Mechanical Problems’. In: Surveillance 7 International Conference, Chartres, France, 2013, pp. 1’16.
[5] D.G. Childers, D.P. Skinner and R.C. Kemerait, ‘The Cepstrum: A Guide to Processing’, Proceedings of the IEEE, Vol. 65, 1977, pp. 1428’1443.
[6] M. El-Ghamry et al., ‘Indirect measurement of cylinder pressure from diesel engines using acoustic emission’, Mechanical Systems and Signal Processing, Vol. 19, pp. 751’765.
[7] D. Slepicka et al., ‘Comparison of Nonparametric Frequency Estimators’, In: Dyer C, eds. 2010 IEEE Instrumentation & Measurement Technology Conference Proceedings, Austin, TX, 2010, pp. 73’77.