Author Topic: How to wire/GND everything correctly to get accurate ADC readings in my project?  (Read 3456 times)

0 Members and 1 Guest are viewing this topic.

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
Hi

so I got this project of mine, which I'm working on for quite some time now and making good progress. Most things work quite well and satisfying however one thing kinda destroys my brain on a regular basis.
I get quite inaccurate readings from the ADC and I mostly blame my ground plane design for it as the ground loop for the ADC inputs seems a big large this way.
But how could I improve that?

Here is my project schematics: https://github.com/mamama1/LabPSU_Darlington/blob/master/schematics.pdf
board preview: https://github.com/mamama1/LabPSU_Darlington/blob/master/preview.PNG

Description of the project:
It is (or wants to be) a precision Lab PSU using the Teensy 3.5 as its brain, it's ADC and an external MCP4922 DAC with an external 2.048V reference for both the DAC and the ADC.

tech details regarding the issue:
The ADC measures this on its channels:
- output voltage right at the darlingtons
- output voltage at an external sense line (only one sense line for now, unfortunately)
- current across an 10mOhm shunt and amplified by a LTC6102
- whether the PSU is in constant current mode or not (basically looking whether there is a certain level of voltage on IC2B's output or not)

I'm always about 1-2% percent off when it comes to voltage or current measurement. Doesn't matter if it is 1V or 10V or 10mA or 3A.
In an earlier release i did use a MCP3204 external SPI ADC which gave me better results (quite bang on, actually), however I wanted to save cost and that ADC was also entirey on the analog part of the ground plane and had it's pins nearer together so I guess the ground loop was reasonably smaller as well.

CC mode works quite well, sub 1% off, so it really seems only the ADC readings are what's not as good as they could be.

Thanks for any advice!

PS: feel free to copy/reuse/fork/follow this repo! Open Source hardware FTW!
Boron rhymes with moron
 

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
*bump* anyone got an idea? need more details?
I'm really not sure whether I should try and optimize that or just go with an external ADC like the MCP3204 or the ADS1115...
Boron rhymes with moron
 

Online coppercone2

  • Super Contributor
  • ***
  • Posts: 11334
  • Country: us
  • $
highlight the circuit path of the analog front end with some yellow lines, I am not gonna figure that out

Also, think ghost busters, don't cross the streams(traces). Your schematic is annoying to read. And seperate ground on everything, even if right next to each other
 

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
yeah i know, sorry for the schematic, didn't put the cleanness into it, which I should have.

in the attached image I tried to hightlight the ADC part + the voltage reference.
left is current sensing and right is voltage sensing (onboard) + sense line sensing (that 2-pin pinheader).

the two pins on the left side of the teensy are ground pins which are connected to the board. the upper one is called analog ground and is connected to normal ground via a ferrite bead ON the teensy board itself and to the analog ground plane of my board and the lower pin is normal ground wich is connected to the "digital" ground of my board where all the nasty switching stuff and spi communication happens (yeah, apart from the DAC on the right side of the voltage reference, which is SPI as well).

thanks for trying to help!
Boron rhymes with moron
 

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
ok I have now bodged in an MCP3204 ADC into the circuit in a very bad way (long wires, breadboard) and I'm getting waaaay better readings, almost bang on (only a few mV out, that'd be more an issue of a lack of resolution).
so I'm gonna ditch that onbard ADC and make a new board with the MCP3204 onboard.

here's a photo of the flying-wire ADC for your amusement.

Boron rhymes with moron
 

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
use a solid ground plane for the entire project.
The ADC seems to be very lacking in terms of performance. I would personally suggest and ADS1219 (about 5$, forget the ADS1115 since the price difference is very little) or if you can spend a bit more, it's bigger brother, the ADS1220. they offer insane performance for their price. also the I couldn't find the ADC in your schematic as it's way too messy. are there any filtering on the inputs? what's the sampling rate? these can all effect the reading accuracy.

you don't have to ditch the "onboard" ADC and use an entirely separate part for it. if the part is through hole, just make an adapter board for it, otherwise re spin the PCB. they cost so little that it would be a terrible idea to just bodge stuff there when you can get prototypes for less than 10$ from china (the likes of jlcpcb).

I know I'm a T.I fanboy but I really never had much luck with ADCs/DACs from micro chip. T.I and analog devices / linear technologies parts always seem way better, although AD / LT parts usually come at a price premium, so I stick to T.I for the most part.

I'm assuming your main problem is INL + DNL. they must be calibrated out. otherwise a 12 bit ADC with 4 bit INL + DNL is effectively a 10 bit ADC.
In my experience grounding never seems to be an issue, unless you placed digital traces right in between / under the adc input tracks. if you're concerned about that, separate the digital and analog grounds, and only join them under the DAC / ADC. this application note probably helps you:
https://www.analog.com/en/analog-dialogue/articles/staying-well-grounded.html (check where they show actual layouts, you don't need to read the entire thing)

You can also check the recommended layout provided by T.I in the datasheets of ADS1115/ADS1219. I can provide you with schematics of some of my designs where I have reached about 2/3uV (lets just say 10uV as a worst case scenario!) accuracy (NOT RESOLUTION,ACCURACY) which is pretty good in my books.
 
The following users thanked this post: nemail2

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
hi

thanks for your help!
sorry for the messyness of the schematics. if i rip it apart and redo it, I'd have to reroute the board as well... :(

the ADC which I'm currently using is "onboard" the Teensy 3.5 respectively integrated in the Teensy 3.5 MCU (MK64FX512VMD12 Cortex-M4F). That's why you didn't find it in the schematics :-)
attached you'll find an image of how my ADC inputs are filtered and fed.

regarding the sample rate, I'm not entirely sure (shame on me), but I have set it to the slowest possible value using the according Teensyduino library (Arduino fanboy here)...

I'll respin the PCB anyway (using JLCPCB for a year or so now). I bodged the MCP3204 in there like that to check whether and how it would work at all, not to leave it there like that, flapping around in the breeze on a dodgy breadboard ;-) Making a pin header and adapters for various ADCs is a nice idea, but I'd be concerned about affecting the measurements because of the header and longer distance, maybe bad contacts and stuff... And I'd have to figure out a way for all the various pinouts with and without an external VREF (guess I'd have to include the VREF on the adapter PCB with the ADC) and for the various interfaces (SPI, I2C)... But I guess that's doable...

I once tried an ADS1115 and I was quite stunned by its performance and I like TI too, so you won't hear any negative things from me there ;-)

Unfortunately I don't know how to calibrate out INL and DNL :( But I'm willing to learn...

The MCP3204 gives quite good performance as well (at least for me, for this usage, it was satisfying, i guess) and costs only about half of the ADS1219. I quite like the MCP3204.. I think if I'd go with a TI job, I'd use the ADS1220 because of the integrated voltage reference and the PGA (i hope the integrated VREF is good enough?). But that's obviously like three times as expensive as the MCP3204. Unfortunately I'd still need the REF3120AIDBZR voltage reference if I'd use the ADS1220 because there is still the DAC (MCP4922) which needs one, so no cost savings there :(

I dunno... MCU integrated ADC seems to kind of suck, maybe because of my layout (although there are absolutely NO digital traces near the ADC input lines). MCP3204 gives good results (at least good enough i think) and is cheap. ADS1*** ADCs are really nice but quite expensive compared to the MCP3204...
The DAC is out a few mV anyway, maybe because of the opamp feedback loop resistors or offsets or whatever (didn't investigate yet), so what's the point in having a 10µV accurate reading... :-)
Yes, I wanted to have the PSU to be precise but how precise do I really need for powering general stuff... If it is within 50-100mV of set voltage, thats OK for 99% of the stuff and it way outperforms that spec..

---

Regarding the ground plane: I read everywhere that I have to connect all grounds (essentially I have analog, digital and power ground) at a single star point. If I connect DGND and AGND underneath the ADC, I'd violate that rule, wouldn't I?

Regarding my ground plane design, I was told to measure between two ground points (I took AGND/power GND at the output and DGND down near the Teensy MCU) with my oscillocope using AC couple mode and different time bases while loading the PSU with some heave PWM dimmed load (i took my LED stripes dimmer, loaded it with 3A of LED stripes and dimmed it to about 80%). I have attached the results but I don't know whether that's good or not?

"massepunkte.png" shows where I have measured.
SDS00012.png:
50 Hz, I guess that's coming from mains

SDS00011.png:
500 kHz, looks like switching noise of the TPS5430 switching regulator which I was using in this particular design I have currently built up here (replaced by 78xx switching drop-in replacements later)

SDS00010.png:
500 Hz, looks like PWM frequency

SDS0008.png:
I guess that's SPI traffic to the SPI display
Boron rhymes with moron
 

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
calibrating INL and DNL is not an easy task. it would be simpler for a DAC compared to an ADC however, since you can buy a 24 bit ADC and an extremely stable voltage reference for under 20$, but a 24 bit DAC alone would probably cost more than that.

In order to calibrate those errors, you first need to calibrate out offset error (ADS1XXX family allow you to short the inputs together so you can get a reading, preferably average it out over a long period (about 1 or 2 seconds) which gives you the offset code, since with the inputs shorted together, you must be getting 0. any other code is offset error). then you should calibrate out gain error as well (no on chip method for this one unfortunately, you can read on how to do this if you are interested). Now you can begin to calibrate out the INL and DNL  :-DD

I use the example for a DAC rather than ADC, but the overall idea is the same:
For example calibrating DNL and INL of a 16 bit DAC after the offset and gain have been accounted for, using a 24 bit ADC.

connected the output of the DAC directly to the ADC. write a program that steps through codes with each step being X number of codes (the smaller the X, the more accurate the calibration). Read the actual output with the ADC and store it in an EEPROM (maybe your MCU has one large enough, otherwise use an external one). then you will use a look up table for the actual output value you want, and see what value of the DAC produces that output. Again, this is not a trivial task, so for beginners it's best to get a good ADC with preferably 1LSB INL and 1LSB DNL if possible.

Also your DAC shouldn't be a few mV off! that is insane on a 2.048V reference with 12 bits. 12 bits is 4096 codes. if you're off by 2 codes (INL + DNL seems to be 2LSB which is fine) that is just 1mV error. a "few" mV is more than that. maybe you haven't calibrated offset and gain errors? maybe this is good enough for you so I'm not sure anyways.

If I were you, I would get the 24 bit ADCs (ADS1219 is about twice as expensive as the one you're currently using). this will allow you to calibrate your DAC like mentioned above. the internal voltage reference of those ADCs is also more than good enough for 90% of applications. I used a very expensive reference in one of my designs and it barely made a difference. certainly not worth the 10$ price tag (ADR420BRZ-REEL7). for the DAC you will need a reference, but if you plan on calibrating everything, you can ignore any "initial accuracy" values and get something with low temperature drift and low long term drift. those are more important than the initial accuracy. otherwise you have to calibrate over and over as they drift.

Also a side note:most ADS1XXX have PGA and decent internal voltage references, plus a very flexible input MUX. so don't worry about their performance.

Going the route of a daughter board for ADC / DAC : if you use 0.1" headers and solder them (NOT SOCKET) , there will be very little to no difference, especially at DC (very low frequencies) where you're only concerned with the resistance rather than "impedance" and the pins don't have much resistance. If you want to use a socket, bad contact / high contact resistance can be an issue, so it's best to avoid that.

Why integrated ADCs on the MCUs suck? simply because they are SAR topology. all of the ones I mentioned are Sigma Delta topology, which can do noise shaping. that means if you take care of high frequency noise where the SD ADCs perform poorly, they filter out low frequency noise themselves, resulting in very accurate readings (High signal to noise ratio). SAR ADCs on the other hand can't do this. they can use over sampling and averaging,etc to get better results, but it's really pushing your luck at that point. This is inherent to their design.

Also in case of a power supply, output ripple is a much bigger concern than actual value. if you are accurate to lets say 1mV but there is 100mV ripple, that design is no good at all! for switching applications they usually create multiple phases that allow for good transient response, as well as low ripple. if you want to get started on this watch GPU PCB analysis videos by Gamer nexus on youtube. for example this one:

otherwise I would say your current design is good enough.

Regarding ground planes: no. this is exactly what you want. that "Single point" will be under your DAC / ADC. this is also exactly why the digital portion of those chips is on one side and the analog portion is on another side. (see figure 6 here: http://www.ti.com/lit/an/slyt512/slyt512.pdf) to further isolate noise, you can use two separate supplies for the analog and digital sections. I personally slap 2 LDOs (one for each section) since they are so cheap.

The ADC filtering is pretty poor (almost nonexistent ) and it seems to be single ended rather than differential. I didn't check to see if the MCP ADC allows for differential setup, but that can be a big improvement too. this is how I got better than 10uV accuracy:
"Capture.png"
RN1 and RN2 are 1k resistor networks which add input protection, as well as filtering in combination with the capacitors.
C6 and C5 are X2Y capacitors (feed through capacitors) which reduce high frequency noise with respect to ground. again, SD ADCs only need HF filtering since they do noise shaping.
C3 and C4 are there to reduce differential noise. I used C0G capacitors which are meant for these applications, so they are a bit more expensive than your generic 100n decoupling cap.

I haven't designed a PSU yet, but a lot of precision electronics (millivolt meters, milliohm meters, etc) so I'm probably thinking of orders of magnitude better accuracy that necessary here  :-DD take all of what I said with a grain of salt and see what is "good enough" in your books.

« Last Edit: May 28, 2019, 04:27:20 pm by OM222O »
 
The following users thanked this post: nemail2

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Short answer - with those popular MCU breakout boards you will never get a clean +/- 1LSB reading off the ADC, imho. The only way to proceed is:
a) to have the MCU directly placed on the main pcb, or,
b) to use an external ADC placed on the main pcb.
4 layers help. Star grounding, good decoupling, no switching regulators.
Otherwise you have to count with up to 10LSBpp noise or more.
You may also do several ADC readings and average results such you filter out the noise a bit.
« Last Edit: May 28, 2019, 06:23:56 pm by imo »
Readers discretion is advised..
 
The following users thanked this post: nemail2

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
A common practice is to follow a switching regulator with a linear regulator. you can also create a linear regulator using an op amp, an output pass element and a shunt resistor. then the switching regulator always produces about 1v higher than the actual desired output voltage and the linear regulator cleans up the noise. the power dissipation in the LDO will be kept small too since the switch mode converter is tracking the voltage and keeping a small difference.
 
The following users thanked this post: nemail2

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
You cannot get a really clean output from such an regulator (switcher->lin regulator). The noise of the switcher is pretty high energetic such it is not to filter to the levels a single linear PSU may produce..
Readers discretion is advised..
 
The following users thanked this post: nemail2

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
You cannot get a really clean output from such an regulator (switcher->lin regulator). The noise of the switcher is pretty high energetic such it is not to filter to the levels a single linear PSU may produce..

In most cases a bulk capacitor + MLCC takes care of this issue on the input. if the noise is too high, often a CLC filter is used:


A common mode choke can also be used instead of a simple inductor to further reduce noise.
 
The following users thanked this post: nemail2

Offline nemail2Topic starter

  • Regular Contributor
  • *
  • Posts: 206
  • Country: at
oh thank you very much. now i have to spend money for two ADCs  :-DD

Sorry for the late response, didn't have much time for hobbying around recently.

I have now tested out the ADS1115 (because I already had it here, ready on a breakout board) and well.. it is more than good enough for me in differential mode (even single ended is really good). in single ended mode i get readings which are about 2mV off most of the time and in differential mode (even without any filtering, slapped together on a breadboard) I get sub-millivolt errors only, which won't be shown on the display anyway. that's definitely good enough for me.

I'm now kinda struggling to decide whether I should really use differential mode and use 2 ADCs (I need 4 channels, unfortunately) or whether I should just go with single ended configuration.

i don't think I'd want to afford the more expensive ADCs like the ADS1219, that'd be really too much, i think. especially if I had to buy two of them, let alone if I need more prototypes/revisions of my design. unsoldering those ADS1xxx to re-use them is no fun without proper rework equipment (without destroying or at least damaging them). I do only have a soldering station (at least a decent JBC one).

calibrating the DAC would be out of my capabilities as well, that's really just too high sophisticated for me and I can't squeeze it into my head, unfortunately. maybe another time, when my knowledge and skills have evolved.

i have searched for 8 channel ADCs like the ADS1xxxx series but the only ones I found were like TQFP64 style packages (although affordable, they started at about 8-9€). i don't think I want to use such a TQFP64 beast in my design...

also, i have already 4 ADS1115 lying around here (bare chips in a reel), so I wouldn't have to buy any of them, at least for the next two board revisions, if I go with the differential setup.

what do you think?

ps: differential setup would allow me to provide sense wire inputs which would go directly to the ADC's differential input pins. the + line would have the voltage divider + the series resistor for protection of course but what about the ground line? are there common protection techniques which I should utilize? what if I connect the sense lines in reverse polarity, i'd then feed way to high voltage into the completely unprotected, bare ADC pin?!

thanks again for all your advices, stuns me every time how much I can learn here and how people are willing to help.

attached two photos of the measurements which make me happy :) and how crude everything is wired together :)
Boron rhymes with moron
 

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
I would personally use the differential method, even if it means using to ADS1115 chips.
Don't bother with 8 channels for now, cost of two separate ones is the same for the most part.

About connecting the voltage backwards: it causes no issues. the ADS1xxx family are bipolar, so one of the bits is a sign bit, so it can be both positive or negative. that makes your 16 bit ADS1115, a 15 bit ADC. I'm not sure if this is intended or not, but same is true for the ADS1219. it's effectively a 19bit ADC if you look at the ENOB table provided in the datasheet. I can only imagine the names come from that.

the ADC has input protection ESD diodes built in. the only protection needed is some series resistance to the inputs. 1K should be more than good enough. in the schematic I posted earlier, RN1 and RN2 act as series protection resistors AS WELL AS being a part of the filter circuit. hitting 2 birds with one stone  ;)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf