This seems like an interesting use case involving rotational speed estimation from a tachometer signal. Working with sampled pulse signals often involves subtle issues related to signal scaling, transition thresholds, or insufficient edge events. Many of us have run into this when the pulse shape or sampling resolution does not quite fit the expectations of the “tachorpm” function.
If the “tachorpm” function is returning the message "no tachometer pulses were detected. Try adjusting the state levels.", this typically indicates that the algorithm was unable to find valid rising or falling edges in your signal. A few important checks and adjustments can help resolve this.
Here are some thoughts and directions:
- Verify the Sampling Rate vs. Revolution Frequency - It is easy to conflate revolutions per second (rev/s) with sample rate. If your system performs 8 rev/s (which equals 480 RPM), and the signal is sampled at 240 Hz, you will get approximately 30 samples per revolution. This should be adequate in most cases, but it's important to be sure of these numbers.
- Visualize the Input Signal - Before passing it to “tachorpm”, always inspect the shape and transitions of the signal. This will help determine whether the pulses are distinguishable and clean.
- Explicitly Set State Levels - If the waveform is not ideal or if it’s not perfectly square, the automatic detection of threshold levels may fail. You can try manually specifying state levels:
rpm = tachorpm(yn, fs, "StateLevels", [lowLevel highLevel]);
Replace lowLevel and highLevel with approximate min and max signal values. This often helps if the signal is slightly noisy or not strictly binary.
- Preprocess the Signal if Needed If the waveform is more analog or sinusoidal, consider thresholding or binarizing it before use. One way is to create a binary pulse train by applying a logical threshold. This will allow the function to detect edges more reliably.
- Check Signal Duration and Number of Pulses Make sure the signal segment you pass includes multiple rotations. If only 1–2 pulses are present, “tachorpm” will not be able to compute RPM reliably. Try extending the duration or capturing more data.
Each of the above steps is worth checking in sequence. It is usually a combination of clean signal transitions, correct sample rate, and correct state levels that ensures the “tachorpm” function can detect pulses accurately.
The following documentation links can be referred to for a better understanding: