I get a bit riper 87 yrs young.
Those readings are a bit strange. That 791mV seems nonsense. All the battery voltages add up nicely at 3.33V per cell and your measurement of cell 1 is OK at 3.33V (3 dec places is also a bit questionable in practise, 2 will do)
BUT if you do a couple of sums at batt 4, 791mV is the error, expected 3.33V, measured 2.539V, this plus 791mV = 3.3V. All very strange. I would have expected the voltage measured across the 3k resistor to be 10.02 or in round figures close to 10V. Measure the other dividers and see if you get similar results. Like measuring the error instead of the actual voltage drop.
There is something fundamentally wrong here. Either with your circuit or connections, resistor values, connection problems (dry solder joints etc) or measurement techniques. I might be able to lash up a set of batteries to try and see what is happening but I don’t think I can find 4 (I might be able to try AAAs). The suspicious bit is that you seem to have measured the exact error voltage across the 3k resistor instead of 10V. Just how this happens I don’t know. I think I would need to have the set up in front of me and do some digging. Try doing those voltage readings again with the ADC disconnected. There may be some funny currents floating around but just at the moment I can’t see it. It would be nice to be able to measure currents around the circuits but it would have to be non invasive like a clamp meter as anything else would upset any divider circuits. I have a clamp meter which gets down to mA resolution but I don’t suppose you have one of these.
I think you will have to check, check and check again but get the divider system right before you connect anything else. I will continue to think. If the same result with the ADC disconnected (as I suspect will be the case) there are some other checks which you can do. Firstly though make sure everything is right.
Really appreciate the time you are putting into this.
I guess you are a bit like me, once there is a problem, we simply can’t let go until it is solved.
The voltage drop across the series resistors progressively get’s larger from Cell 2 to Cell4.
In other words inline with the increasing Resistors.
I think the A2D input impedance is so low that drawing the current that it needs, causes the Voltage drop.
That means we are measuring a lower Voltage instead of 1/4 of 13.32 , or 1/3rd of 9.998, or 1/2 of 6.659.
So 0.791V / 3000 ohm = 264 Micro Amps, I would have thought it would draw pico amps.
I guess I could drop the resistors to 600 Ohm and 200 Ohm to ground but that could potentially deliver > 11mA to the AIN.
But my guess is that there will still be a voltage drop to deal with.
Either way, I will send this pic to TI and await a reply.
In the meantime I have changed the software to read WRT Earth and then subtracting the previous cells.
This whole installation is setup in a Triton Camper, so will test it all tomorrow and see if charging the battery will give a linear response.
Not so. Don’t do that. The input impedance to the AINs is 6MΩ. @ 3V the input current should be 0.5µA or 500nA.
The max input current of 10mA quoted would occur if the device is subject to an input voltage of 0.3V above the supply. In that case the input is clamped to that figure by diodes. It is this situation where over current can occur and destroy the clamping diodes thus probably destroying the input circuitry. A series resistor is used to limit this current in the event of accidental over voltage. The 10mA is quoted as the max current these diodes can tolerate continuously.
Getting back to that 3k resistor in the divider. The total resistance to ground is 3k + 1k = 4k to ground. Thus at 13.2V the current would be 3.3mA (to ground). This passes through the 1k resistor so the drop across this is 3.3V. That is what I would expect to measure at the 3k and 1k junction. Your numbers to drop the voltage with a divider are correct and 3.3V would be expected at each junction. This is why I think there is something strange going on. There is a mistake somewhere to some unforeseen currents cancelling and upsetting things. I just can’t see it at the moment. I might be able to lash up 4 AAs as an experiment but it can’t happen for a few days. Do as I ask and repeat these measurements with the ADC disconnected and just have the battery bank and voltage dividers stand alone and see what results.
Regarding battery 1, you can remove this 1k resistor to ground and instead connect it to the AIN as a series current limiter for the reasons above. The other 1k, 2k and 3k resistors on the other batteries should perform this function.
This would indicate that things are not exactly as you have drawn. Maybe somehow connection of the ADC is upsetting things or you have made an error somewhere. That is why I previously asked that you measure the voltages of the battery set up and divider in isolation to try to establish where the problem actually is.
The simulation is done with Tina which is a very reputable simulation package and is actually used as the engine for quite a few 3rd party suppliers.
PS I did another run with a 6MΩ resistor in parallel with R1, R2 and R3 to simulate the ADC analog inputs with no change in simulation readings. As I expected.
Bob, have resolved the problem.
By turning OFF the Rpi, so that I could measure the Voltages in the divider circuit, it also turned OFF
the supply to the A2D board.
For some reason that board draws much more power when Off.
I guess there is active buffering that changes the impedance when powered up.
I have recorded the information and I will post later this afternoon as I want to include a photo and also a text file of 500 samples to show the variation
Sunlight reflections on the screen make a poor picture, so after dark.
There is still a bit that defies imagination. How did you measure 791mV across the 3k resistor and 2539mV across the 1k. By all definitions and rules these 2 voltages should add up to 13.2V and that is FACT. So there must have been some measuring technique error here somewhere.
According to the chip data sheet block diagram all the inputs should be open circuit until switched to the actual ADC by a MUX. And I did manage to find a circuit for that board and there is nothing between the input and the IC.
There is however the clamping diodes back to VCC which then goes to ground via the indicator LED which could provide a path for some current until the board is powered in which case the clamping diode will be biased off. This I gleaned from the circuit I found for the board.
This is one reason I asked that you disconnect the ADC inputs and measure voltages with the batteries and divider stand alone. This was to isolate the problem and if you obtained results as the simulation this part of the system could be declared no problem. You apparently did not do this and I did not request this be done to improve my health. You must appreciate that fault finding remotely can be difficult at the best but near impossible if you can’t do as asked. It gets a bit frustrating when I believe I could have isolated (but not necessarily fixed) the problem in about half an hour with a decent DMM (which you seem to have). But I have had many years of practice at this sort of thing.
Anyway the problem seems to be now isolated but I think my reasons for the extra current are closer than yours. You can prove this by cutting the tiny track between the pads thus isolating that LED and if I am correct the problem should go away.
Irrespective what happens here the voltages measured across the 1k and the 3k resistors should have added to 13.2V or whatever is measured at the battery. There is no argument, that must happen.
Cheers and let me know how you go.
PS: Link to circuit. You can see the pads I mean, meant to be cut if indicator LED not required. https://learn.adafruit.com/assets/112763
Just had a thought (now don’t laugh). My puzzle has been the 0.7891V you measured across the 3k resistor.
Now is it possible this could have been 10.791V and due to poor lighting or something else you have missed the “10”. It would not be hard to do if the sun was on the meter or something.
I suggest this because 10.791 plus 2.539 adds to 13.33V which is something like I would expect give or take some tolerances. Your original measurement of 0.791 if done properly breaks every rule in the book and Mr Ohm and Mr Kirschoff would have some re-writing to do. I think this scenario is close to the mark.
Cheers again Bob
Me like yourself have spent many years trouble shooting. Having been the designer of 250 computerised weighing sytems all over the world,(from Diamonds to garbage) I know A2D converters intimately. But obviously not the ADS1115 as it was more then likely a specific design for the Rpi and the cost reflects that.
The 791 mV was calculated after measuring the Cell voltage (above the 3k) and then measuring the AIN pin when all the power was off. Now normally this means the A2D is out of the circuit.
However the voltage at the AIN and the Voltage of the cell calculated to a 791 mV difference which could only be as a result of current flowing through the 3k resistor and some to ground via the 1K.
Never thought that the ADS1115 would sink current whilst powered down.
Anyway the problem was identified.
Attached a photo of the screen showing pertinent information.
In summary there were 2 errors in trying to make this work.
1: You highlighted the fact that I shoud be measuring WRTEarth.
2: Me being over enthusiastic in switching off all loads beforee measuring Cells
and as a result getting large voltage drops in the divider network.
What is outstanding is that I don’t know how linear the device will be from
3.00 to 3.600 volts. I would expect over such a small range it will be very linear.
It takes about 15 seconds to read 500 x 4 Readings shown on top left of screen.
Will post the reult of the 500 readings after I work out the variations.
You clearly state in your drawing that the voltage at the cell was 13.32V and the voltage at the other end of the 3k was 2.539V This is clearly NOT 791mV.
This points to your measurement technique.
Don’t forget your DMM resistance of 10MΩ this could make a slight difference to your ADC numbers while the meter is present but it should only be a couple of counts. Check it and see. Put the DMM across an AIN input while the ADC is displaying and you may or may not see a slight drop. This will be the actual voltage WHILE THE METER IS CONNECTED but should not be too significant.
I stated above that I believe it is NOT the IC passing a little bit of current but caused by the indicator circuit LED which is an add on. Draw yourself a little circuit and you will see what I mean. The IC input circuit is in the data sheet and I linked the Adafruit board circuit above. There would probably not be enough current to illuminate the LED.
That is what voltage dividers do. They drop voltage. ALL the dividers in your circuit will pass current according to Mr Ohm which is Voltage divided by divider total resistance. If all cells are 3.3V then this current will be 3.3mA which will drop 3.3V across each of the 1k resistors and 3.3, 6.6 and 9.9 volts across the other 1k, 2k, and 3k resistors respectively. That is just how voltage dividers work. So in this scenario all the AIN inputs would be 3.3V
The input resistance of the ADC chip is 6MΩ (assuming the IC is set for 4.096V FSD) which is only present when that channel is selected by the internal MUX, the rest of the time it is open circuit. The 6MΩ is high enough to be ignored.
As drawn the dividers are in circuit at all times.
The dividers will be VERY linear and produce the same voltage ratio over whatever voltage you throw at it until the resistors burn out. Which in your case is not likely to happen, worst case would be the 3k which is dissipating much less than 40mW. Any non linearity will be due to the actual ADC in the IC which I expect would be good enough to get within a couple of mV. Do doubt there will be a graph somewhere indicating linearity but will leave that up to you.
You haven’t commented on my suggestion of using the first 1k resistor in series as a current limiter instead of connecting to ground. You can leave this to ground if you wish, that is just an unnecessary 3mA used but I would recommend a resistor in series with all the AIN inputs as a safety precaution in case of accidents. This is entirely up to you but as the primary source (13.2V) is well above the IC VCC (5V) I would recommend it.
If that screen shot is the measurement of the 4 cells what is wrong with that. A spread of 1 to 4mV overall is not bad at all.
It was intended to highlight the difference between the Calculated Voltage (3.33v) at AIN and what I was getting (2.539) was in error by 791 mV.
I had a look at the Link but could not make out from what is shown, how the AIN pin ended up supplying current to the led circuit. But that is not important, as we now know the Voltage at the AIN pin MUST be measured whilst the A2D board is powered ON. In fact now there is no need to measure there at all.
The Cell Voltages WRTE is only needed once to calculate the Multiplier.
Again that doesn’t say precisely what was intended. “and as a result getting Larger than anticipated voltage drops in the divider network”
I understand that the resistors will be linear, but my concern was/is that the A2D converter be Linear.
I agree with the shifting of the 1k on Cell 1 to be in series with the signal and will do that.
The spread (Delta) of 0.003 mV is more to do with how well the Cell balancer works.
During heavy current charging this will spread out to 30 + mV but then a couple of hours without charge current (or low current) it pulls back into line.
I have put quite a few safe guards into the system design.
Transmitting the pertinent information by Wifi to the cab where it is superimposed onto the Hema Map
LCD every few minutes.
A blue flashing light in my rear vision mirror if there is an Alarm.
Charging, Load , Inverter and Alarm are all on Auto /Off/Manual switches.
A small eBay Voltage Window detector drops the negative rail to the SSR’s if the battery goes out of spec.
This was the last obstacle to everything working, so I am happy with the result.
I think that it is important that you know how this can happen. It has nothing to do with the IC. Those protection diodes are fitted to almost everything these days but the offending components are on board external the ADC IC
Have attached a sketch which will hopefully explain what I mean.
The 10k resistor shown to the left of the LED is for I2C address change. I think both these links are connected by default and that puts these two circuits in parallel in series with the protection diode effectively in parallel with the 1k divider resistor when the IC is not powered. Boy that is a mouthful but I hope you can grasp what I mean.
This would apply to all inputs that have a voltage divider (or series resistor) present. When the IC is powered this protection diode is biased OFF so the effect is not present. When the input exceeds VDD+0.3V the diode will conduct but as this is a probably a fault condition this small bit of extra current does not really matter.
I thought you said you MEASURED this 0.791V, not calculated it. That is what I questioned as that could not happen if everything is as drawn.
I hope this goes some way to solving the puzzle.
I understand and see the reasoning behind your analyses.
As promised here is a bar graph of 500 reading of Cell4 (Battery Voltage)
Quite surprising to see so many spikes with such huge variances.
This means I will have to write a more intelligent filter routine as these values really alter the accuracy.
I will determine the source of these variations.
Considering that this system is a completely passive system where the only generator of noise would be the Rpi.
If it is not noise (will hook up a CRO) then they must be bad reads .
In either case I will filter them out.
You are not reading too fast are you. You may be not allowing enough time for the ADC to settle and do its thing. I am not going to go through the data sheet again but I seem to remember noticing something about the time it takes to do a reading. Remember too that you are reading 4 inputs which are rapidly switched by the MUX. It then has to be processed by the I2C system and sent out. This all takes time and you might be cutting off readings before the process has finished.
Just a thought.
The way this ADC works is that until a valid new reading is available the data retrieved is the previous reading. I had already concluded that at 4 mSec between reads, I would get an occasional repeat.
So my delay is set at 6 mSec.
Just thought seeing the data like that could be usefull for other users of the ADS1115
As a final update on this project, I thought some members reading this thread may like an update.
Taking 500 readings of each cell with 6 msec between each.
I sorted the 500 readings from Highest reading into 10 x 10 count regions.
Then looked to find the region with the highest number of samples. (where most of the stable readings are).
Using that 10 count window, I averaged all the readings that qualified. (293 samples in my test)
Final result using the same data with my earlier vs later method showed 3 mV higher for the Cell.
Not much I know, but if you are going to work with data, may as well be accurate.
If the 3mV is the difference between your DMM and the ADC result then I personally would be very happy with that. That would be almost within your DMM spec surely. 3mV in 3V would be 0.1%. Most DMMs are quoted +/- x% plus a variation of the last digit. If your DMM resolution on that range is 1mV I think that result is pretty good. A bit would depend on how much confidence you had in the calibration status of your DMM too.
Anyway good to see you seem to have that sorted.
Bob, I am having a problem that I don’t understand at all.
When I am modifying the software, I use a larger monitor and Mouse keyboard connected.
Then I use Geany for the programming changes.
When I have made the changes, I return to the Terminal and run the program.
That is the method I have used to calibrate the ads1115 so it reads voltages correctly.
The stability is within 2 mV both on the cells and total battery voltage.
I am pleased with that.
Then when I am done I copy the program to the correct folder /usr/bin and shut down the Rpi.
I remove the monitor , keyboard and mouse.
Then power the Rpi with it’s own 7" LCD.
The reported counts from the ads1115 falls by about 350 counts on each of the 4 A2D’s.
I go to the battery and measure and it is still as before.
This has happened 3 times now, which means I can’t trust the values it is reporting.
Tried powering down and back up again, but it stays at the low count.
I let it warm again to see if the counts would creep up, but NO it stays nice & stable.
It is almost like the reference inside the ads1115 is corrupting (if that is possible)
Before I post this with TI, thought I would give you a hoy first.
Edit: I wonder if leaving the battery inputs ON, whilst the Rpi is OFF is causing a problem.
The A2D board would have 3.3 v Inputs but NO power supply. ???
I am afraid I am not familiar at all with RPi. It all seems a bit too flakey for my feeble mind.
That could be a bit of a worry. If it was a fault condition I would almost expect the incorrect readings to move around a bit.
I have not got the data sheet up now but even though I know enough about complicated digital things to be a bit dangerous I do know enough to be able to break the operation of this chip down to the individual boxes . There is actually only 1 ADC, the inputs are switched by the MUX to this block either 4 individual (referenced to ground) or 2 differential inputs. OK so far. the resultant readings are processed by some I2C device which I know nothing about. All good.
Now somewhere at the back of my mind I think I saw something about some of these ADC devices have the ability to change their resolution. Like 10bit, 12bit, 16bit etc. Now is it possible that this chip falls into that category and somehow the resolution is being changed. If say the resolution changed from 16bit to 12bit this would certainly account for a change like the 350 counts you are experiencing. You will have to go through the data sheet and find out if this could occur.
The other reason as you suggest is a change to the reference. Check but I think this is accessible so can be measured. You might measure this in the good condition and fault condition. Don’t worry if the voltage read is not precise as the meter resistance might influence it slightly, it is a variation between the 2 conditions you are looking for.
You should not do any damage as the MUX switches should all be open (I think, although one never knows) and you will only get that bit of leakage via the clamping diode as previously described. BUT you can never be sure. It would be worth a try keeping it powered and might not be a good idea having inputs without power. Just don’t know.
Edit. Another possibility. This device has a programmable FSD (or gain). I believe you are using the default gain, Unity or 4.096 (I think) FSD. What if this were somehow changing to 2/3rds gain or 6V FSD. This would certainly do it. The way to get some idea if you note the ADC readings in the good condition and again in the fault condition. If the fault readings are about 2/3rds of the expected good readings it is possible that this is happening somehow…
I don’t see how. The mind boggles a bit does it not.
Unless you have a ground loop problem somewhere.It is turning out to be a thing that has to be seen first hand to offer any more solutions I think. I assume you are driving the 240V monitor via the HDMI port. Is the 7" screen connected to the same point? If not one of the 5V supplies might be sagging a bit when you use this port.
I think the RPi gets a bit stroppy when the volts drop a bit. Somebody mentioned a while back that the “official” RPi supplies are 5.1V to allow for the small drop in the wiring. Leave me out of it. Most of the things I am used to working with would handle 10% before anything untoward happened. But if that is the way it is well, that is the way it is.