Understanding what to read on this FFT Plot  - Page 1
Forum section: electronics / testgear

author: trys
author_rank: Regular Contributor
timestamp: December 07, 2017, 07:53:11 pm
content: Hiya all,I'm going around in circles at the moment, so hopefully somebody can shed some light on something for me please.I measured the THD+N of the JDS6600 Arbitrary Function Generator using a cheapo USB soundcard and the software, Arta in the videohttps://youtu.be/4OhI2spU988I was then I was asked if I'd baselined the soundcard that I used. At that stage I had only done a loopback test.Anyhow, fastforward a couple of days and I've build a incandescent bulb stabilized Wien Bridge Oscillator.So far so good.So I've hooked up the oscillator to the scope, and below is the FFT plot I get. The scale is 10dBV.Am I right in thinking that the noise floor is about -60dB and that there are no obvious harmonics?I'm a novice with this FFT malarkey, so any help would be appreciated!Thanks,Trys

author: metrologist
author_rank: Super Contributor
timestamp: December 07, 2017, 08:11:09 pm
content: That's what I would say, but can you increase your sample rate?

author: trys
author_rank: Regular Contributor
timestamp: December 07, 2017, 08:37:51 pm
content: Metrologist,Thanks for that. I've increased the sample rate for CH1 (it's now 1GSa/s) but I can't see how the FFT sample rate goes up (but up from 50kSa/s to 200kSa/s) - presumably it needs so many samples to do carry out the FFT itself?Here's the screenshot (the fundamental frequency is just on the left).Trys

author: alsetalokin4017
author_rank: Super Contributor
timestamp: December 07, 2017, 09:32:53 pm
content: On the Rigol DS1054z you now have the option to use either the Screen data ("Trace") or the entire memory buffer data for the FFT. You might try comparing the results you get using the two modes. (Mode > Trace or Memory*, on second page of FFT settings menu)Unfortunately you have to reset your FFT display settings when switching between Trace and Memory. (Bug? Or just another UI infecility?)

author: metrologist
author_rank: Super Contributor
timestamp: December 07, 2017, 10:52:03 pm
content: That's what I was trying to remember. I also don't recall if averaging applied, and there are different window filters to try (such as flattop). I only played with it once after they enhanced the feature, I guess because I have a decent SPA.

author: trys
author_rank: Regular Contributor
timestamp: December 08, 2017, 01:49:47 pm
content: Quote from: alsetalokin4017 on December 07, 2017, 09:32:53 pmThanks for that suggestion. I'd seen that option, but wasn't too certain what it meant befor you explained it!I'm not getting very far with the Memory* option, as it seems as though the lowest Hz/Div is 1MHz which is well above the audio end that I want to look at. I've attached the plot, but by today I'm messing with a Wien Bridge running at around 12.6KHz.Quote from: metrologist on December 07, 2017, 10:52:03 pmI've tried HiRes mode and that's given more detail and gone through the different window filters, the Blackman one is the one on the plots above. The flattop is the least flat of them funnily enough. I'll have to read up on the different FFT filters.Thanks!Trys

author: rhb
author_rank: Super Contributor
timestamp: December 08, 2017, 03:40:22 pm
content: You're pretty much at the limit of what the scope will do. It's an 8 bit ADC. You'll get some increase in dynamic range by averaging. Random noise is suppressed 1/sqrt(n). So averaging 256 samples should get you a 24 dB increase in dynamic range.You're probably better off transferring the data to a PC and using Octave or MATLAB to do the signal processing. You'll get much better frequency resolution. The frequency resolution is proportional to the reciprocal of the length of the recording in seconds. The exact value depends upon how you treat the start and end of your data (i.e. window choice). You can also measure frequency drift and other things.

author: trys
author_rank: Regular Contributor
timestamp: December 08, 2017, 09:36:44 pm
content: rhb,You've pretty much said what I hoped somebody would say, or rather I found it hard to believe that I'm looking at an oscillator with no THD. The 8 bit (even with oversampling) is showing it's limit with Mr Hewlett's incandescent lamp stabilized wien bridge oscillator.I've tried three different sound cards, two based on CM108, and a more exotic looking one with SPDIF outputs that identified itself as a "CM106 like device". I've rigged them up to my PC (linux) and I've been using ARTA for the time being. I've been reading up about Open Octave (the MATLAB-alike), and looks very interesting - I shall give it a spin.In the mean time. Here is a shot of the "incandescent lamp stabilized wien bridge oscillator" (shown in red) superimposed on what the trace looks like with the oscillator turned off (basically all the rest with all the white/blue lines).As far as I can see the oscillator is only spitting out two detectable harmonics (red spikes), all the rest is background noise. Something in my lab is creating a very solid 1 KHz signal!Trys

author: PA0PBZ
author_rank: Super Contributor
timestamp: December 08, 2017, 10:00:45 pm
content: Your signal seems to be at 1200Hz, not 1200 KHz?

author: rhb
author_rank: Super Contributor
timestamp: December 09, 2017, 12:47:08 am
content: A 24 bit sound card will let you make some very good measurements of audio frequencies.Octave is very easy to use, though interpreting the results is a bit more difficult. The FFT output consists of positive frequencies and mirror reversed negative frequencies. The Nyquist frequency is in the middle and DC is the first value. There should be plenty of tutorials online.Search on "Max Wien, Mr. Hewlett and a Rainy Sunday Afternoon"It's the title of an article by Jim Williams which appears in his book "Analog Circuit Design". It's a great article.

author: b_force
author_rank: Super Contributor
timestamp: December 09, 2017, 02:58:03 am
content: I agree with that.Nowadays it's pretty easy to measure noise down to something like -100 - 120dB with a decent (USB) soundcard.Btw, keep in mind that the type of window also has an effect on what you see.

author: TMM
author_rank: Frequent Contributor
timestamp: December 09, 2017, 05:04:00 am
content: Quote from: rhb on December 08, 2017, 03:40:22 pmDoesn't work on a Rigol IIRC because the sample memory is still 8bit. Would need >12bit sample memory to realise the benefit of averaging when the noise floor is dominated by the scope's ADC.Increasing the FFT length will lower the amount of power in each FFT bin because there are more bins, so you can 'see' a bit deeper into the noise floor even if the integrated noise is the same (calculated THD+N won't change). Try setting a longer length than 16384 in ARTA.As it turns out I've done FFT measurements on a wien bridge oscillator before:https://tinyurl.com/ybtjyqtkOne thing that will destroy your noise floor are ground loops. For this reason you will get all kinds of spurious junk show up at -80dB or so if you attempt to measure a mains powered device with a mains referenced/powered PC sound card. Even if one device uses a double insulated plug pack you are still referenced to mains earth via the Y capacitor so you still have an AC ground loop. One way to avoid the problem is to use a laptop running off battery power with a USB soundcard, another way is to float your signal source - run the wien bridge off batteries. Try to avoid using 'flying leads' (separate wires for ground and signal) if you can as if they are spaced apart they will pick up RFinterference which will be aliased by your soundcard/ADC and result in spurious tones. Twisting the ground and signal wires together helps, coaxial cables are best. Placing a low impedance load at the ADC input can help kill noise also - about 1-10Kohm should do. Too high impedance and the noise won't be attenuated enough, too low impedance and you'll over stress the opamp driving the signal and increase distortion.

author: rhb
author_rank: Super Contributor
timestamp: December 09, 2017, 05:41:04 pm
content: Quote from: trys on December 08, 2017, 01:49:47 pmMuch to my astonishment, even Keysight are very lame in their window choices. My preference is usually a triangle aka Bartlett window. That's a sinc**2 in frequency which suppresses the sidelobes of the sinc function produced by a rectangular window (i.e none). Wikipedia will tell you about more windows than I had ever heard of in 30 years of DSP work. Most are very niche windows or variations on the same idea done back in the days before FFTs became common. The Blackman is probably the best choice of what's offered for your purposes.

author: trys
author_rank: Regular Contributor
timestamp: December 14, 2017, 04:56:01 pm
content: I've really learnt a great deal from all your replies - thank you so much.I've found the Blackman window to be the easiest to work with for finding harmonics. The strange thing is that FFT seems to literally work off the image of the scope signal itself (rather than the underlying signal) so if I alter period until until I get Moire patterns then the corresponding FFT display goes pretty silly too, (or say if I set a volts/div too low).Not having much luck with FFT from the memory.SO the good news is, that using your suggestions I've managed to get down to about 100dB on an USB soundcard (the oscillator and laptop both on batteries, short coax). Using ARTA at the moment, and also sampling into Audacity and using the spectrum analyzer option.I have considered going in the middle of a field somewhere with it, but I'm not quite mad enough to have that level of dedication at the moment. It's also very cold.Quote from: rhb on December 09, 2017, 12:47:08 amThat's a very interesting article indeed - I thought I'd stumbled on the wrong one at first with it starting with an obituary.Quote from: TMM on December 09, 2017, 05:04:00 am

author: rhb
author_rank: Super Contributor
timestamp: December 15, 2017, 02:01:37 am
content: Sadly, Jim Williams has departed this world. But what he left behind is just magnificent. I'm sure he would be very pleased with your project. And not the least bit bothered that you didn't do it all in a single rainy Sunday afternoon.Have fun and PM me if you have a particular question about the FFT. I'd be *extremely* embarrassed if I couldn't explain it to a 12 year old.

author: trys
author_rank: Regular Contributor
timestamp: December 15, 2017, 11:48:40 am
content: It's very sad that Jim Williams has gone, but the wit and warmth in his writing carries on thankfully. Every home lab library should have a copy of his work! ("Max Wien, Mr. Hewlett and a Rainy Sunday Afternoon") I re-read that chapter again today, and I'm still getting great nuggets of gold in it.Thank you so much for introducing me to Jim's work.It is indeed disappointing that I didn't do it in a single rainy Sunday afternoon, but thankfully here in Manchester (UK) there are plenty of rainy days (many of them Sundays too). This afternoon promises showers too, so I should be in luck.I'm a fair bit older than 12 years old, but hopefully you can explain it nonetheless.Trys

author: rhb
author_rank: Super Contributor
timestamp: December 15, 2017, 03:21:08 pm
content: Retracing Jim's work in that article is on my bucket list.A 24 bit soundcard will directly get you 0.06 ppm resolution for measuring the THD. Under the assumption of Gaussian distributed random noise, you can average a large number of FFTs to increase the dynamic range of the harmonic measurements. The improvement is 1/sqrt(N). So averaging 64 measurements will get an additional 3 bits or 18 dB.I strongly suspect that correlated noise in the ADC will make even 1 ppm challenging. However, by taking long recordings and breaking them into segments with random start times, that should not pose anything more than an additional detail to be attended to. It would have been unthinkable when I was in grad school, but now averaging a million 1 Mpt FFTs is trivially done in at most a few hours.There are even cooler things that can be done if you're interested in seeing if you can beat Jim's results. Read the introduction to this paper:https://statweb.stanford.edu/~donoho/Reports/2004/l1l0EquivCorrected.pdfThe proofs are quite daunting, but actually applying the math is really easy. In solving Ax=y, the A matrix rows would consist of the sines and cosines of the FFT in exponential form using Euler's equation. The y vector would be the measured data. The solution of x would provide the coefficients of the FFT but without the smearing that occurs in a normal FFT which is L2 (least squared error) rather than the L1 (least summed absolute error) obtained using linear programming. Add up the coefficients of the harmonics, divide by the coefficient of the fundamental and even Jim would be jealous of the resolution.Have Fun!Reg

author: trys
author_rank: Regular Contributor
timestamp: December 18, 2017, 02:38:19 pm
content: Reg,It's quite incredible that 24 bit soundcards are readily available (as opposed to being hyper specialized pieces of kit), and at quite reasonable prices.The maths in that proof is beyond me now, unless I really sat down and was determined to slog through it. Too many years have passed since my university days for that unfortunately.Quote from: rhb on December 15, 2017, 03:21:08 pmI'm not understanding that (sorry), so if I compare a 16bit to 24bit sampling, where N is a difference of 8 bits, how do I work out the improvement?Trys

author: rhb
author_rank: Super Contributor
timestamp: December 18, 2017, 05:28:54 pm
content: I warned you not to read the math ;-) It took me a lot of effort to understand what was going on and why it works. Hairiest math I've ever encountered and I'm a 64 year old oil industry geophysicist. But *not* a mathematician.I was referring to what I call "sprinkling Gauss water on the problem".Under the assumption of Gaussian distributed, zero mean random noise, as you average more samples, the Gaussian noise reverts to the mean value, zero. But a non-random signal reverts to its mean which is not zero. The mean value of the random noise drops by 1/sqrt(N).6 dB is 20 * log(2). 8 bits is 48 dB as each bit is double the previous bit. So let's suppose that the fundamental is at 0 dBm and we have a harmonic which is -180 dBm. The dynamic range of a 24 bit ADC is approximately 144dB. In reality it is less, but that's not relevant for this discussion. So to measure the harmonic at -180 dBm we need to get at least 36 dB additional dynamic range. So we need to multiply the signal by 4000 to get the 36dB gain. We're going to do that by adding one term at a time. 5*6 = 6+6+6+6+6. In fact, if you want to *measure* a signal at -180 dB relative to the peak signal, you would need to sum 10,000 samples or more. And make sure that the input signal was at the maximum value of the ADC input.Because there is abundant time correlated noise at that signal level, 1 nanowatt, we need to take a long recording and randomly select 4000 start times. These *must* be random, so a Mersenne Twister PRNG is required. The frequency resolution is approximately 1/(N*dT) where N is the number of samples and dT is the sample rate. It gets more complicated because the manner in which the ends of the time series are tapered affects the actual resolution. The previous formula just gives the spacing of the frequency bins in the FFT.There are other complications though. We're doing floating point math and a lot of it. So we have to contend with errors. I don't want to look up a proper estimate. It's seriously tedious and really doesn't matter. The FPU of an x86 is 80 bits. There are arbitrary precision math libraries which will process as many digits as needed. The GLPK package uses this to avoid the limitations of the 80 bit FPU.Already this is way past what Jim Williams could do with a top line HP instrument. But it gets better.If we know the fundamental frequency, which is easily measured to high accuracy with a GPSDO referenced counter, then we know *exactly* what the envelope of each peak in the spectrum looks like. A rectangular window in time is a sinc(x) (i.e. sine(x)/x) function. So, we can setup an A matrix in which every row is a term of the form exp(2*Pi*k/dT) (IIRC. I'd check if I were coding this). Then we solve Ax=y using the simplex solver in GLPK and voila! We have a very high accuracy measurement of the THD of the oscillator using a $100 or less sound card and a PC instead of a $10-20K instrument.The main limitation is how patient are you. High accuracy requires long samples and lots of computer time. But it's easily doable in a few hours to a day to absurd precision and accuracy. Very quickly one would run into ADC errors that would need to be explicitly accounted for in the A matrix. That would probably have to be done in a separate solution of Ax=y where y is the x from the first problem and the A matrix is a model of the ADC errors.There is a good bit of work to be done in characterizing residual correlated noise and accounting for it. But once you have that, you toss it into the A matrix and throw that part of the answer away. The requirement of knowing the frequency is merely pedagogical. In actual practice, one would simply setup the A matrix for the general case.Rather long winded, but hopefully I've been clear. So if you decide you'd like to beat Jim Williams's result you don't need an expensive instrument from Keysight. The A matrices get very large, so they way you do those is to write a small program that generates the A matrix and then you feed that to the glpsol executable in GLPK.There's a bunch of stuff I've glossed over, so if something is not clear, just ask. The process is long winded and messy, but not hard to do.

author: TMM
author_rank: Frequent Contributor
timestamp: December 20, 2017, 05:46:13 am
content: For what it's worth, current 24bit ADC ICs sampling at audio frequencies are at best around 16bit effective. The average PC soundcard is probably ~12 or 13bit effective THD+N, mostly due to non-linearity and some low level spurious tones which are inaudible. There are some 24bit ADC ICs which can achieve around 22bit effective but only at very low frequencies / low sample rates (<10Hz) and of course you need to design an analogue frontend, powersupply, low-jitter reference clock which performs accordingly to build a working 22bit effective system - at that point buying a 6.5/7.5 digit bench multimeter starts to look like an attractive solutionOn a PC sound card there are diminishing returns taking a windowed measurement longer than about 10 seconds at 1kHz. The only reason you'd want to go longer than that is if you were analysing a low frequency signal and/or needed very fine frequency resolution.

author: trys
author_rank: Regular Contributor
timestamp: December 23, 2017, 07:58:48 pm
content: Thank you both for your replies. My apologies for taken so long to reply though.rhb - I must admit I had to do a lot of searching around to even get close to understanding what you meant by that. I hadn't even got as far as the number of bins for a FFT - but I've caught up now with that! The thing is though, that none of these additional samples (by averaging sampling) can be attained on an 8 bit ADC of the scope as far as I can tell, but only as you say in a sound card which is incredibly cheap by comparison of the equivalent test gear. I take it by the references to the open source GTK's you are referring to the use of GNU Octave that was mentioned?TMM - I've experience the diminishing returns of averaging more than a few seconds when I was using Arta with my very basic USB Sound card. The spectrum seemed to settle to a reasonably consistent plot after a few seconds and adding several seconds of averaging. I take it then that 12-13 bit effective THD+N is about 70 to 80 dB roughly?I'm hopefully getting a 24 bit audio interface, a Behringer umc204hd, for Christmas (that is, if the right thing was sent, because my wife has wrapped up the box ready for Christmas). It's pretty good timing, because with endless fiddling with different bulbs and negative feedback resistance values of my lamp-stabilized Wien Bridge oscillator I can only see the noise floor and no obvious harmonics using the FFT function of the Rigol. I've not been able to tame the FFT to show my any more useful data, so the audio interface should come in useful beyond that.I'm also considering making a little faraday cage to put the interface and the oscillator under test into also. I'll see how it goes, but that's another topic altogether.I've learnt a lot about FFT, but it's uncovered a whole chunk of stuff that I need to learn too. My apologies for the basic questions!Thanks again,Trys

author: rhb
author_rank: Super Contributor
timestamp: December 23, 2017, 11:49:08 pm
content: In principle you can go as far as you want using an 8 bit ADC. But more than a few bits and things start getting seriously gnarly. I've never tried doing it. I just know the basic math. There is doubtless a great deal I don't know despite 30 years of professional DSP work in the oil industry.I was referring to Gnu Octave. I started using it long before it got "Gnu" tacked on the name.A factor of 2 is 1 bit more dynamic range. So 12 bits equals 72 dB. There are some usage conventions that enter the picture. a 12 bit ADC will be using 1 bit for the sign, so the amplitude range will be 11 bits or 66 dB instead of 72 dB. As noted, there are then issues of linearity, the fact that datasheets lie and other issues both known and unknown.There is certainly no need to apologize for basic questions. I have a personal interest in your project as I'd like to have a modern version of the HP200C and the HP200x that I have. I'd also like to see a low cost equivalent to the unspeakably expensive THD analyzer Jim Williams used. I prefer that you do all the work as it will benefit you more than it would me. But if you encounter a roadblock in the math, I'll definitely sort it out. I may tell you something that's wrong, but if I do, I'll sort it out. I'm at the age where there are a lot of things for which I don't quite remember all the details.

author: rhb
author_rank: Super Contributor
timestamp: February 05, 2018, 05:10:03 pm
content: "It's not so remarkable that the dog sings badly as that it does at all." Mark TwainUnfortunately, simplex is difficult to parellelize. It will be interesting to see what can be done with the ADC-FPGA-CPU setup in a Zynq based scope. One might need to ship the data to a workstation for processing. But compressive sensing should be fairly easy to implement on the hardware in the GDS-2072E and the LAN & USB ports provide good bandwidth to a PC if more CPU is needed. But the first step is to develop sampling and storage algorithms using the FPGA and DMA.The periodic nature of oscilloscope signals makes the desired solution sparse most of the time. The Zybo Z7-20 looks to be a good initial dev board before mixing it up with the Instek.