DSPRelated.com
Forums

Sampling frequency requirements

Started by Allan Wilson August 2, 2004
Hi,

I've got a sampling frequency question.

I have two signals, which only have frequency components up to about 100Hz,
from two sensors in a liquid stream. I need to get the phase (time)
difference between these two signals with a resolution of 0.2ms to be able
to calculate the velocity of the liquid to the accuracy required. Note the
velocity of the liquid is continuously variable and needs to be measured at
about 5Hz.

Up until now I have been collecting 1024 sample blocks of the two signals at
5000 samples/second and cross-correlating them to get the phase difference.
This has worked well.

My question is, if my signals only have frequency components below 100Hz do
I have to sample at 5000Hz to get the time resolution I need? (I'm look to
embed the code in a DSP and want to cut back the buffer/sampling
requirements)

Any thoughts would be appreciated

Allan


Allan Wilson wrote:
> Hi, > > I've got a sampling frequency question. > > I have two signals, which only have frequency components up to about 100Hz, > from two sensors in a liquid stream. I need to get the phase (time) > difference between these two signals with a resolution of 0.2ms to be able > to calculate the velocity of the liquid to the accuracy required. Note the > velocity of the liquid is continuously variable and needs to be measured at > about 5Hz. > > Up until now I have been collecting 1024 sample blocks of the two signals at > 5000 samples/second and cross-correlating them to get the phase difference. > This has worked well. > > My question is, if my signals only have frequency components below 100Hz do > I have to sample at 5000Hz to get the time resolution I need? (I'm look to > embed the code in a DSP and want to cut back the buffer/sampling > requirements) > > Any thoughts would be appreciated > > Allan > >
In theory, of course, you only need to sample a little bit above 200Hz for sufficient information. Your algorithm may get complicated with lower sampling rates, however. What sort of signals do you have? If you have a 50Hz sine wave, for instance, you could sample at an exact multiple of 50Hz and compare the phases of each signal. This would be way easy. If your signals are some weird arbitrary thing then you would have to work harder -- you could probably do something that started with a polyphase filter concept and worked from there to the mathematical equivalent of your 1024-point cross-correlation. I'm sure it'll be easy to understand once you actually get it working :). An alternative might be to continue to sample at 5000 samples/second, but do your cross-correlation in chunks. This would require a lot of bookkeeping, and obviously wouldn't change your sampling, but it may dramatically reduce your buffering. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
My signals are some "weird arbitrary thing". Large variations at ~1Hz plus
small ripples (vaild variations) at higher frequencies.
Allan

"Tim Wescott" <tim@wescottnospamdesign.com> wrote in message
news:10grh2i7tffi970@corp.supernews.com...
> Allan Wilson wrote: > > Hi, > > > > I've got a sampling frequency question. > > > > I have two signals, which only have frequency components up to about
100Hz,
> > from two sensors in a liquid stream. I need to get the phase (time) > > difference between these two signals with a resolution of 0.2ms to be
able
> > to calculate the velocity of the liquid to the accuracy required. Note
the
> > velocity of the liquid is continuously variable and needs to be measured
at
> > about 5Hz. > > > > Up until now I have been collecting 1024 sample blocks of the two
signals at
> > 5000 samples/second and cross-correlating them to get the phase
difference.
> > This has worked well. > > > > My question is, if my signals only have frequency components below 100Hz
do
> > I have to sample at 5000Hz to get the time resolution I need? (I'm look
to
> > embed the code in a DSP and want to cut back the buffer/sampling > > requirements) > > > > Any thoughts would be appreciated > > > > Allan > > > > > In theory, of course, you only need to sample a little bit above 200Hz > for sufficient information. Your algorithm may get complicated with > lower sampling rates, however. > > What sort of signals do you have? If you have a 50Hz sine wave, for > instance, you could sample at an exact multiple of 50Hz and compare the > phases of each signal. This would be way easy. > > If your signals are some weird arbitrary thing then you would have to > work harder -- you could probably do something that started with a > polyphase filter concept and worked from there to the mathematical > equivalent of your 1024-point cross-correlation. I'm sure it'll be easy > to understand once you actually get it working :). > > An alternative might be to continue to sample at 5000 samples/second, > but do your cross-correlation in chunks. This would require a lot of > bookkeeping, and obviously wouldn't change your sampling, but it may > dramatically reduce your buffering. > > -- > > Tim Wescott > Wescott Design Services > http://www.wescottdesign.com
Allan Wilson wrote:

> Hi, > > I've got a sampling frequency question. > > I have two signals, which only have frequency components up to > about 100Hz, from two sensors in a liquid stream. I need to get > the phase (time) difference between these two signals with a > resolution of 0.2ms to be able to calculate the velocity of the > liquid to the accuracy required. Note the velocity of the liquid > is continuously variable and needs to be measured at about 5Hz. > > Up until now I have been collecting 1024 sample blocks of the two > signals at 5000 samples/second and cross-correlating them to get > the phase difference. This has worked well. > > My question is, if my signals only have frequency components below > 100Hz do I have to sample at 5000Hz to get the time resolution I > need? (I'm look to embed the code in a DSP and want to cut back > the buffer/sampling requirements) > > Any thoughts would be appreciated > > Allan
Reading this post carefully, revealed that you already worked in a lot of trivial approaches. Won't be that easy to improve your solution. Nevertheless, here's an idea: time resolution of 0.2ms requires sample distance of 1/5000Hz. But these samples need not be 'real' measurement data. They might be result of interpolation... 1) Lowpass filter (down to whatever is acceptable) 2) Decimation (Sample rate reduction, 500/s or so) 3) Calculate your phase difference (@ 2ms precision) 4) Average over consequent measurements will give you the required precision! Depends on your signals, if this works. The basic thought behind is: don't buffer raw data, because they're many. Instead, buffer consequent results, because they're less. Bernhard
"Allan Wilson" <allanw@wave.co.nz> wrote in message news:<cekd9r$jse$1@news.wave.co.nz>...
> Hi, > > I've got a sampling frequency question. > > I have two signals, which only have frequency components up to about 100Hz, > from two sensors in a liquid stream. I need to get the phase (time) > difference between these two signals with a resolution of 0.2ms to be able > to calculate the velocity of the liquid to the accuracy required. Note the > velocity of the liquid is continuously variable and needs to be measured at > about 5Hz. > > Up until now I have been collecting 1024 sample blocks of the two signals at > 5000 samples/second and cross-correlating them to get the phase difference. > This has worked well. > > My question is, if my signals only have frequency components below 100Hz do > I have to sample at 5000Hz to get the time resolution I need? (I'm look to > embed the code in a DSP and want to cut back the buffer/sampling > requirements) > > Any thoughts would be appreciated
I assume you sample at 5 kHz in order to have the lag 1 coefficient in the cross correlation series closer than the 2 ms required in accuracy? It *might* be possible to get the job done at a smaller sampling rate. You could try to use the phase of the cross spectrum and extract the time lag from the phase slope. Check out chapter 5 of Bendat & Piersol: "Random Data", 3rd. ed., 2000. Extracting the lag estimate frm the cross spectrum phase involves solving a weighted LMS problem as well as requiring the signals to be "sufficiently coherent". The work saved on the lower sampling rate may very well be outweighed by the complex computations on the cross spectrum. Rune
"Allan Wilson" <allanw@wave.co.nz> wrote in message
news:cekd9r$jse$1@news.wave.co.nz...
> Hi, > > I've got a sampling frequency question. > > I have two signals, which only have frequency components up to about
100Hz,
> from two sensors in a liquid stream. I need to get the phase (time) > difference between these two signals with a resolution of 0.2ms to be able > to calculate the velocity of the liquid to the accuracy required. Note the > velocity of the liquid is continuously variable and needs to be measured
at
> about 5Hz. > > Up until now I have been collecting 1024 sample blocks of the two signals
at
> 5000 samples/second and cross-correlating them to get the phase
difference.
> This has worked well. > > My question is, if my signals only have frequency components below 100Hz
do
> I have to sample at 5000Hz to get the time resolution I need? (I'm look to > embed the code in a DSP and want to cut back the buffer/sampling > requirements)
Allan, It sounds like you do have to sample at the higher rate. You are looking for good temporal resolution. This corresponds to high bandwidth. It seems to me that a temporal resolution of 0.2ms corresponds to sampling at least as frequently as 0.1ms and perhaps more frequently depending on system characteristics. But, perhaps 0.2ms or 5000Hz is adequate for your application. Here is the rationale: If you subject a system to a step input and if the step response is roughly 0.2ms then the sytem bandwidth is roughly 5kHz. That being the case, you should measure system output at a rate greater than 10kHz because any input can create an output with a bandwidth of 5kHz. Here is a different rationale: A sinusoid will change twice per cycle. So, if a system can support a particular sinusoidal throughput then it must support two major changes of amplitude per cycle. This might seem like a cyle length of 0.4ms then or 2500Hz - which would have to be sampled at greater than 5kHz. However, this doesn't equate to measuring the temporal difference between sharply defined "events". I really believe that your application will determine which case makes the most sense. An empirical way to determine adequate sampling is this: Use a symmetrical FIR lowpass filter with rather sharp cutoff. Set the sampling frequency for the filter and of your data at 20kHz if you can. Successively reduce the lowpass filter cutoff frequency until the output no longer supports the measurement you need to make. [I'm assuming you have an algorithm that will operate on the data more or less independent of the sample rate). Sample at something like 2.5 times or greater the bandwidth of the limiting lowpass filter. This approach should serve to take into account all of your application and system characteristics. (I mean that "it will" rather than "you must"). See if that doesn't work. Make sure to run some test cases that you understand pretty well. Fred
Fred Marshall wrote:
> "Allan Wilson" <allanw@wave.co.nz> wrote in message > news:cekd9r$jse$1@news.wave.co.nz... > >>Hi, >> >>I've got a sampling frequency question. >> >>I have two signals, which only have frequency components up to about > > 100Hz, > >>from two sensors in a liquid stream. I need to get the phase (time) >>difference between these two signals with a resolution of 0.2ms to be able >>to calculate the velocity of the liquid to the accuracy required. Note the >>velocity of the liquid is continuously variable and needs to be measured > > at > >>about 5Hz. >> >>Up until now I have been collecting 1024 sample blocks of the two signals > > at > >>5000 samples/second and cross-correlating them to get the phase > > difference. > >>This has worked well. >> >>My question is, if my signals only have frequency components below 100Hz > > do > >>I have to sample at 5000Hz to get the time resolution I need? (I'm look to >>embed the code in a DSP and want to cut back the buffer/sampling >>requirements) > > > Allan, > > It sounds like you do have to sample at the higher rate. > > You are looking for good temporal resolution. This corresponds to high > bandwidth. > > It seems to me that a temporal resolution of 0.2ms corresponds to sampling > at least as frequently as 0.1ms and perhaps more frequently depending on > system characteristics. But, perhaps 0.2ms or 5000Hz is adequate for your > application. > > Here is the rationale: > If you subject a system to a step input and if the step response is roughly > 0.2ms then the sytem bandwidth is roughly 5kHz. That being the case, you > should measure system output at a rate greater than 10kHz because any input > can create an output with a bandwidth of 5kHz. > > Here is a different rationale: > A sinusoid will change twice per cycle. So, if a system can support a > particular sinusoidal throughput then it must support two major changes of > amplitude per cycle. This might seem like a cyle length of 0.4ms then or > 2500Hz - which would have to be sampled at greater than 5kHz. However, this > doesn't equate to measuring the temporal difference between sharply defined > "events". > > I really believe that your application will determine which case makes the > most sense. > > An empirical way to determine adequate sampling is this: > > Use a symmetrical FIR lowpass filter with rather sharp cutoff. > Set the sampling frequency for the filter and of your data at 20kHz if you > can. > Successively reduce the lowpass filter cutoff frequency until the output no > longer supports the measurement you need to make. > [I'm assuming you have an algorithm that will operate on the data more or > less independent of the sample rate). > Sample at something like 2.5 times or greater the bandwidth of the limiting > lowpass filter. > This approach should serve to take into account all of your application and > system characteristics. (I mean that "it will" rather than "you must"). > See if that doesn't work. > Make sure to run some test cases that you understand pretty well. > > Fred > > >
High bandwidth or low noise. An offset of 200us is 7.2 degrees, which should be detectable with a 100Hz sine wave, or bandlimited signals which are no higher than 100Hz. It would be best to use a method that allows plenty of phase averaging, to beat down the noise at the cost of detection (not signal) bandwidth. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Thanks for your inputs
Allan

"Allan Wilson" <allanw@wave.co.nz> wrote in message
news:cekd9r$jse$1@news.wave.co.nz...
> Hi, > > I've got a sampling frequency question. > > I have two signals, which only have frequency components up to about
100Hz,
> from two sensors in a liquid stream. I need to get the phase (time) > difference between these two signals with a resolution of 0.2ms to be able > to calculate the velocity of the liquid to the accuracy required. Note the > velocity of the liquid is continuously variable and needs to be measured
at
> about 5Hz. > > Up until now I have been collecting 1024 sample blocks of the two signals
at
> 5000 samples/second and cross-correlating them to get the phase
difference.
> This has worked well. > > My question is, if my signals only have frequency components below 100Hz
do
> I have to sample at 5000Hz to get the time resolution I need? (I'm look to > embed the code in a DSP and want to cut back the buffer/sampling > requirements) > > Any thoughts would be appreciated > > Allan > >