Jump to content

I have an op amp question for those who, unlike me, actually know how these things work!


G+_Chris O'Riley
 Share

Recommended Posts

opamp_batt.jpg

I have an op amp question for those who, unlike me, actually know how these things work!

 

My goal is to check the voltage of a battery without draining it while the device is off/not active. I don't need to know the voltage at all times, only when it drops below a given level. Basically, I just want to have the device know when a lipo cell drops too low.

 

So, in the attached schematic, the microcontroller (powered by a 5v boost regulator not shown) drives PB0 high, which would be 5 volts. That goes through a resistor divider to drop it to my cut-off voltage of, say, 3.5 volts. That, and the +v from the battery go to the inputs of an op amp. The output of the op amp is read by PB2. Once the battery voltage drops below the 3.5v from PB0, shouldn't the output of the op amp flip from + to - or vice versa?

 

From what I've read, op amps draw virtually no current from the inputs vs. connecting the battery directly to a microcontroller input even through a high-ohm resistor.

 

Ok, so what do I have totally wrong? ;) Or would the battery drain through, say, a megaohm resistor directly to a pin be so low as to not be worth the effort to try to improve on?

 

Thanks in advance!

Link to comment
Share on other sites

I'd be powering the micro (and other things) from a 5 volt boost regulator from the same battery being measured. So it would always have a stable 5 volts from which to generate the 3.5 volt reference to compare with the voltage directly from the battery. I suppose I could connect the resistor divider directly to the +5 supply from the boost regulator vs. a pin on the micro.

 

But so long as I choose an op amp with an appropriate voltage range, it sounds like you're saying this would work?!!

 

I looked at analog comparators as well, and it seems they're basically this type of circuit. Almost all the op amp circuits I've seen use feedback from the output back into one of the inputs, but for what I'm looking to accomplish, it didn't seem like that was necessary.

 

Thanks for the reply!

Link to comment
Share on other sites

The circuit performance will have extreme variations depending on the particular Op-Amp used. In particular the input leakage current can be anywhere from picoamps up to milliamps.

 

Here's a good tutorial on Op-Amps, read sections 1 through 3 and then you can skip up to section 11 for comparator applications.

electronics-tutorials.ws - Operational Amplifier Basics - Op-amp tutorial

 

If you don't want to go that in depth on Op-Amps I suggest looking at one of the battery monitor IC's where the manufacturer has worked out all the analog issues for you. If on the other hand you want to learn a lot about Op-Amp applications I highly recommend The Op-Amp Cookbook by Walter Jung.

Link to comment
Share on other sites

I would do it all in code on the microcontroller. I would have it read an input pin and then "map" that reading to a scale (say 0 to 10), and then if the value drops below your threshold voltage, do something (send a text, flash a warning LED, etc.) Set a delay so it only reads once every X minutes (hours?)

Link to comment
Share on other sites

Thanks for the comments and ideas everyone, I'm reading up more on op amps. I was under the impression there was very little input current leakage, which made me assume they could be used in this case without draining the battery.

 

Ben, thanks for the link, I'm looking to build this into a very small PCB, so that wouldn't work as a separate component, but I'll definitely investigate how it works.

 

For some more details, I've been checking battery voltage by reading directly with a pin on an ATtiny. The device I'm working on has a on/of switch, which I'm interested in eliminating. The on/off switch completely cut off the battery from the circuit, but now I'm hoping to use a momentary button for on/off by temporarily pulling up an enable pin on a boost regulator, which would then be held high by a pin on the micro. When it finished doing it's thing, the micro would pull the enable pin low, basically cutting it's own power and turning everything off. But that would mean the battery would be connected permanently, which means if I want to read the battery voltage, I have to do so in some way that won't continually drain it 24/7, or at lest slow enough that the drain would be negligible.

Link to comment
Share on other sites

Chris O'Riley I haven't used one and haven't read about them in many years but, IIRC the A2D inputs on an ATtiny have very low current draw so unless you choose an Op-Amp with lower input bias current it won't help.

 

Also I seem to remember that at least some of the parts in the ATtiny line have an analog comparator built-in that IIRC has even lower input bias current than the A2D inputs.

Link to comment
Share on other sites

Chris O'Riley Learning how OpAmps work is fine, but you might not want to use one for this project. The ATtiny can do what you want. Adding any other device (such as an OpAmp) will only draw more current and defeat your purpose.

You'll need an ATtiny programming board, something like this:

sparkfun.com - Tiny AVR Programmer - PGM-11801 - SparkFun Electronics

and the free Arduino software. Plus you'll need to install the proper drivers into the Arduino software to recognize the ATtiny, but all that is easy enough.

Link to comment
Share on other sites

 Share

×
×
  • Create New...