DSPRelated.com
Forums

Real-time frequency detection

Started by CoyoteBoy July 12, 2007
Hi all, this is my first post, although ive read a few im going to be
cheeky and take before giving, but I will stick around and try to
contribute!

I've been scouting about a bit but cant find the answer to my question
with Google - ive found lots of "almost" answers but not much in the
way of examples.

I have a stream of data coming from a sensor. That sensor will seeing
two components of motion - an overall, almost steady state, component
and a damped vibrational component at somewhere around 3-8Hz. Im
sampling it at ~300Hz, with some known jitter (or at least the time of
each sample is known to the nanosecond). So in effect I have a stream
of real numbers, and the time of their samplings, that could be around
zero or not and follow the general trend of being a step with a higher
frequency sine superimposed upon it. An example of what i mean is
here:
http://tinyurl.com/363365
Overall there is a controller attempting to return the signal to 0
error, but it cant deal with that AND the vibration so....

What I'm trying to do is extract the vibrational component, phase and
period and amplitude would be nice but not necessary, in order to be
able to recreate the antiphase signal for a sort of vibration
cancellation, much like ANC, but with limited effect on the steady
state component.

So now you know my aims.... I was looking at FFT but from google
examples I cannot quite get my noggin around the inputs and output
forms etc and i think they might be a little overkill for detecting a
single mode of vibration. I have access to matlab/scilab but im coding
this up in C so that it can be implemented real-time in a control
situation in a linux/RTAI environment.

Id considered differentiating the input signal and using the zero
crossings to determine the period, using the actual values at those
zeros to give me the phase.

Can anyone throw any light on the situation for me, DSP is not my area
of expertise and im venturing into new territory. If you could point
me to a good book on the subject that would suffice - most of the
books Ive seen seem to assume you have a good knowledge of DSP
already.

Cheers all!
J

James wrote:
...
> I have a stream of data coming from a sensor. That sensor will seeing > two components of motion - an overall, almost steady state, component > and a damped vibrational component at somewhere around 3-8Hz. Im > sampling it at ~300Hz, with some known jitter (or at least the time of > each sample is known to the nanosecond). So in effect I have a stream > of real numbers, and the time of their samplings, that could be around > zero or not and follow the general trend of being a step with a higher > frequency sine superimposed upon it. An example of what i mean is > here:http://tinyurl.com/363365 > Overall there is a controller attempting to return the signal to 0 > error, but it cant deal with that AND the vibration so.... > > What I'm trying to do is extract the vibrational component, phase and > period and amplitude would be nice but not necessary, in order to be > able to recreate the antiphase signal for a sort of vibration > cancellation, much like ANC, but with limited effect on the steady > state component.
Hi James, I'd like to rephrase your question so to fully understand the problem. Let's say you are measuring (sampling) a continuous-time signal x(t), ie. you have measurement pairs (x_i, t_i), with x_i = x(t_i). Next, you assume that x(t) has the parametric form x(t) = c + a sin(2 pi f t + p), where the constant c is the "steady state component" and a,f, and p are the amplitude, frequency and phase of the "damped vibrational component". You would like to estimate the signal parameters (c,a,f,p) from the measurements (x_i, t_i), where i=1,2,...,N (N is the number of measurements). Is that correct? One question aside: what kind of sensor gives you the sample pairs (x_i, t_i)? Most just return the samples x_i, assuming a given sampling period T, ie. t_i = i T. Sounds interesting. Regards, Andor
I forgot:

...

> with x_i = x(t_i).
To make the problem non-trivial, one usually assumes additive measurement noise, ie. the measurement returns y_i = x_i + e_i, where e_i is usually a independent and zero-mean error process.
CoyoteBoy wrote:
> If you could point > me to a good book on the subject that would suffice - most of the > books Ive seen seem to assume you have a good knowledge of DSP > already.
You need to get a copy of Rick Lyons' book "Understanding Digital Signal Processing" 2nd edition. Rick hangs out here, and sometimes he answers questions. His book is an excellent introduction to the topic. Another one for you to check out is "The Scientist and Engineer's Guide to Digital Signal Processing," by Steven W. Smith, available in print and online at http://www.dspguide.com -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 A pessimist is an optimist with experience

CoyoteBoy wrote:

> I have a stream of data coming from a sensor. That sensor will seeing > two components of motion - an overall, almost steady state, component > and a damped vibrational component at somewhere around 3-8Hz.
> Overall there is a controller attempting to return the signal to 0 > error, but it cant deal with that AND the vibration so....
If you have a controller in a loop, this falls into the domain of control systems.
> What I'm trying to do is extract the vibrational component, phase and > period and amplitude would be nice but not necessary, in order to be > able to recreate the antiphase signal for a sort of vibration > cancellation, much like ANC, but with limited effect on the steady > state component.
So, the system as a whole should behave like a lowpass filter. To do that, you need to feed back the high passed signal in antiphase.
> Id considered differentiating the input signal
Not a bad idea, actually. However you need the highpass filter, not the differentiator.
> and using the zero > crossings to determine the period, using the actual values at those > zeros to give me the phase.
You don't have to know the period and phase. The feedback should take care of that. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 12 Jul, 14:31, Andor <andor.bari...@gmail.com> wrote:
> James wrote: > > ... > > > > > I have a stream of data coming from a sensor. That sensor will seeing > > two components of motion - an overall, almost steady state, component > > and a damped vibrational component at somewhere around 3-8Hz. Im > > sampling it at ~300Hz, with some known jitter (or at least the time of > > each sample is known to the nanosecond). So in effect I have a stream > > of real numbers, and the time of their samplings, that could be around > > zero or not and follow the general trend of being a step with a higher > > frequency sine superimposed upon it. An example of what i mean is > > here:http://tinyurl.com/363365 > > Overall there is a controller attempting to return the signal to 0 > > error, but it cant deal with that AND the vibration so.... > > > What I'm trying to do is extract the vibrational component, phase and > > period and amplitude would be nice but not necessary, in order to be > > able to recreate the antiphase signal for a sort of vibration > > cancellation, much like ANC, but with limited effect on the steady > > state component. > > Hi James, > > I'd like to rephrase your question so to fully understand the problem. > Let's say you are measuring (sampling) a continuous-time signal x(t), > ie. you have measurement pairs > > (x_i, t_i), > > with x_i = x(t_i). Next, you assume that x(t) has the parametric form > > x(t) = c + a sin(2 pi f t + p), > > where the constant c is the "steady state component" and a,f, and p > are the amplitude, frequency and phase of the "damped vibrational > component". You would like to estimate the signal parameters (c,a,f,p) > from the measurements (x_i, t_i), where i=1,2,...,N (N is the number > of measurements). Is that correct?
Correct :) Although I'm not too worried about the c component as I have a normal PD controller dealing with that fairly well at the moment.
> One question aside: what kind of sensor gives you the sample pairs > (x_i, t_i)? Most just return the samples x_i, assuming a given > sampling period T, ie. t_i = i T.
I have a high frame-rate camera delivering error-from-centre-of-frame and have programmed RTAI to keep track of the time intervals at which each frame error is recorded - there will be slight delay due to transport errors and calculations at the camera end but I assume that is relatively constant and therefore can be worked around. This data is generally at 300Hz but varies a little as it is sent over dedicated ethernet link. Its an interesting puzzle :) I like the idea of two-timescale control but I cant find many examples of its execution. Thanks J
> You need to get a copy of Rick Lyons' book "Understanding Digital Signal > Processing" 2nd edition. Rick hangs out here, and sometimes he answers > questions. His book is an excellent introduction to the topic. > > Another one for you to check out is "The Scientist and Engineer's Guide > to Digital Signal Processing," by Steven W. Smith, available in print > and online athttp://www.dspguide.com > > -- > Jim Thomas Principal Applications Engineer Bittware, Inc > jtho...@bittware.com http://www.bittware.com (603) 226-0404 x536 > A pessimist is an optimist with experience
Thanks for that, I'll see if I can get hold of a copy of either or both asap.
On 12 Jul, 15:06, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> If you have a controller in a loop, this falls into the domain of > control systems.
Yes, its a very flexible robot manipulator of sorts.
> So, the system as a whole should behave like a lowpass filter. To do > that, you need to feed back the high passed signal in antiphase. > Not a bad idea, actually. However you need the highpass filter, not the > differentiator.
Ahh thats more sense yes, I cant see the forest for the trees!
> You don't have to know the period and phase. The feedback should take > care of that.
So in essence I would need: Input signal -> High pass -> vibration controller compensators ->Low Pass -> PD/PID -> To give overall position control. ? J
On 12 Jul, 16:24, CoyoteBoy <james.buc...@gmail.com> wrote:
> On 12 Jul, 15:06, Vladimir Vassilevsky <antispam_bo...@hotmail.com> > wrote: > > So, the system as a whole should behave like a lowpass filter. To do > > that, you need to feed back the high passed signal in antiphase. > > Not a bad idea, actually. However you need the highpass filter, not the > > differentiator.
I've not yet found an example implementation of a digital high pass filter through google but I'll pop into the university library tomorrow and see what I can see :) I was thinking that a low-pass (moving windowed average with a window as long as 1 period of the vibrations should cover it?) subtracted from the original signal would give only the high frequency content but would give a (relatively) long delay on the "not quite steady state" side. Thanks for your input!
CoyoteBoy wrote:
> On 12 Jul, 16:24, CoyoteBoy <james.buc...@gmail.com> wrote: >> On 12 Jul, 15:06, Vladimir Vassilevsky <antispam_bo...@hotmail.com> >> wrote: >>> So, the system as a whole should behave like a lowpass filter. To do >>> that, you need to feed back the high passed signal in antiphase. >>> Not a bad idea, actually. However you need the highpass filter, not the >>> differentiator. > > I've not yet found an example implementation of a digital high pass > filter through google but I'll pop into the university library > tomorrow and see what I can see :) > > I was thinking that a low-pass (moving windowed average with a window > as long as 1 period of the vibrations should cover it?) subtracted > from the original signal would give only the high frequency content > but would give a (relatively) long delay on the "not quite steady > state" side.
Moving average may be adequate, but there are better ways for the samw cost. Browse the relevant chapters at http://dspguide.com/ Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;