2
\$\begingroup\$

I am trying to measure voltage & current off a solar charge controller from panel, battery & load simultaneously with my arduino. I have managed to achieve this by tying all the negatives together and using it as GND, however, when I do that the charge controller doesn't function properly and when I switch to off-mode the loads still run. After checking the instruction manual further, I found out that the positives are shared common between Pan, Bat, Load. This was confirmed with a multimeter.

So now what I am thinking of doing is using the positive from the battery as the GND reference and then measuring all other voltages (through voltage dividers with respect to the GND). The voltages should then range between -17V to 0V.

However, I have read that the analog input pins are not able to read negative voltages, and with respect to the positive GND, the Analog inputs will all be negative.

EDIT: I was thinking of using an amplifier to invert positive ground to a negative ground, meaning I could measure all the positive sides of the voltages. But after getting answers from you guys it seems I may not have to use an amplifier and a voltage divider may suffice. I have currently included a 2 resistor voltage divider between each analog input, +5V source, Vmeasure which you can see in the diagram below.

According to my calculations, if this works, @-17V I should see 0.6V @ analog input. @0V I should see 4V at analog input.

I'd appreciate feedback on this circuit, and below in the second image I've also included a piece of another method suggested by @jonk (thanks), and would be interested in knowing what the benefits are of method B) over method A)

Thanks!

Ps. the ameters are there in place of ACS712 current sensors which also go into analog input pins.

Method A)

schematic

simulate this circuit – Schematic created using CircuitLab

Method B (EDIT: This method has worked, I am still yet to test method A) thanks @Jonk))

schematic

simulate this circuit

\$\endgroup\$
  • \$\begingroup\$ I think the schematic is missing? \$\endgroup\$ – jonk Oct 31 '16 at 18:52
  • \$\begingroup\$ @jonk it looks like it's there for me. Can you see it now? If not, I'll just throw in a screenshot :) \$\endgroup\$ – Ken H Oct 31 '16 at 18:59
  • \$\begingroup\$ Are those resistors your attempt at providing a voltage divider for your analog inputs? Or are they required by your charge controller for some odd reason? \$\endgroup\$ – jonk Oct 31 '16 at 19:01
  • \$\begingroup\$ Also, is -12 V the largest value you need to measure? Or can that voltage be even more negative? \$\endgroup\$ – jonk Oct 31 '16 at 19:03
  • \$\begingroup\$ My attempt at providing a voltage divider. The voltage drop across each of the 2 resistors should be the same as the voltage of panel, load, battery respectively - so i used the divider to get the voltage down to something the arduino could input. \$\endgroup\$ – Ken H Oct 31 '16 at 19:03
1
\$\begingroup\$

If you want measure input voltages that may be both negative and positive, using an Arduino ADC where the analog input pins can't read negative voltages, then you might consider the following style of three-resistor divider shown on the left side (the right side we will get towards):

schematic

simulate this circuit – Schematic created using CircuitLab

The \$V_i\$ terminal goes to what you want to measure and the \$V_o\$ pin goes to your ADC input (or to a buffer amplifier, if you prefer.)

Your Arduino ADC needs to see an input impedance that is less than \$10\:\textrm{k}\Omega\$, total. With the above divider arrangement, this is \$R_{IN}=R_i+R_p\vert\vert R_g\$. Roughly speaking, since \$R_p\$ or \$R_g\$ will be larger than \$R_p\vert\vert R_g\$, we just need to make \$R_i+R_p\lt 10\:\textrm{k}\Omega\$.

But taking into account your worst case \$V_i=-17\:\textrm{V}\$ and power supply of \$V_{CC}=5\:\textrm{V}\$, it must also be the case that \$R_p \lt \tfrac{5}{17} R_i\$. Another consideration that comes from a separate equation solving for \$R_g\$ suggests that \$R_p \lt \tfrac{2}{9} R_i\$. So \$R_i \lt \tfrac{10\:\textrm{k}\Omega}{1+\tfrac{2}{9}}\$. So that is our more important constraint. \$R_i \le 8.2\:\textrm{k}\Omega\$. That's a standard value of \$R_i =8.2\:\textrm{k}\Omega\$ and I then just picked \$R_p=1.8\:\textrm{k}\Omega\$ as an appropriate standard value, as well.

From this, you can compute \$R_g=V_o\frac{R_i R_p}{\left(V_{CC}-V_o\right) R_i - \left(17+V_o\right) R_p}\$, where you get to pick \$V_o\$ when \$V_i=-17\:\textrm{V}\$. It's not linear, though. Looking at the curve, I think \$R_g=2.7\:\textrm{k}\Omega\$ looks good.

The input impedance is now \$9.3\:\textrm{k}\Omega\$, which meets the needed criteria for the ADC. And at \$V_i=-17\:\textrm{V}\$ you will get \$V_o=670\:\textrm{mV}\$ and at \$V_i=-10\:\textrm{V}\$ you will get \$V_o=1490\:\textrm{mV}\$ and at \$V_i=0\:\textrm{V}\$ you will get \$V_o=2650\:\textrm{mV}\$.

In the above case, I'm assuming you can share grounds, of course.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the answer @jonk That all makes sense regarding impedance and how to calculate correct resistor values. I'll test on my Arduino shortly - just wanted to confirm first though, what is the purpose of the resistor Rg between common positive -> v0? Could this voltage divider be achieved with just Ri & Rp? Also the +5V that is being provided by the Arduino, is it provided with reference to the arduino GND? So if we put lets say +12 on the Arduino GND, the Arduino can still supply +5V with reference to the GND (and not actually -7V) am I correct? Thanks mate! \$\endgroup\$ – Ken H Nov 1 '16 at 3:02
  • \$\begingroup\$ @KenH \$R_g\$ and \$R_p\$ make up a resistor divider, dividing down the Arduino power supply's +5 V to something else -- +3 V. But this now has a Thevenin resistance of about \$1.1\:\textrm{k}\Omega\$, against which \$R_i\$ works. I'm assuming that you will set the Arduino common to the charge controller common, but that you will NOT connect any other part of the power supplies together. DO NOT put +12 onto the Arduino ground. That's not the purpose here!! \$\endgroup\$ – jonk Nov 1 '16 at 4:26
  • \$\begingroup\$ first of all, thanks a lot for your time mate! I've posted a couple of edits on my question to make what I'm thinking about a bit more clear. Please see the diagrams. Firstly, I am wondering whether or not the voltage divider of the first circuit will work, without the Rg? Secondly, in response to your +12V warning, I was planning on connecting the charge controller common (which is ~ +12 relative to the negative side). However I think it was a terminology issue on my behalf, so is it safe for me to connect the positive charge controller common into GND? Thanks! \$\endgroup\$ – Ken H Nov 1 '16 at 4:36
  • \$\begingroup\$ @KenH I gather you are using a +9 VDC mains-powered unit to supply power to the Arduino's voltage regulators, which can then provide +5 V to operate the Arduino. And that you then have access to tap into the +5 V supply rail of the Arduino for the resistor dividers. Is that correct? (Or is that +9 V battery I see there an accident?) \$\endgroup\$ – jonk Nov 1 '16 at 5:04
  • \$\begingroup\$ You are correct @jonk I am using a 9VDC supply. I would ideally like to power the arduino with the battery (from charge controller) via a buck converter. But I figured there would be issues in using it as a power supply and also GND. Am I correct? Or do you also know a way around this? \$\endgroup\$ – Ken H Nov 1 '16 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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