Contenido principal

tachorpm

Extract RPM signal from tachometer pulses

Description

rpm = tachorpm(x,Fs) extracts a rotational speed signal, rpm, from a tachometer pulse signal vector, x, that has been sampled at a rate of Fs Hz.

If you do not have a tachometer pulse signal, use rpmtrack to extract rpm from a vibration signal.

[rpm,t,tp] = tachorpm(x,Fs) also returns the time vector, t, and the detected pulse locations, tp.

[___] = tachorpm(x,Fs,Name=Value) specifies options using name-value arguments and any of the previous syntaxes.

tachorpm(___) with no output arguments plots the generated RPM signal and the tachometer signal with the detected pulses.

example

Examples

collapse all

Load a simulated tachometer signal sampled at 300 Hz.

load tacho

Compute and visualize the RPM signal using tachorpm with the default values.

tachorpm(Yn,fs)

Increase the number of fit points to capture the RPM peak. Too many points result in overfitting. Verify this result by zooming in on the area around the peak.

tachorpm(Yn,fs,FitPoints=600)

axis([0.47 0.65 1320 1570])

Choose a moderate number of points to obtain a better result.

tachorpm(Yn,fs,FitPoints=100)

Add white Gaussian noise to the tachometer signal. The default pulse-finding mechanism misses pulses and returns a jagged signal profile. Verify this result by zooming in on a two-second time interval.

rng("default")
wgn = randn(size(Yn))/10;
Yn = Yn + wgn;

[rpm,t,tp] = tachorpm(Yn,fs,FitPoints=100);

figure
plot(t,Yn,tp,mean(interp1(t,Yn,tp))*ones(size(tp)),"+")
hold on
sl = statelevels(Yn);
plot(t,sl(1)*ones(size(t)),t,sl(2)*ones(size(t)))
hold off
xlim([9 10])

Adjust the state levels to improve the pulse finding.

sl = [0 0.75];

[rpm2,t,tp] = tachorpm(Yn,fs,FitPoints=100,StateLevels=sl);

plot(t,Yn,tp,mean(interp1(t,Yn,tp))*ones(size(tp)),"+")
hold on
plot(t,sl(1)*ones(size(t)),t,sl(2)*ones(size(t)))
hold off
xlim([9 10])

Input Arguments

collapse all

Tachometer pulse signal, specified as a row or column vector.

Example: double(chirp((-1.5:1/2e2:1.5),14,1.1,8,'quadratic')>0.98) resembles a tachometer signal, sampled for three seconds at 200 Hz, and obtained during a quadratic run-up/coast-down test.

Sample rate, specified as a positive scalar expressed in Hz.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: rpm = tachorpm(x,Fs,PulsesPerRev=3,OutputFs=1e3) specifies that there are three tachometer pulses per revolution and that the returned RPM signal is to be sampled at 1 kHz.

Number of tachometer pulses per revolution, specified as a real-valued scalar.

State levels used to identify pulses, specified as a two-element real-valued vector.

The first element of the vector corresponds to the low-state level and the second element corresponds to the high-state level. Choose the state levels so that all pulse edges cross within 10% of both of them. If this option is not specified, then tachorpm computes the levels automatically using the histogram method, as in the statelevels function.

Output sample rate, specified as a real-valued scalar.

Fitting method, specified as one of these values:

  • "smooth" — Fit a least-squares B-spline to the pulse RPM values.

  • "linear" — Interpolate linearly between pulse RPM values.

B-spline breakpoints, specified as a real-valued scalar.

The number of breakpoints is a tradeoff between curve smoothness and closeness to the underlying data. Choosing too many breakpoints can result in overfitting. The function ignores this argument if you set FitType to "linear".

Output Arguments

collapse all

Rotational speeds, returned as a vector expressed in revolutions per minute.

This argument has the same length as x.

Time vector, returned as a vector of positive values expressed in seconds.

Pulse locations, returned as a vector of positive values expressed in seconds.

Algorithms

The tachorpm function performs these steps:

  1. Uses statelevels to determine the low and high states of the tachometer signal.

  2. Uses risetime and falltime to find the times at which each pulse starts and ends. It then averages these readings to locate the time of each pulse.

    Note

    The tachorpm function detects rising and falling edges independently and in pairs, and without assuming whether a rising or falling edge occurs first along the tachometer signal. If a pulse starts mid-cycle –for example, when the high state follows a rising-falling-rising edge pattern but the signal begins with a falling edge– the function might pair the edges incorrectly. To make sure that the function calculates the RPM accurately in such cases, trim the tachometer signal so its first edge is a rising edge marking the start of a full pulse cycle.

  3. Uses diff to determine the time intervals between pulse centers and computes the RPM values at the interval midpoints using RPM = 60 / Δt.

  4. If FitType is specified as "smooth", then the function performs least-squares fitting using spline. If FitType is specified as "linear", then the function performs linear interpolation using interp1.

References

[1] Brandt, Anders. Noise and Vibration Analysis: Signal Analysis and Experimental Procedures. Chichester, UK: John Wiley & Sons, 2011.

[2] Vold, Håvard, and Jan Leuridan. “High Resolution Order Tracking at Extreme Slew Rates Using Kalman Tracking Filters.” Shock and Vibration. Vol. 2, 1995, pp. 507–515.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2016b