I sample a zero to 400Hz varying pulse train at 4kHz and post-process this pulse train data by MATLAB to obtain each single pulse's period. So for instance below represents a 0 to 6V pulse. The green line is the mid point 3V. So in MATLAB I find the first sample point which crosses up the mid voltage green line and the consecutive sample point which crosses up the green line. These points are shown in red dots. So the time distance between these two red dots gives me the period of that particular pulse. That is how I calculate each pulse period from the logged data.

enter image description here

My question is how can I estimate the error due to sampling rate? Imagine The pulse is 400Hz and sampling rate is 4kHz; and if I increase the pulse sampling rate up to 8kHz how does the accuracy change?

And if I measure and know the actual rise time of the pulse as 2μs, how can I relate the sampling frequency I will use to the pulse period measurement accuracy?


1 Answer 1


If you have consecutive samples that indicate the waveform has passed through the green line all you can say is that the waveform passed from below to above (or vice versa), somewhere in the time frame formed by 1 sample period of 4 kHz (i.e. +/- 125 us).

If your sampling is 8 kHz then the accuracy is +/- 62.5 us.

If you are trying to measure the period your result can be off by twice this amount (worst case). That's for one measurement and clearly, if there are multiple measurements that can be made (because the period varies very gradually) then averaging is your friend.

The rise time is irrelevant unless it was so slow that it caused noise jitters close to where the waveform passes the green line.

  • \$\begingroup\$ Thanks a lot. But I used these values you estimated for 4kHz sampling and very surprised. I hope you can also give a hint to this comment. In my case 400Hz pulse is from a pulse output of a calibrated windmeter relates to 25m/s wind speed. So 1/16 ratio is the transfer function from pulse freq to the wind speed. If you say the accuracy is 125 us, at 25m/s the period can be measured as 2625us instead of 2500us and 2625us is 381Hz. So instead of 400Hz one can measure 381Hz and think the wind speed is 381/16 = 23.8m/s. This is a huge error 25 - 23.8 = 1.2m/s error. Am I doing something wrong? \$\endgroup\$
    – GNZ
    Mar 11, 2020 at 14:48
  • \$\begingroup\$ Am I doing something wrong? - No, that sounds about right. \$\endgroup\$
    – Andy aka
    Mar 11, 2020 at 15:05
  • \$\begingroup\$ If you know there's a limit on how fast the rise-time can be, and it's more than 2 or 3 sample periods, then you can interpolate between data points and get a much smaller error bound than the sample period. \$\endgroup\$
    – The Photon
    Mar 11, 2020 at 15:54
  • \$\begingroup\$ @ThePhoton I see the error shrinks for long measurements. \$\endgroup\$
    – GNZ
    Mar 11, 2020 at 16:18
  • \$\begingroup\$ @Genzo I don't know what you mean by "long measurements" but it's probably something different from my suggestion of interpolating between data points. \$\endgroup\$
    – The Photon
    Mar 11, 2020 at 16:20

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.