EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: AxisCat on January 22, 2024, 03:38:47 pm

Title: Help with ADC Converter
Post by: AxisCat on January 22, 2024, 03:38:47 pm
Hi All,

This is my first time working with an ADC, I purchased this an Adafruit 4-Channel ADC based on the TI ADS1015 chip. 

https://learn.adafruit.com/adafruit-4-channel-adc-breakouts (https://learn.adafruit.com/adafruit-4-channel-adc-breakouts)

Here is a picture of it:
(https://i.postimg.cc/L6JjqmgG/ADC.png) (https://postimg.cc/0bqzFRfC)

The (4) pigtail wires are soldered directly to the analog in channels on the board.  When I run it in single-ended mode just like you see pictured I am getting a voltage reading on all four channels:

(https://i.postimg.cc/CKbyHZdt/reading.png) (https://postimages.org/)

When I run it in differential mode it bounces around between a fraction of a millivolt or two.  I have spent the last several days researching things, especially causes of noise and I am still stuck on why I get a reading when the wires are not attached to anything?

Can someone give me a nudge in the right direction?

Thanks!
Axis





Title: Re: Help with ADC Converter
Post by: Kleinstein on January 22, 2024, 04:02:24 pm
The ADC is not made to be used with open inputs. There is not defined voltage and it can easily pick up mains hum. For a test one would more connect the input to ground.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 22, 2024, 04:16:01 pm
Thanks for the reply and that makes sense.  I did have it hooked up to my project (differential mode) and was getting very noisy readings which is why I thought I would start with the bare minimum and move up to finding the source of the interference.  I will hook it back up and work with it some more.  Hope I can reach back out if I get stuck again.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 22, 2024, 05:01:12 pm
I guess my mistake was I thought this ADC would work like a DMM.  Using my DMM i had stable measurements from a few millivolts up to the max of about 3 volts I was measuring.  I understand I need to determine the source of the noise before I can address it.  Do you have any suggestions on how I can start?  With my limited experience I don't even know if that is a reasonable question to even ask.
Title: Re: Help with ADC Converter
Post by: MarkT on January 22, 2024, 07:42:56 pm
Most ADCs require a low impedance source, typically an opamp follower, to drive them due to all the switched capacitance involved during conversion.

Some ADCs have built-in opamps which can simplify things.

Without low impedance sources you can also get crosstalk between inputs with a multiplexed ADC.

One way to lower the dynamic impedance on an ADC input is with a capacitor to ground - of course this only works well for low frequency signals.  100nF is usually enough.

Mine the datasheet for suggested circuits, often that's the route to trouble-free use of a chip.
Title: Re: Help with ADC Converter
Post by: Zero999 on January 22, 2024, 11:27:01 pm
The ADS1015 has a programmable gain amplifier on the input, which will internally connect the ADC to a low impedance source.

It sounds like an issue with the common mode range being exceeded. The issue with connecting an input to ground is, it would mean that negative voltages, would take the other input negative, which will cause problems. It's better to bias the inputs to half the supply voltage, so both positive, as well as negative voltages can be measured. Connect a high value resistor, try 1M, from both power supply rails to one of the inputs, it doesn't matter whether it's the - or +. That will ensure said input sits at half the power supply voltage.
Title: Re: Help with ADC Converter
Post by: Kleinstein on January 23, 2024, 11:58:47 am
The PGA in the ADS1015 and many other SD ADCs is not a real amplifier, but realized by more frequent sampling of the input. One can see this from an input impedance that goes down with gain.
In addition to the average impedance, the input current is in pulses to charge sampling capacitors. If the source is not low impedance there should be added capacitance - though the right choice here can be a bit tricky and effect the linearity. So one would still want a reasonable low impedance signal source. For the differential mode this also means a DC path to ground, not just a connection between the 2 inputs. With chip internal clamping diodes it may work with only the signal between the differential inputs, but not guaranteed and possibly with added errors.

Even with a real amplifier at the input one would still need a defined voltage to make sense of the result. The readings with an open input are just not relevant and not need to worry about this.
Title: Re: Help with ADC Converter
Post by: iMo on January 23, 2024, 12:09:58 pm
First step to get an advice is to show your schematics.
How are the inputs of your 1115 wired.
This is how people here communicate the technical details..
Title: Re: Help with ADC Converter
Post by: MarkT on January 24, 2024, 11:17:28 am
The PGA in the ADS1015 and many other SD ADCs is not a real amplifier, but realized by more frequent sampling of the input.
That's not what the datasheet says - it has a differential PGA before the sigma-delta ADC.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 24, 2024, 02:14:39 pm
Hi All,

I will post a complete schematic of what I am doing a bit later so everyone can see.  I have been playing around with low pass RC filters along with smoothing in software and the results are promising.

Thanks!
Title: Re: Help with ADC Converter
Post by: AxisCat on January 24, 2024, 04:14:00 pm
It is a bit messy but here is my schematic.  The power supply was a kit I bought from Jamco.  I am running it at +/- 10 volts.  The MCU is powered via a USB cable from my PC.  At the moment I am running single end on A0.

(https://i.postimg.cc/Hx36MD6p/diagram.png) (https://postimg.cc/2bbdpJpJ)multi hosting (https://postimages.org/)
Title: Re: Help with ADC Converter
Post by: AxisCat on January 24, 2024, 06:25:12 pm
I can sorta visualize how the low pass filter between my signal and ADC works.  The cutoff frequency is about 7hz.  With being that low would it not filter out AC main hum?
Title: Re: Help with ADC Converter
Post by: Kleinstein on January 24, 2024, 07:11:07 pm
With low pass filter will reduce mains hum, but it is still only a 1st oder low passe and thus an attenuation factor of some 7 or 14 for 50 / 100 Hz.
A similar, additional filter action can be obtained from a larger capacitor (e.g. 1 nF) at the TIA in parallel to the 20 M.

The more effective way to suppress hum is averaging over a number of ADC readings to cover a multiple of 20 ms, so some 66 readings or a multiple of this with a 3300 SPS reading rate.
Depending on how good the frequencies match, the suppression may well reach a factor of 100 to 1000  (0.1% error in the frequency).

It still makes sense to have both the analog low pass filter and the suppression by integration of a multiple of mains periods, as one has to get the hum small enough, not to get saturation for the single readings or signal in bettween. The analog low pass also help with some other noise.

The PGA in the ADS1015 and many other SD ADCs is not a real amplifier, but realized by more frequent sampling of the input.
That's not what the datasheet says - it has a differential PGA before the sigma-delta ADC.

The datasheets shows the PGA in a functional block diagram - so there is a PGA functionality, but this tells nothing about how this function is realized. On a quick look I have not found an exlicite mentioning how this is done, but there are tell tale signs that this uses more frequent sampling: the input impedance goes down with more gain and the accuracy for the gain is rather good, with simple powers of 2 for the gain.  It is common to find this version of PGA. E.g. the ADS1213 explicitely explains using the more frequent sampling to get similar gain steps.
Title: Re: Help with ADC Converter
Post by: Manul on January 24, 2024, 07:22:17 pm
So from the photo I see that you soldered wires to A0-A3 and I understand that you want to use these as single ended channels. In any single ended signal chain ground is critical, because everything else is measured relative to it. How you connected your ground? Have you noticed, that this module's GND is not ADC GND? There is ferrite bead in between. ADC ground is actually called A-, you should use that. You also should ensure that no other currents except signal is flowing through that ADC ground connection.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 25, 2024, 01:36:10 am
Thanks for the help and I did not pickup on that A- is the ADC ground.  My initial plan was to run differential mode but I don't know what I would gain from that, maybe you can advise me.  So I need to ground A- correct?
Title: Re: Help with ADC Converter
Post by: AxisCat on January 25, 2024, 01:50:25 am
Thanks for sticking with me on this.  At one time i did have a larger feedback capacitor and the circuit started ringing.  I don't remember the exact value I was using.  I did a fair amount of reading on to select the feedback capacitor but to be honest it wasn't very clear to me so I used a spreadsheet I downloaded:
(https://i.postimg.cc/NF1P7GF5/TIA.png) (https://postimages.org/)
This stabilized the circuit.  But I can try a 1nf to see what it does.

Also the averaging I did in the software was just a simple running average of 20 values taken 50ms apart.  But it was as close to magic as I have ever seen in bringing dark signal down to a stable < 1 mV.  Really cool.
Title: Re: Help with ADC Converter
Post by: dobsonr741 on January 25, 2024, 02:47:43 am
Powering the opamp from +/-10V can send the same voltage to the ADC. You have a current limiting 2.2K, so you are within the absolute maximum 10mA. It’s not a precision device, and it’s cheap - so allowing the ESD protection diodes to conduct is forgivable.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 25, 2024, 03:29:39 am
Thanks for the reply.  I have to be very careful that I don't send too much voltage to the ADC because it can send close to the full 10 volts if I allow it to see ample light.  In my project the signal is very weak and it takes the 20M resistor just to get it up to close than 3 volts.  The 2.2k resistor is part of my RC filter so I didn't think of it in terms of a current limiting device.  I admit I am struggling with a lot of aspects on this project. 

But since you brought it up I have thought about what would be the ideal voltage to run the TIA at.  Looking at the data sheet is shows 10 volts typical so that is what I chose.  Here is a link to the photodiode module:
 https://www.lasercomponents.com/de/?embedded=1&file=fileadmin/user_upload/home/Datasheets/luna/si-pin/det-amp-no-fr/sd100-42-22-231.pdf&no_cache=1 (https://www.lasercomponents.com/de/?embedded=1&file=fileadmin/user_upload/home/Datasheets/luna/si-pin/det-amp-no-fr/sd100-42-22-231.pdf&no_cache=1)
Title: Re: Help with ADC Converter
Post by: radiolistener on January 25, 2024, 10:51:34 am
Thanks for the reply and that makes sense.  I did have it hooked up to my project (differential mode) and was getting very noisy readings which is why I thought I would start with the bare minimum and move up to finding the source of the interference.  I will hook it back up and work with it some more.  Hope I can reach back out if I get stuck again.

In order to reduce noise, you're needs to power ADC module from low noise PSU and use wire pair (GND+signal) for every input. Don't use GND from MCU module, you're needs to provide signal source with ground from ADC module and keep signal and ground wires close as a pair in order to reduce receiving RFI on the wires.

For better noise isolation, there is needs power filter for ADC, buffer to isolate noise through data lines and special measures for wires layout. But with external module it's almost impossible to keep noise stable and low enough, because it uses wires with flexible geometry, which will receive a lot of noise from environment.
Title: Re: Help with ADC Converter
Post by: Manul on January 25, 2024, 11:35:44 pm
Thanks for the help and I did not pickup on that A- is the ADC ground.  My initial plan was to run differential mode but I don't know what I would gain from that, maybe you can advise me.  So I need to ground A- correct?

No, you don't need to ground A-, it IS ground, ADC ground. You need to use it as your signal ground. So for instance, in the schematic diagram which you posted, 10uF capacitor (your low pass filter) should be connected to A- and your amplifier ground should also be connected to A-. Hopefully it makes sense.

Ground is just a concept, you may call any point "ground" if you want. So there may be multiple "grounds" in a circuit. In signal processing circuits there are usually two, which we call digital ground (or simply ground) and analog ground, abriaviated GND and AGND. Ground (in other words - point of reference) for single ended analog signals must be clean from noise, that's why it is separated. Any other currents should ideally never flow through that path. It is sometimes difficult to avoid other currents to flow and ground loops. That is where differential mode shines. But it is quite possible to make decent single ended systems too if we follow best practices and know basic rules.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 26, 2024, 11:37:45 am
10uF capacitor (your low pass filter) should be connected to A- and your amplifier ground should also be connected to A-. Hopefully it makes sense.

Yes, that makes perfect sense.  I appreciate everyone's help as I only have a couple of months of really trying to understand this stuff.

I am going to move on to differential mode now which was my intention from the start.  I guess I expected this ADC to read voltage 'out of the box' like my DMM does and wasn't understanding why the ADC was so noisy.   Maybe because the DMM's power is isolated (9v battery?)

Zero999 mentioned earlier in a reply about negative voltage messing with the ADC and biasing one input to halfway between the power rails would resolve this. 
Connect a high value resistor, try 1M, from both power supply rails to one of the inputs, it doesn't matter whether it's the - or +. That will ensure said input sits at half the power supply voltage.

I need to investigate what he was saying to do so I understand it more clearly
Title: Re: Help with ADC Converter
Post by: MarkT on January 26, 2024, 01:11:26 pm
DMM's use dual-slope integration to do analog->digital conversion, so their effective noise bandwidth is close to 1Hz, whereas many ADC's have a bandwidth measured in MHz, so the noise power is 6 orders of magnitude greater for an ADC, but they can measure many orders of magnitude faster as a result.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 26, 2024, 02:00:44 pm
Gotcha... so for my application speed is not an issue.  I can take whatever amount of time i need for a measurement within reason.  Like 2-5 seconds.  Based on this what would your recommendation be for filtering?
Title: Re: Help with ADC Converter
Post by: MarkT on January 26, 2024, 02:26:17 pm
RC filter with R*C = 1.44 * settling time / bit resolution.

So for 12 bit, R*C ~= 0.6, so maybe 560k and 1µF
Title: Re: Help with ADC Converter
Post by: AxisCat on January 26, 2024, 04:15:01 pm
Thanks for the formula... that helps a lot
Title: Re: Help with ADC Converter
Post by: Manul on January 26, 2024, 04:31:08 pm
I am going to move on to differential mode now which was my intention from the start.  I guess I expected this ADC to read voltage 'out of the box' like my DMM does and wasn't understanding why the ADC was so noisy.   Maybe because the DMM's power is isolated (9v battery?)

It can work as a multimeter. It is a mere 12 bit converter, if you get high noise, certainly you are doing something wrong. Not to criticise you, but it's probably a combination of using wrong ground, plus connecting everything willy nilly on the breadboard, plus maybe some common mode currents in your signal path due to power supply or something.
Title: Re: Help with ADC Converter
Post by: Kleinstein on January 26, 2024, 05:37:37 pm
The ADS1015 is a 12 bit ADC only, but the picture shows a PCB with the 16 bit brother ADS1115, that would be the much better choice.
These are both SD ADCs and are thus also kind of integrating. With no large pause between the conversions they can even have an advantage when it comes to the noise BW. One may want to do some extra averaging to get closer to a full number of main cycles, if mains hun is an issue. This could reduce the noise quite a bit.

For a test it could help to record the data at a resonable high speed and check if one can see the mains hum part. The ADCs are fast enough for this. This would also give a hint on the actual speed of the units.

The purpose of analog filtering would mainly be to avoid too much hum so that it could cause clipping or reduce the available range or ADC internal gain. To avoid extra noise from the resistor and loading effect from the ADC, I would not make the resistor too large. So I would avoid more than some 100 kOhms. The main low pass filtering can come from digital filtering by averaging.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:07:37 pm
The more I work with this the more I understand it.  I don't think I am exactly there yet.  Here is my latest schematic based on differential measurements on the ADC:

(https://i.postimg.cc/3N8qWQ6j/diagram.png) (https://postimages.org/)www keyboard (https://keyboardtester.co/keyboard-tester)

I am also running a software filter that takes a measurement every 20ms and averages them over a total of 66 values.  Here is the output I get.  The Y-axis is in milivolts. So that is +/- .05 mV. 

(https://i.postimg.cc/fy7Bcq4z/chart.png) (https://postimages.org/)

Can you all let me know what I need to change next?

Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:10:42 pm
Sorry, typo on the diagram... I do have the 16 bit ADS1115 version.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:15:15 pm
Thanks for the reply.  I was just making a comparison between my volt meter and this ADC.  My goal is read voltage from the photodiode module say 0 to the max the ADC can handle for decent dynamic range.

I understand the breadboard is really terrible.  I am just trying to get a feel for things before I do some proper permanent connections. 
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:18:58 pm
It is obvious I am struggling with some understanding here.  I just haven't had much experience with it and I am trying my best to learn.  I have learned a lot from this thread so I want to thank everyone for that.
Title: Re: Help with ADC Converter
Post by: JustMeHere on January 27, 2024, 07:31:31 pm
Are you twisting your leads around each other?  This can help noise.

Also, try a 20-100 nF or so cap across the inputs.
Title: Re: Help with ADC Converter
Post by: Kleinstein on January 27, 2024, 07:33:16 pm
The current number show a peak to peak noise of some 0.05 mV which already looks quite good. Of cause this depends on the FS range choosen for the ADC - chances are one would use a +-2 V or maybe +-4  V range.

The photodiode part is likely rather sensitive to mains hum, either electric and optically via the modulation of light sources with 120 Hz.

For hum suppression it makes sense to average multiple readings - ideally with no extra waiting time in between, just the speed how they come in from the ADC in free running mode. It looks like the slow modes are limited by the 16 bit resoultion / quantization. So it may make sense to not use the absolute slowest mode of the ADC but better use a higher speed and average a few more readings to cover the whole time.  Before I accidentily assumed 50 Hz mains - so the target for the integration is a multiple of 20 ms as mains period, but 16.67 ms for a 60 Hz country.
It may also make sense to measure fast enough (e.g. 860SPS)  to resolve the 60 / 120 Hz, so one knows how much hum is actually there to start with. For this a smaller capacitor for the analog filter would be needed.
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:49:31 pm
I haven't done any twisting yet but actually planned on it once I get a workable circuit.  Thanks for the reply
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 07:54:39 pm
Good stuff.  We are 60 hz.  And I was thinking about the AC light source.  Wish it was DC but can't afford that kinda setup with.  I had thought about using a trigger and interrupt to sync the light source with ADC before I new I needed to do all this averaging.  Lots of learning going on still.
Title: Re: Help with ADC Converter
Post by: JustMeHere on January 27, 2024, 08:51:10 pm
I haven't done any twisting yet but actually planned on it once I get a workable circuit.  Thanks for the reply

Twisting is incredibly important. The two wires are magnetically coupled.  The more area that magnetic field covers, the more noise you will produce and receive.  The noise you produce will interfere with the ADC.

You want your lead wires touching as much as possible.  On PCBs the two traces will be next to each other and the same length. 
Title: Re: Help with ADC Converter
Post by: AxisCat on January 27, 2024, 09:06:17 pm
I think I have my final circuit figured out.  Just throwing this out there, I can make the signal wires from the photodiode module to the ADC very short, say like 1" maybe a lil less.  Would that help?  Or short conductors along with twisting? Twisted cable with a shield?? Maybe mount the entire thing in a metal enclosure?  Just brain storming some.
Title: Re: Help with ADC Converter
Post by: Kleinstein on January 27, 2024, 10:17:54 pm
A short cable from the sensor helps. The signal from the sensor is anyway not that sensitive, as it is a low impedance signal. No need for shielding as the signal is not sensitive to capacitive coupling anyway. A simple shield helps litte against magnetic coupling. This needs a small area / twisting and with a short distance it should not be that bad even if not twisted.
Title: Re: Help with ADC Converter
Post by: JustMeHere on January 28, 2024, 05:14:25 am
If it's short then don't worry so much about twisting.  Twisting helps keep the wires close together more than anything.  (In this application at least)
Title: Re: Help with ADC Converter
Post by: AxisCat on January 28, 2024, 04:31:51 pm
Just wanted to thank all the fine folks here with helping me out.  I was able to do my first measurement run.  Basically it is a VB program that controls both my monochromator and the MCU that reads the ADC.  It steps through a range of light wavelengths and records the intensity as read by the photodiode.

(https://i.postimg.cc/fLKYkTPR/light.png) (https://postimages.org/)