Go Down

### Topic: analogRead Voltage 1.4x VCC (Read 266 times)previous topic - next topic

#### evalonso

##### Sep 14, 2017, 12:41 amLast Edit: Sep 14, 2017, 02:23 am by evalonso Reason: image
Good evening!

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: https://electronics.stackexchange.com/questions/107741/required-output-impedance-for-adc-input
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.
Code: [Select]

for(int i = 0, Vsense = 0; i < (Samples+1);i++){
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).

Thanks!

#### jremington

#1
##### Sep 14, 2017, 01:57 am
What is the short circuit current (Isc) of the solar cell in full sun?

A better choice for the shunt resistor is Voc/Isc (nearest standard value).

#### Wawa

#2
##### Sep 14, 2017, 02:12 am
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..

#### evalonso

#3
##### Sep 14, 2017, 02:27 am
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!

#### freaklabs

#4
##### Sep 14, 2017, 03:07 am
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.
FreakLabs
Open Source Wireless Sensor Networks
https://freaklabs.org

#### edgemoron

#5
##### Sep 14, 2017, 03:15 am
What is the solar cell's short circuit current or claimed wattage?

#### Wawa

#6
##### Sep 14, 2017, 03:38 am
Using this, I should implement a unity gain difference amplifier, then measure against 1.1v? Thanks for your input!
80mA through a 1.5ohm shunt is 120mV across the shunt.
That can be measured directly with an analogue input.

With 1.1volt Aref enabled, you should get an A/D count of >=100.
~1% resolution might be enough for your needs.
Leo..

Go Up