DSPRelated.com
Forums

Real-time sinusoidal parameter estimation?

Started by alecwei October 20, 2008
Hi folks,

I need to estimate the frequency and phase of a sinusoid in the presence
of noise with a fairly high accuracy.  The algorithm will most likely be
implemented on an FPGA for a real-time control system.  I have done some
research on the net and experimented with MATLAB a bit, and the only robust
solution (least-squares based) I came up with uses singular value
decomposition (SVD) of large matrices (hundreds x hundreds), which is
really impractical for an FPGA.  My feeling is that anything that uses
matrix decomposition or inversion will probably be too complex in terms of
computation and resource usage.  Could someone recommend an estimation
algorithm that is robust and practical at the same time?  Let's assume the
number of samples to estimate from will be around 300.  Thanks all!


alecwei wrote:
> Hi folks, > > I need to estimate the frequency and phase of a sinusoid in the presence > of noise with a fairly high accuracy. The algorithm will most likely be > implemented on an FPGA for a real-time control system. I have done some > research on the net and experimented with MATLAB a bit, and the only robust > solution (least-squares based) I came up with uses singular value > decomposition (SVD) of large matrices (hundreds x hundreds), which is > really impractical for an FPGA. My feeling is that anything that uses > matrix decomposition or inversion will probably be too complex in terms of > computation and resource usage. Could someone recommend an estimation > algorithm that is robust and practical at the same time? Let's assume the > number of samples to estimate from will be around 300. Thanks all! > >
How wide is the frequency range, how many cycles are in your 300 samples, how much noise, how predictable is the amplitude? There are a lot of different ways you could do this, each one with it's advantages and disadvantages, and better or worse fit to your problem. For a moderately narrow frequency range and lots of cycles per sample interval you could break your 300 samples into bunch of little one-cycle sets at the nominal frequency, and estimate the phase of each set. Then you can unwrap the phase and find the offset and slope of the collection. This will _probably_ work OK for a +/- 10% variation in frequency from nominal (I'd have to do some math to be sure). Alternately, is there a reason you can't lock onto the signal with a PLL? Once locked this would track frequency and phase in a predictable manner, and would have the advantage of having IIR dynamics which are both minimum phase and easier to model as part of a control system. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
On Oct 21, 2:41&#4294967295;pm, Tim Wescott <t...@seemywebsite.com> wrote:
> alecwei wrote: > > Hi folks, > > > I need to estimate the frequency and phase of a sinusoid in the presence > > of noise with a fairly high accuracy. &#4294967295;The algorithm will most likely be > > implemented on an FPGA for a real-time control system. &#4294967295;I have done some > > research on the net and experimented with MATLAB a bit, and the only robust > > solution (least-squares based) I came up with uses singular value > > decomposition (SVD) of large matrices (hundreds x hundreds), which is > > really impractical for an FPGA. &#4294967295;My feeling is that anything that uses > > matrix decomposition or inversion will probably be too complex in terms of > > computation and resource usage. &#4294967295;Could someone recommend an estimation > > algorithm that is robust and practical at the same time? &#4294967295;Let's assume the > > number of samples to estimate from will be around 300. &#4294967295;Thanks all! > > How wide is the frequency range, how many cycles are in your 300 > samples, how much noise, how predictable is the amplitude? > > There are a lot of different ways you could do this, each one with it's > advantages and disadvantages, and better or worse fit to your problem. > > For a moderately narrow frequency range and lots of cycles per sample > interval you could break your 300 samples into bunch of little one-cycle > sets at the nominal frequency, and estimate the phase of each set. &#4294967295;Then > you can unwrap the phase and find the offset and slope of the > collection. &#4294967295;This will _probably_ work OK for a +/- 10% variation in > frequency from nominal (I'd have to do some math to be sure). > > Alternately, is there a reason you can't lock onto the signal with a > PLL? &#4294967295;Once locked this would track frequency and phase in a predictable > manner, and would have the advantage of having IIR dynamics which are > both minimum phase and easier to model as part of a control system. > > -- > > Tim Wescott > Wescott Design Serviceshttp://www.wescottdesign.com > > Do you need to implement control loops in software? > "Applied Control Theory for Embedded Systems" gives you just what it says. > See details athttp://www.wescottdesign.com/actfes/actfes.html
A PLL has a lock range. Normally the free-running frequency of the VCO defines the centre frequency and the frequency varies up and down with respect to this (as in FM). He would need to have a range of frequencies and set-up the PLL carefully at the centre. If you change the free-running frequency you need to change the loop dynamics too. Hardy
HardySpicer wrote:

   ...

> A PLL has a lock range. Normally the free-running frequency of the VCO > defines the centre frequency and the frequency > varies up and down with respect to this (as in FM). He would need to > have a range of frequencies and set-up the PLL carefully at the > centre. > If you change the free-running frequency you need to change the loop > dynamics too.
Look up the characteristics of the CD4046 (or, e.g., HCF4046). In one configuration it can lock to any frequency in its range above the out-of-lock frequency, which can be set at will. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On 21 Okt, 02:01, "alecwei" <alec...@gmail.com> wrote:
> Hi folks, > > I need to estimate the frequency and phase of a sinusoid in the presence > of noise with a fairly high accuracy.
No you don't. If you *really* need the phase (and very, *very* few people do) you need the amplitude as well.
> &#4294967295;The algorithm will most likely be > implemented on an FPGA for a real-time control system. &#4294967295;I have done some > research on the net and experimented with MATLAB a bit,
What about textbooks on the subject?
> and the only robust > solution (least-squares based) I came up with uses singular value > decomposition (SVD) of large matrices (hundreds x hundreds),
Then you're doing it wrong. Somebody else already mentioned PLLs. If you want to go with model-based frequency estimation you only need to compute SVDs of the order 1.5D - 2D where D is the number of sinusoidals present in the signal.
> which is > really impractical for an FPGA. &#4294967295;My feeling is
Gut feeling is a good thing if you have the experience to back it up. If you don't have the experience, try the method and measure the performance. Ask yourself: What is it you *really* dislike about the method? The computational complexity? The amount of work needed to get a result? Either is a valid reason to choose some other approach, but it's up to you know exactly why you discard one given method. Just don't blame the computational expenses if you are unable (or don't want) to do the job from scratch. There might be some library available you can base your solution on.
> that anything that uses > matrix decomposition or inversion will probably be too complex in terms of > computation and resource usage.
Don't know about that as I don't know the computational capacities of modern FPGAs. I do know that linear algebra and those sorts of things are not trivial to implement. Which is why there might be libraries available.
>&#4294967295;Could someone recommend an estimation > algorithm that is robust and practical at the same time?
I am sure somebody will, if you come up with a useful description of what you try to do.
>&#4294967295;Let's assume the > number of samples to estimate from will be around 300.
That might just disqualify the PLL, as it will need some time to lock on to the signal. Rune
> > >&#4294967295;Let's assume the > > number of samples to estimate from will be around 300. > > That might just disqualify the PLL, as it will need some > time to lock on to the signal. > > Rune
Rune et al, One of the cool things about dsp where the signal is sampled and stored is you can make multiple passes forwards and backwards through the data until you get phase locked. This can be a way to ameliorate issues stemming from balancing lock time with noise sensitivity by effectively lengthing the lock time. Clay

clay@claysturner.com wrote:

> > Rune et al, > > One of the cool things about dsp where the signal is sampled and > stored is you can make multiple passes forwards and backwards through > the data until you get phase locked.
This is a wrong approach. You are not gaining any new information by making multiple passes through the same set of data. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

alecwei wrote:

> Hi folks, > > I need to estimate the frequency and phase of a sinusoid in the presence > of noise with a fairly high accuracy.
How much of noise? How high is fairly high?
> The algorithm will most likely be > implemented on an FPGA for a real-time control system.
So, the question is most likely a homework.
> I have done some > research on the net and experimented with MATLAB a bit, and the only robust > solution (least-squares based) I came up with uses singular value > decomposition (SVD) of large matrices (hundreds x hundreds), which is > really impractical for an FPGA.
"MATLAB does all thinking for us" (tm)
> My feeling is that anything that uses > matrix decomposition or inversion will probably be too complex in terms of > computation and resource usage.
My feeling is that you don't have a clue, and just spewing the smart scientific words. Did you try to read books?
> Could someone recommend an estimation > algorithm that is robust and practical at the same time?
Frequency counter and AC rectifier?
> Let's assume the > number of samples to estimate from will be around 300. Thanks all!
There are many algorithms ranging from FFT to AR or PLL, depending on what exactly do you have and what exactly do you need. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
>On 21 Okt, 02:01, "alecwei" <alec...@gmail.com> wrote: >> Hi folks, >> >> I need to estimate the frequency and phase of a sinusoid in the
presence
>> of noise with a fairly high accuracy. > >No you don't. If you *really* need the phase (and very, *very* few >people do) you need the amplitude as well. > >> =A0The algorithm will most likely be >> implemented on an FPGA for a real-time control system. =A0I have done
som=
>e >> research on the net and experimented with MATLAB a bit, > >What about textbooks on the subject? > >> and the only robust >> solution (least-squares based) I came up with uses singular value >> decomposition (SVD) of large matrices (hundreds x hundreds), > >Then you're doing it wrong. Somebody else already mentioned PLLs. >If you want to go with model-based frequency estimation you only >need to compute SVDs of the order 1.5D - 2D where D is the >number of sinusoidals present in the signal. > >> which is >> really impractical for an FPGA. =A0My feeling is > >Gut feeling is a good thing if you have the experience >to back it up. If you don't have the experience, try the >method and measure the performance. > >Ask yourself: What is it you *really* dislike about >the method? The computational complexity? The amount of >work needed to get a result? Either is a valid reason >to choose some other approach, but it's up to you know >exactly why you discard one given method. > >Just don't blame the computational expenses if you are >unable (or don't want) to do the job from scratch. There >might be some library available you can base your >solution on. > >> that anything that uses >> matrix decomposition or inversion will probably be too complex in terms
o=
>f >> computation and resource usage. > >Don't know about that as I don't know the computational >capacities of modern FPGAs. I do know that linear >algebra and those sorts of things are not trivial >to implement. Which is why there might be libraries >available. > >>=A0Could someone recommend an estimation >> algorithm that is robust and practical at the same time? > >I am sure somebody will, if you come up with a useful >description of what you try to do. > >>=A0Let's assume the >> number of samples to estimate from will be around 300. > >That might just disqualify the PLL, as it will need some >time to lock on to the signal. > >Rune >
There are plenty of applications where phase is *very* important, for example, in interferometric measurements. Just that you aren't informed in this doesn't mean they don't exist.
>If you want to go with model-based frequency estimation you only >need to compute SVDs of the order 1.5D - 2D where D is the >number of sinusoidals present in the signal.
I'm interested in hearing about this approach. There is only one single sinusoid present in the signal, so only a 2D SVD is needed?? We implemented a MATLAB algorithm based on the paper "On- and Off-line identification of Linear State Space Models" by Marc Moonen et al, and the size of the SVD is on the order of the number of input samples => hundreds by hundreds. And I'm sure you know this, the complexity of SVD is O(n^3).
> > >alecwei wrote: > >> Hi folks, >> >> I need to estimate the frequency and phase of a sinusoid in the
presence
>> of noise with a fairly high accuracy. > >How much of noise? >How high is fairly high? > >> The algorithm will most likely be >> implemented on an FPGA for a real-time control system. > >So, the question is most likely a homework. > >> I have done some >> research on the net and experimented with MATLAB a bit, and the only
robust
>> solution (least-squares based) I came up with uses singular value >> decomposition (SVD) of large matrices (hundreds x hundreds), which is >> really impractical for an FPGA. > >"MATLAB does all thinking for us" (tm) > >> My feeling is that anything that uses >> matrix decomposition or inversion will probably be too complex in terms
of
>> computation and resource usage. > >My feeling is that you don't have a clue, and just spewing the smart >scientific words. Did you try to read books? > >> Could someone recommend an estimation >> algorithm that is robust and practical at the same time? > >Frequency counter and AC rectifier? > >> Let's assume the >> number of samples to estimate from will be around 300. Thanks all! > >There are many algorithms ranging from FFT to AR or PLL, depending on >what exactly do you have and what exactly do you need. > > >Vladimir Vassilevsky >DSP and Mixed Signal Design Consultant >http://www.abvolt.com > >
>How much of noise? >How high is fairly high?
The SNR of the measured samples is less than 30dB. And the level of error needs to be within 1% for the phase and frequency estimations.
>So, the question is most likely a homework.
This is not a homework question.
>"MATLAB does all thinking for us" (tm)
MATLAB is a useful tool for modeling, sure it doesn't give all the answers.
>My feeling is that you don't have a clue, and just spewing the smart >scientific words. Did you try to read books?
I did. I read papers on MUSIC, ESPRIT, maximum likelihood detectors, and bunch of nonlinear optimization ones. However most of these are of more academic interest and not a whole lot of practical value. Perhaps I'm going in the wrong direction, trying to find some sort of a least-squares or curve fitting method to estimate the parameters by brute force.