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)
simulate this circuit – Schematic created using CircuitLab
Method B (EDIT: This method has worked, I am still yet to test method A) thanks @Jonk))
Answer
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):
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.
No comments:
Post a Comment