DSPRelated.com
Forums

Re-sampling

Started by Pierre de Vos February 3, 2007
On Feb 5, 1:27 pm, "Pierre de Vos" <pierre.de...@webmail.co.za> wrote:
> > Back to the problem at hand: I'm doing a new design and would like to > achieve an accuracy (of power) in the region of 0.005% or better. I'm > changing to a ADSP-21262 floating point Sharc and redesigning the analogue > circuits. At the same time I want to look at the DSP algorithms to see if I > can't squeeze out a bit more accuracy. Therefore the original question. > The method I followed previously does introduce some jitter and I'm looking > at going for fixed sampling rate this time (at a higher rate). I had to do > a lot of work to implement points 1 to 6 above and would like to re-use some > of the code if possible. > > Knowing little about multirate systems I thought that it might be possible > (on the new more powerfull dsp) to manipulate the incoming samples to always > have the required amount per cycle. I know that for this to work an > accurate period measurement must still be made, but hoping with the new dsp > I can do this in software instead of with a zero-crossing detector.
since you're signal is mostly sinusoidal, you can still use a zero- crossing detector (detect zero crossing with only positive slope or only negative slope) to get the difference in samples between zero crossings. then that number, which would always be an integer even though it is unlikely your period will be an integer number of samples, is input to a LPF with DC gain of 1 (0 dB). that will average out the integer valued inputs and give you a very accurate measure of the period (in fractional samples). with that value you can resample the input accurately to 128 or some fixed number of samples per period. also, for RMS, don't bother with Simpson's rule or anything like that : square the sample value and input that into a similar LPF (with DC gain of 1) and square-root the output. rot's o' ruk with this. r b-j
On Feb 3, 8:12 am, "Pierre de Vos" <pierre.de...@webmail.co.za> wrote:
> Hi All, > > I need to re-sample a signal sampled at a fixed rate. The fundamental > frequency of the signal can be from 45-65Hz. The re-sampling must give 2^N > amount of samples per cycle of the fundamental. The employed method must be > adaptive - if the fundamental frequency changes, it must still give 2^N > samples/Cycle for the current frequency. > > Anybody have any ideas how to attack this problem? > > Pierre
Sounds like pitch-synchronous feature extraction - a very tricky problem, for speech signals at least... For simple signals, however, you might be able to come up with more or less robust algorithm in reasonable time frame.. Even zero-crossings might do it, just make sure you don't have a DC offset.
Jerry Avins wrote:
(I wrote)

>> How about computing separately half cycle current, half cycle voltage, >> and phase shift. Then multiply current, voltage, and cos(phase shift).
> Harmonics can create asymmetries that could be a problem for the half > cycle approach. The current and voltage samples ideally need to be > simultaneous and must in any case be nearly so.
Yes, I wasn't too serious about that one. At the time I was wondering what half cycle meant when the current and voltage are not in phase. You then have to say which (current or voltage) you use to measure cycles. The OP explained the problem in more detail today. -- glen
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:1170727783.164507.118270@k78g2000cwa.googlegroups.com...
> On Feb 5, 1:27 pm, "Pierre de Vos" <pierre.de...@webmail.co.za> wrote: >> >> Back to the problem at hand: I'm doing a new design and would like to >> achieve an accuracy (of power) in the region of 0.005% or better. I'm >> changing to a ADSP-21262 floating point Sharc and redesigning the >> analogue >> circuits. At the same time I want to look at the DSP algorithms to see >> if I >> can't squeeze out a bit more accuracy. Therefore the original question. >> The method I followed previously does introduce some jitter and I'm >> looking >> at going for fixed sampling rate this time (at a higher rate). I had to >> do >> a lot of work to implement points 1 to 6 above and would like to re-use >> some >> of the code if possible. >> >> Knowing little about multirate systems I thought that it might be >> possible >> (on the new more powerfull dsp) to manipulate the incoming samples to >> always >> have the required amount per cycle. I know that for this to work an >> accurate period measurement must still be made, but hoping with the new >> dsp >> I can do this in software instead of with a zero-crossing detector. > > since you're signal is mostly sinusoidal, you can still use a zero- > crossing detector (detect zero crossing with only positive slope or > only negative slope) to get the difference in samples between zero > crossings. then that number, which would always be an integer even > though it is unlikely your period will be an integer number of > samples, is input to a LPF with DC gain of 1 (0 dB). that will > average out the integer valued inputs and give you a very accurate > measure of the period (in fractional samples). with that value you > can resample the input accurately to 128 or some fixed number of > samples per period. > > also, for RMS, don't bother with Simpson's rule or anything like > that : square the sample value and input that into a similar LPF (with > DC gain of 1) and square-root the output. > > rot's o' ruk with this. > > r b-j > >
r-b-j, Good idea, I will try...
> "robert bristow-johnson" <rbj@audioimagination.com> wrote in message
(snip)
>also, for RMS, don't bother with Simpson's rule or anything like >that : square the sample value and input that into a similar LPF (with >DC gain of 1) and square-root the output.
There is an interesting discussion of Simpson's rule, I believe in Numerical Recipes. First they consider integrating with Simpson's rule. Next, the do the same integral with one step of trapezoid, followed by Simpson's rule, and the final step trapezoid. The result is then good to the same order as using Simpson's rule as only 2 out of N steps are done with trapezoid. Next, average the two, which interleaves the alternating 2/3, 4/3 of Simpson, except for the first two and last two integration points. -- glen
glen herrmannsfeldt wrote:
> Jerry Avins wrote: > (I wrote) > >>> How about computing separately half cycle current, half cycle voltage, >>> and phase shift. Then multiply current, voltage, and cos(phase shift). > >> Harmonics can create asymmetries that could be a problem for the half >> cycle approach. The current and voltage samples ideally need to be >> simultaneous and must in any case be nearly so. > > Yes, I wasn't too serious about that one. At the time I was wondering > what half cycle meant when the current and voltage are not in phase. > You then have to say which (current or voltage) you use to measure > cycles. The OP explained the problem in more detail today.
I haven't read today's message yet. A half cycle needn't start and end at zero crossings. In fact, it can't do both in the presence of second harmonic. A half cycle can start at arbitrary phase and continue for 180 degrees. 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;
robert bristow-johnson wrote:

   ...

> since you're signal is mostly sinusoidal
Don't bet on that! Very substantial third harmonic components can be introduced by transformer and motor iron. Power thyristors can make the line currents look real funny!
> you can still use a zero- > crossing detector (detect zero crossing with only positive slope or > only negative slope) to get the difference in samples between zero > crossings.
Provided SCR spikes don't make multiple zero crossings. Light low-pass filtering should fix that.
> then that number, which would always be an integer even > though it is unlikely your period will be an integer number of > samples, is input to a LPF with DC gain of 1 (0 dB). that will > average out the integer valued inputs and give you a very accurate > measure of the period (in fractional samples). with that value you > can resample the input accurately to 128 or some fixed number of > samples per period. > > also, for RMS, don't bother with Simpson's rule or anything like > that : square the sample value and input that into a similar LPF (with > DC gain of 1) and square-root the output.
I'm still curious about the requirement for a power number every cycle. 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;
On Feb 7, 12:16 pm, Jerry Avins <j...@ieee.org> wrote:
> robert bristow-johnson wrote: > > ... > > > since you're signal is mostly sinusoidal > > Don't bet on that! Very substantial third harmonic components can be > introduced by transformer and motor iron. Power thyristors can make the > line currents look real funny! > > > you can still use a zero- > > crossing detector (detect zero crossing with only positive slope or > > only negative slope) to get the difference in samples between zero > > crossings. > > Provided SCR spikes don't make multiple zero crossings. Light low-pass > filtering should fix that.
well, then Pierre will need to do more legitimate pitch detection like we do for audio waveforms. you know, AMDF or ASDF or autocorrelation. since he's using a SHArC, he oughta have plenty of computational muscle to do that. r b-j
On Feb 7, 12:45 pm, "robert bristow-johnson"
<r...@audioimagination.com> wrote:
> On Feb 7, 12:16 pm, Jerry Avins <j...@ieee.org> wrote: > > > > > > > robert bristow-johnson wrote: > > > ... > > > > since you're signal is mostly sinusoidal > > > Don't bet on that! Very substantial third harmonic components can be > > introduced by transformer and motor iron. Power thyristors can make the > > line currents look real funny! > > > > you can still use a zero- > > > crossing detector (detect zero crossing with only positive slope or > > > only negative slope) to get the difference in samples between zero > > > crossings. > > > Provided SCR spikes don't make multiple zero crossings. Light low-pass > > filtering should fix that. > > well, then Pierre will need to do more legitimate pitch detection like > we do for audio waveforms. you know, AMDF or ASDF or > autocorrelation. since he's using a SHArC, he oughta have plenty of > computational muscle to do that. > > r b-j- Hide quoted text - > > - Show quoted text -
"legitimate pitch detection" ??? :-) With more than 400 issued and pending US patents in 704/207 alone, related to various minor and obvious improvementns of correlation, AMDF or frequency based pitch-detection techniques, the pitch detection you are proposing might as well be "illegitimate", without him actually knowing it :)
On Feb 7, 12:59 pm, "fizteh89" <d...@soundmathtech.com> wrote:
> > "legitimate pitch detection" ??? :-) > > With more than 400 issued and pending US patents in 704/207 alone, > related to various minor and obvious improvements of correlation, > AMDF or frequency based pitch-detection techniques, the pitch > detection you are proposing might as well be "illegitimate", without > him actually knowing it :)
i was sorta expecting you to pipe in about this after my Feb 4 post to this thread, Dmitry. glad you're here. i don't consider "auto-correlation", "AMDF", or "frequency-domain" to be completely descriptive terms. there are several ways to do pitch detection using any of these. some of these "various minor and obvious improvements" are in patents, some are not, some of those that are not are published in some old IEEE journal, others are (ostensible) trade secrets. some haven't been thunk of yet. some are not so minor or obvious and are repackaged and obfuscated in so-called "new" techniques. some of those, though neither minor nor obvious, are yet to be demonstrated as improvements for some classes of input signal. some (like zero-crossing) make assumptions about the nature of the input signal that can only be reliable for certain signal classes. Jerry pointed out to me that this assumption is *not* reliable for AC power signals (which was my previous thought). in that case, zero- crossing is not legitimate since there are possibly more than two zero crossings per period (something i did not expect). r b-j