Hi, Hope someone can help probably basic electronic but cant figure it out.....
I want to measure the VIN voltage to my board and ive written the code ok but it needs compensated for the fact i have a 10K resistor connected on pin 14! therefore if in input:
4.87V i get a bandgap ref reading of 3.30V as ive lost 1.57V accross the 10K resistor @ 0.487 mA
or 4.22V i get a reading of 3.01V due to the loss of 1.21V accross the 10K resistor @ 0.422 mA
can anyone derive a formula to compensate for this and correct for different values.. XD XD XD.......?
Your verbal discription is not real clear to me. What is needed is a simple schmatic drawing of how you have wired everything up and the values of the components. I'm not sure at all that you are using the term band-gap properly.
It would help if you could draw a circuit and explain more carefully what you are trying to do. I think what you are saying is that you want to be able to build a voltage divider that will enable you to measure your main Vin voltage, using the Arduino built-in 1.1V A2D reference. Is that correct?
i have a 10K resistor connected on pin 14! therefore if in input:
Why?
There is no need to wire anything to anything. You need to write software to access the analogue multiplexers above 7. One of these is the internal band gap. By measuring that with Vcc as the reference you can work out what the value of Vcc is.
I suspect you may be mixing up Arduino pin numbering with ATMEL AVR ping numbering. Arduino (on a 168) doesn't have an analogue input numbered 14. Please have a look at the reference manual for analogRead() and analogReference(). analogRead() - Arduino Reference
You are going to have code more like:
analogReference(INTERNAL);
:
:
result = analogRead(0);
I suspect you may be mixing up Arduino pin numbering with ATMEL AVR ping numbering. Arduino (on a 168) doesn't have an analogue input numbered 14.
Actually, "14" is the correct ADMUX value to read the internal bandgap voltage but the Arduino analogRead function no longer allows access to it (as of IDE 18, I believe).
result = 1126400L / result; // Back-calculate AVcc in mV
...varies a bit from processor to processor. If you need an accurate VCC value, you will have to determine the actual bandgap voltage for your processor.