Go Down

Topic: Voltage Divider (Read 4269 times) previous topic - next topic

SagarDev

Separately. Fixed load.
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

aarg

Separately. Fixed load.
For a simple battery go/nogo battery tester, it will work. But rather than measuring current, it will just draw a nominal current to test the batteries internal resistance more thoroughly.

If you just need to know if the battery is good or not, this will work.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

dwightthinker

First, using 1% resistors will not get you to 12 bits of accuracy.
12 bits is 0.024%.
As has been mentioned, It will draw 8.26 ma. It would be
be a heavy load for a 9 volt battery. As the only load, it would do
an alkaline battery in in less than a month.
Dwight


Wawa

As the only load, it would do an alkaline battery in in less than a month.
Make that two days.
Leo..

dwightthinker

Make that two days.
Leo..
9V alkalines are rated at 400 -500 mah.

Wawa

9V alkalines are rated at 400 -500 mah.
400 / 8.26 = 48hours = two days

dwightthinker

400 / 8.26 = 48hours = two days
Oops, my bad.
Dwight

aarg

If the (mostly silent) OP just wants a battery tester, then the current consumption is a moot point.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

polymorph

Until the OP tells us what they are trying to accomplish, this is all moot.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

SagarDev

Okay. I shall use 10K resistors at each terminal. What should be my code to measure the battery voltage and current?
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

Wawa

If you have a 10k resistor, a 100k resistor, and a 100n cap, then try this sketch.
It uses the more accurate 1.1volt Aref.
Leo..
Code: [Select]
/*
displays the voltage of a 9V battery
works with 3.3volt and 5volt Arduinos
uses the internal 1.1volt reference
10k resistor from A1 to ground, and 100k resistor from A1 to +batt
100n capacitor from A1 to ground for stable readings
*/
float Aref = 1.075; // change this to the actual Aref voltage of ---YOUR--- Arduino (1.000 - 1.200), or adjust to get accurate voltage reading
unsigned int total;
float voltage; // converted to volt

void setup() {
  analogReference(INTERNAL); // use the internal ~1.1volt reference, change (INTERNAL) to (INTERNAL1V1) for a Mega
  Serial.begin(9600); // ---set serial monitor to this value---
}

void loop() {
  analogRead(A1); // one unused reading
  for (int x = 0; x < 11; x++) { // 11 analogue readings and 1/11 voltage divider = no additional maths
    total = total + analogRead(A1); // add each value
  }
  voltage = total * Aref / 1024; // convert readings to volt
  // print to serial monitor
  Serial.print("The battery is ");
  Serial.print(voltage);
  Serial.println(" volt");
  total = 0; // reset value
  delay(1000); // readout delay
}

SagarDev

Do you have a sketch without Aref(a simpler one)?
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

aarg

Are you ever going to tell us exactly what this device is supposed to do? Not just how the circuit operates, but its purpose? >:(
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

SagarDev

The purpose of this is to measure voltage and current from a 9V battery and the percentage of power remaining in the battery.
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

dwightthinker

This measures current and voltage with 12-bit accuracy.
Leo..
If you read the specs carefully, you'll see that it talks about resolution.
The only mention of accuracy was the current sense resistor.
To get the accuracy it would still be needed to be calibrated over some
temperature range.
Dwight

Go Up