0
\$\begingroup\$

I'm currently trying to read a sine voltage between about -5 V and +5 V at 50 Hz using an ADS1115 and a Raspberry Pi.

I'm writing the code in Python and using the Adafruit library for the ADC. I have seen different implementations with a negative voltage rail and a voltage divider that might work (if I have understood it correctly) and I also assume that it isn't a software problem.

My goal is to sample the sine wave (5 Vpp) and plot it on the monitor (I'm using Matplotlib).

If a voltage divider would work, how would I dimension it to fit the purpose? Should I even use a voltage divider? I'm having a really hard time understanding how to solve this.

\$\endgroup\$
2
  • \$\begingroup\$ @jsotola My goal is to sample the sine wave and plot it on the raspberry pi using matplotlib (I'll edit the question). Right now I can only sample the positive periods and not the negative (can go below GND-0.3V). \$\endgroup\$
    – Konrado
    Commented Dec 31, 2021 at 0:48
  • \$\begingroup\$ Does the AC share a ground with the RPi? If it does, it gets a lot trickier. \$\endgroup\$
    – DKNguyen
    Commented Dec 31, 2021 at 1:55

4 Answers 4

2
\$\begingroup\$

I would approach this a bit differently from the previous answers, given the inaccessible internal voltage reference and the optionally differential input(s) of the ADS1115 (and the nice 2's complement bipolar measurement of differential signals).

schematic

simulate this circuit – Schematic created using CircuitLab

The TL431 is used to bias the inputs well within the input common-mode range. It is not used as a reference, so voltage changes will not affect the signal. It's slightly sub-optimal to use the 2.5V reference as-is but it saves a couple resistors.

Output differential voltage is +/-1.246V for +/-5V in, so you can use the 2.048V range on the ADS1115. Differential input impedance on that range is typical 4.9M\$\Omega\$ so loading isn't very significant. Input voltages below -7.5V will go below zero V at the ADC input.


Note that even the maximum sample rate of the ADS1115 is not great for sampling a 50Hz signal- you'll get fewer than 9 samples per half-cycle typically, and there is no way of synchronizing the measurements with the input or stabilizing the sample rate since the clock is an inaccessible internal RC oscillator.

If your purpose is simply to measure the AC voltage you might be better to use a precision rectifier and low-pass filter and measure the DC output with the ADS1115. It will also require less resources than trying to process samples of the AC waveform.

\$\endgroup\$
2
  • \$\begingroup\$ The purpose of this differential voltage divider VS a traditional single-gate divider is to decrease fluctuation due to thermal effects on divider resistance? \$\endgroup\$
    – dizcza
    Commented Nov 5, 2022 at 12:44
  • 1
    \$\begingroup\$ The dividers have two purposes - to divide down the input volage and to bias the analog input(s) within the common mode range. By using the differential arrangement the reference voltage becomes much less important. Since ADS1115 does not have an externally accessible reference voltage this greatly reduces what could be a major source of error. \$\endgroup\$ Commented Nov 6, 2022 at 20:17
1
\$\begingroup\$

Below circuit ( recommended by an expert from TI, link: https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/705210/ads1115-voltage-divider-for-differential-voltage ) worked very well with ADS1115 + Arduino for bi-directional voltage measurement !! (Vcc can be 3 to 5V) It is successfully measuring as low as +/- 2V range voltages (with the same 1:200 voltage divider) with ads.setGain(GAIN_SIXTEEN) and also I able to measure higher voltages above +/- 500 V by keeping the programmable gain of ADS1115 at ads.setGain(GAIN_TWOTHIRDS)) or ads.setGain(GAIN_ONE)) enter image description here

\$\endgroup\$
0
0
\$\begingroup\$

If the RPi and AC do not share a ground, you can AC couple and DC bias to mid supply:

schematic

simulate this circuit – Schematic created using CircuitLab

But no isolation, and I assume this is mains, and I assume you got +/-5V from the mains through a stepdown transformer. If not and you used a divider, get rid of it and use a transformer. Not safe.

If you stepped it down to +/-2.5V via transformer that would be be best. Then you do not need the divider or buffer, and the 10V supply could be 5V.

\$\endgroup\$
0
\$\begingroup\$

If you want a simple solution that doesn't require opamps or other active circuits, you can offset the -5 - +5 signal with your 5V supply:

Connect your input via 10 kΩ to the ADC's input. Connect that node also to +5 V with another 10 k Ω. Now the ADC will see signals from 0 to +5 V which represent: ADC = (5V+VIN)/2

If you don't have +5 V, use +3.3, and adjust the 2nd 10k (5k would work in that case). Note this will attenuate your input (you lose 1 bit of resolution, and may add some small noise to your signal (from the 5 V supply's noise). There may also be a DC offset from variations in the 5V.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.