Is it possible to configure / use the ADS1115 to read a differential voltage between inputs A0 and A1 and read a single ended voltage on inputs A2 and A3.
I have only seen code that will use the ADS115 in either differential or single ended.
To add a little clarity,
I would like to measure the voltage across a resistor using a differentail input to calculate the current flow in a circuit and use 2 single ended inputs to measure a battery voltage and a solar panel voltage wrt ground.
Is it possible to configure / use the ADS1115 to read a differential voltage between inputs A0 and A1 and read a single ended voltage on inputs A2 and A3.
Yes, it is possible. Have a look at the internal multiplexer in section 9.3.1 (page 15) of the datasheet. This multiplexer configures the value to be measured. For one measurement you can configure A0 and A1 to be connected to the ADC input while for the other measurements you connect A2 and GND or A3 and GND to the input of the ADC.
Thanks for the replies.
I do have another idea and that is to take a differential reading between A0 and A1, then take a single ended reading from A0 then A2.
Would that be possible to take different readings from the same input?
A0 would take a single ended reading for solar panel voltage
A0/A1 would take a differential reading for voltage across a resistor to calculate current flow
A2 would take a single ended reading for battery voltage.
I know I could just take a single ended reading on A1 take A1 from A0 to get the same value but then what would be the point in having differential inputs?
I have (hopefully) included a quick drawn schematic to help explain.
Thanks
Martin
Depending on how you have wired everything you don't need a differential reading at all.
Current sensing resistor low side, i.e. between negative pole of your solar panel and the load. The voltage over that resistor will give you the current. You need either an amplifier, or set the ADS1115 gain high (it can go down to 256 mV full scale).
The voltage sensing is I suppose using a voltage divider (unless your panel produces a low enough voltage). Two largish resistors (mind the quite low input impedance of the ADS1115 - check data sheet!), mid point to another input of the ADS1115. You probable need a quite low gain for this one, I expect a higher voltage than on your current sensor.
Connect Arduino GND to solar panel GND (negative pole).
Well I re-wired everything as per the diagram I posted.
I read a differential voltage across the load resistor and then calculate the current flow.
I read the input voltage on the hot side of the solar panel and the battery voltage.
Originally, I was using 4 x AA 2000mA/h NiMh cells but have managed to find a tiny 6-volt 4000mA/h lead acid battery which I will now use.
My potential dividers for the inputs are a little high I think, originally, they were on the Arduino and it was set to use the 1.1v internal reference so all inputs had to be below 1.1volts. No point using supply as a reference as this is hardly stable!
There were problems with the Arduino mini pro analogue inputs, for some reason they were changing their impedance in the middle of the night and showing a sudden drop in all voltages. Very strange problem that I couldn't be bothered trying to figure out. (Another story).
I am running the ASD1115 with default gain of 2/3rds which gives me a resolution of 0.1875mV which is far more than what I require. I could alter the gain, but I don't need the extra resolution, I am quite happy with a 1mV resolution for my needs.
So far it seems to be running well, I could change the potential divider resistors for maybe 10/10 instead of 50/10 and even running with a 6-volt battery would only put 3v onto the inputs, well within the range. I will wait and see what voltage my solar panels will go up to when in strong sunlight before I change anything.
Yes, good idea with the INA219, unfortunately I don't have any, but I will add it to my next Chinese order as it could come in handy.
It would still leave me with problem of the voltage readings. I know the Arduino has 10 bit up to +5v ish A-D's but I have found them to be very unreliable on the Arduino I was using.
I don't know why or what was going wrong, but the impedance of the analogue inputs seemed to drop considerably.
For example, I would have 5 volts on from my battery, and though a potential divider would have approximately 800mV to an analogue input. I was using the internal reference of 1.1volts.
For no apparent reason, it would suddenly indicate I only had 3.5 volts from the battery. I have changed batteries several times thinking I had faulty cells, but then it suddenly started to do it while I was there.
The battery was checked (whilst still online) and was 5volts, but the Arduino indicated 3.5volts, checking the potential divider now shows only 500-600mV, which did correspond with the 3.5 volts.
As the resistors in the potential divider had not suddenly changed their resistance, the only thing it could have been was the Arduino itself.
This was starting to happen regularly until it reached the point where it was changing from good to bad several times per minute.
At that point I gave up and decided to move to the ADS1115 as I have 3 of them lying around.
Even with a cheap knock-off that shouldn't happen as it's still the same processor. Input impedance of the analog pins is in the tune of 50 GOhm iirc. That's a few orders of magnitude higher than that of the ADS1115!
So when the voltage measured on the pin dropped to 500 mV, what were the measurements for the same voltage divider with the Arduino disconnected?
Those measurements just don't make sense, and I do suspect other problems such as poor soldering joints.