Expanding analog inputs

Rasmus Godske

Member
Joined
Jun 7, 2018
Messages
39
I'm currently working on my 18650 Tester which are able to charge/discharge and make read the internal resistance. This means I need to read a lot of analog signals, three per cell to be exact.

I amusing a ESP32 with limited amount of ADC GPIO pins, so I havecome up with a potential solution.

To expand my analog pins Iamusingmultiple8-channel analog multiplexer/demultiplexer called74HC4051. For each 74HC4051 I can map 8 analog inputs to one ADC pin. My problem is that those analog signals from the 18650 batteries can reach 4.2V, and the ESP32 is 3.3V, so I have to usea voltage divider on the output of the 74HC4051. The circuit can be seen in figure 1 below.
When using a voltage divider on the output of the IC, the voltage at the output of the 74HC4051(Z) is ~200mV lower than than the Cell voltage. Thereforethe measured voltage to meassured by the ESP would be wrong. I have tried analysing it with my oscilloscope which can beseen in figure 2.

When I disconnect ground in the voltage divider as seen in figure 3, the voltage drop across the IC is gone, which can beas seen in figure 4.


My guess is that the 74HC4051, have a resistance as well, and therefore also takes part in the voltage divider and my question is how can I convertthe voltage from 4.2V to 3.3V, in my case, without having a to use a voltage divider on every single analog input? Could it be done with an OP-amp?

All help is highly appreciated :)


Circuit 1:

[img=600x256] Figure1: With the voltage divider

[img=600x260] Figure 2: Osciliscope of circuit with voltage divider. C1(Yellow) is the Cell Voltage andC2(Blue) is voltage at Z




Circuit 2:

[img=600x253] Figure 3: Without the voltage divider, or it's not grounded.


[img=600x259]
Figure 4: Osciliscope of circuit with voltage divider. C1(Yellow) is the Cell Voltage andC2(Blue) is voltage at Z
 
A couple of things to check:
1. Does the ADC connection go anywhere other than the oscilloscope during your test.
2. Have you checked the resistor values are the stated values using a multimeter.
3. Do you get the expected result (1.2V ish) if the take the ic out of circuit and connect the potential divider directly to the cell voltage?
 
Have you thought of adding an external ADC with many inputs instead? They are cheap and work via SPI or other protocol. Thats how I have done it here to bypass below problem :D

I have not had time to dig into that one and I dont know the specs of it either. But many of the muxes wont let through voltage 1:1 in to the other end. It have electronics inside that have drops over. You basically need one that is 1:1 voltage ref based instead.
 
watts-on said:
A couple of things to check:
1. Does the ADC connection go anywhere other than the oscilloscope during your test.
2. Have you checked the resistor values are the stated values using a multimeter.
3. Do you get the expected result (1.2V ish) if the take the ic out of circuit and connect the potential divider directly to the cell voltage?

I have double checked that there aren't any misplaced connection, also that the resistor values are as expected, and the voltage divider does work as expected if it's isolated. I'm pretty confident that the problem is that when grounding the R2 to the ground, the voltage divider actually consist of three resistors instead of only two. So it's the Resistance in the IC in series with R1 and R2.

daromer said:
Have you thought of adding an external ADC with many inputs instead? They are cheap and work via SPI or other protocol. Thats how I have done it here to bypass below problem :D

I have not had time to dig into that one and I dont know the specs of it either. But many of the muxes wont let through voltage 1:1 in to the other end. It have electronics inside that have drops over. You basically need one that is 1:1 voltage ref based instead.

Well actually I am not using the analog pins on the ESP, but instead a ADS1115, which uses I2C and it works great. The problem is that to measure voltages at 4.2V it needs a higher VCC voltage, and the SCL and SDA pins are dependant on the VCC voltage. So the SCL and SDA aren't 3.3V, therefore i would need a logic converter for each ADS1115 I am using.
I decided not to mention external ADC, because that wasn't the problem in my case :p
 
So you want to multiplex to the ADS1115? I would just hook up more of those instead :D And of course voltage divide the inputs on them.
I would love to see how you can multiplex and measure voltage easily like that. I never found a cheap and working solution so i went with multiple 1115 instead.

You can have 4 of them on same bus and that would be 16 channels in total. But yeah it should be cheaper with a multiplexer. Hmm I will dig into my old projects I think i have some examples somewhere
 
daromer said:
So you want to multiplex to the ADS1115? I would just hook up more of those instead :D And of course voltage divide the inputs on them.
I would love to see how you can multiplex and measure voltage easily like that. I never found a cheap and working solution so i went with multiple 1115 instead.

You can have 4 of them on same bus and that would be 16 channels in total. But yeah it should be cheaper with a multiplexer. Hmm I will dig into my old projects I think i have some examples somewhere

Yeah, my first plan was to use multiple ADS1115 as well, and went pretty fare with it, until i realised that they can only have 4 different addresses haha


Then I found the 74HC5041 which gives 8 times more inputs per analog pin the ADS1115 have, so with oneADS1115 and four 74HC5041 you can read upto 32 signals :p

And using 4 of these setup you have 128 analog pins in total, which is 42 cells to be tested at oncein my setup at least.

I have already started making the schematics for it:here, if you are interrested :)

I just need to find a solution for this problem that I have atm.
 
Ah ok :) I dont have a straing answer on the multiplex part more than I know it is an issue to be able to get a straight 1:1 voltage in and multiplex it. Potentially its cheaper to set 1 uC per 4 1115?. Yeah it gets complex doing that though...
 
RasmusGodske said:
I'm pretty confident that the problem is that when grounding the R2 to the ground, the voltage divider actually consist of three resistors instead of only two. So it's the Resistance in the IC in series with R1 and R2.

Hmm I think if that were the case then you would get a result that is lower in voltage than expected not higher.
What voltage do you see at the Z pin during that Figure 2 screen shot?

Edit:
Sorry I just re-read your top post and you are showing the Z pin. So what voltage did you see at the ADC connection?
 
Like you've suggested, the issue is the loading of the resistors on the output of the 74HC5041.
at 4.2V, the 2.5k load ie about 1.6mA, is quite high.
The spec sheet I found shows it has an internal on resistance of about 80 ohms at 4.5V & this also changes (rises) as the voltage drops (ie make measurements like this worse).
It also varies per input of the mux...
So that explains the voltage difference you're seeing.

You need a buffer between the 74HC5041 output & the resistor network like eg an op amp.
If you come out of the 74HC5041 & into the +ve input of an op amp & connect the op amps output to the -ve input it will track the input with minimal error & buffer it nicely for you.
eg a NE5230, LM358, etc

You could also change your resistor divider to be eg 10k & 15k or even 100k & 150k for R1 & R2. I couldn't quickly find what the input impedance on the ESP32 ADC pin is & this would be a factor here.
Changing the resistors alone would reduce errors but still have a significant error.
 
The ESP32 has 2x I2C, so that would help get you to 4 ADS1115's.

Or, you could go with a TCA9548A 1-to-8 I2C multiplexer (Texas Instruments). Adafruit has a breakout for this IC

Here's a list of I2C mux's, as well
http://www.ti.com/interface/i2c/switches-and-multiplexers/products.html

Note: I didn't read "all" of the above suggestions, so I2C mux may have been mentioned. If so, my apologies ;)
 
daromer said:
Ah ok :) I dont have a straing answer on the multiplex part more than I know it is an issue to be able to get a straight 1:1 voltage in and multiplex it. Potentially its cheaper to set 1 uC per 4 1115?. Yeah it gets complex doing that though...

Oh okay, yeah it would be way cheaper, and very easy to expand if needed. I think the 1:1 voltage solution would be a voltage follower with an OP amp, as Redpacket also suggest.

watts-on said:
RasmusGodske said:
I'm pretty confident that the problem is that when grounding the R2 to the ground, the voltage divider actually consist of three resistors instead of only two. So it's the Resistance in the IC in series with R1 and R2.

Hmm I think if that were the case then you would get a result that is lower in voltage than expected not higher.
What voltage do you see at the Z pin during that Figure 2 screen shot?

Edit:
Sorry I just re-read your top post and you are showing the Z pin. So what voltage did you see at the ADC connection?

Don't quite remember, but when calculating back what the Vin, I did get the same result so that part worked as expected I would guess.

Redpacket said:
Like you've suggested, the issue is the loading of the resistors on the output of the 74HC5041.
at 4.2V, the 2.5k load ie about 1.6mA, is quite high.
The spec sheet I found shows it has an internal on resistance of about 80 ohms at 4.5V & this also changes (rises) as the voltage drops (ie make measurements like this worse).
It also varies per input of the mux...
So that explains the voltage difference you're seeing.

You need a buffer between the 74HC5041 output & the resistor network like eg an op amp.
If you come out of the 74HC5041 & into the +ve input of an op amp & connect the op amps output to the -ve input it will track the input with minimal error & buffer it nicely for you.
eg a NE5230, LM358, etc

You could also change your resistor divider to be eg 10k & 15k or even 100k & 150k for R1 & R2. I couldn't quickly find what the input impedance on the ESP32 ADC pin is & this would be a factor here.
Changing the resistors alone would reduce errors but still have a significant error.

I tried changing the resistors to 100k and 150k, but the error was still too high for it's purpose. I will go to my school tomorrow and see if I can find a suitable op amp, and do as you suggested. That seems as the good solution :D
 
Just for added info:
http://www.ti.com/product/tca9548a/datasheet said:
1-to-8 Bidirectional Translating Switches
I2C Bus and SMBus Compatible
Active-Low Reset Input
Three Address Pins, Allowing up to Eight TCA9548A Devices on the I2C Bus
Channel Selection Through an I2C Bus, In Any Combination
Power Up With All Switch Channels Deselected
Low RON Switches
Allows Voltage-Level Translation Between 1.8-V, 2.5-V, 3.3-V, and 5-V Buses
No Glitch on Power Up
Supports Hot Insertion
Low Standby Current
Operating Power-Supply Voltage Range of
1.65 V to 5.5 V
5-V Tolerant Inputs
0- to 400-kHz Clock Frequency

$1.55USD from DigiKey/Mouser

ESP32 I2C (x2) -> TCA9548a (x8) (8x channels) -> ADS1115 (x4)

2 * 8 * 4 * 8= 512 connected devices
 
Korishan said:
Just for added info:
http://www.ti.com/product/tca9548a/datasheet said:
1-to-8 Bidirectional Translating Switches
I2C Bus and SMBus Compatible
Active-Low Reset Input
Three Address Pins, Allowing up to Eight TCA9548A Devices on the I2C Bus
Channel Selection Through an I2C Bus, In Any Combination
Power Up With All Switch Channels Deselected
Low RON Switches
Allows Voltage-Level Translation Between 1.8-V, 2.5-V, 3.3-V, and 5-V Buses
No Glitch on Power Up
Supports Hot Insertion
Low Standby Current
Operating Power-Supply Voltage Range of
1.65 V to 5.5 V
5-V Tolerant Inputs
0- to 400-kHz Clock Frequency

$1.55USD from DigiKey/Mouser

ESP32 I2C (x2) -> TCA9548a (x8) (8x channels) -> ADS1115 (x4)

2 * 8 * 4 * 8= 512 connected devices

I have thought about doing using the TCA9548a, but think it is above my student budget. Even though it sounds pretty awesome to be able to have that many cells tested at once :p Maybe when I find a better supply of cells and got time to work some more :)


Just a small update.
After doing some testing with the LM358, I figured out that it can't output a voltage above 3.7V with the V++ set to 5V. Or at least I need to choose some resistors other than
100k ->150k ohm resistors. So I will try finding another one.


[img=300x319]
 
Rasmus Godske said:
I have thought about doing using the TCA9548a, but think it is above my student budget. Even though it sounds pretty awesome to be able to have that many cells tested at once :p Maybe when I find a better supply of cells and got time to work some more :)

Well, you don't "have" to have that many connected ;)
Get 1 TCA IC to start with, and then expand from there.

The biggest issue with the voltage dividers is that the resolution is a sliding scale, and noisy. That's why I decided to not go that route with my design
 
Back
Top