Shop OBEX P1 Docs P2 Docs Learn Events
Sampling a potentiometer with an ADC — Parallax Forums

Sampling a potentiometer with an ADC

David BetzDavid Betz Posts: 14,511
edited 2020-12-08 20:24 in Accessories
I'm working with the ESP8266 chip that is on the Parallax WX wifi module and I'm trying to connect an external ADS1115 chip to read an analog potentiometer. Unfortunately, the signal from the ADC is very noisy. I did a web search and found that this sort of problem can be caused by the radio on the ESP8266 drawing too much power from the power supply and generating noise on either the internal ADC or an external ADC chip. Can anyone point me to a good power supply design for the ESP8266 that will solve the ADC noise problems. I tried connecting a big 1000uF capacitor across the power supply and that helped but didn't completely fix the problem.

Also, how good are the software ADCs for the Propeller 1? I don't really need a lot of resolution to read a pot. Might that be a better choice than the ADS1115? It, of course, could be used for a lot more than just reading a pot!
«1

Comments

  • I never had any luck using the Propeller to measure a pot. Very noisy.

    I have used an MCP3202 with great success that I used with the Gimbal sold by Parallax.

    That's what I used for the Plug and Play demo.

    Mike
  • iseries wrote: »
    I never had any luck using the Propeller to measure a pot. Very noisy.

    I have used an MCP3202 with great success that I used with the Gimbal sold by Parallax.

    That's what I used for the Plug and Play demo.

    Mike
    Are you saying that the MCP3202 will work better for me than the ADS1115? I'm thinking that most if not all of the noise I see with the ADS chip is due to an unstable power supply. Maybe my topic should have been "How to create a stable power supply for the ESP8266 that will support a relatively low noise ADC input".

  • Well, the propeller generates it's own noise due to the pulsing and constant changing in current draw that using the MCP3202 made reading the resistance of the Gimbal very stable even with the constant changes in voltage.

    The ESP8266 on the other hand has a higher draw due to the 2.7 mhz WiFi connection that it has to maintain to operate. I would think that the ADS1115 would have some smoothing of the power on it's input unless your having interference from the transmitter on the ESP8266.

    Mike
  • Is it safe to use two 3.3v power supplies at the same time? For example, can I let the ESP8266's onboard power supply handle power for the ESP and then use a breadboard power supply for the ADC? Or might I run into trouble if the 3.3v levels aren't exactly the same on the two supplies?
  • Should be no problem as long as they share a ground connection.

    In my setup the ESP8266 is using the 3.3v supply while the MCP3202 is using a 5v supply.

    Mike
  • I tried using the Parallax PowerPal supply to power the ADC and the ESP module's internal supply to power the ESP8266 but I still get a fair amount of noise on the ADC. I just have a pot wired to one of the ADC inputs. The wiper on the pot is connected to the ADC pin and the other two pins are connected to 3.3v and GND.
  • That should work just fine. You don't have a scope? What kind of noise are you seeing?

    Mike
  • I have not used that chip but I see Adafruit makes a breakout board for that.

    Mike
  • I replaced the ESP8266 with another microcontroller and I still get the same noise on the ADC input so it doesn't have anything to do with the wifi radio. I must be using the ADC chip wrong. Time to read the data sheet more thoroughly!
  • Did you try hooking the input pin to a 3.3v supply and also try grounding it to see if reads correctly then.

    Mike
  • Grounding the input gives me -32 with a gain of 1. Connecting the input to 3.3v give me a value of around 25450 but it fluctuates about +/- 50.
  • That would mean that you have 7,712 units per volt. You should be able to divide out the 50 units without losing any resolution.

    Mike
  • I have put small caps across the analog input and ground before to try and smooth out readings, it seemed to work. This was for a thermistor voltage dividing circuit. I have read that this is not a good practice, however I'm not sure it matters as long a your sampling rate is low. I can't remember what value of cap I used. If I recall correctly the cap was between .1uf and 10uf.



    Shawn
  • Low cost ADCs can be noisy. In the camera control projects I work on we use the MCP320x series to read joysticks and pots. Even with that, I have a background cog that keeps provides an 8-reading running average to the foreground program. This helps. In the ESP32 you might be able to define a task that does this.
  • A lot of ADC chips don't like high impedance sources.
    I've had trouble reading 10K pots directly with ADC chips. Adding an op amp buffer really helps.

    I know I was told the same thing by someone on the forum and adding the buffer cured the troubles I was having.
  • When it comes to buffering analog signals for conversion, careful selection of the op amp is prime, even in cases the better op amp is not that cheap.

    Due to its specs, perhaps TI's OPA388 (singles; OPAx388 is the general nomenclature, spanning up to quad devices/package) can be a good choice for a try, speccialy in such a low voltage application.

    As for the price, it starts from US 2.54 (single units, @Digikey), but can come down easily to near a buck (in 1000s, @Digikey, or even lower, directly from TI), depending on package selection.
  • kwinnkwinn Posts: 8,697
    Duane Degn wrote: »
    A lot of ADC chips don't like high impedance sources.
    I've had trouble reading 10K pots directly with ADC chips. Adding an op amp buffer really helps.

    I know I was told the same thing by someone on the forum and adding the buffer cured the troubles I was having.

    Yanomani wrote: »
    When it comes to buffering analog signals for conversion, careful selection of the op amp is prime, even in cases the better op amp is not that cheap.

    Due to its specs, perhaps TI's OPA388 (singles; OPAx388 is the general nomenclature, spanning up to quad devices/package) can be a good choice for a try, speccialy in such a low voltage application.

    As for the price, it starts from US 2.54 (single units, @Digikey), but can come down easily to near a buck (in 1000s, @Digikey, or even lower, directly from TI), depending on package selection.

    Both good points. High impedance sources may not provide enough current to fully charge the ADC input capacitance, so a suitable op amp may be needed to take care of that.
  • Duane Degn wrote: »
    A lot of ADC chips don't like high impedance sources.
    I've had trouble reading 10K pots directly with ADC chips. Adding an op amp buffer really helps.

    I know I was told the same thing by someone on the forum and adding the buffer cured the troubles I was having.
    Thanks for the advice. I guess I'll look for a circuit that uses an op amp to drive the ADC.

  • Duane DegnDuane Degn Posts: 10,588
    edited 2020-11-23 04:58
    David Betz wrote: »
    I'll look for a circuit that uses an op amp to drive the ADC.

    It's pretty much the easiest OpAmp circuit there is. No resistors needed in this circuit.

    The output from the OpAmp goes to both the ADC input AND the negative feedback on the OpAmp.

    I signal you want to buffer connects with the positive feedback pin.

    Here's part of a schematic for a quad buffer.

    OpAmpBuffer.PNG

    I hope others will correct me if there's a better way.

    Edit: To be clear, the schematic shows four buffer circuits. You only need one OpAmp if you only have one signal.
    972 x 1018 - 31K
  • For what it's worth, I was using a 10K pot with a MCP3002 chip and everything worked fine. The MCP3002 is a 10-bit chip. When I switched to a MCP3208 chip (12-bits) I had trouble getting reliable readings. People on the forum made a bunch of suggestions which helped me get my circuit working again. This is when I learned about the OpAmp solution.

    The capacitor solution mentioned in this thread can sometimes work but there are a few caveats which make the OpAmp buffer a more reliable solution (based on what I've learned so far).

    I looked for the thread where all this was discussed without any luck.
  • Just digging a bit deeper (and cheaper), I believe I've found another good alternative for an ADC input-buffer amplifier.

    https://ti.com/product/OPA325

    At its datasheet, there is enough information at the application section, in order to drive you safely, towards getting the results you want.

    Hope it helps
  • David BetzDavid Betz Posts: 14,511
    edited 2020-11-26 02:51
    I see that the ADC I've been trying to use has this feature. Could this be used instead of the op-amp?
    The ADS1114 and ADS1115 also integrate a programmable gain amplifier (PGA) and a programmable digital comparator.
    I've been using the ADS1115.
  • YanomaniYanomani Posts: 1,524
    edited 2020-11-26 12:38
    Given you're using a potentiometer with the endpoints connected between 3.3V and GND (and an ADS1115), with its wiper routed to one of ADC's inputs (AIN[3:0]), you should configure the input MUX section properly, routing the chosen input to AINp (positive input of PGA's), and GND to AINn (negative input of PGA's).

    You'll also need to configure PGA's FSR to +-4.096V, in order to get a proper range.

    Since the common-mode input impedance of the amplifier is way high (6MOmh, typical) at both the +-4.096V and +-2.048V ranges, you can also craft a suitable resistive divider, in order to attain a total excursion near 2.2V 2.0V (easy with commonly available resistor values), and set PGA's FSR to +-2.048V, in order to max resolution.

    By properly selecting divider's resistors values (and percent tolerance; precision ones are better), you can get even closer to 2.048V, and enjoy ADC's maximum resolution, but then you will be depending on voltage regulator's precision.

    There will be ever some trade-offs to consider. :smile:
  • Looking at TI's support forums, it appears your problem is very similar to one of the already solved cases.

    I'm just wondering how to apply it to you exact problem, without having to resort to any external op amp, since reading thru TI's forum posts and comparing the stated solution to available information at the datasheet, still shows that programming the internal PGA will not be enough to get rid of ADS1115's sensibility to more than ~1kOmh of input inpedance.

    Unless the potentiometer you'd selected has indeed a low resistance, IMHO you'll still need to select a suitable low noise, rail-to-rail operational amplifier, with all its surruounding bells and whistles, in order to get the samplings.

    https://e2e.ti.com/support/data-converters/f/73/t/696357?ADS1115-voltage-divider-measurement
  • Duane Degn wrote: »
    David Betz wrote: »
    I'll look for a circuit that uses an op amp to drive the ADC.

    It's pretty much the easiest OpAmp circuit there is. No resistors needed in this circuit.

    The output from the OpAmp goes to both the ADC input AND the negative feedback on the OpAmp.

    I signal you want to buffer connects with the positive feedback pin.

    Here's part of a schematic for a quad buffer.

    OpAmpBuffer.PNG

    I hope others will correct me if there's a better way.

    Edit: To be clear, the schematic shows four buffer circuits. You only need one OpAmp if you only have one signal.
    I'm finally getting back to this. What opamp do you recommend?

  • David Betz wrote: »
    What opamp do you recommend?

    I don't know enough about opamps to know which one is a good choice for this application.

    You're probably safe to use one of the ones suggested by Yanomani.

    Here's a dual OPA2388 opamp in a SOIC package on Mouser (an early recommendation by Yanomani).

    Here's a link to a OPA325 Yanomani also recommended.

    I case anyone wasn't sure what Yanomani meant by
    OPAx388 is the general nomenclature, spanning up to quad devices/package

    You substitute "x" with the number of channels. The chip I linked earlier is OPA2388 and has two opamps in the chip. An OPA4388 has four opamps per chip. The single opamp chip of this type is the OPA388.

    Just as the OPAx388 may have different numbers of channels, the OPAx325 uses the same sort of naming convention. Here's a four channel OPA4325.

    I don't think I've used any of the chips listed above myself but I don't have any reason to think they wouldn't work well for this application. I've used the OPA4317 chip before but I didn't design the circuit in which it was used and I don't know why that particular opamp had been selected.
  • Sorry. The one he recommended was a surface mount chip. At present, I'm looking for a through-hole chip so I can work with it on a breadboard. I have some LM324N chips. I might just try one of those.
  • David BetzDavid Betz Posts: 14,511
    edited 2020-12-08 20:26
    I tried using the LM324N opamp and it didn't help. Also, I notice that the noise increases if I touch the pot. Not sure where to go from here.
  • Shawna wrote: »
    I have put small caps across the analog input and ground before to try and smooth out readings, it seemed to work. This was for a thermistor voltage dividing circuit. I have read that this is not a good practice, however I'm not sure it matters as long a your sampling rate is low. I can't remember what value of cap I used. If I recall correctly the cap was between .1uf and 10uf.
    Did you try putting a capacitor between the input and ground like Shawn suggested? You should also have a bypass cap between power and ground on the ADC chip.

  • Dave Hein wrote: »
    Shawna wrote: »
    I have put small caps across the analog input and ground before to try and smooth out readings, it seemed to work. This was for a thermistor voltage dividing circuit. I have read that this is not a good practice, however I'm not sure it matters as long a your sampling rate is low. I can't remember what value of cap I used. If I recall correctly the cap was between .1uf and 10uf.
    Did you try putting a capacitor between the input and ground like Shawn suggested? You should also have a bypass cap between power and ground on the ADC chip.
    Yes, I added a .1 uf cap between the pot wiper and ground.

Sign In or Register to comment.