DSPRelated.com
Forums

effects of variable sampling rate on spectrum of a signal

Started by Mitja Nemec April 15, 2011
On Apr 19, 1:12=A0am, Tim Wescott <t...@seemywebsite.com> wrote:
> On 04/18/2011 12:39 AM, Mitja Nemec wrote: > > > (snip) > > > Thanks for all the comments and especially for the nomenclature. I > > really appreciate your help and comments. > > > I hoped that I was clear enough, though clearly I do need some > > practice how to describe my system (and English is not my primary > > language =96weak excuse I know). > > This is my first clue. =A0There's nothing wrong with your written English=
.
> > > > > > > > > > > Before I begin with description of my system I should say that at the > > moment only relative frequency accuracy is required. I am aware that > > achieving absolute accuracy some $ and thought (which in the end > > translates to $) will have to be put in accurate clock source. > > > I have a MCU, which controls the power stage (full bridge, with LC > > filter at the output) which generates voltage. Frequency, amplitude > > and harmonic content are controlled by MCU. For the sake of this > > discussion let's limit the reference voltage to first harmonic only. > > The primary goal is to generate voltage with very low deviation (THD > > in case of first harmonic only) in steady state from the reference > > value, regardless of load current. Note that transient response is not > > a factor, and once in steady state the load current does not change. > > Because of this I chose repetitive action controller (where each > > period has the same number of samples and error at sample #43 in > > previous period is used for corrective action at sample #43 in this > > period, or more specifically if number of samples per period is 1024, > > output of the controller at instant n depends only on error at instant > > n-1024). As the device is also generating reference value there is no > > need to lock onto the signal (I am inherently locked on the signal). > > The requirements of repetitive action controller limit the system in > > the way that the number of samples per period must be constant. > > Otherwise the performance of the controller (output voltage shape) > > falls dramatically. > > > It is the frequency of the reference (and output voltage) signal, that > > must be relatively accurate to 0.01Hz. And it must be adjustable, so > > picking a correct crystal (e.g. 10.24MHz or similar) and going with > > correct multiple is not really an option. Though supplying the MCU > > with variable clock out from a fractional divider is an interesting > > idea for the next revision of HW/SW. > > > The dithering of the sampling clock is already in place (I did not > > mention it as I wanted to keep the explanation simple) and basically > > looks like this. Every sampling interval I calculate the length of the > > next sampling interval in MCU clock cycles. Then I add to it remainder > > calculated in previous sampling interval (read on) and I round it to > > integer. The difference between rounded integer and un-rounded value > > is the remainder and is stored for next sampling period. So if > > sampling interval should be 1952 and 1/3, the sequence of length of > > sampling intervals would look like 1952, 1952, 1953, 1952, 1952, > > 1953, ... with remainder values 1/3, 2/3, 0, 1/3, 2/3, 0, ... > > > The FFT I do in the system is only a FFT of a load current and I need > > only first and higher harmonics of it so FFT out of one period is good > > enough for my purposes (mainly monitoring the THD of the current and > > not really measuring it, thus I can afford to be sloppy). > > > As said the system works fine at the moment and the main reason for my > > post is so that I could get some background on what I am actually > > doing. I know that some of you might have a problem with the idea that > > some might take a tool without knowing any background and then using > > it. I must say that I am also not ecstatic about it, but I am not in > > the position to say to the boss "we can probably do this, just let me > > read extensively on the subject for a month and then I can get to do > > actual work" (actual for boss, I consider education and thinking about > > problems also part of the work). So here I am with some spare time > > trying to delve deeper into theory behind my work. > > Given that your goal is to use information from prior cycles to correct > the current one, I'm not sure that you want to use an FFT at all -- if > what you want is a voltage to be generated with some specific periodic > waveform, then you should be able to do this using purely time-domain > methods. >
The voltage control is done purely in time domain with repetitive controller. The FFT I am talking about (and I obviously be more clear about it) is just for monitoring the current and THD of the current (note monitoring and not actually measuring)
> > Linguistic note: This isn't an English thing, it's a DSP thing. =A0In > engineering usage at least, the "n'th" harmonic of a sine wave is the > one where x(t) =3D sin(n * 2 * pi * f) -- so the fundamental is your 1st > harmonic, twice the fundamental is your second harmonic, DC is the > zero'th harmonic. etc. > > -- > > Tim Wescott > Wescott Design Serviceshttp://www.wescottdesign.com > > Do you need to implement control loops in software? > "Applied Control Theory for Embedded Systems" was written for you. > See details athttp://www.wescottdesign.com/actfes/actfes.html
Again I find that I conveyed some things not clearly enough. My device is generating voltage, that should follow reference value. Now the reference value can consist only of first harmonic or it can have some higher harmonics added to the first one. My point was only that if reference value has some higher harmonics in it then the THD of the output voltage (not current) is not really the measure how good the control is. Anyhow from the responses your observation is spot on. My written English might be good enough, but I have difficulties conveying what I mean or describing the system accurately. I'll have to work on this and I appreciate your questions as all this is a good exercise for me Mitja
On Apr 19, 1:10=A0am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> Mitja Nemec wrote: > > (snip) > > > Thanks for all the comments and especially for the nomenclature. I > > really appreciate your help and comments. > > You do weird things in the weird way. > There is no need for FFT, 1024 samples, and dithering mumbo jumbo. > First, generate the fundamental and all harmonics of interest by means > of the DDS. Convert to PWM as needed. Find the THD by multiplying your > output to harmonics. Minimize the THD by adjusting the harmonics. That > doesn't take much of the processing and memory. A 8-bit microcontroller > is sufficient. BTW, I've done exactly that with Atmel AVR. > > Vladimir Vassilevsky > DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
If you can bear with me I'd like to ask you if you can shed some light on proposed scheme. I have problems just with the "Find the THD by multiplying your output to harmonics". I only know how to find THD by knowing the magnitude of first and higher harmonics (Wikipedia style). Is there another way of calculating THD of a signal. What if I want to have signal which consist of first and let say 10% of third harmonic. Then THD is not really a proper metrics to see how my output signal is close to the reference one, or could I expand the definiton of THD in this case to be (sum of all harmonics without first and third)/(sum of first and third harmonic)? Mitja Nemec
On Apr 19, 1:12=A0am, Fred Marshall <fmarshallxremove_th...@acm.org>
wrote:
> Mitja, > > I don't see *anything* wrong with your English. =A0So, let's concentrate > on the system description - because it's still not all that clear to me. > =A0 So, I'll now wade through the rather lengthy description you've given > - with comments and questions interspersed below: > > On 4/18/2011 12:39 AM, Mitja Nemec wrote:> (snip) > > ...... only relative frequency accuracy is required. ....... > > > > > MCU, which controls the power stage (full bridge, with LC > > filter at the output) which generates voltage. Frequency, amplitude > > and harmonic content are controlled by MCU. > > ***OK > > >For the sake of this > > discussion let's limit the reference voltage to first harmonic only. > > The primary goal is to generate voltage with very low deviation (THD > > in case of first harmonic only) in steady state from the reference > > value, regardless of load current. > > ***Perhaps language here: Of course you apply a THD measurement to a > sinusoid (usually the fundamental). =A0The "first harmonic" might be > confused with the "second harmonic of the fundamental" - but I take it > you mean THD of the fundamental frequency. =A0And, just to be clear, any > THD measurement must include the harmonics and not only the fundamental > .. in the sense of measuring it. =A0You likely know this so I'm being pic=
ky. As noted in my post to Tim I obviously have problems conveying my design. To explicitly state: I know that fundamental and first harmonic are the same and for a THD you need to know higher harmonics as well.
> > >I chose repetitive action controller (where each > > period has the same number of samples and error at sample #43 in > > previous period is used for corrective action at sample #43 in this > > period, or more specifically if number of samples per period is 1024, > > output of the controller at instant n depends only on error at instant > > n-1024). > > ***Now, this really confuses me. =A0Here's my paraphrasing back: > - I generate a sinusoid in the MCU using an internal clock and (as > later) a sine table which generates 1024 sinusoidal samples. > - I have (abritrarily?) chosen the 43rd sample to use as a reference > point for measuring (cycle-by-cycle?) error. > - On the 43rd sample, I compare [something I don't know what!!] with > [something else I don't know what] to generate an error. > I guess my problem here is that I don't see the difference between the > MCU output and the "output of the controller".
- generated sinusoidal signal is a reference value for the controller - error in 43rd sample has impact only and only on next 43rd sample within a period error in 44th sample has impact only and only on next 44th sample within a period and so on - On 43rd sample I compare reference value with output value to generate an error signal - Output of the controller is basically PWM output of MCU I hope that the discrete equation of repetitive controller will shed some light: Out(z) =3D In(z) + Out(z)*G*z^-N or written as a transfer function: H(z) =3D 1/(1-G*z^-N), where ^ is a power operator, G is gain of the controller and N is number of samples within a period.
> > >As the device is also generating reference value there is no > > need to lock onto the signal (I am inherently locked on the signal). > > ***If it is inherently locked to the signal then why the feedback > mechanism at all?
I was referring to frequency locking as I am generating a signal, which has to be corrected slightly by the controller I do not need to worry about locking the frequency(period) of repetitive controller with controlled signal.
> > > The requirements of repetitive action controller limit the system in > > the way that the number of samples per period must be constant. > > Otherwise the performance of the controller (output voltage shape) > > falls dramatically. > > Hmmm... I don't know the term "repetitive action controller" so I found > this which sounds pretty close to what you're describing: > > http://www.ufsm.br/gepoc/publicacoes/congressos/New%20Repetitive%20Co... > > Ah! =A0"Repetitive Controlled PWM Inverters" =A0Is that the term you're > looking for? > > Fred
Yes, sorry about the confusion, I've seen some references calling the principle repetitive action controller and I assumed this is a accepted way of calling it. Mitja Nemec
On Apr 17, 12:24=A0am, Fred Marshall <fmarshallxremove_th...@acm.org>
wrote:

(snip)

> > - How do you decide when to switch sampling frequencies?
This is covered in my reply to Glen Herrmannsfeldt.
> > - How do you know that it's "working well"?
I measure the output of my system with frequency analyzer.
> > I rather suspect that while the system is working well that there are > artifacts of the approach that defy the measures you're taking. =A0You ma=
y
> not be getting what you expect - although it seems good enough. > > So, please allow me to encourage you to help us understand the bigger > picture. =A0Then we might be able to comment further. > > I agree that "sample rate dithering" is about as close a name that makes > sense for further research. =A0It would be interesting to know where else > your particular approach has been used. =A0References? > > Fred
Thanks for the name it really opened a path to a lot of references Mitja

Mitja Nemec wrote:

> On Apr 19, 1:10 am, Vladimir Vassilevsky <nos...@nowhere.com> wrote: > >>Mitja Nemec wrote: >> >>>(snip) >> >>>Thanks for all the comments and especially for the nomenclature. I >>>really appreciate your help and comments. >> >>You do weird things in the weird way. >>There is no need for FFT, 1024 samples, and dithering mumbo jumbo. >>First, generate the fundamental and all harmonics of interest by means >>of the DDS. Convert to PWM as needed. Find the THD by multiplying your >>output to harmonics. Minimize the THD by adjusting the harmonics. That >>doesn't take much of the processing and memory. A 8-bit microcontroller >>is sufficient. BTW, I've done exactly that with Atmel AVR. >> > > If you can bear with me I'd like to ask you if you can shed some light > on proposed scheme. I have problems just with the "Find the THD by > multiplying your output to harmonics". I only know how to find THD by > knowing the magnitude of first and higher harmonics (Wikipedia style). > Is there another way of calculating THD of a signal. What if I want to > have signal which consist of first and let say 10% of third harmonic. > Then THD is not really a proper metrics to see how my output signal is > close to the reference one, or could I expand the definiton of THD in > this case to be (sum of all harmonics without first and third)/(sum of > first and third harmonic)?
You see, I am a professional and I work for money. Therefore I would be glad to discuss your problem privately. My contact is at the web site. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 04/18/2011 07:23 PM, Rune Allnor wrote:
> On Apr 18, 7:06 pm, Tim Wescott<t...@seemywebsite.com> wrote: >> On 04/18/2011 03:23 AM, Rune Allnor wrote: >> >>> On Apr 18, 9:39 am, Mitja Nemec<kore...@yahoo.co.uk> wrote: >> >>>> ... or more specifically if number of samples per period is 1024, >> >>> As I said before, this is where you make the mistake. Despite >>> views that are often aired in this forum, one can never design >>> a practical system with such criteria in mind: One designe a >>> system with *some* sample rate (subject to some degree of jitter), >>> and the signal is *quasi* periodic to within *some* accuracy one >>> does not know. >> >> Rune, you are _not_ being clear, and given that you didn't answer my >> previous query for expansion on this it's rather frustrating. > > *Somebody* is not being clear; I suspect it's the OP. > >> What's the matter with 1024 samples, as long as the sampling rate is >> sufficient for his lowest frequency of excitation? > > Who was talking about excitation? In the first post there was > talk about 'I don't want to use windows and I am worrying about > spectral leakage.' None of that has to do with exciatation. > It has to do with PSD measurements.
The OP was, later. If you have a signal that's periodic enough, and at a known frequency, then you don't need windows. Period. That has to do with PSD measurements, too. The only question becomes "how do I know if it's periodic _enough_". -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On 04/18/2011 11:12 PM, Mitja Nemec wrote:
> On Apr 19, 1:10 am, Vladimir Vassilevsky<nos...@nowhere.com> wrote: >> Mitja Nemec wrote: >>> (snip) >> >>> Thanks for all the comments and especially for the nomenclature. I >>> really appreciate your help and comments. >> >> You do weird things in the weird way. >> There is no need for FFT, 1024 samples, and dithering mumbo jumbo. >> First, generate the fundamental and all harmonics of interest by means >> of the DDS. Convert to PWM as needed. Find the THD by multiplying your >> output to harmonics. Minimize the THD by adjusting the harmonics. That >> doesn't take much of the processing and memory. A 8-bit microcontroller >> is sufficient. BTW, I've done exactly that with Atmel AVR. >> >> Vladimir Vassilevsky >> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com > > If you can bear with me I'd like to ask you if you can shed some light > on proposed scheme. I have problems just with the "Find the THD by > multiplying your output to harmonics". I only know how to find THD by > knowing the magnitude of first and higher harmonics (Wikipedia style).
> Is there another way of calculating THD of a signal. Assuming that the excitation is a perfect sinusoid and noise isn't a significant issue, you can also do it by comparing (power in the output) to (fundamental power in the output), or (with higher potential accuracy), (non-fundamental power in the output) to (fundamental power in the output). You get the non-fundamental power in the output by notching out (or otherwise subtracting) the fundamental from the output.
> What if I want to > have signal which consist of first and let say 10% of third harmonic. > Then THD is not really a proper metrics to see how my output signal is > close to the reference one, or could I expand the definiton of THD in > this case to be (sum of all harmonics without first and third)/(sum of > first and third harmonic)?
You could define it that way, but what if you had some perverse case where the distortion is substantially from 1st-harmonic to 3rd? Your proposed method is probably the best that you can do. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
RE: [On 4/18/2011 11:30 PM, Mitja Nemec wrote:]

Mitja,

OK, let me paraphrase back to see if I understand:

You compare the nth output sample with the nth input sample where the 
input samples are exactly periodic so the comparison could be viewed as 
delayed one period or not ... it doesn't matter.

The comparison generates an error which you use to do something....

So, it's understandable to me that this looks a bit like a "lock" type 
of process even though the output frequency should track the input 
frequency anyway, right?

It's about distortion control it appears.

Does that about sum it up?

Was the reference helpful?

Fred
On Apr 19, 6:51=A0pm, Tim Wescott <t...@seemywebsite.com> wrote:
> On 04/18/2011 07:23 PM, Rune Allnor wrote: > > > > > > > On Apr 18, 7:06 pm, Tim Wescott<t...@seemywebsite.com> =A0wrote: > >> On 04/18/2011 03:23 AM, Rune Allnor wrote: > > >>> On Apr 18, 9:39 am, Mitja Nemec<kore...@yahoo.co.uk> =A0 =A0wrote: > > >>>> ... or more specifically if number of samples per period is 1024, > > >>> As I said before, this is where you make the mistake. Despite > >>> views that are often aired in this forum, one can never design > >>> a practical system with such criteria in mind: One designe a > >>> system with *some* sample rate (subject to some degree of jitter), > >>> and the signal is *quasi* periodic to within *some* accuracy one > >>> does not know. > > >> Rune, you are _not_ being clear, and given that you didn't answer my > >> previous query for expansion on this it's rather frustrating. > > > *Somebody* is not being clear; I suspect it's the OP. > > >> What's the matter with 1024 samples, as long as the sampling rate is > >> sufficient for his lowest frequency of excitation? > > > Who was talking about excitation? In the first post there was > > talk about 'I don't want to use windows and I am worrying about > > spectral leakage.' None of that has to do with exciatation. > > It has to do with PSD measurements. > > The OP was, later. =A0
Later, yes. Not in his first post.
> If you have a signal that's periodic enough, and at > a known frequency, then you don't need windows. =A0Period. =A0
Judging from classroom texts, one might get that impression.
> That has to do > with PSD measurements, too. =A0The only question becomes "how do I know i=
f
> it's periodic _enough_".
No. No questions. One never know those thigs outside the classroom concocted-hypothetical-what-if-excercise setting. In real life one needs to deal with imperfections like - Noise - Nonlinearities - All kinds of deviations from the simple models I'd expected that you, of all people (including the comp.dsp regulars), should know this. Rune
On Apr 20, 3:33=A0am, Tim Wescott <t...@seemywebsite.com> wrote:
> On 04/18/2011 11:12 PM, Mitja Nemec wrote: > > > > > > > > > On Apr 19, 1:10 am, Vladimir Vassilevsky<nos...@nowhere.com> =A0wrote: > >> Mitja Nemec wrote: > >>> (snip) > > >>> Thanks for all the comments and especially for the nomenclature. I > >>> really appreciate your help and comments. > > >> You do weird things in the weird way. > >> There is no need for FFT, 1024 samples, and dithering mumbo jumbo. > >> First, generate the fundamental and all harmonics of interest by means > >> of the DDS. Convert to PWM as needed. Find the THD by multiplying your > >> output to harmonics. Minimize the THD by adjusting the harmonics. That > >> doesn't take much of the processing and memory. A 8-bit microcontrolle=
r
> >> is sufficient. BTW, I've done exactly that with Atmel AVR. > > >> Vladimir Vassilevsky > >> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com > > > If you can bear with me I'd like to ask you if you can shed some light > > on proposed scheme. I have problems just with the "Find the THD by > > multiplying your output to harmonics". I only know how to find THD by > > knowing the magnitude of first and higher harmonics (Wikipedia style). > > =A0> Is there another way of calculating THD of a signal. > > Assuming that the excitation is a perfect sinusoid and noise isn't a > significant issue, you can also do it by comparing (power in the output) > to (fundamental power in the output), or (with higher potential > accuracy), (non-fundamental power in the output) to (fundamental power > in the output). =A0You get the non-fundamental power in the output by > notching out (or otherwise subtracting) the fundamental from the output. > > > What if I want to > > have signal which consist of first and let say 10% of third harmonic. > > Then THD is not really a proper metrics to see how my output signal is > > close to the reference one, or could I expand the definiton of THD in > > this case to be (sum of all harmonics without first and third)/(sum of > > first and third harmonic)? > > You could define it that way, but what if you had some perverse case > where the distortion is substantially from 1st-harmonic to 3rd? =A0Your > proposed method is probably the best that you can do. > > -- > > Tim Wescott > Wescott Design Serviceshttp://www.wescottdesign.com > > Do you need to implement control loops in software? > "Applied Control Theory for Embedded Systems" was written for you. > See details athttp://www.wescottdesign.com/actfes/actfes.html
Well thanks to all of you, I've got a lot to think about so I'll start gathering literature and if I come on another problem that I have difficulties solving/understanding it I'll come here for help. Mitja