This is my first post so sorry if I make any mistake.

The entire signal length in the screen shot below is 10 second. I ran a first order low pass filter (digital) at 10Hz cut-off frequency, and I obtained the orange/yellow line in the picture. Please ignore the red and the blue line for now.

I wonder if there is an algorithm that I can extract all of the lowest values of the green plot in real-time and reconstruct/interpolate data along the way like the black line that is shown below?

The green signal (50Hz) is the DFT result of a raw 1kHz sine data that is sampled at 10kHz. I really hope that we can find a light-weight algorithm for the filter, since the entire code has to run on a microcontroller.

I would love to hear your suggestions. And let me know if anything is needed for clarification.

enter image description here

  • $\begingroup$ for the future: all (major) operating systems, even windows, have a screenshot function, so that you don't have to make photos with your camera/cameraphone. (also, clean your screen ;) ) $\endgroup$ – Marcus Müller Apr 17 '19 at 6:27
  • $\begingroup$ I should have done that :) Thanks for the suggestion $\endgroup$ – Khoily Apr 17 '19 at 17:14

Normally you could do some valley detection. Scipy does this (https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html) but this requires knowing a chunk of the signal in advance so you couldn't do it real time.

For real time maybe you could look at the derivative of the signal and notice when it goes from negative to positive, it would find valleys although it may not be as smooth as your black line. Maybe also check out this: https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data

| improve this answer | |
  • $\begingroup$ I'm pretty sure that it has some tunable parameters which will help you capture more of the valleys if some are missed. I'm not sure as to which interpolation method is best for your application but you can try linear interpolation between points and see if this is good enough. If you interpolate at the times of the original signal you can have exactly the same number of points $\endgroup$ – MrHat Apr 17 '19 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.