I am attempting to measure the voltage drop across a shunt (1.5 Ohm) in series with a solar cell to determine output current, and thus try to implement some MPPT. Since Vsolar is 1.4x VCC, i will need to lower the voltage to measure. From my basic understanding of microcontrollers, I need to insure the impedance is not too high for an accurate measurement. After reading here: Required output impedance for ADC input? - Electrical Engineering Stack Exchange
the rule of thumb seems to be Z <= 10k.
Given max Vsolar is 7.2V, and with max 5% tolerance on R1/R2, I have chosen 1.8k and 3.8k, Which would give 5.04V if R1 was at its minimum tolerance and R2 was at its max. (circuits Attached) R1+R2 should leak only 1mA, so im assuming they are not too small.
With this circuit implemented, My results have been spotty at best(noisy). The current i am measuring is on the order of 80mA max (supplied by Bench supply to test) with 40mA typ. The difference in voltage across the shunt floats between 0 and 18 (i.e 1000-982), which comes to (18/1023)*7.2 = 85mA. Ive since implemented averaging, which has only slightly helped.
for(int i = 0, Vsense = 0; i < (Samples+1);i++){
analogRead(VSensePin);
VSense = analogRead(VSensePin)+Vsense;
if(i == Samples){
VSense = (VDec*VRatio)/Samples //VDec = 5/1023, VRatio = voltage ratio of R1/R2 (7.2/5)
}
}
My questions are this:
1.) With this sampling method, do i need to add a delay between samples?
2.) Is the resolution just too low for accuracy?
3.) Do i need to add a difference amplifier?
4.) Is there anything wrong with this sampling method or is there a better implementation? Thanks!
I haven't ruled out my circuit either, and should note the PCB trace is a few inches long. I tried to follow good routing techniques, though i havent designed many boards (< 10).
Using 1.1volt Aref on your code will give more/stable readings (more values), and five times the resolution.
See the Aref page in the help>Reference tab of the IDE.
Call for the 1.1volt Aref in setup(), and change this: VDec = 1.1/1024
1.1 value might need calibration, e.g. 1.074/1024
Don't post code snippets. There might be other things wrong with your code.
Leo..
Wawa:
Using 1.1volt Aref on your code will give more/stable readings (more values), and five times the resolution.
See the Aref page in the help>Reference tab of the IDE.
Call for the 1.1volt Aref in setup(), and change this: VDec = 1.1/1024
1.1 value might need calibration, e.g. 1.074/1024
Don't post code snippets. There might be other things wrong with your code.
Leo..
Using this, I should implement a unity gain difference amplifier, then measure against 1.1v? Thanks for your input!
I think the voltage drop you're assuming is incorrect. You're posting that a full voltage drop will occur across the shunt resistor. Actually, with a 1.5 ohm resistor and max 100 mA across it, you will only get 150 mV of drop or 0.15V across it. You actually have nothing to worry and don't need a divider. The divider you implemented will only decrease the voltage even more which might be why you're seeing strange readings.
You will need to implement an opamp in a differential configuration to measure the voltage difference across the shunt. Then you can feed that into the analog pin and read it.
Hope that helps.