ADC design with the ADC124S101 - Page 1
Forum section: electronics / projects

author: antonmi97
author_rank: Contributor
timestamp: April 17, 2019, 10:15:07 pm
content: Hello,I want to make a embedded true RMS current meter and I want to use theADC124S101as my ADC. Now, I've never designed my own ADC circuit and in the datasheethttp://www.ti.com/lit/ds/snas283d/snas283d.pdfI wasn't able to find out how the adc's output is mapped.I know it's a 12 bit ADC (0 - 4096) and that the maximum analog input it VCC+0.3V (from the datasheet).Does that mean that0V == 0 & VCC == 4096with a linear distribution in between?Any advice for a novice is very welcome and appreciated!

author: mariush
author_rank: Super Contributor
timestamp: April 17, 2019, 10:19:35 pm
content: See page 18 in datasheet:http://www.ti.com/lit/ds/symlink/adc124s101.pdfBecause the reference for the ADC124S101 is the supply voltage, any noise on the supply will degrade devicenoise performance. To keep noise off the supply, use a dedicated linear regulator for this device, or providesufficient decoupling from other circuitry to keep noise off the ADC124S101 supply pin. Because of theADC124S101's low power requirements, it is also possible to use a precision reference as a power supply tomaximize performance. The four-wire interface is also shown connected to a microprocessor or DSP.You could use a 4.096v voltage reference to power the chip. and that way your output will be exactly 1mV per step ...Voltage references aren't expensive, here's one that's cheap but not super great when it comes to tolerance and temperature coefficient :https://www.digikey.com/product-detail/en/microchip-technology/LM4040CYM3-4.1-TR/576-2568-6-ND/1858327this one's slightly better:https://www.digikey.com/product-detail/en/microchip-technology/MCP1501T-40E-CHY/MCP1501T-40E-CHYDKR-ND/5844654anyway... digikey has only 477 voltage references with fixed 4.096v in stock :https://www.digikey.com/short/pphwnq

author: antonmi97
author_rank: Contributor
timestamp: April 18, 2019, 11:07:50 am
content: Thank you very much for your answer. Helped me a lot!This is what I have in mind for now:Power theADR443BRZ precision 3V referencefrom my 5V SMPS (with all the recommended passives), use the 3V reference to power my ADC124S101 12-bit 1MSPS ADC and with that I should get a resolution of0.732 mV/bit.Another thing I would like to know is if I'm right with mymemory calculations. So I'm hoping for a 1MSPS rate and I'll be sampling for about 166 milliseconds (~10 mains cycles 60Hz). With that I should get 166 666 samples of 12-bit values which I'll have to store in 16-bit values. That will use about 2.7 Mbit or less than 350 kB of memory.So my plan is to first take the samples, store them in memory, do some processing, spit out the result, clear the memory and repeat. Any takes on this? Have I made any mistakes with my calculations?

author: mikerj
author_rank: Super Contributor
timestamp: April 18, 2019, 11:54:46 am
content: Your maths looks ok, but 1MSPS seems like an excessively high sample rate for the application.

author: MasterT
author_rank: Frequent Contributor
timestamp: April 18, 2019, 12:13:40 pm
content: Your choice of the adc isn't correct. For current metering the most important parameter is dynamic range. Math is simple, to have 1:1000 working input scale ( 1mA : 1A), and accuracy 1% at the lower end, dynamic range is 1:100 000. It demands 17-bits ADC as a minimum. Otherways PGA's, a lot of calibration at each steps of the pga, and error in fast varying current application. This is why sigma-delta adc architecture is common for power metering, great dynamic range and linearity for low price.

author: mariush
author_rank: Super Contributor
timestamp: April 18, 2019, 12:30:55 pm
content: Doing floating point divisions and multiplications in microcontrollers is hard, it takes a lot of cpu cycles. So doing value x 0.732 would take much more than just having 1 value per mV, if your voltage reference is 4.096v ...Are you aiming for higher precision, to get closer to 0.732 mV per bit? If that's the case, it may be cheaper to just use a 14bit ADC or even a 16 bit ADC.Considering the range you have, which is 0.33v to 2.97v, with 1 bit per mV you have valid values between 330 .. 2970 , or 2640 values. This forces you to use 12 bits per reading.So you'll use 3 bytes for every 2 measurements ... 256 KB will allow you to store 174762 values (256 x 1024 * 2 values / 3 bytes per value = 174,762 )If you want to save memory space, it may make sense to use a bigger voltage reference if you can squeeze the valid range into 2048 possible values.For example, with a 5v reference, you would have 1.22mV per step, so a maximum of 2048 would give you 2499mV and if you add 270 values (330mV/1.22) you would be able to store up to 2499+270 = 2769 or 3.378v into 11 bits. This would allow you to pack 8 readings into 9 bytes of memory.So 256 KB of memory would allow you to store 233k values ... or you could use 128 KB to store ~ 120k values. It would allow you for example to use a cheap 128 KB SRAM on i2c or SPI and 32-64 KB of ram on the micro to store your 150-175 K readings before performing calculations on them.Also, for a 5v reference to work, you'd probably need at least 5.3v ... your SMPS would probably have to output 5.5v and then you'd have to use a LDO for your micro...It's up to you to determine if it's worth dealing with multiplying by 0.732 (with 3v reference) or ~1.22 (with 5v reference) or if you'd rather keep things simple and use 4.096v reference which gives you 1mV per step.Again, shifting a value by 2 bits to the left of right is basically a couple of cycles in the microcontroller while multiplying or dividing would take much more. You may not even have to do any shifting... just do all your math with 1mV per step and scale the final result if needed... work with mV until the very last step where you convert to V by dividing with 1000If your calculations are simple enough, you may even be able to do the calculations on the fly or on small chunks of measurements .. like for example do around 20k measurements (which will use less than 32 KB of RAM), then spend a few ms calculating what couldn't be calculated as values came in, then repeat ... do this 5-10 times until you get your 150k readings or as many as you need.Up to you to figure out if those few ms of pause in reading would matter to you or not (if you even need to pause due to too much calculations)Also, it may be cheaper to just use an ADC with internal voltage reference.For example, ADS8661IPWR has an internal 4.096v reference but it's only 1 inputs, so you may have to use 2 of these if you want to measure voltage and current at same time:https://www.digikey.com/product-detail/en/texas-instruments/ADS8661IPWR/296-45425-1-ND/6695819But still, it would around 4.3$ for each instead of 7-8$ for that 4 channel plus 5-8$ for the 3v reference... you're saving money.If you want more bits, here's 18bit 100kSamples per sample with internal voltage reference :https://www.digikey.com/product-detail/en/texas-instruments/ADS8699IPWR/296-49544-1-ND/9462547

author: antonmi97
author_rank: Contributor
timestamp: April 18, 2019, 03:56:58 pm
content: Quote from: MasterT on April 18, 2019, 12:13:40 pmHm, I'm not sure I get your argument about dynamic range. I want to measure household devices at 120V for currents of (0.02A to 16A). My sensors sensitivity is 66 mV/A so the ADC should be able to measure it with the resolution of 0.73 mV/bit. Could you elaborate a bit more, please?Quote from: mariush on April 18, 2019, 12:30:55 pmThe post processing time isn't relevant since I only need results every 5 seconds for example. How could I save 8 readings of 11 bits into 9 bytes of memory??In general, whatsampling rate and bit countwould you guys recommend for measuring True RMS mains current (for very ugly wave forms) in the range of0.02A to ~16A

author: MasterT
author_rank: Frequent Contributor
timestamp: April 18, 2019, 04:33:14 pm
content: Quote from: antonmi97 on April 18, 2019, 03:56:58 pmI'm not sure I follow your math, 66mV/A * 0.02A = 1.32 mV. Setting this value (leaving peak-to-peak & RMS coeff. out of scope for now) as bit reference, measurements become binary, 20 mA, 40 mA, .... 100 mA. I think, you want to see something in between, 20.5 or 81.0 mA? Averaging does help to fill the gaps, but INL for 12-bits ADC would create another problem, accuracy would be off by 20 mA somewhere in the middle of the scale.

author: antonmi97
author_rank: Contributor
timestamp: April 18, 2019, 05:02:15 pm
content: My sensor (ACS733-20AB) measures current in the range of -20A to 20A and it outputs voltage with the same waveform as the current passing through it. I want to sample the voltage on it’s output with an ADC and then get the RMS current out of the samples. I already do this but with an ADC that is way too slow, now it’s time to speed things up.That’s why I’m asking you guys for advice on what ADC type, how many bits and most importantly what sampling rate?Any help is very very welcome

author: MasterT
author_rank: Frequent Contributor
timestamp: April 18, 2019, 05:29:21 pm
content: A lot depends on application, for power metering usually 20 x ac frequency = 20x 50(60) = 1000 (1200) Hz sampling rate is o'k.Number of bits defined by accuracy, 1% in all 0.02 - 16A range demands 17-bits.Type of adc doesn't matter, as long as INL strictly specified in DS. Sigma-Delta type, same like audio codecs is fine .SAR ADC may run at higher sampling rate, to simplify anti-aliasing filter design.For Hall current sensor, based on my experience, it's quite complicated to get noise-free small current measurements w/o heavy filtering data.

author: mariush
author_rank: Super Contributor
timestamp: April 18, 2019, 07:13:59 pm
content: Quote from: antonmi97 on April 18, 2019, 03:56:58 pmYou can't, i was stupid. For some reason in my mind I was thinking 10bit instead of 12bit, and 9 bit instead of 11 bit. I apologize for confusing you.You'd use 11 bytes for 8 values ... 3 bit x 8 = 24 bits or 3 bytes + 8 bytes

author: antonmi97
author_rank: Contributor
timestamp: April 18, 2019, 10:38:57 pm
content: Quote from: MasterT on April 18, 2019, 05:29:21 pmAre you sure about the sampling rate? I currently use theADS1015(12-bit 3.3kHz) and I'm quite sure you can't get all the high frequency components in the current wave form for example from SMPS, microwaves, and other appliances that havenon-sinusoidal current wave forms. 1200 Hz would be enough if the wave form was more/less a nice sine wave, but for most of the things it won't be.That's why I wanted to ask you guyswhat sampling rate is enoughto cover it all within like +/- 1%. I guess the quite high frequency components at 200 kHz are so insignificantly short (narrow) that I don't even have to bother with them. Right?

author: MasterT
author_rank: Frequent Contributor
timestamp: April 19, 2019, 03:36:08 am
content: Quote from: antonmi97 on April 18, 2019, 10:38:57 pmThere are standards for power measuring, I'm sure for North America ANSI defines bandwidth up to 20-th harmonics of the AC waveform. So 1200 Hz is a band, sampling rate is a different species. MInimum is x2 by Nyquist = 2400 samples per second. Period.Pushing this rate up makes sense for a number of reasons:- simplify anti-aliasing filter design;- to do oversampling for increasing resolution of the adc;- to run a software LPF, reducing noise getting into measurements band.From the analog.comQuotehttps://www.analog.com/media/en/technical-documentation/data-sheets/ade9153a.pdf

author: antonmi97
author_rank: Contributor
timestamp: April 19, 2019, 06:08:50 am
content: QuoteSo with the adc output bandwidth of 1.6 kHz, a good enough sampling rate would be 10*bandwidth = 16 kSPS? I’ll have a more detailed look at the datasheet, but 1 MSPS seems definitely like a overkill for now.