On Mon, 25 Jul 2011 10:31:20 -0500, Vladimir Vassilevsky wrote:
> Tim wrote:
>
>
>> Any thing you do would, perforce, be Kalman _based_
>
> Yes. The problem can be stated as minimization of the error vector. As
> such, it is the application for RLS.
Actually, if the noise (negligible or not) is known, as well as the
frequency, then a Kalman filter for the offset, inphase and quadrature
components ought to be pretty easy. Then you're just a half step away
from the phase. If you expect the phase to drift you should be able to
accommodate that, too.
I haven't pondered an H-infinity filter for a time-varying system (which
is the model you'd be building your Kalman filter around) but it'd be
worth a look to get more robustness.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply by steveu●July 25, 20112011-07-25
>On Mon, 25 Jul 2011 03:52:33 -0500, steveu wrote:
>
>>>samples you'll be able to estimate amplitude, frequency, phase and
>>>offset. If the frequency is known exactly, then you just need three.
>>>But that's probably an absurd assertion at .001 Nyquist: at that
>>>frequency, noise that's normally pretty darn easy to ignore is going to
>>>loom large, and you'll need more that four successive samples.
>>
>> The DESA approach is certainly fast, but its super sensitive to noise.
>> Vlad didn't say how accurate the answer needs to be, and the noise is
>> negligible, so I guess DESA will be OK. :-)
>
>That's what I thought. Negligible noise = magic happens.
>
>What does DESA stand for? I know what I was suggesting, but I'm not
>familiar with the abbreviation (and I found two candidates for it on the
>web of the wide world).
Discrete Energy Separation Algorithm, which is an extension of the Teager
Kaiser Energy Operator, which is what your 3 or 4 sample strategy boil down
to as standard well defined algorithms.
Two candidates might be DESA1 and DESA2, as people often describe two
variants of the same theme. :-)
Steve
Reply by Vladimir Vassilevsky●July 25, 20112011-07-25
Tim wrote:
> Any thing you do would, perforce, be Kalman _based_
Yes. The problem can be stated as minimization of the error vector. As
such, it is the application for RLS.
VLV
Reply by Tim●July 25, 20112011-07-25
On Mon, 25 Jul 2011 03:52:33 -0500, steveu wrote:
>>On Sat, 23 Jul 2011 14:05:31 -0500, Vladimir Vassilevsky wrote:
>>
>>> There is a control loop which matches the amplitude and the phase of
>>> generated analog real sine wave to a digital reference. The frequency
> of
>>> the sine wave is known; it could be set anywhere from 0.001 to 0.999
>>> of Nyquist. The system is very linear by itself, the noise could be
>>> neglected, and the waveform could be considered to be a pure sine. So,
>>> the system has to compensate the amplitude and the phase errors.
>>>
>>> The analog sine wave is sampled by ADC; there is a conversion delay of
>>> few dozens of samples.
>>>
>>> What would be an elegant way to make such loop, with the minimum
>>> response time and the parameters independent from the generated
>>> frequency?
>>>
>>> A trivial approach would be I/Q conversion in one way or another. That
>>> would result in the loop timeconst at the order of a period of the
>>> lowest frequency. Slow.
>>>
>>> The other way could be direct negative feedback. I can filter a
>>> frequency band of interest to keep the stability, then phase shift it
>>> appropriately and apply as a negative feedback. Not sure if that could
>>> work; however it would require a lot of recalculation when changing to
> a
>>> different frequency.
>>>
>>> I can take a set of samples over a given time period and solve for the
>>> most likely amplitude and phase. That could be fairly complex and the
>>> result is going to be frequency dependent, too.
>>>
>>> What would be your opinion?
>>
>>No matter what you do, you are constrained by the noise, the uncertainty
>>in the analog circuitry (which is, I assume, what you are setting out to
>>correct), and the speed that its going to take to get an estimate.
>
>>If the noise is _really_ not an issue, then given any four successive
>>ADC
>
>>samples you'll be able to estimate amplitude, frequency, phase and
>>offset. If the frequency is known exactly, then you just need three.
>>But that's probably an absurd assertion at .001 Nyquist: at that
>>frequency, noise that's normally pretty darn easy to ignore is going to
>>loom large, and you'll need more that four successive samples.
>
> The DESA approach is certainly fast, but its super sensitive to noise.
> Vlad didn't say how accurate the answer needs to be, and the noise is
> negligible, so I guess DESA will be OK. :-)
That's what I thought. Negligible noise = magic happens.
What does DESA stand for? I know what I was suggesting, but I'm not
familiar with the abbreviation (and I found two candidates for it on the
web of the wide world).
> On second thought, maybe
> only a stupident would say the noise is negligible before looking at it
> in the context of a potential solution.
Nah.
>>So, bottom line, my opinion is that you can do things to speed things
>>up,
>
>>but at your very low frequencies you're still going to have a slower
>>lock
>
>>time. And, if you pin your loops effective sampling rate to the
>>frequency (which is often a wise thing to do in a digital PLL), you're
>>going to run into excess lag from the ADC that complicates the job of
>>stabilizing the loop.
>>
>>I think you can do it, because I know that you're smart. I think that
>>if
>
>>the noise (and distortion) really is low and the settling time really is
>>critical that you should seriously consider making your initial
>>estimates
>
>>from less than a whole cycle. I think that if the settling time is
>>really critical, and if you know when the frequency changes, that you
>>should seriously consider a formal Kalman filter construction, to get
>>the
>
>>best compromise between settling and accuracy -- but I think that you
>>know what's best in the end, so I think I won't insist.
>
> If the SNR is genuinely pretty high, maybe a two phase scheme would work
> - a rough initial estimation based on DESA, followed by a tight tracking
> scheme (maybe Kalman based).
I'm not sure exactly what your "DESA" is, but if you have a chunk of a
sine wave, then as that chunk gets to be more and more of a full cycle
you can get a better and better phase/offset/amplitude/frequency
estimate. I'm not sure if your DESA accommodates that, but I know it's
possible to do so.
Any thing you do would, perforce, be Kalman _based_, since a Kalman
filter is linear and extracting phase from a sine wave isn't. Estimating
offset and the amplitudes of the inphase and quadrature portions of the
sine wave _would_ be a linear operation, however, so I suppose that if
one were willing to accept that atan2(optimal estimate, optimal estimate)
is pretty close to an optimal estimate of angle, then one could come up
with a time-varying Kalman filter almost by propping up a textbook next
to one's keyboard and starting to type.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply by steveu●July 25, 20112011-07-25
>On Sat, 23 Jul 2011 14:05:31 -0500, Vladimir Vassilevsky wrote:
>
>> There is a control loop which matches the amplitude and the phase of
>> generated analog real sine wave to a digital reference. The frequency
of
>> the sine wave is known; it could be set anywhere from 0.001 to 0.999 of
>> Nyquist. The system is very linear by itself, the noise could be
>> neglected, and the waveform could be considered to be a pure sine. So,
>> the system has to compensate the amplitude and the phase errors.
>>
>> The analog sine wave is sampled by ADC; there is a conversion delay of
>> few dozens of samples.
>>
>> What would be an elegant way to make such loop, with the minimum
>> response time and the parameters independent from the generated
>> frequency?
>>
>> A trivial approach would be I/Q conversion in one way or another. That
>> would result in the loop timeconst at the order of a period of the
>> lowest frequency. Slow.
>>
>> The other way could be direct negative feedback. I can filter a
>> frequency band of interest to keep the stability, then phase shift it
>> appropriately and apply as a negative feedback. Not sure if that could
>> work; however it would require a lot of recalculation when changing to
a
>> different frequency.
>>
>> I can take a set of samples over a given time period and solve for the
>> most likely amplitude and phase. That could be fairly complex and the
>> result is going to be frequency dependent, too.
>>
>> What would be your opinion?
>
>No matter what you do, you are constrained by the noise, the uncertainty
>in the analog circuitry (which is, I assume, what you are setting out to
>correct), and the speed that its going to take to get an estimate.
>If the noise is _really_ not an issue, then given any four successive ADC
>samples you'll be able to estimate amplitude, frequency, phase and
>offset. If the frequency is known exactly, then you just need three.
>But that's probably an absurd assertion at .001 Nyquist: at that
>frequency, noise that's normally pretty darn easy to ignore is going to
>loom large, and you'll need more that four successive samples.
The DESA approach is certainly fast, but its super sensitive to noise. Vlad
didn't say how accurate the answer needs to be, and the noise is
negligible, so I guess DESA will be OK. :-) On second thought, maybe only a
stupident would say the noise is negligible before looking at it in the
context of a potential solution.
>So, bottom line, my opinion is that you can do things to speed things up,
>but at your very low frequencies you're still going to have a slower lock
>time. And, if you pin your loops effective sampling rate to the
>frequency (which is often a wise thing to do in a digital PLL), you're
>going to run into excess lag from the ADC that complicates the job of
>stabilizing the loop.
>
>I think you can do it, because I know that you're smart. I think that if
>the noise (and distortion) really is low and the settling time really is
>critical that you should seriously consider making your initial estimates
>from less than a whole cycle. I think that if the settling time is
>really critical, and if you know when the frequency changes, that you
>should seriously consider a formal Kalman filter construction, to get the
>best compromise between settling and accuracy -- but I think that you
>know what's best in the end, so I think I won't insist.
If the SNR is genuinely pretty high, maybe a two phase scheme would work -
a rough initial estimation based on DESA, followed by a tight tracking
scheme (maybe Kalman based).
Steve
Reply by Rune Allnor●July 25, 20112011-07-25
On Jul 23, 9:05=A0pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> There is a control loop which matches the amplitude and the phase of
> generated analog real sine wave to a digital reference. The frequency of
> the sine wave is known; it could be set anywhere from 0.001 to 0.999 of
> Nyquist. The system is very linear by itself, the noise could be
> neglected, and the waveform could be considered to be a pure sine. So,
> the system has to compensate the amplitude and the phase errors.
>
> The analog sine wave is sampled by ADC; there is a conversion delay of
> few dozens of samples.
>
> What would be an elegant way to make such loop, with the minimum
> response time and the parameters independent from the generated frequency=
?
>
> A trivial approach would be I/Q conversion in one way or another. That
> would result in the loop timeconst at the order of a period of the
> lowest frequency. Slow.
>
> The other way could be direct negative feedback. I can filter a
> frequency band of interest to keep the stability, then phase shift it
> appropriately and apply as a negative feedback. Not sure if that could
> work; however it would require a lot of recalculation when changing to a
> different frequency.
>
> I can take a set of samples over a given time period and solve for the
> most likely amplitude and phase. That could be fairly complex and the
> result is going to be frequency dependent, too.
>
> What would be your opinion?
Under the constraint that the signal consits of exatly one
sinusoidal and some noise, at a fairly high SNR, I'd have a
look at an AR(1) parametric model:
1) Estimate the parameter of that model on the fly
2) Use the parameter and whatever other data pop out
of the algorithm to estimate the amplitude and phase.
I have no idea what it takes to pull something like
this off (or even if it can be done), but there is
half a chance that you might be able to estimate the
amplitude and phase on a per sample basis.
But again: Am algorithm as suggested will fail if
the signal does not comply to the stated constraints.
Rune
Reply by Tim●July 24, 20112011-07-24
On Sat, 23 Jul 2011 14:05:31 -0500, Vladimir Vassilevsky wrote:
> There is a control loop which matches the amplitude and the phase of
> generated analog real sine wave to a digital reference. The frequency of
> the sine wave is known; it could be set anywhere from 0.001 to 0.999 of
> Nyquist. The system is very linear by itself, the noise could be
> neglected, and the waveform could be considered to be a pure sine. So,
> the system has to compensate the amplitude and the phase errors.
>
> The analog sine wave is sampled by ADC; there is a conversion delay of
> few dozens of samples.
>
> What would be an elegant way to make such loop, with the minimum
> response time and the parameters independent from the generated
> frequency?
>
> A trivial approach would be I/Q conversion in one way or another. That
> would result in the loop timeconst at the order of a period of the
> lowest frequency. Slow.
>
> The other way could be direct negative feedback. I can filter a
> frequency band of interest to keep the stability, then phase shift it
> appropriately and apply as a negative feedback. Not sure if that could
> work; however it would require a lot of recalculation when changing to a
> different frequency.
>
> I can take a set of samples over a given time period and solve for the
> most likely amplitude and phase. That could be fairly complex and the
> result is going to be frequency dependent, too.
>
> What would be your opinion?
No matter what you do, you are constrained by the noise, the uncertainty
in the analog circuitry (which is, I assume, what you are setting out to
correct), and the speed that its going to take to get an estimate.
If the noise is _really_ not an issue, then given any four successive ADC
samples you'll be able to estimate amplitude, frequency, phase and
offset. If the frequency is known exactly, then you just need three.
But that's probably an absurd assertion at .001 Nyquist: at that
frequency, noise that's normally pretty darn easy to ignore is going to
loom large, and you'll need more that four successive samples.
So, bottom line, my opinion is that you can do things to speed things up,
but at your very low frequencies you're still going to have a slower lock
time. And, if you pin your loops effective sampling rate to the
frequency (which is often a wise thing to do in a digital PLL), you're
going to run into excess lag from the ADC that complicates the job of
stabilizing the loop.
I think you can do it, because I know that you're smart. I think that if
the noise (and distortion) really is low and the settling time really is
critical that you should seriously consider making your initial estimates
from less than a whole cycle. I think that if the settling time is
really critical, and if you know when the frequency changes, that you
should seriously consider a formal Kalman filter construction, to get the
best compromise between settling and accuracy -- but I think that you
know what's best in the end, so I think I won't insist.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply by Peter K.●July 23, 20112011-07-23
On Jul 23, 3:05�pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
>
> What would be your opinion?
>
Interesting question!
Julius O. Smith III suggests that the optimal (least squares) sense is
taking the DTFT at the frequency of interest:
https://ccrma.stanford.edu/~jos/sasp/Sinusoidal_Amplitude_Phase_Estimation.html
Obviously, the accuracy of this will depend on the length of the
transform, obviously, which could be too long for what you want. I
believe that a simple recursive formulation of the DTFT at the known
frequency would give you very similar results. You could also
incorporate a slight amount of damping, which might be beneficial to
allow a level of "forgetting" if the phase and amplitude change.
Ciao,
Peter K.
Reply by John●July 23, 20112011-07-23
On Jul 23, 3:05�pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> There is a control loop which matches the amplitude and the phase of
> generated analog real sine wave to a digital reference. The frequency of
> the sine wave is known; it could be set anywhere from 0.001 to 0.999 of
> Nyquist. The system is very linear by itself, the noise could be
> neglected, and the waveform could be considered to be a pure sine. So,
> the system has to compensate the amplitude and the phase errors.
>
> The analog sine wave is sampled by ADC; there is a conversion delay of
> few dozens of samples.
>
> What would be an elegant way to make such loop, with the minimum
> response time and the parameters independent from the generated frequency?
>
> A trivial approach would be I/Q conversion in one way or another. That
> would result in the loop timeconst at the order of a period of the
> lowest frequency. Slow.
>
> The other way could be direct negative feedback. I can filter a
> frequency band of interest to keep the stability, then phase shift it
> appropriately and apply as a negative feedback. Not sure if that could
> work; however it would require a lot of recalculation when changing to a
> different frequency.
>
> I can take a set of samples over a given time period and solve for the
> most likely amplitude and phase. That could be fairly complex and the
> result is going to be frequency dependent, too.
>
> What would be your opinion?
>
> Vladimir Vassilevsky
> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
From your description it sounds like a Hilbert Transform could provide
the magnitude and phase of the input at the known frequency on a per-
sample basis.
John
Reply by robert bristow-johnson●July 23, 20112011-07-23
On Jul 23, 3:05�pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> There is a control loop which matches the amplitude and the phase of
> generated analog real sine wave to a digital reference. The frequency of
> the sine wave is known; it could be set anywhere from 0.001 to 0.999 of
> Nyquist. The system is very linear by itself, the noise could be
> neglected, and the waveform could be considered to be a pure sine. So,
> the system has to compensate the amplitude and the phase errors.
>
> The analog sine wave is sampled by ADC; there is a conversion delay of
> few dozens of samples.
>
> What would be an elegant way to make such loop, with the minimum
> response time and the parameters independent from the generated frequency?
>
> A trivial approach would be I/Q conversion in one way or another. That
> would result in the loop timeconst at the order of a period of the
> lowest frequency. Slow.
>
> The other way could be direct negative feedback. I can filter a
> frequency band of interest to keep the stability, then phase shift it
> appropriately and apply as a negative feedback. Not sure if that could
> work; however it would require a lot of recalculation when changing to a
> different frequency.
>
> I can take a set of samples over a given time period and solve for the
> most likely amplitude and phase. That could be fairly complex and the
> result is going to be frequency dependent, too.
>
why, if the frequency is known, would you want the parameter
estimation alg to *not* use this known frequency to aid its
calculation of estimated phase and amplitude?
do you have DC possibly contaminating the input signal.
BTW, if no frequency search is necessary (that means you *are* making
use of the given frequency), i would think that some quadrature
correlation would be the best method, but it might require one entire
period. another method would be the classic PLL.
r b-j