Possibility of using Audio codecs for measuring DC stuff - Page 1
Forum section: electronics / projects

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 14, 2017, 09:42:26 am
content: Hi,I need cheap way of reading and generating precision DC voltages, I was wondering if something like UDA1380 which is an audio codec or similar ones can do the job, what are the pitfalls? also what's their ENOB? for example in the UDA1380 it says the signal-to-noise ratio at fs = 48 kHz is about 97dB so can we calculate the ENOB is (97-1.76)/6.02 or something near 16bits? since this part has DC filters that can be disabled, have you done something similar? I need ADC and DAC with at least 16bit ENOB with low prices, do you know any other way around, the sample rate of 20K or more is enough for my job. I'm looking to do the job with a budget of under 2$

author: coppice
author_rank: Super Contributor
timestamp: October 14, 2017, 12:16:57 pm
content: I didn't look specifically at the data sheet from the UDA1380 but the general picture with audio codecs is they don't care too much about DC offsets or gain. In practice the gain variation of most of them is not too bad. A temp coeff of 25ppm seems typical. Its the DC offset you need to worry about for good DC measurements. Not only can it be quite large, it isn't always very stable.

author: Cerebus
author_rank: Super Contributor
timestamp: October 14, 2017, 02:56:20 pm
content: As has been said, audio codecs generally have horrible DC characteristics. Up your budget a bit and look at the LTC24xx parts for some serious DC precision at a bargain price. e.g. LTC2400 nominal 24 bits, actual ENOB determined by how much you want to pay for a voltage reference and low offset/drift op-amps, 5-10 ppm accuracy relatively easily achieved, under $5 in quantity, under $8 one-off.

author: ebclr
author_rank: Super Contributor
timestamp: October 15, 2017, 06:48:46 am
content: Simple cheap and reach you needshttps://www.silabs.com/documents/public/data-sheets/C8051F35x.pdfA little more expensive one higher than your needshttp://www.ti.com/lit/ds/symlink/msp430fg6626.pdfA litle expensive, "creme de la creme"http://www.analog.com/media/en/technical-documentation/data-sheets/ADuC7060_7061.pdf

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 16, 2017, 06:05:50 am
content: Thanks for the hints, the MCU's looks definitely cool, but I need two ADC and two DAC's the MCU's seems to have the the ADC but lack the DAC.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 16, 2017, 06:57:40 am
content: I think the other next best thing would be HX710A part, but is there a way to change it to accept single ended ground reference input? do you have any Idea? they are so damn cheap!

author: Berni
author_rank: Super Contributor
timestamp: October 16, 2017, 07:05:04 am
content: Problem with audio chips for precision DC is that the internal voltage reference is not very stable and they don't have a external reference input.

author: ebclr
author_rank: Super Contributor
timestamp: October 16, 2017, 12:08:42 pm
content: You can easily make a very good dac with PWM

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 16, 2017, 01:51:57 pm
content: What about the programming of the 8051 part? can I use my j-link? or do we have an opensource one?

author: Cerebus
author_rank: Super Contributor
timestamp: October 16, 2017, 02:17:59 pm
content: Quote from: ebclr on October 16, 2017, 12:08:42 pmYes, but with painfully slow settling time; excellent linearity, but slow to settle. Say you use a 16 bit counter on a 16MHz clock (e.g. Arduino). That will give you a 244 Hz fundamental square wave, so you'll want a low pass filter of at most 50 Hz, which will give you a settling time to 16 bits of 222 ms. Roughly speaking that is, these are only "back of a fag packet" calculations.

author: Kalvin
author_rank: Super Contributor
timestamp: October 16, 2017, 02:27:00 pm
content: Quote from: Cerebus on October 16, 2017, 02:17:59 pmUsing two or three PWM-outputs one can reduce the settling time considerable:https://www.edn.com/design/analog/4441113/A-faster-PWM-based-DACHowever, for many applications this may be still too slow.

author: Cerebus
author_rank: Super Contributor
timestamp: October 16, 2017, 02:49:19 pm
content: Quote from: Kalvin on October 16, 2017, 02:27:00 pmIt all depends what you're aiming for. The variant you've linked to introduces a dependence on the resistor ratios which, if you're after good linearity, requires very good tempco on the resistors which can get expensive. The great advantage of PWM is linearity - some of the very best calibrators use PWM DACs.There's also a smoothing scheme that uses an integrator, a hold capacitor and some analogue switches to switch between them synchronously with the PWM. There's an EDN circuit idea on it somewhere. It effectively settles in a PWM cycle or two, but I've never got it to work quite satisfactorily, but it's a plausible compromise between linearity and settling time. Found it:https://www.edn.com/design/analog/4323340/Fast-settling-synchronous-PWM-DAC-filter-has-almost-no-ripple.

author: ebclr
author_rank: Super Contributor
timestamp: October 16, 2017, 06:17:59 pm
content: To program the silabs 8051F350 you need a U-EC6https://pt.aliexpress.com/item/C8051F-Emulator-Downloader-Programmer-U-EC6-USB-Downloader-JTAG-C2/32813334292.html?spm=a2g03.search0104.3.18.K6xTtl&ws_ab_test=searchweb0_0,searchweb201602_1_10152_10065_10151_10068_10344_10345_10342_10343_10340_10341_10307_10060_10155_10154_10056_10055_10054_10538_10537_10059_10536_10535_10534_10533_100031_10099_10338_10103_10102_10052_10053_10142_10107_10050_10051_10173_10084_10083_10080_10082_10081_10110_10111_10112_10113_10114_10312_10313_10314_10078_10079_10073,searchweb201603_2,ppcSwitch_5&btsid=bc3d0f9c-d30d-4262-bbcd-6d008bef1599&algo_expid=ca8cbcd3-cdb5-49d6-805e-8ee69ab88b2f-2&algo_pvid=ca8cbcd3-cdb5-49d6-805e-8ee69ab88b2f

author: Kleinstein
author_rank: Super Contributor
timestamp: October 16, 2017, 07:12:36 pm
content: For less ripple on a PWM DAC one can also use a kind of partial SD modulation, like using 10 or 8 Bit HW PWM and modulation by +-1 step in software. This reduces the amplitude of the lowest frequency component considerably. However the problematic range near 0 and full scale gets larger.In some cases a simple inaccurate, but high resolution (and not large gap) R2R DAC and a feedback loop with the ADC for corrections can work too.

author: Berni
author_rank: Super Contributor
timestamp: October 17, 2017, 05:34:19 am
content: This thread is mostly about ADCs tho, but yeah PWM can be quite useful when you need a cheap DAC.There are not many cheats you can take to get a cheap high resolution measurement ADC out of something that was not meant to be one. What you get in integrated form will mostly be sigma delta ADCs and the 24bit ones can provide some pretty impressive performance, if you are willing to pay 10 to 40 bucks for a chip that is.The best bet might be building your own dual slope ADC. It only needs a few simple analog components while the time measurement of the slope can be done using hardware timers in a MCU.But for any sort of AC measurement the audio ADCs are awesome. They let you look at -120dB signals pretty clearly and even do it at pretty nice sample rates of 192KHz and similar.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 17, 2017, 06:43:06 am
content: Thanks guys for the useful hints,QuoteIt seems that you know some good trickswould you enlighten me on Implementing the Dual slope ADC,since I have a MCU in the design, doing almost nothing

author: Berni
author_rank: Super Contributor
timestamp: October 17, 2017, 07:25:42 am
content: Best is to read up on thishttps://en.wikipedia.org/wiki/Integrating_ADCThings start becoming a bit more complicated when you want high speed out of one of t these. As you want more resolution that means you have to make the integration time longer and this means you can't make as many measurements per second. Multislope designs get around this problem by only using the slow slopes once its close to the final value. Because these use different value resistors to switch between, this means that the resistors need to be very precise or they need to be calibrated for every PCB (One costs money, other costs manufacturing time).

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 17, 2017, 07:33:11 am
content: Thanks BerniDo we have a real app-note or open source project doing it in real hardware and explaining everything with practical details?

author: MasterT
author_rank: Frequent Contributor
timestamp: October 18, 2017, 01:00:06 am
content: I did measurements of ENOB for WM8731 ones, 15 bits approximately, with HPF "on". For DC I would expect no more than 11-12 bits. You may get better accuracy via implementing self calibration, adding precise DC reference and switch, than use uCPU to track DC drift in real time, interrupting DC voltage monitoring few times in a minute or so.In overall, IMHO, it makes sense if 20-48 ksps is necessary.It's not clear what is your application, first topic says 20 ksps than 5-10 sample per second was brought into discussion.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 18, 2017, 08:57:58 am
content: Thanks, I need to measure the DC voltages of a power supply for monitoring, so something like 100-200SPS to maximum of 20KS would be enoughso maybe in the future I have some room for improvement.

author: MasterT
author_rank: Frequent Contributor
timestamp: October 18, 2017, 09:59:28 am
content: Ok, I see.I was inclined to the same approach, of using audio codec for fast multi-channel data acquisition, since 16-bit SAR ADC would cost 30$ and over & DAC way above 10$, having 12-13 ENOB noise free out of 16-bits by specification.But in your case, for just 200 sps there are better options, NAU7802 for example, 2 channel 24-bits 320 sps, and < 3$ CADhttps://www.digikey.ca/product-detail/en/nuvoton-technology-corporation-of-america/NAU7802SGI/NAU7802SGI-ND/2769782

author: Berni
author_rank: Super Contributor
timestamp: October 18, 2017, 10:09:34 am
content: That looks like a rather impressive chip for the price.

author: danadak
author_rank: Super Contributor
timestamp: October 18, 2017, 10:26:53 am
content: The OP requires 20K SPS @ 16 bits.Regards, Dana.

author: fcb
author_rank: Super Contributor
timestamp: October 18, 2017, 11:41:38 am
content: As others have pointed out, the problem with using Audio targeted ADC/DAC's is that the conversion references tend to be hidden and not well controlled. Nobody in consumer audio really cares if your gain is a smidge out or has a high TC or varies a little with wander on your 3v3 rail.But, there are ways to solve this.Five years ago I designed a product that used 2 stereo DAC's (Wolfson kindly obsoleted them recently..) to create 4 DC voltage levels. We had a 'calibrate' function that would use a CMOS switch, comparator and voltage reference to work out calibration levels if the temperature changed or if a certain time had elapsed. You could use the spare channel of an audio DAC to do the same without affecting the main output. Watch out for the step response on audio DAC's!ADC's are different, most audio ADC's don't like DC. They'll often null it out. However that doesn't stop you, if you turn your DC into switched DC - but that approach would only work a few hundred SPS - better to buy a proper ADC. If you want 20KSPS/16 bit, your probably going to have to bite the bullet..If your ADC level input is fairly consistent, then you could use a spare audio DAC to generate a precision subtraction voltage and then use a lower resolution ADC. All boils down to development time vs. production cost.Some nice, cheap (& available!) audio ADC/DAC's that have exposed the internal references: UDA1334 and UDA1361.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: October 18, 2017, 12:22:36 pm
content: Thanks, since I have a reference inside the design, is it wise to power the audio DAC with a Voltage reference, So we can make sure we have a stable and referenced ADC and DAC?

author: Wimberleytech
author_rank: Super Contributor
timestamp: October 18, 2017, 05:58:26 pm
content: "Silicom" Labs Too funny.

author: Berni
author_rank: Super Contributor
timestamp: October 19, 2017, 05:30:33 am
content: Running the ADC from a stable supply voltage wont solve everything. The internal reference at least won't be affected by supply variation but it is still affected by temperature and its possible that it slowly walks around on its own even.As for audio ADCs handling DC i have put DC in to some of the higher end chips and they take it just fine, but they did have a configuration pin for turning off the internal high pass filter.The only way to really know is to take a a few ADC chips and test it with the sort of input your application might provide it. Most audio ADC chips are easy to run where you only need to give it a clock and it spits out data so you could just bodge wire one on a SMD breakout board and hook it to a scope with I2S serial decode to display the data. One good measurement is worth a 1000 expert opinions.

author: coppice
author_rank: Super Contributor
timestamp: October 19, 2017, 02:06:59 pm
content: Quote from: Berni on October 19, 2017, 05:30:33 amThe problem with audio ADCs and DACs is not whether they can handle a DC signal. Almost all of them can. Its the huge DC offset you typically get. If this were rock solid you could probably calibrate away most of it, but it isn't always that stable.

author: b_force
author_rank: Super Contributor
timestamp: October 19, 2017, 03:14:22 pm
content: Wasn't it that the topology used in audio ADCs is not working for DC signals, cause they keep 'hunting' or something?

author: coppice
author_rank: Super Contributor
timestamp: October 19, 2017, 04:27:28 pm
content: Quote from: b_force on October 19, 2017, 03:14:22 pmPretty much anything with a feedback loop has some amount of hunting going on. However, a sigma-delta converter starts out with a very high 1, 2, or whatever bit sampling rate, and decimates down to a much lower 16, 24, or whatever bit sampling rate. The great majority of the noise due to hunting, which is like a rapid minor oscillation in the pre-decimated domain, is way beyond the Shannon rate of the converter, and gets filtered off during decimation.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 19, 2017, 04:48:24 pm
content: Some DAC / ADCs might show rather large idle tones at DC. Some ADCs (don't know about DACs) do remove DC and thus won't work with DC at all. Many audio codecs also need a constant flow of data, even if constant values are wanted. Usually the gain and offset drift is not that good, but often still not very bad.As audio usually is at least 2 channels one could use one ADC channel to monitor an external reference and thus way tie the data to an external reference even if the ADCs/DACs use an internal one only.For the ADCs there are some alternative, relatively cheap ADCs (e.g. MCP39xx series) with reasonably DC specs.

author: b_force
author_rank: Super Contributor
timestamp: October 19, 2017, 05:38:58 pm
content: Quote from: Kleinstein on October 19, 2017, 04:48:24 pmThis was actually what I was referring to.I personally don't really get the issue, there are plenty of affordable 12 and 16 bits ADCs for DC signals.Even 24 bit it not that much more.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 20, 2017, 11:46:13 am
content: The ADC part is easy and also affordable. The MCP3911 is affordable (e.g. $2-3 range) and in many respects similar to the Audio ADC, but with good DC specs too.The more difficult part is the DAC - essentially all cheap 16 Bit DACs are audio. At least I have not found a SD 24 Bit DAC with good DC specs and a low price. I am sure some people would like to have some, even if the price is not that low.So it is a very legitimate question if there are some of the audio DAC (or complete codecs) that do have good enough specs to make them attractive for DC use.

author: coppice
author_rank: Super Contributor
timestamp: October 20, 2017, 12:04:50 pm
content: Quote from: Kleinstein on October 20, 2017, 11:46:13 amPut an audio DAC in the mode where it can output DC. Feed its output back to a spare ADC input, measure the error in the resulting output signal, and correct the value fed to the DAC. Monitor for drift, and update as needed.