Author Topic: Question: Cheap pure sine wave genertor 1khz?  (Read 18910 times)

0 Members and 1 Guest are viewing this topic.

Offline trobbins

  • Frequent Contributor
  • **
  • Posts: 765
  • Country: au
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #50 on: January 14, 2020, 03:49:53 am »
Dreams, dreams...
Circa 130dB plot taken whilst having fun with the harmonic null technique:
https://dalmura.com.au/static/Loopback%20distortion%20trim.JPG
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #51 on: January 14, 2020, 03:30:55 pm »
...
Record L->L, L->R, R->L &  R->R

Solve for the input and output errors of each channel and correct.  At each frequency and amplitude there are 4 equations and 4 unknowns.

You can get almost arbitrary accuracy via signal processing with large datasets.

No, you can't. The issue is that harmonic's  magnitude & phase (thd-n) are not  constants. Doesn't matter how big  data sets  are, how accurate equation written or what precision of the floating math. The data becomes a junk after a few milliseconds, because ADC is drifted, always changing - there is no single static constant magnitude & phase below -100 dBc with audio ADC, or -110 with precise SAR.   Same with a DAC. During debugging my project, I came to conclusion that uCPU has to continuously monitor each thd-n and make adjustment "on the fly" .
Calibration & look-up table doesn't work, actually it does for stm32f767 internal 12-bits DAC with initial start-up thd-3 about -70 dBc, LUT could fix this value to -95/-100, but than magic show begins.

I'm shocked!  Truly shocked!  You mean there is noise in the data?  We'll have to give up!

In seismic exploration it is routine to get 40-60 dB or more improvement in the signal to noise ratio. I have seen many examples where the initial SNR was so bad that it did not appear that there was any data at all, just noise.  But after some DSP the signal is 30-40 dB above the noise.

The data of interest is the reflected energy from a rock layer over 40,000 ft below the surface arriving 10-12 seconds after  the source impulse was initiated.  That is *only* possible because we exactly match the phase from sample to sample while summing hundreds of thousands of samples into each output sample. Every sample has a different propagation delay which has to be determined in order to sum the correct samples.

I've suggested this every time someone has come along wanting to do audio THD measurements.  With a good 24 bit, 192 kHz card one should get quite spectacular results.  I've got a page of mathematics floating around on which I analyzed the problem to verify that my assertions were correct.

If someone wants to do it, I'll help them over the bumps, but I'm interested in RF, not audio and am not interested in doing a grad school semester project to simply prove I can.  I stopped doing that sort of thing 30 years ago. 

Once you can send the integer 6e6  followed by 191,999 zeros to the sound card and record it, standard seismic software (Seismic Unix et al) can take it from there.  Record a loop of [6e6,zeros(1,191999)] sent as integers to the card for 24 hours and you can suppress random noise by 49 dB.  Add 6 dB for each extra day of recording.   Systematic and correlated noise will take more processing, but summing 86,400 192,000 sample FFTs will get you a *very* long way towards the goal.  Systematic error is handled by the L-L, L-R, R-R & R-L error solution for the input and output ADC & DAC errors.  Once random and systematic error terms have been suppressed one can address the correlated noise.  How hard that is is dependent upon to nature of the noise.  Until someone shows me the result of the first two steps I can't say how to do that.  It could easily turn into many weeks or months of work.  This is *NOT* something you can do on an MCU.  This requires a fast workstation with lots of memory and is only practical in recorded time.  Even a many core desktop is unlikely to do it in real time.

The preceding will require three 16.5 GB data files recorded over 3 days.  Straight thru, cross over and DUT to a splitter to both channels to test a single output amplitude.  Each amplitude will be different.  However, testing every amplitude is not practical over the range of 24 bits.

For an intro to signal processing intended for scientists and engineers:

An Introduction to Digital Signal Processing
John H. Karl
Academic Press 1989

The canonical mathematical reference on Wiener-Shannon-Nyquist analysis (the predominant techniques used):

Random Data
Bendat and Piersol
Wiley 4th ed 2010

Those cover all the work up to 2010.  Work by Donoho and Candes in 2004-2008 has started another advance of equal importance.  However, the computational burden is much higher, so it will not replace Wiener-Shannon-Nyquist.  And at current oil prices the seismic industry has completely collapsed.  So no money is being spent developing it further in the oil industry which pioneered DSP in the first place.

Have Fun!
Reg
 
The following users thanked this post: egonotto

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #52 on: January 14, 2020, 04:41:58 pm »
What you described is a pure oversampling, based on sqrt(S/N), when averaging 4 samples improves SNR by 2. It's only applicable with random Gaussian noise.  THD is different species, it does not go down with averaging, or increasing fft size. And adc noise is not random.
 

Offline trobbins

  • Frequent Contributor
  • **
  • Posts: 765
  • Country: au
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #53 on: January 14, 2020, 11:44:19 pm »
MasterT, the RightMark testing in link below shows a similar noise floor level below signal FS in the THD+Noise test result.



https://www.dearhoney.idv.tw/SoundCard/EMU0404USB/E-MU0404USB_96K_Out.htm
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #54 on: January 15, 2020, 12:54:35 am »
What you think, is if there is a line at -130 than your sound card has THD+N = -130? It's wrong. Look at this picture:
908988-0

Taking test with bigger fft-size, you can drop a line to -160 or -200. There is fft processing gain, 10xlog(M/2). So, getting back to your diagram, you should look at the highest peak except fundamental, and it's slightly below -100. Period. Software thd correction would not be possible with this peace of junk better than 0.001%. Not 0.0001% as you says earlier
 

Offline trobbins

  • Frequent Contributor
  • **
  • Posts: 765
  • Country: au
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #55 on: January 15, 2020, 02:03:25 am »
The RightMark plot shows raw harmonic performance, as I was also able to reproduce.

However, if then the signal source is adjusted to add nulling harmonic levels (as per link in earlier email, and repeated below) and the spectrum shows a particular harmonic descending to the noise floor then is the harmonic now suppressed to circa -130dB below fundamental, or is there a disconnect somewhere ?

https://dalmura.com.au/static/Loopback%20distortion%20trim.JPG
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #56 on: January 15, 2020, 03:15:07 am »
What you described is a pure oversampling, based on sqrt(S/N), when averaging 4 samples improves SNR by 2. It's only applicable with random Gaussian noise.  THD is different species, it does not go down with averaging, or increasing fft size. And adc noise is not random.

Yes, grasshopper.  The Gaussian random noise goes down.  The THD and other noise processes do not.  I am glad you have grasped my point.

This is very useful as it allows us to  to address the non-Gaussian random and correlated noise processes.  Of which there are many.  Each of which requires appropriate measures. And in many cases, a significant amount of work  simply to identify and very often years of effort to eliminate.  But eventually one gets to the point that precise and accurate measurements can be made despite the noise.  At least in theory.  Having spent many years fixing bugs and dealing with weird data, I suspect that much of the time the idea is correct, but the implementation is wrong.

It's rather like an onion.  There are many layers.   But before you can reach one, you have to remove all the outer ones.

Most of the EE community has a view of DSP which is 10-20 years out of date.  The oil industry was investing millions on  DSP  for seismic processing before digital data could even be collected.  They knew digital data was coming.  They were paying for it.  TI was created to build recording equipment for GSI, their parent company. 

My PhD supervisor at Austin had been head of research at GSI before he left for academia.  He was one of the 7 members of the Geophysical Analysis Group consortium working under Norbert Wiener with funding from the oil industry in the early 1950's.  Enders Robinson and Sven Treitel, whose papers were collected as the "Robinson & Treitel Reader"and eventually merged into a book, were the major apostles as my supervisor had very poor writing skills.

Sadly, even within Amoco, which employed Sven, things were often done incorrectly.  I ran into this a few months into my career in seismic.  I called Sven at the labs in Tulsa to ask him about it.   He told me I was correct. And added, "But the prophet is often not believed in his own country", or words to that effect.

In summary, yes, it can be done.  But you have to know how.

Havfe Fun!
Reg
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6203
  • Country: ro
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #57 on: January 15, 2020, 03:43:37 am »
It doesn't matter if the noise is Gaussian or not, but it must be uncorrelated with the measuring signal, and must have a zero average for the integrating time.
 
The following users thanked this post: egonotto

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #58 on: January 15, 2020, 04:48:46 am »
The RightMark plot shows raw harmonic performance, as I was also able to reproduce.

However, if then the signal source is adjusted to add nulling harmonic levels (as per link in earlier email, and repeated below) and the spectrum shows a particular harmonic descending to the noise floor then is the harmonic now suppressed to circa -130dB below fundamental, or is there a disconnect somewhere ?

https://dalmura.com.au/static/Loopback%20distortion%20trim.JPG
What the point in generation distorted signal, that eliminates distortion introduced by adc later on?  Makes you happy? This is not what this topic about - to generate clean sine wave.
Objective is synthesis pre-distorted digital data that would wipe out non-linearity of the DAC Obviously, you need right tool, THD meter that capable to see results. And something like TI's  ads127l01 , sadly I hate a package.
 

Offline trobbins

  • Frequent Contributor
  • **
  • Posts: 765
  • Country: au
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #59 on: January 15, 2020, 05:27:30 am »
MasterT, the point is that the DAC of a soundcard can be set up to generate a much lower distortion signal than can be generated by just the raw DAC output signal of the soundcard when asked to generate a sinewave.

How do you then measure the DAC's performance?  Well that is the point of the loopback test, but as indicated earlier that then includes a distortion contribution from the soundcard ADC.  So the loopback spectrum plot shows that the DAC plus ADC performance can exhibit a measured distortion profile where the HD components are down at the noise floor level.  For a 15 year old soundcard, that noise floor level is circa -130dB below the fundamental, but it appears you don't have confidence in that measurement process (and have yet to explain that succinctly imho).

If a much better, and more expensive ADC was available for making measurements, then that should be able to gauge what the actual soundcard DAC harmonic distortion profile really is.  And yes maybe some further tweaking of the added harmonic distortion magnitudes/phases (in REW) could achieve a better null.  Unfortunately I don't have access to such equipment, so can't confirm the actual performance.  But it does appear to provide the cheapest bang for your buck solution imho.
 

Online Marco

  • Super Contributor
  • ***
  • Posts: 6722
  • Country: nl
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #60 on: January 15, 2020, 06:33:32 am »
Circa 130dB plot taken whilst having fun with the harmonic null technique:
https://dalmura.com.au/static/Loopback%20distortion%20trim.JPG

You are correcting for the combined non-linearity of the DAC/ADC this way, which means you are adding real harmonics which the ADC can't "see".

Still, it proves the DAC/ADC are stable enough to get 130 dB of consistency in between calibration ... and there are ways to separate out the ADC non-linearity from the DAC non-linearity. It works over a small frequency band, but as I said last time analogue switches are cheap (and have vanishingly low distortion when feeding an non inverting opamp buffer, a couple 100 milli-Ohm of channel modulation in the switch does nothing with a >10^9 Ohm load).
« Last Edit: January 15, 2020, 06:57:09 am by Marco »
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #61 on: January 15, 2020, 12:10:20 pm »
...
  For a 15 year old soundcard, that noise floor level is circa -130dB below the fundamental, but it appears you don't have confidence in that measurement process (and have yet to explain that succinctly imho).
I already says, thd -n magnitude & phase are variables. They vary with temp, voltage , input level, freq., and coupe hundreds other parameters. It's not clear, how long do you track your equipment to get this down to -130, but I think  long time accumulation   approach is not right way. Instantaneous, sporadic deviation would not be visible on long term statistical data. Fast, 1--2 msps >16bits adc offers much faster loopback control.
 I tried with CS4344 & CS5361 last summer, thought sigma-delta would get me better linearity than SAR AD798X, but for some reasons - bread-boarding, adc driver or volt/temp instability, I hardly could get -90 despite whatever they say in DS. Also possible, I got fake chips. 
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #62 on: January 15, 2020, 03:43:05 pm »
A few points:

1 bit = 6 dB   But you need to use ENOB, not the output word size. I don't recall seeing 24 bit sound cards 15 years ago.  130 dB requires an ENOB of 21.67 bits which in turn requires a 24 bit ADC.

In seismic we measure and correct for ADC skew, location accuracy, channel to channel gain and phase error.  All these things are being controlled as tightly as possible.  But if the work requires more accuracy it can be done in post processing.  That's a very powerful concept.

A common correction these days is water depth changes of fractions of an inch because of tides, currents and subsea topography.  Those maps you see showing the topography of the deep ocean seafloor?  Those are made by measuring the bumps on the surface of the sea by bumps in the seafloor from satellites.  If your equipment is floating in  the water you can't dynamically correct for changes in the water depth. The correction is done in processing by shifting everything to a common datum.

Once the ADC and DAC errors  have been measured using the loopback I outlined earlier, the input sine wave WAV file has a Wiener inverse filter applied to predistort the waveform so that analog errors are corrected before they happen.  This is fundamental to modern cell tower transmitters.

The ADC errors have their Wiener inverse applied after acquisition to ensure that the DUT actually sees a pure sine wave.

You don't need a better sound card to measure a sound card.  just do the loopback test I mentioned and the algebra will remove the sound card errors once you characterize them.

If anyone wants help implementing the sound card correction send me a PM.  I have no interest in doing it myself right now as I need to build a 16' x 12' screened room for a new lab area first.  I do hope to work my way through Jim Williams' paper some day.  To do that in a meaningful way I have to measure the THD at each iteration of the design.  I do not want to buy an HP distortion analyzer to do that.  I don't care all that much about audio equipment beyond using it.  I have been playing guitar for 50 years.

Just for fun, I checked and I have directed people to "Max Wien, Mr. Hewlett and a Rainy Sunday Afternoon"  in 16 posts on EEVblog.  Like many of my contemporaries, I revere Jim Williams.

Reg
 

Offline trobbins

  • Frequent Contributor
  • **
  • Posts: 765
  • Country: au
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #63 on: January 16, 2020, 12:04:40 am »
March 2006 product entry, so circa 14 years (although the software took some time to mature):
http://ixbtlabs.com/articles2/proaudio/emu-0404-usb.html
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #64 on: January 16, 2020, 01:18:44 am »
Boy,  I bet those were $$$. 

I bought a Korg 1600 Mk II DAW circa 2004-2005 after despairing of finding a USB device which would work with Linux.  So I had been looking at audio interfaces a lot just before those appeared.   I bought a Tascam USB unit, but the software was so flaky I couldn't make it work. So I bought a packaged system that did work even if the UI was agony for ~$1300. 16 bit 44.1 kSa/s only.
 

Online schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2223
  • Country: mx
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #65 on: January 16, 2020, 01:36:30 am »
Subscribing to thread
 

Online Grandchuck

  • Frequent Contributor
  • **
  • Posts: 648
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #66 on: June 26, 2021, 08:24:07 pm »
Thread revival time.  Got some new ICs: OPA2810.  Time to try another low distortion oscillator circuit and used an old and simple one based on a circuit from a 1994 Elecktor magazine.  The modified schematic is shown here along with the THD reading.  I changed R3 from 2.05 k to 2.2 k and eliminated C3 and C4 (I might add them later and see if it makes any difference).  I also added a 5 k potentiometer on the output.

The construction is also shown with a close view of the IC and its adaptor.  There is an 8-pin dual-inline socket on the board so it is easy to pop in other ICs such as a TL0821 (tried one and it works, but with a bit more distortion).

The actual THD is below 0.001% because the 8903B residual noise and distortion are too high for this measurement.  I see a new rabbit hole coming  :-DD
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3710
  • Country: nl
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #67 on: June 27, 2021, 05:56:05 am »
Very interesting stuff about the 1KHz sine generation here :-+

I wrote code running on an STM32F303 for making a very good sine wave. I myself do not have the equipment to check the quality, but a friend of mine, whom I wrote it for, told me the distortion is very low.

One can check it out here: https://github.com/pecostm32/STM32F303_Sine_Square_Generator

Online Grandchuck

  • Frequent Contributor
  • **
  • Posts: 648
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #68 on: June 27, 2021, 12:45:30 pm »
Thanks.  Lots of bits makes for low THD:
     THD(%) = 1/(2^N) x 100 (where N is the number of bits)
That is the ideal case.  In practice, the THD is higher.  i.e. my Siglent 14 bit generator gives about 0.008% (ideally, 0.006%).
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16618
  • Country: us
  • DavidH
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #69 on: June 28, 2021, 02:15:15 pm »
Thanks.  Lots of bits makes for low THD:
     THD(%) = 1/(2^N) x 100 (where N is the number of bits)
That is the ideal case.  In practice, the THD is higher.  i.e. my Siglent 14 bit generator gives about 0.008% (ideally, 0.006%).

That assumes that the linearity is commensurate with the resolution, which is rarely the case, and even achieving better than 0.01% requires attention to the audio path after the DAC.  Typically at least 2 bits are lost to non-linearity of the DAC but it is 3 or 4 bits with some devices which is revealed by integral non-linearity specifications or 8 or 16 counts.

Testing of 16 bit and greater ADCs is a real challenge and where the various "parts per billion" oscillator designs come into play.
 
The following users thanked this post: nctnico, egonotto, Grandchuck

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14203
  • Country: de
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #70 on: July 24, 2021, 07:07:30 pm »
Thanks.  Lots of bits makes for low THD:
     THD(%) = 1/(2^N) x 100 (where N is the number of bits)
That is the ideal case.  In practice, the THD is higher.  i.e. my Siglent 14 bit generator gives about 0.008% (ideally, 0.006%).

The formula includes quite some simplifiaction. Looks like it assumes very high BW to also include the very high harmonics. With a limite BW (even the usual 22 kHz with Audio) quite a bit of the digital step noise gets removed, especially with an oversampling DAC, which is the norm.

In addition there are INL errors from the DAC and following stages. So real world noise can be higher of lower.

The Elector Wien bridge circuit is the very basic one, not specially made for low noise. So it hase relatively high demand on the OPs. It is more like good for testing the OPs than actually generating a very low noise sine.  For lowest destortion it often helps to have 2 OPs in the oscillator itself with the OPs working as inverting vonfiguration and this with zero (or near zero) common mode voltage. This avoids the distorion from the limited CMRR.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #71 on: July 24, 2021, 08:21:09 pm »
The canonical schematics are in:

"Max Wein, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams.  Because he understood transistors at the most basic level, he was able to achieve better performance than the best instrument available.

Have Fun!
Reg
 

Online Grandchuck

  • Frequent Contributor
  • **
  • Posts: 648
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #72 on: July 27, 2021, 06:59:00 pm »
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3483
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #73 on: July 27, 2021, 07:16:39 pm »
Wow!   They claim no measurable distortion using a 24 bit sound card.

If it meets the specs it's an excellent soundcard calibrator.  Though switched frequencies in octave steps from A 22.5 Hz would be far better.

Have Fun!
Reg
 

Online Grandchuck

  • Frequent Contributor
  • **
  • Posts: 648
  • Country: us
Re: Question: Cheap pure sine wave genertor 1khz?
« Reply #74 on: July 28, 2021, 05:36:04 pm »
Has anyone built one of these?

https://www.ebay.com/itm/184691239077?hash=item2b0074a8a5:g:q6wAAOSw4tNgTC70

Schematic shown here.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf