Goertzel self test
ozpropdev
Posts: 2,792
in Propeller 2
Hi Chip
I've been running some Goertzel tests today and i'm getting erratic results.
I am looping the Goertzel output back into itself (via 270R resistor) and taking samples while sweeping from10kHz to 2MHz.
What i'm seeing is quite large phase and power changes as well as a lot of noise.
System clock speed also affects results.
Not sure if I'm doing something wrong (more than likely) .
Here's some snippets from the data collected
Any ideas?
I've been running some Goertzel tests today and i'm getting erratic results.
I am looping the Goertzel output back into itself (via 270R resistor) and taking samples while sweeping from10kHz to 2MHz.
What i'm seeing is quite large phase and power changes as well as a lot of noise.
System clock speed also affects results.
Not sure if I'm doing something wrong (more than likely) .
Here's some snippets from the data collected
60 MHz sys clock 100000Hz X=$000BE714 Y=$00012E3A rho=$000BF608 theta=$04072BF2 2090000Hz X=$FFFFC828 Y=$00007776 rho=$000083DE theta=$51D104A1 80 Mhz sys clock 100000Hz X=$000FE366 Y=$000148E2 rho=$000FF0AC theta=$03498D31 2090000Hz X=$FFFFF807 Y=$0000AE56 rho=$0000AE85 theta=$41DCAA5C 100 MHz sys clock 100000Hz X=$0013DF51 Y=$00016316 rho=$0013EBB2 theta=$02D6D7F9 2090000Hz X=$00002738 Y=$0000D666 rho=$0000D9F5 theta=$38A0E418As Goertzel frequency increases power values reduce and phase shifts.
Any ideas?
Comments
About these Goertzel measurements, if you are looking at a frequency of 100KHz, using a system clock of 80MHz for, say 10ms, and then you do the same measurement of 100KHz for 10 ms from a 160MHz clock, you are going to get twice the accumulated sine and cosine samples. This is going to affect power, but not necessarily the phase angle.
I will run these kinds of tests tonight to see what I get.
Doesn't seem to have made any differenct to results.
I will keep digging.....
You've got %TT = %01 in your ADC mode setting that isn't a smart mode. I vaguely remember an exchange between you and Chip on this, but I can't find it.
I have the same TT setting as Chip's Goertzel demo.
Tried all 4 combinations, no difference.
And I might have imagined the %TT part too. I'm not sure what bit7 Chip is talking about now.
I'm seeing things being really stable, but, crazy enough, the same kind of ADC noise we've been battling is showing up here, causing low frequency wandering.
HEY!!! I just made my signal frequency a multiple of 60Hz and the dang wandering went away. It looked like a beat frequency and it was! WOW!! If I tweak my frequency to really sync to the ambient 60Hz, IT TOTALLY GOES AWAY!!!!
Here is the code I'm playing with:
For this program, pin 8 = X and pin 9 = Y for X,Y mode on a scope. It makes sense to just look at the accumulations as coordinates, instead of the rho,theta approach.
Are you still on Bench supplies ? - what is their 60Hz ripple ? What about ambient 60Hz fields ?
With a DAC driving a ADC, there are no board-level HiZ nodes ?
What about unused pins ? - they should not be left to float.
I'm still on bench supplies. Not sure what their ripple is. Certainly ambient 60Hz field in here.
I need to see what 60Hz-multiple sampling does for the ADC now.
So, are the testers here in the Antipodes seeing 50Hz noise?
Here I have P0 outputting the Goertzel reference signal, a sine wave of 1.2MHz (multiple of the 60Hz power all around me, so it cancels noise) for 1200 cycles, so each measurement takes 1ms.
I'm using P12 as a 100x magnification ADC input to the Goertzel multiply-and-accumulate. This means about +/-18mV full-span, so it's sensitive.
The P0 DAC output is touching my body, so I'm like a broadcast antenna, and a piece of wire connected to P12 is a receiving antenna. My proximity to the P12 wire has huge and precise effect on the Goertzel output, which is coming out of P8 and P9 in the form of X,Y signals to go into my scope for viewing in X,Y mode.
I am really pleased with how good the signal-to-noise ratio is. This is working just like I hoped it would.
Check this video out:
(must download the attachment)
Here's the code that does it:
@ozpropdev, this looks really handy for your project
Going to spend some quality time with Goertzel tomorrow.
One nice thing about this Goertzel setup is that the ADC's low-frequency thermal wandering is out-of-band and gets filtered away. The ADC seems to work ideally in this mode.
Each subsequent measurement is started with a new XCONT instruction which specifies the ADC pin to look at. It would be interesting to switch among several ADC pins and track them in sequence, repeatedly. What kind of data could be gleaned by doing that, I wonder. I think, by placing their antennae in different directions, you could resolve direction from where signal is coming from. So many things are possible.
Here's the code. I just increment the ADC pin each time through, to cycle through all four:
Wikipedia's Mains Electricity by Country shows a comprehensive listing.
https://en.wikipedia.org/wiki/Mains_electricity_by_country
As always, providence comes in help again, and Australia is listed among the 50 Hz ones.
Maybe using a 12.288 MHz, clipped sine, VCTCXO could even enable calibration under sofware control, both numerically and also thru a filtered pin DAC.
The above frequency was selected because it can be divided by 50, 60, generating a lot of binary and decimal submultiples (including 32768).
It has to be tested how HDMI sinks would react to 245.7600 MHz. I believe it won't give a dime for the difference and will work solid and stable like a Rock(lin)!
Do you mean as a multiple of 60Hz ?
It does make sense to sync things up to 60Hz, as there will be harmonic chirps at various parts of 60Hz, from things like Dimmers and SMPS Power factor correctors.
You want all those artifacts fixed in time, not walking thru your data.
The way to fully null 50/60Hz effects, for DC measurements, is to measure for a whole cycle.
12.288MHz is a rare value, more common are GPS related valued, like 19.2MHz and 26MHz
The PLL means either of those can be used, ans still have whole-number relations with 50Hz/60Hz
19.2M/60 = 320000
19.2M/50 = 384000
26M/50 = 520000
26M/60 = 433333.3333' - so you need a x3 in the PLL, if you want whole-numbers.
Currently cheapest VCTCXO at digikey is
NT1612AA-48MHZ-END5173A NDK America, Inc. XTAL OSC VCTCXO 48.0000MHZ 990 - Immediate $0.92400/500 (1.60mm x 1.20mm) 0.018" (0.45mm)
Next is
ASVTX-11-121-19.200MHZ-T Abracon LLC XTAL OSC VCTCXO 19.2000MHZ SNWV 3,225 - Immediate $1.13576/500 (3.20mm x 2.50mm) 0.035" (0.90mm)
and if you check at lcsc these appear (notice the prices here... )
TCXO lcsc
KDS Daishinku 1XTW26000CGA SMD-3225_4P In stock: 2196 Ship Immediately 26MHz 1.5ppm relow 0.2ppm temp 1ppm/yr aging
1+ $0.3298 100+ $0.2807 1000 $0.2695
KDS Daishinku 1XXA26000MAA SMD-2520_4P In stock: 3980 Ship Immediately
1+ $0.3061 100+ $0.2604 1000+ $0.2500
I'm not sure how 48MHz clipped sine drive would go on a P2, certainly worth testing. At some point, the Xtal amplifier will run out of gain.
19.2 & 26MHz I'd expect to have no problems.
This also illustrates the importance of a wide-choice-footprint design on the PCB
That's the point Chip is making I think. There is no measuring in his examples. He's getting success just by approximating a mains frequency multiple.
Then this is posted: