rechargable batteries for uninterruptible power supply

Ah, I see. In that case a 3904 and, yeah, a 50 mA divider network.
If including a transistor is too much trouble, maybe the test load could be split across two or three AVR pins in parallel. I can't recall if the max current spec is on a pin-by-pin basis, or for the aggregate of all pins though.

gardner:
You could make the ground leg of the voltage divider be an Arduino output pin. Make it low to assert ground, take your A2D measurement, then make it an input and write a 0 to it, to turn off the pull-up. It should not sink much current in this state.

The measurement is from the voltage divider (battery's 9V pole) to A1, and the switch is controlled by a relais, so that there isn't always current flowing.
What is the "ground leg of the voltage divider"? Do you just mean ground?

And what do you think about this idea (schematics)?

karlok:
The measurement is from the voltage divider (battery's 9V pole) to A1, and the switch is controlled by a relais, so that there isn't always current flowing.
What is the "ground leg of the voltage divider"? Do you just mean ground?

I was only suggesting an alternative to using a relay to control whether the voltage measurement circuit draws current. R3 and R4, in the schematic, form a voltage divider and test load for the battery. Where R4 connects to ground, I am suggesting connecting instead to an Arduino input/output pin. Under software control, you can make this pin "low" (~= ground) or make it an input, which will not flow any current to speak of. Then R3 can go straight to your battery, and no need for a relay.

The Arduino pins cannot handle much current, so you might have to use larger values for R3 and R4, to get the current under 20mA. Another alternative would be to use a transistor, like a 2N3904 which can handle 200mA in this situation, to control the R4 ground connection.

I'm not sure how important it is that the test load you place on the battery is substantial. The less substantial the load may be, the simpler the circuit can be. The relay approach could place a 1,000mA or larger load. A small transistor could handle up to 500mA, a direct connection, up to about 15-20mA. Depending on what pins you have available, you could parallel-up multiple pins to sink more current, up to a total limit of 100mA. 35mA spread across 2 pins would be a good bet, IMO.

Ok now I understand.

gardner:
so you might have to use larger values for R3 and R4

This goes for R1 and R2, too?

And I changed the resistance values of R3, R4.
However, I think if D5 is not GND, then 9V goes straight to A1 which is not good because it is limited to 5V. Dangerous?
If D5 is GND then I understand how it works, is digitalWrite(5,LOW) really the same as attaching something to GND?
I attached the schematics like I understood it.

karlok:
Ok now I understand.

gardner:
so you might have to use larger values for R3 and R4

This goes for R1 and R2, too?

And I changed the resistance values of R3, R4.
However, I think if D5 is not GND, then 9V goes straight to A1 which is not good because it is limited to 5V. Dangerous?

Yes, best to drive a npn switching transistor to pull the voltage divider to ground.

If D5 is GND then I understand how it works, is digitalWrite(5,LOW) really the same as attaching something to GND?

Yes, but it carries a maximum current limit of 40 ma and the actual 'ground voltage' at the pin when commanded low will tend to rise slowly as the current draw is increased. There should be a graph or specification showing the value of outputLow voltage Vs current draw for an output pin in the AVR datasheet for the specific chip.

I attached the schematics like I understood it.

And if I have an always current flowing though the voltage divider and the analog input, what do you think, how much current is drawn?
Additionally, I am interested in the way of how to calculate the current drawn and the estimated life using what the battery says about its mAh ...
So, assuming R3=10K, R4=1K. Higher resistor values decrease the current drawn, AFAIK.
Battery full = 9V, i.e. 9V*1K/(10K+1K)=9V/11 =0.8V (analogRead = 164)
But how to calculate the current drawn ??

karlok:
However, I think if D5 is not GND, then 9V goes straight to A1 which is not good because it is limited to 5V. Dangerous?

Yes. I missed that, sorry. I was thinking that Vbatt was in a safe range, but it's not. And with a small R3 value, a problematic current flow could occur.

retrolefty:
Yes, best to drive a npn switching transistor to pull the voltage divider to ground.

I thing to get the A1 voltage in the safe range, the switching has to be done on the high side and with Vbatt > Vcc I think that would have to be an PNP eg: 2N3906 on the high side -- this is where I get fuzzy. Maybe a relay would be the simpler approach. In any event I think my trick of using output pins to supply the ground leg is not enough on its own to make this work.

Hello.

Now I think about a way of not having any switch:

karlok:
And if I have an always current flowing though the voltage divider and the analog input, what do you think, how much current is drawn?
Additionally, I am interested in the way of how to calculate the current drawn and the estimated life using what the battery says about its mAh ...
So, assuming R3=10K, R4=1K. Higher resistor values decrease the current drawn, AFAIK.
Battery full = 9V, i.e. 9V*1K/(10K+1K)=9V/11 =0.8V (analogRead = 164)
But how to calculate the current drawn ??

For calculation assume capacity Q=2000mAh, and current drawn: I = 50mA, then I think time: t=Q/I=2000mAh/50mA=40h (that would be bad, it is not even two days)

( I had an idea with a relay. )

karlok:
And if I have an always current flowing though the voltage divider and the analog input, what do you think, how much current is drawn?
Additionally, I am interested in the way of how to calculate the current drawn and the estimated life using what the battery says about its mAh ...

It's tough to exactly specify the relationship between charge level, battery capacity, current and voltage. There is a relationship there, but there are a million factors that affect it. I believe your battery type should be primary Alkaline AA cells. Googling around for Alkaline battery discharge curves, I get things like this: Discharge tests of Alkaline AA batteries 100mA to 2A

The take away from this is that the voltage/charge state is relatively linear until the battery is about 80% finished.
So where you set your threshold of acceptable charge is gonna be somewhere on this relatively flat part of the curve.

So, assuming R3=10K, R4=1K. Higher resistor values decrease the current drawn, AFAIK.
Battery full = 9V, i.e. 9V*1K/(10K+1K)=9V/11 =0.8V (analogRead = 164)
But how to calculate the current drawn ??

Current drawn is 9V / (10K + 1K) = 0.82mA

This is a quite light current draw -- probably 2% of what your project would draw. You get a better clue about the state of charge on alkaline cells if you place a load on them and look at the voltage they generate under load. At a guess, your project would draw a few dozen mA. Let's say 35 mA.

In order to place a load of 35mA on a 9V nominal battery, you would need a resistance of 260 ohms. To drop 9V nominal voltage into a 0..5V A2D input range, you need the centre of the divider around half way.

100R + 180R = 280R total, which would draw a current of 32mA -- pretty close.

Then 9.2V / 280R * 100R = 3.3V -- your maximum reading for fully charges batteries.

Can it be approximated with 2000mAh/0.82mA = 2440h (even if the relation is not really linear how the graph shows)

karlok:
Can it be approximated with 2000mAh/0.82mA = 2440h (even if the relation is not really linear how the graph shows)

Yes, but I'm not sure where you're going.

If you mean that you intend to NOT switch the battery test circuit on and off, but just leave it connected all the time, then This is giving you a rough idea how long the thing will last. But in this case you are really measuring the open circuit (no load) voltage of the batteries, and in this case there's no need to draw so much current from them. You could set up a voltage divider with 100K on each leg, and the current would then be only 45 microamps, and your battery life would hardly be effected beyond normal shelf life at all, maybe not at all.

This was what I was getting at back here: rechargable batteries for uninterruptible power supply - #44 by gardner - Project Guidance - Arduino Forum

But then Jack mentioned that you would be better to test the batteries under load: rechargable batteries for uninterruptible power supply - #45 by JChristensen - Project Guidance - Arduino Forum

So now we're here. If you want to just measure open circuit voltage on the batteries, then no need for anything fancy, just a pair of high value resistors is all you need.

I don't understand why I should check the batteries with load.
Increasing the resistor values will decrease the current drawn. And the only thing I want to check is whether the batteries are still able to work as a power source if they are needed.
I think this is what I was told here to pay attention to.
And sorry if I don't understand you in the right way, I am still new to this...

karlok:
I don't understand why I should check the batteries with load.
I want to check is whether the batteries are still able to work as a power source if they are needed.

I understand the confusion, and I am partly the cause of it.

What you really want to know, is "are these batteries able to run my project, if I need them to?". The best way to know for sure is to put a load on them about the same level as your project would, and see if they can handle it. If you go buy a "battery tester" this is exactly what it does.

If you do not put load on the battery, you will be reading "open circuit" voltage. For some battery chemistries, open circuit voltage is a reasonable measure. For Alkaline, not so much. It is possible for Alkalines to look okay at open circuit, but really have no juice in them when you load them. So the test-under-load procedure is preferable. The down side is that you can't leave the load on all the time, or the batteries run down, defeating the whole purpose. Thus some switching approach.

It's really up to you which way you want to go in your project.

To complicate things even more, if you want to hear about zener diodes, I can think of a way to make the output-pin-as-ground trick work, and keep the A1 voltage within limits.

Hello!

gardner:
What you really want to know, is "are these batteries able to run my project, if I need them to?".

Exactly! :wink:

However, as far as I know, the only reason why the batteries cannot supply enough power, is that they have too less voltage.
And this can be checked with reading their voltage.
So if the V_batt is enough (say 7V) then they can supply power for everything, otherwise they cannot.
This is how I would say, the batteries work like. Even if I don't know much about this, neither about the chemistry of them.

The trick is that the battery may have a nice voltage like 8.5V with no load, but it may be good, in which case it will drop to 8.2V when you put a load. Or it could be dead, in which case it might drop to 3V when you put a load.

Testing with no load tells you something -- obviously if the open circuit voltage is 3V, the battery is no good -- but it doesn't give you the full story.

Maybe you've had the experience of using a flashlight with a dead battery, and when you turn it on, it shines well for a half second, and then dims to nothing after about 3 seconds. If you measured the voltage on those flashlight batteries with no load, they would have probably registered alright. It's only when you put the load by turning it on that you see the real situation.

It's really up to you how you want to handle this. You haven't said what the project actually is, so I have no opinion about the relative risk of the two approaches. For all I know, you're building an oxygen meter for a critical care hospital -- or a timer that reminds you to change the water in you tropical fish. Arguably at different ends of a risk spectrum.

Yep, I see - the more reliable the system has to be, the more important is how I check the batteries.
By now, this is just theoretically, for something, that I might need in future. I don't always do things because I need them, but I want to extend my knowledge.

According to what is written on the battery, it is a Mignon LR6 (according to IEC), and this is what Wikipedia knows as Alkaline/Manganese battery.
So, this is a battery, you told, that does not reveal its real quality by measuring OCV. Is it a value I cannot trust on, or one I should just change the threshold to a higher value?

gardner:
The trick is that the battery may have a nice voltage like 8.5V with no load, but it may be good, in which case it will drop to 8.2V when you put a load. Or it could be dead, in which case it might drop to 3V when you put a load.

Testing with no load tells you something -- obviously if the open circuit voltage is 3V, the battery is no good -- but it doesn't give you the full story.

Maybe you've had the experience of using a flashlight with a dead battery, and when you turn it on, it shines well for a half second, and then dims to nothing after about 3 seconds. If you measured the voltage on those flashlight batteries with no load, they would have probably registered alright. It's only when you put the load by turning it on that you see the real situation.

It's really up to you how you want to handle this. You haven't said what the project actually is, so I have no opinion about the relative risk of the two approaches. For all I know, you're building an oxygen meter for a critical care hospital -- or a timer that reminds you to change the water in you tropical fish. Arguably at different ends of a risk spectrum.

Not if you are the fish! :wink:

Not bad :smiley:

It is really not easy for me to decide how much worth it is the possibly effort, if at all.

retrolefty:

gardner:
or a timer that reminds you to change the water in you tropical fish. Arguably at different ends of a risk spectrum.

Not if you are the fish! :wink:

Actually from the point of view of the fish those two situations would still be at different ends of the risk spectrum, it's just the designation of what end is "Low" and "High" would change. After all, why would the fish care about what goes on in a human hospital... :stuck_out_tongue:

retrolefty:
Not if you are the fish! :wink:

Fish rarely litigate. Although the SPCA dragged some poor bastard into court here in Ontario charged with failing to brush the dog's teeth, so you never know I guess.