My electricity meter has a front panel LED which pulses in proportional to the current energy rate. The frequency changes but the pulse width is set at 250ms. Due to environmental conditions there's plenty of noise. Currently I'm sampling this at 10kHz, the pulses may be a few seconds apart.

I would like to filter these pulses and ignore anything else that wasn't 250ms long (ie the noise) and find the frequency of the train. Are there any suitable methods to achieve this?

My first thought was to differentiate the signal but this would be easily confused by large noise spikes. I also wondered about testing it's coherence with a simulated pulse train, but as the frequency changes this would be potentially infinitely intensive AFAIK.

If I was to build an electronic solution I'd use edge comparators to find the pulses. I'm wanting to use NumPy/matplotlib and deal with the signal in the frequency domain, if possible (purely as an educational exercise).

  • $\begingroup$ Do you know whether the time between pulses is always a multiple of 250 ms long? $\endgroup$
    – Kevin Reid
    Dec 14, 2014 at 19:53
  • $\begingroup$ The time between is not a multiple of 250ms, although I'd be interested to know how you'd approach it if it was. $\endgroup$
    – Brownstone
    Dec 14, 2014 at 22:18
  • $\begingroup$ If it was, then you would have is an "on-off keying" digital signal with a bit time of 250 ms, and you could use techniques applicable to that. $\endgroup$
    – Kevin Reid
    Dec 14, 2014 at 22:32
  • $\begingroup$ How are you sensing how you're LED is on or not? $\endgroup$ Dec 14, 2014 at 23:32
  • $\begingroup$ A simple photo diode and op amp combo from my junk box. $\endgroup$
    – Brownstone
    Dec 15, 2014 at 16:32

1 Answer 1


Not an easy problem to solve...

You could always cross-correlate the signal with a replica square wave and then apply simple thresholding to find the pulse locations. Then just count the peaks in a given interval to determine frequency.

I think the square wave nature of the signal could make the signal quite difficult to deal with in the frequency domain because of all the harmonics that comprise it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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