Available on: Flexs Q5C

scope.getPeak()

scope.getPeak(fMin, fMax, [label]) → { bin, freq, amp }

Finds the highest-amplitude peak in a frequency range of the most recent FFT — typically used to measure running speed.

Searches the spectrum of the most recent scope.getWaveform() capture between fMin and fMax and returns the dominant peak.

The optional label string draws a named marker on the FFT amplitude chart in the web interface for the associated capture, which makes verifying the speed lock-on easy.

Measuring RPM. Search a window around the expected electrical or mechanical frequency, then convert. For a 10-pole motor near line frequency:

let speed = scope.getPeak(50, 70, "hz");
let rpm = speed.freq * 120 / 10;

For better precision, re-find the speed on a strong harmonic using a tight tolerance window seeded from the first estimate:

let peak180hz = rpm/60*15;
let speed = scope.getPeak(peak180hz*0.98, peak180hz*1.02, "Speed"); // ±2%
rpm = speed.freq * 4;

Arguments

NameTypeRequiredDefaultDescription
fMin number (Hz) yes Lower bound of the search window.
fMax number (Hz) yes Upper bound of the search window.
label string optional Optional marker label shown on the FFT chart for this capture.

Returns

object { bin, freq, amp } — e.g. {"bin":322,"freq":59.977173,"amp":0.037552}

Example

scope.getWaveform({ "ch":0, "osr":4096, "size":4096, "fft":true,
  "bandpass":false, "fMin":120, "fMax":190, "demod":false, "demodRatio":8 });

let speed = scope.getPeak(50, 70, "hz");
print(string(speed)); // {"bin":322,"freq":59.977173,"amp":0.037552}
let rpm = speed.freq * 120 / 10; // 10-pole motor