DSPRelated.com
Forums

integration of a continuous function

Started by Alex_001 February 23, 2009

Alex_001 wrote:
> > Here's my problem: > > we're aquiring a signal form a piezoelectric force sensor; the analog > signal is filtered by a lowpass filter at 5 kHz and sampled at 100 kHz. In > such a way we get a "smooth" waveform, that is what we want.
Keep in mind the sensor has a frequency response that approximates force in a certain range of frequencies. For instance it may be from 20 to 20KHz the response is more or less linear with the square of the frequency. How the sensor is mounted affects this frequency response. So you can only accurately determine the response in situ.
> > What we need is to calculate the integral of this signal, on a 5 ms > window.
What you should consider is using a filter that is inverse of the frequency response of your system. That will look a lot like integration.
> I was wondering if there's a EASY way to reduce the sampling frequency and > still get an accurate estimate (there are surely ways to do that, but if > too compicated is useless for our application, we'd rather have a higher > sampling frequency).
Is higher frequency above the point where the sensors response is no longer linear with the frequency squared? -jim
> > Following illywhacker's (and someoneelse's) advice, I wrote my continuous > function as a linear combination of shifted sinc functions weighted by the > sample values (recostruction theorem). > Denoting with X(t) the continuous function, and X(n*T) it samples in [0, > To], I got for the integral in [0 T0] (N = total number of samples): > > integral[0 , T0]{X(t)dt} = sum[n=0..N]{X(nT)* integral[-n , > (T0-nT)/T]{sinc(p)dp}} > > Now, the function integral[0 , x]{sinc(x)dx} is known and tabulate (Matlab > implements such a function, for example). So, if my procedure was correct, > it should be not that hard...I will try and let you know. > > Alex
>
> >What could be simpler then a moving average filter? >
it's not what we need..our acquisitions are on a 5 ms windows at different time instants (when particoular events occur)
> > >Extra knowledge is harmful to the idiots.
not everybody can spend all his time reading posts and insulting people..someone has also to work.
>"Matlab does all thinking for us" (TM)
what I need is EXACTLY a cookbook solution...I am not a geniuos like you. (and I cited Matlab just as an example). what's the problem with you man? Chill out!
> >VLV >
clay@claysturner.com wrote:
(someone wrote)

>>>it's well known that sampling a continuous function according to the >>>sampling theorem requirements, you get all the information on the >>>contunuous function just from the samples.
(big snip including things I wrote)
> The sum of the points is pretty close. But a simple correction gets > you closer. Just sum all of the interior points plus add in 1/2 of the > first and last point. The final sum should be scaled by sampling > period (or divided by the sampling rate). This falls out from the > integral of the scaled sync function. The error caused by tails of the > omitted data (data outside of the integration interval) can be diluted > down by taking more samples within the interval via a higher sampling > rate, but the general approach gives a pretty good estimate.
It is well known that sampling at half the frequency of a sine doesn't give the right result. Now, consider a short sampling interval, a sine close to half the sampling rate, and the sine crossing zero near the middle of the interval. The other samples won't be at zero, but they will be very close. It is commonly ignored, but perfect reconstruction below the Nyquist frequency really depends on an infinite interval. For most real problems the interval is sufficiently long that it doesn't cause problems. As I said in my previous post, for a CD 0.25s is plenty long enough. I believe the minimum for a CD track is something like 3 or 4 seconds.
> Of course the OP hasn't given detail about his problem so how good is > good enough for his needs? But I think he, like a lot of people, need > to experiment with this and learn more about the problem at hand and > then be able to specify his problem. Our generic suggestions give him > some things to try.
More details would be nice. I came up with the one case I could think of where integrating the points would not give the right answer. -- glen
Glen Herrmannsfeldt wrote:
> clay@claysturner.com wrote: > (someone wrote) > >>>> it's well known that sampling a continuous function according to the >>>> sampling theorem requirements, you get all the information on the >>>> contunuous function just from the samples. > (big snip including things I wrote) > >> The sum of the points is pretty close. But a simple correction gets >> you closer. Just sum all of the interior points plus add in 1/2 of the >> first and last point. The final sum should be scaled by sampling >> period (or divided by the sampling rate). This falls out from the >> integral of the scaled sync function. The error caused by tails of the >> omitted data (data outside of the integration interval) can be diluted >> down by taking more samples within the interval via a higher sampling >> rate, but the general approach gives a pretty good estimate. > > It is well known that sampling at half the frequency of a sine > doesn't give the right result. Now, consider a short sampling > interval, a sine close to half the sampling rate, and the sine > crossing zero near the middle of the interval. The other samples > won't be at zero, but they will be very close. > > It is commonly ignored, but perfect reconstruction below the > Nyquist frequency really depends on an infinite interval. > For most real problems the interval is sufficiently long that > it doesn't cause problems. As I said in my previous post, > for a CD 0.25s is plenty long enough. I believe the minimum > for a CD track is something like 3 or 4 seconds. > >> Of course the OP hasn't given detail about his problem so how good is >> good enough for his needs? But I think he, like a lot of people, need >> to experiment with this and learn more about the problem at hand and >> then be able to specify his problem. Our generic suggestions give him >> some things to try. > > More details would be nice. I came up with the one case I could > think of where integrating the points would not give the right > answer.
What is the "right answer" when the sample encompass only a small part of the longest period? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Jerry Avins wrote:
(snip, I wrote)

>> It is well known that sampling at half the frequency of a sine >> doesn't give the right result. Now, consider a short sampling >> interval, a sine close to half the sampling rate, and the sine >> crossing zero near the middle of the interval. The other samples >> won't be at zero, but they will be very close.
(snip)
> What is the "right answer" when the sample encompass > only a small part of the longest period?
Yes. Well, if you believe in perfect reconstruction you know what the right answer is. (The signal you sampled in the first place.) But it isn't only part of the longest period, it is only in the sampled signal that it is part of the long period. The signal makes almost one half cycle between sample points. With infinite samples you can extract it exactly. With a large number of samples you can extract it pretty well. With a small number, even many periods of the original signal, you can't. Another way to say it is that the sample interval must be long enough for the reconstruction filter to process. As you get closer to the Nyquist frequency, the reconstruction filter needs more time. -- glen
On Feb 24, 8:11&#4294967295;pm, "Alex_001" <a.bast...@email.it> wrote:
> >What could be simpler then a moving average filter? > > it's not what we need..our acquisitions &#4294967295;are on a 5 ms windows at > different time instants (when particoular events occur) > > > > >Extra knowledge is harmful to the idiots. > > not everybody can spend all his time reading posts and insulting > people..someone has also to work. > > >"Matlab does all thinking for us" (TM) > > what I need is EXACTLY a cookbook solution...I am not a geniuos like you. > (and I cited Matlab just as an example). > > what's the problem with you man? > Chill out!
Don't worry Alex. Genius is a long way from what Vladimir is. On the other hand, Jim's suggestion is relevant. The reconstruction theorem as stated only applies if sampling is really by delta functions which it never is. Presumably what you really want is the integral of the force itself, isn't it? You could get much better results if you knew more details about the sensor, the filtering, and the sampling. illywhacker;
On 24 Feb., 18:51, "Alex_001" <a.bast...@email.it> wrote:
> we're aquiring a signal form a piezoelectric force sensor; the analog > signal is filtered by a lowpass filter at 5 kHz and sampled at 100 kHz. In > such a way we get a "smooth" waveform, that is what we want. > > What we need is to calculate the integral of this signal, on a 5 ms > window. > I was wondering if there's a EASY way to reduce the sampling frequency and > still get an accurate estimate (there are surely ways to do that, but if > too compicated is useless for our application, we'd rather have a higher > sampling frequency).
A reduction close to fs=10kHz is probably not a good idea. You could try to use a sampling rate inbetween like fs=25 kHz (if possible). Assuming the signal really is limited to a bandwidth of 5 kHz the reconstruction filter (imagine a continuous windowed sinc curve with a "cut off" frequency at around 9 kHz) can be rather short (like +/-10 samples) without sacrifycing quality due to the oversampling. Assuming that you're not interested in controlling the exact position of this 5ms window (w.r.t. subsample position) the integral is simply a weighted sum of the samples surrounding your interval with the weights being determined by the sinc curve's integrals (linearity of integration). At fs=25 kHz the interval is 125 "samples long". So, you have some weights for 20 samples around the starting border, some weights for 20 samples around the ending border and 105 equal weights for the samples in the middle because "their sinc" is completely contained in the interval. HTH, SG
On Feb 24, 2:58&#4294967295;pm, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> c...@claysturner.com wrote: > > (someone wrote) > > >>>it's well known that sampling a continuous function according to the > >>>sampling theorem requirements, you get all the information on the > >>>contunuous function just from the samples. > > (big snip including things I wrote) > > > The sum of the points is pretty close. But a simple correction gets > > you closer. Just sum all of the interior points plus add in 1/2 of the > > first and last point. The final sum should be scaled by sampling > > period (or divided by the sampling rate). This falls out from the > > integral of the scaled sync function. The error caused by tails of the > > omitted data (data outside of the integration interval) can be diluted > > down by taking more samples within the interval via a higher sampling > > rate, but the general approach gives a pretty good estimate. > > It is well known that sampling at half the frequency of a sine > doesn't give the right result. &#4294967295;Now, consider a short sampling > interval, a sine close to half the sampling rate, and the sine > crossing zero near the middle of the interval. &#4294967295;The other samples > won't be at zero, but they will be very close. > > It is commonly ignored, but perfect reconstruction below the > Nyquist frequency really depends on an infinite interval. > For most real problems the interval is sufficiently long that > it doesn't cause problems. &#4294967295;As I said in my previous post, > for a CD 0.25s is plenty long enough. &#4294967295;I believe the minimum > for a CD track is something like 3 or 4 seconds. > > > Of course the OP hasn't given detail about his problem so how good is > > good enough for his needs? But I think he, like a lot of people, need > > to experiment with this and learn more about the problem at hand and > > then be able to specify his problem. Our generic suggestions give him > > some things to try. > > More details would be nice. &#4294967295;I came up with the one case I could > think of where integrating the points would not give the right > answer. > > -- glen
Glen, Hopefully the OP's system is not critically sampled, because then all sorts of problems show up such as in your example with the sampling on or near the zero crossings. Now that the OP has added some details (in another branch of this thread), the question arises as to why he wants to integrate. Does he really need a 1/f type of response? Or does he need a lowpass filter smoothing filter because of noise? Is he correcting a response issue with the sensor? Etc? Clay
On Feb 24, 4:10&#4294967295;pm, illywhacker <illywac...@gmail.com> wrote:
> On Feb 24, 8:11&#4294967295;pm, "Alex_001" <a.bast...@email.it> wrote: > > > > > > > >What could be simpler then a moving average filter? > > > it's not what we need..our acquisitions &#4294967295;are on a 5 ms windows at > > different time instants (when particoular events occur) > > > >Extra knowledge is harmful to the idiots. > > > not everybody can spend all his time reading posts and insulting > > people..someone has also to work. > > > >"Matlab does all thinking for us" (TM) > > > what I need is EXACTLY a cookbook solution...I am not a geniuos like you. > > (and I cited Matlab just as an example). > > > what's the problem with you man? > > Chill out! > > Don't worry Alex. Genius is a long way from what Vladimir is. > > On the other hand, Jim's suggestion is relevant. The reconstruction > theorem as stated only applies if sampling is really by delta > functions which it never is. Presumably what you really want is the > integral of the force itself, isn't it? You could get much better > results if you knew more details about the sensor, the filtering, and > the sampling. > > illywhacker;- Hide quoted text - > > - Show quoted text -
I guess the question is whether the OP is really trying to calculate the impulse (momentum transfer)? This usually shows up in situations where you have a very strong force that exists for a brief period of time. Thus you talk about f.delta t as a single quantity. But if you are actually measuring the force and then integrating it over time, you are clearly resolving f(t). I suspect the integration is used for a lowpass smoothing operation. Maybe the OP can let us know why he wants to integrate the force. Clay

illywhacker wrote:
> > On Feb 24, 8:11 pm, "Alex_001" <a.bast...@email.it> wrote: > > >What could be simpler then a moving average filter? > > > > it's not what we need..our acquisitions are on a 5 ms windows at > > different time instants (when particoular events occur) > > > > > > > > >Extra knowledge is harmful to the idiots. > > > > not everybody can spend all his time reading posts and insulting > > people..someone has also to work. > > > > >"Matlab does all thinking for us" (TM) > > > > what I need is EXACTLY a cookbook solution...I am not a geniuos like you. > > (and I cited Matlab just as an example). > > > > what's the problem with you man? > > Chill out! > > Don't worry Alex. Genius is a long way from what Vladimir is. > > On the other hand, Jim's suggestion is relevant. The reconstruction > theorem as stated only applies if sampling is really by delta > functions which it never is. Presumably what you really want is the > integral of the force itself, isn't it? You could get much better > results if you knew more details about the sensor, the filtering, and > the sampling.
That was not really my point. He doesn't want the integral of force. Force is just an abstract concept here so is integration. Movement in space is what produces a voltage. The amount of voltage output for a given displacement depends on the frequency at which that dispacement occurs. The sensor is essentially a filter with a certain frequency response. That means you move the sensor in space at certain frequencies and it attenuates those frequencies in a predictable way. It just acts as a linear filter. The frequency response of this filter just happens to be very close to proportional to the square of the frequency. But it isn't exact. For example, just loosening or tightening the mounting bolt(s) on this type of sensor can change the frequency response curve. If the sensor is mounted in the manner the manufacturer designed it to be and and the movement in space driving it is at frequencies within a certain band you can do simple double numerical integration and get an output that follows the input movement simply because you are applying a filter to the data that happens to be very close to the exact inverse of the sensor's frequency response and thus the output is close to a flat response to the input. But in a real situation it often won't work so nicely because the mounting is not ideal or the input motion is not strictly limited to those frequencies at which the sensor has a simple response curve. -jim