OSH Audio THD instrument and live BOM - Page 1
Forum section: electronics / projects

author: asgard
author_rank: Regular Contributor
timestamp: February 02, 2019, 01:30:10 am
content: I am working on a project that was inspired from an article in NutsVolts this month. It is a respin of an Audio-Range THD instrument that uses modular construction and is a more-or-less complete THD measuring device. I am including here the PDF's of all three of the main assemblies and the "live" BOM spreadsheet. The main point here is not precisely the project as such, but I wanted to contribute how I express a complex bill of materials statement for a multiple-assembly project that people here might use and get ideas about how to set up their own projects. This one has seven worksheets in the Excel document, one for each of the three oscillators, three notch filters, and the main board. I think the likely coolest thing here is the automatic selection of the price-break costing for each part based on the number of units to be produced.J.R. Stoner

author: Aztlanpz
author_rank: Regular Contributor
timestamp: February 03, 2019, 05:17:55 pm
content: I am working on the same thing, but I am using Altium.

author: asgard
author_rank: Regular Contributor
timestamp: February 06, 2019, 11:35:05 pm
content: Not sure of the point of that. The drawings, while prepared with a particular CAD tool, was only incidental to the main purpose, which was to give out a way to do BOM's.

author: moffy
author_rank: Super Contributor
timestamp: February 07, 2019, 12:25:06 am
content: What is your expected performance? i.e. 0.01% or 0.001% etc

author: cat87
author_rank: Regular Contributor
timestamp: February 07, 2019, 08:08:44 am
content: The yhing to warch out for would be the oscillator's own THD. You need it to have at least -80 or -90dB THD to be9f any real use. Because that will ultimately dictate the performance of the whole set-up.Have you built that oscillator yet ?

author: asgard
author_rank: Regular Contributor
timestamp: February 07, 2019, 04:47:05 pm
content: My goal here to to get to 0.005% accuracy. The largest limitation is that I do not presently possess a proper metrology lab so there will have to be some allowance The Oscillator modules have been designed and parts purchased acquired. What really helps is to use better class passive components. I have set minimum stability to 100ppm or better. The modules are simple 2-layer construction, but if I want to respin it later I might go 4-layer to get a bit more ground plane shielding. I do not have very good metal-bending capability here so I will have to "hand-cook" some sort of metal shielding around the PSU and AC inlet, even though the enclosure is plastic. If for whatever reason this goes to any amount of productisation I will contract that out. Those measures would necessarily increase costs.

author: asgard
author_rank: Regular Contributor
timestamp: February 07, 2019, 04:49:38 pm
content: There are three filter and three oscillator assemblies, each tuned with the values indicated in the schematics.

author: rhb
author_rank: Super Contributor
timestamp: February 07, 2019, 05:43:05 pm
content: I'm curious why use an analog design rather than a sound card?With a good card and a custom set of WAV files you can solve for and correct the errors in the input and output sections of both channels.I posted the algebra of the correction to another thread a few weeks ago. If you play a monotone at each frequency in the FFT at multiple amplitudes you should be able to correct all the errors to numerical precision.Give "Max Wein, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams a read.

author: asgard
author_rank: Regular Contributor
timestamp: February 07, 2019, 07:26:58 pm
content: For much the same reason as for any bench instrument, I want to minimize any multi-MHz signals flapping around. To get 0.005% accuracy even the noise level in the 4-layer example Dave recently demonstrated is too much.

author: cat87
author_rank: Regular Contributor
timestamp: February 07, 2019, 09:00:57 pm
content: In case you have't come across this already, here's a link to Cordell's THD analyzer. All analog, just like yours. Maybe this will help somehow. Also, for THS measurements, usually you want the filter and oscillator to be in sync when doing the frequency sweephttp://www.cordellaudio.com/papers/thd_analyzer.pdf

author: asgard
author_rank: Regular Contributor
timestamp: February 08, 2019, 12:15:47 am
content: Here is an updated BOM worksheet. Two things are different. First the main board is now a 100x100mm 4 layer design, with much better notated clearances for the modules. Second is a classic "trap for young players" You will now not be required to pay yourself sales tax for inhouse constructed sub-assemblies. There is a little bit more transparency as to the cost outlay for the board fab. The consumer margin calculation now reaches my desireable price point of $200 per unit, which sets the marginal profit per unit at 0.4. Your mileage may vary on what marginal profit a product requires. As long as that number is greater than one you will not have to make up losses in volume sales L)

author: rhb
author_rank: Super Contributor
timestamp: February 09, 2019, 01:11:07 am
content: Quote from: asgard on February 07, 2019, 07:26:58 pmThe Cirrus Logic WM8860 32 bit digital audio codec datasheet specifies THD at 18 ppm which is slightly better than your 50 ppm. Most of the codecs I looked at were around 25-30 ppm THD+N.It's important to understand that the noise that Dave showed is *radiated* noise. It is not noise on the signal traces.You can correct for THD in the ADC and DAC. If you generate a WAV file with a pure sine wave, play it back through each DAC and record it with both ADCs, you can correct the codec THD. Random noise can be suppressed by averaging many FFTs from a long recording. It's also the easiest way to solve the calibration problem in the bargain.All modern music production is digital unless someone is making direct to disk vinyl again. I can assure you that all that equipment would show similar levels of radiated EMI to what Dave demonstrated. The sole exception would be the direct to disk gear.In the 70's everyone competed for the lowest THD rating amplifiers. The fundamental problem is that the speakers and microphones are several percent THD. So even if the amplifier THD were zero, the result would not change noticeably.Aging and temperature will cause an analog THD meter to vary in a manner which is difficult to correct. A DSP approach can be recalibrated every time it is used. And at ~$150 for a 2x2 24 bit 192 KSa/S USB interface, it's certainly cheap enough.As your computer almost certainly already has a sound card, I suggest you start by writing the calibration code for that and then see if you can beat it with an analog design. As it is not studio recording gear, you probably can by a small margin. I doubt that you can beat the studio gear, but I could be wrong.I'm a retired reflection seismic research scientist/programmer. DSP does not get more complex than reflection seismology. With wells that run $200+ million to drill, no one bats an eyelash about spending a few million on DSP, *if* they are convinced it will improve the results. We have to deal with waves, tides, changing water temperatures and currents, changing sediment velocities, noise no one is quite sure where it comes from though marine life are a prominent source and all manner of other strange things which have to be analyzed, characterized and removed.BTW My Tek 485 is entirely analog. I'd bet that probing it would show similar levels of EMI to Dave's example. The horizontal sweep has to go from max to zero as fast as possible to get ready for the next sweep. That falling edge generates lots of high frequency harmonics.At a bare minimum, implementing a sound card based THD meter will help you build the Wein bridge oscillators you need and teach you a lot about measuring THD.I won't write the code for you, but I will give you a detailed description and answer questions. This is the sort of thing I did for 30+ years at PhD level for major and super-major oil companies. For extraneous reasons I did not get my PhD. But most of my clients did, many of them from Stanford. If any of us had a problem, the first step was to go across the hall, which either got an answer or a "go talk to Joe, he mentioned something about that over lunch a few weeks ago."I do *not* like being retired. It is not even close to the level of fun I had going to work. But along with many friends, I'm too old to get a job again. I ran an "orphan home for lost problems", so lots of strange and interesting things would walk in my office or appear in my Inbox.

author: asgard
author_rank: Regular Contributor
timestamp: February 09, 2019, 02:51:59 am
content: Actually I appreciate that. I don't need any code written for me, as in my previous life I developed microcore logic and code to implement beamforming hearing aid devices. In order to accurately compensate for head-related transfer functions (look that one up if you want to be sleepy) I had to use some hefty DSP in 40-core multiprocessors. One can appreciate the code density when you have to have a 42-bit accumulator for IIR functions in a 15-bit processor, with a budget of 192 words of memory for code and data. Anyway, after all that noise I wanted to see how "simple" I can make an accurate bench instrument, and I think a quad op-amp is quite robust for an accurate oscillator or filter. I am compromising enough to require a good (Rigol-class) oscilloscope to collect and integrate the THD measurements outside of this unit.

author: rhb
author_rank: Super Contributor
timestamp: February 09, 2019, 11:32:29 pm
content: Actually, I've been thinking about writing the code, though obviously you don't need it.After reading the datasheets I got to wondering how much improvement in THD one could achieve by running a calibration routine. I've always admired the Jim Williams essay I cited earlier. Building a super low distortion Wein bridge oscillator seems like a fun project and naturally I'd need some way to characterize it.If you've not read it, it's pp 7-19 of: web.mit.edu/6.101/www/s2017/handouts/williams.pdfJim's final version had a THD of 3 ppm!Current notion is sweeping across both frequency and amplitude :FrequencyStartStopStep (linear or log)AmplitudeStartStopStep (weighting??)FFTLengthRepetitions to average

author: asgard
author_rank: Regular Contributor
timestamp: February 10, 2019, 06:48:30 am
content: It seems to me two more corrections would have to be done - first to characterize the inevitable non-linearity of the converters, and second to account for drift in the sample clock because after all, Nyquist uber alles.

author: rhb
author_rank: Super Contributor
timestamp: February 10, 2019, 04:50:14 pm
content: Actually, Nyquist does not rule, Shannon does. Compressive sensing evades Nyquist, but not Shannon. Nyquist addressed the case of regular sampling which results in a convolution in the frequency domain with a spike series. The Nyquist limit is where the adjacent images of the spectrum overlap.The attached figure is from "A Mathematical Introduction to Compressive Sensing" by Foucart and Rauhut. There are 5 sinusoids (top left) that make up the 64 point series (lower left) and those 5 sinusoids are *exactly* recovered (lower right) with only 16 randomly selected samples. One more than the Shannon minimum of 15.The point of sampling all the amplitudes at all the frequencies is to deal with non-linearities. The variation of the sampling clock will require more thought. That is a *very* extensively studied problem in reflection seismology as the sources and receivers are never exactly uniformly spaced. But I think a sparse L1 pursuit would solve it to within 1/f noise.If you feel any random pains that will be me sticking pins in a voodoo doll of a Norse deity for bringing up the clock variance

author: ciccio
author_rank: Frequent Contributor
timestamp: February 10, 2019, 08:35:23 pm
content: Quote from: rhb on February 07, 2019, 05:43:05 pmThank you for the citation.I googled fo it and found some really interesting pages to be read this evening.

author: rhb
author_rank: Super Contributor
timestamp: February 10, 2019, 09:29:03 pm
content: The attitude towards learning that Jim displays just makes you feel good. Anything by Jim Williams is a pure delight to read.

author: Kleinstein
author_rank: Super Contributor
timestamp: February 11, 2019, 11:01:11 am
content: An analog THD meter can be relatively easy for a single frequency, as the oscillator and notch can be well tuned. It gets way more difficult if the frequency is variable. Like with the purely digital approach one could correct for some of the source errors - so the limit is at something like 1/10 the source quality, maybe a little better, if the system and DUT is broad band and very stable.Today I would also prefer the more digital way - it takes quite some effort to make a Wien bridge oscillator as good as a good sound card.

author: asgard
author_rank: Regular Contributor
timestamp: February 11, 2019, 05:14:54 pm
content: My approach here is to have three representative oscillator/filter pairs switched in, 100Hz, 1KHz, and 10KHz. All six modules are tuned to as great an accuracy as I can achieve. One thing I have been considering lately is how to represent the analysis, either as a result of an FFT executed on the scope, or another simple analog method, which is a peak-detect and hold circuit after the notch filter. That would only require a multimeter to directly measure the power density of the distorted spectrum. Again the goal here is not to achieve perfection, which we all know is the enemy of good-enough. What I wanted to do is to show how an adequately good benchtop instrument can be constructed with a BOM budget of $200 or less. Also, the point was to show how the project can be managed adequately well using some schmarts in an Excel spreadsheet in a way that scales

author: Kleinstein
author_rank: Super Contributor
timestamp: February 11, 2019, 05:27:19 pm
content: I think it makes absolute sense to use some kind of FFT to look at the signal after the notch. This has a few benefits: one can use it to check the tuning (too much base frequency coming through) and one can differentiate between the harmonics. So a certain level one could even subtract the levels from the source, if the DUT is broad band and does not alter the harmonics very much. Looking at it an a FFT way also allows for more tolerance to noise.The FFT could also provide another digital notch function, so suppressing residual base frequency. The analog notch would be still needed or at least very useful to keep the demand on the ADC low.At least for the relatively low frequencies a simple µC base solution might be sufficient.

author: rhb
author_rank: Super Contributor
timestamp: February 11, 2019, 07:13:27 pm
content: i do not know of a single DSO with a decent FFT. I've had experience with MSOX3104T, RTM3104, Instek MSO-2204EA, Rigol DS1102E and LeCroy LC684DLX. The Instek and the LeCroy are the best of the lot. The Keysight, R&S and Rigol are completely useless.FWIW the Instek GDS-2000E series has a very nice FFT based SA function. Instek only supports it on the MDO line, but you can hack the key and run it on a GDS-2072E. However, the programmer did not calculate the modulus of a complex number correctly. So if you sweep a crystal you see a parallel resonance peak, but instead of a notch for the series resonance it's a peak. Duh!I strongly recommend just using the DSO to collect the data and then using Octave to do the analysis.

author: asgard
author_rank: Regular Contributor
timestamp: February 11, 2019, 08:08:11 pm
content: Here is a slightly modified version of the track-hold circuit. Is is configured for a precision peak detector with compensation for the diode reverse leakage. The MOSFET sets the sample collection period to 8us with an 8us dead time to allow the storage capacitor to completely discharge. The timing is set with a precision 50% duty cycle pulse train from the 555. I know it is not a "true" power density measurement, just a peak finder. But for my purpose it will show in a very simple way how much distorted signal is passing through a DUT, especially if as you say we can accurately calibrate the THD of the oscillators to -90 dB or better.

author: rhb
author_rank: Super Contributor
timestamp: February 11, 2019, 09:59:40 pm
content: Have you read the Jim Williams paper? It's starts on page 7web.mit.edu/6.101/www/s2017/handouts/williams.pdfHis final oscillator design was less than 3 ppm THD. But the details of how he analyzed the errors should prove helpful.

author: asgard
author_rank: Regular Contributor
timestamp: February 11, 2019, 10:38:31 pm
content: Yes, I read it. Kinda makes me super smart to make the whole project super modular so if I were to adopt such a type oscillator it would only require a respin of a rather small board assembly. The only problem is to see about sourcing some of the parts for the specific example oscillator as some are quite probably obsolete. But other than that it is intriguing.

author: rhb
author_rank: Super Contributor
timestamp: February 12, 2019, 12:10:18 am
content: What I really wanted to call attention to was his methodology. not copying the circuit.

author: asgard
author_rank: Regular Contributor
timestamp: February 12, 2019, 01:40:48 pm
content: I will have to do a little thinking about two of the things in that article, first the use of a CdS cell/LED pair to substitute for the JFET, and the other is the use of two adjacent 1N4148 diodes to somehow thermally stabilize the circuit. I suppose that involves why a series reference diode also needed to be there.

author: asgard
author_rank: Regular Contributor
timestamp: February 12, 2019, 05:42:41 pm
content: for what it is worth this is the oscillator module prototype. The fact is that for whatever design changes I want to make in the future, the cost is mitigated by the modular design method employed here. That lowers the bar to adoption for this instrument to what I hope is a manageable level.The main point of this thread was not any specific circuit design decision, but an overall management strategy using what I hope is a useful spreadsheet tool that allows for project visibility from parts purchases to fabrication and assembly. This instrument is intended as an example of a multi-assembly project employing such a tool.

author: rhb
author_rank: Super Contributor
timestamp: February 12, 2019, 06:22:16 pm
content: Very nice. My interests lean a lot in the RF direction. I eventually want to assemble a collection of modules that can be used for prototyping a design. For that, having everything in metal boxes with standard connectors, dimensions, etc is desirable. So very much in the same vein as your efforts.But I'm still buying test gear so I haven't got to the PCB and BOM yet.I suspect that to really understand Jim's paper you should review the detailed physics of the devices. Williams, Pease and Widlar were renowned for their understanding of subtle details that less thoughtful people just blundered by and which were the difference between a circuit working and not working. I also think the inclusion of the A2 output trace in the figures is a strong hint.

author: asgard
author_rank: Regular Contributor
timestamp: February 14, 2019, 01:23:40 am
content: These two pictures are the notch filter module and a view of the EAGLE image for the main board (the rev A board is coming back from fab sometime later this month, so the pretty parts picture is not available yet). This picture is after I decided to allow for a seventh module to contain the track-and-hold circuit and another bypass toggle associated with it. I am breadboarding the track-hold now and will test it externally for now, but allowance is made for the next (rev B) run to modularize it. It might have to be done with SMD parts to fit the form factor, but specifying the parts for the ultra-stable construction I want is way more problematic in the 0805 or 0603 sizes I typically use.

author: asgard
author_rank: Regular Contributor
timestamp: February 14, 2019, 01:45:34 am
content: I suppose, rhb, that for your purpose then something like my modular system could be used, except the board interconnect would incorporate some sort of SMA and rigid coax arrangement instead of the Molex KK type? What about UFL? I can see modules (37x50mm) each containing a mixer, attenuator, pre-amp, and the like. The power rails are +/- 12V which is fine for the JFET op-amps I use, but would that be usable with your kind of RF circuitry?

author: asgard
author_rank: Regular Contributor
timestamp: February 14, 2019, 01:48:41 am
content: Actually that broadens my questions a bit further. I don't have the instrumentation to measure it, but does anybody know what are typical insertion and return losses from a right-angle THD Molex KK type connector with 2.54mm geometry?

author: rhb
author_rank: Super Contributor
timestamp: February 14, 2019, 03:39:02 pm
content: I am planning on using SMA connectors for RF with 90 degree cables for most connections because I was able to get lots of them cheap. I'll make up other cables as needed.I plan to use boxes made of galvanized steel. It's easy to solder, has fairly good H and E field shielding properties and i can get all the scraps I want from an HVAC shop. I'll probably build some small bending brakes of a piece of steel channel and angle for a few standard sizes so that all I need to do to make a box is cut the sheet, clamp it in place, fold it and solder the corners The board will mount to the lid using standoffs with connectors, controls , etc on the underside of the the circuit board. Each size will require two brakes, one slightly larger than the other so the two nest properlyOnce a module is finished it will be soldered shut with connector labels on the top and a schematic on the bottom.Power and control is still an open question. I want feed thru capacitors on power and signal lines but have not identified a suitable item. They are difficult to find at affordable prices. Generally power would be 12 V but other levels as needed. I'm only interested in very low power (QRPp) operation. In some cases e.g. an MCU control block, there will be an internal 3.3 V regulator in a subcompartment.MiniCircuits sells connectorized version of their parts which package the device in a metal enclosure with the connector of your choice. But at eye watering prices.U.FL is only good for RF test points as they are only last for a very small number of connections. I plan to place them in strategic locations that can be jumpered in w/ zero ohm resistors.So that's the *theory*. It will be interesting to see what reality is like. I'm sure it will evolve over time. I got the general idea when I opened up my HP 8601A sweeper. It's a standard set of die cast boxes which are sized to fit a standard chassis. The connectors are on the lids and the boards are edge mounted to the lids.With regard to measuring insertion and return loss for the connectors you're using I *think* that you could do that with an impedance bridge and an appropriate test jig. However, I really don't think there is much reason to even consider connector insertion and return losses at these frequencies. Surface oxidation resistive effects probably dominate. In any case, to be useful you'd have to be maintaining a constant impedance level everywhere. It looks a lot like a rabbit hole that would consume a lot of time. Before you go too far in that direction, set up the algebra and look at the magnitude of the effects at audio frequencies. If the connector losses matter you'll have to calculate the impedances all along the signal path.I just bought an HP 8753B VNA which covers 300 KHz to 3 GHz so I shall be going to VNA school for a while. I've also developed a bit of an OCD issue with EMI, so it is likely to get augmented with another instrument that covers lower frequencies so I can properly characterize EMI filters. That gets *very* messy because power system impedances are not well defined and definitely not 50 ohms.

author: asgard
author_rank: Regular Contributor
timestamp: February 14, 2019, 09:20:52 pm
content: This is the layout intended for the track-hold module. It also sits in 37x50mm 4-layer construction, albeit with offset board interconnect and not centered.

author: asgard
author_rank: Regular Contributor
timestamp: February 20, 2019, 05:09:42 pm
content: Here are links to the PCB's at OSH Park:https://oshpark.com/shared_projects/BGlH40tEhttps://oshpark.com/shared_projects/OEj5Q82Zhttps://oshpark.com/shared_projects/SFhUT8ohThe Track/Hold module will be last but that will require more bench testing before I can release that.

author: asgard
author_rank: Regular Contributor
timestamp: March 14, 2019, 01:32:30 pm
content: Here is a potential trap for yourng players. Electromechanical datasheets are the worst. Every vendor seems to have their own method of doing mechanical drawings that are, unfortunately, unique. Also, never attempt to interpret them at 2:00 in the morning. Main board needs a respin because the rotary switch gazoutas won't go into the gazintas.