Simple Minimum Voltage Sensing Circuit for Battery Condition Concept?

Thread Starter

MechE74

Joined Jun 21, 2018
13
Hello, first time poster so please dont hurt me :D My background is mechanical and I know enough about electronics to be dangerous, but I muddle through as much of it is fun and interesting.

Anyhow, I am working on a project using a microcontroller that can take between 3-5V on its bus logic pins, to control some solenoids, powered by a 20V battery. What I would like to do is to have the system change modes when the battery voltage drains to 15V. This has led me down a worm hole of headache.
First thought was well, I can take a 15V 2% Zener reverse biased and place it across my Positive and Negative bus lines with something like a 220 ohm resistor, the resistor being between the diode and ground. Thought was, any time battery voltage is above 15V, power would go through, and the 220 ohm resistor would keep power consumption low.
Problem with that is I cannot have 15V going to my controller pin. I don't want to do a simple voltage divider using two resistors in series incase the voltage creeps above 5V or below 3.3v on the range.
So I figured well, I can add a second zener, a 3.9V across my tap upstream of the resistor. This way my voltage going to the MCU would be limited to 3.9V as anything over 3.9V will drain to the ground through the Zener.
But that got me thinking the current path will simply avoid the resistor at this point, and simply pass through all of the zeners when voltage is above 15V. So I came up with the concept of two 430ohm resistors. One to replace the 220, and one to go downstream of the 3.9V Zener. See Schematic.

Does this look like this would work? Or am I going about this all wrong. The rest of the circuit is somewhat simple. It feeds a LM2940 to run the microcontroller and some sensors, and the micro controller is connected to IRL540s to run the solenoid. Again, I would like to have the microcontroller poll a bus pin for presence of a high signal from the Zener circuit to alert the user to swap batteries when it drops below 15V.

Thanks!
Voltage Sense Circ.jpg
 

dl324

Joined Mar 30, 2015
16,845
TLDR - post was poorly formatted (to borrow a phrase used by another member "a wall of text") and difficult to read. If you would have just used some whitespace between what would otherwise be a good paragraph, it would have helped.

I'd use a voltage comparator and have it trigger some circuit (like a disconnect) when battery voltage drops too low. You can google "low voltage cutoff" or similar.
 

-live wire-

Joined Dec 22, 2017
959
It sounds like there are two things going on here. You want to make undervoltage protection for your battery and power your microcontroller from a larger voltage source. For powering the microcontroller, simply get a buck (step down) converter. You can go with an SMPS if you want it to really be efficient, or you can go with a simpler linear regulator. You can get one cheap off of ebay. For undervoltage protection, you want something like this:

capacitor for smoothing, ignoring sudden momentary drops --> reference + voltage divider --> op amp as a comparator, high when reference is greater than battery voltage (error signal) --> reset of an S/R latch --> latch connects mosfet to ground, mosfet prevents anything from getting power. latch only gets set by pushbutton.

You need some sort of a latch to avoid oscillations. If you don't know what those components are, or how they work, feel free to ask. You can, of course, get a commercial board that has that protection feature, and more. But it sounds like you really want to do DIY. Also, make sure to fuse it or have some sort of overcurrent protection.
 

Thread Starter

MechE74

Joined Jun 21, 2018
13
Thanks for the replies, this is awesome. Sorry, I tried to make the post describe where I was coming from, but apparently it came out as messy as the mind it originated in.

I am not trying to initiate a power down/reset when the battery starts losing charge.
What I am doing is using a 20V battery with a Ah capacity of between 1.5 and 5Ah. The end result will be used to perform a task that takes about a day. That process will involve firing a 12V, 30W solenoid for a couple of seconds a few times per minute.

The microcontroller and its power supply could run for days and days on one of the small batteries. But I dont want the battery voltage to go below 15V for a few reasons involving the solenoid.

I do not want the MCU to power down when the battery drops below 15V. Since even at a battery voltage of 8V the MCU can still run properly, what I want it to do is to remain powered on, but go into a routine where it sounds an alarm, disables the solenoid and prompts the user to install a fresh battery pack.

I figured I could simply do this by having circuit that sets a pin high or low depending if voltage was above or below 15V on the battery pack. I can think of ways to do this using reference voltage chips and op amps etc but the parts start accumulating for what seems to be such a simple task.

Thats what had me messing with the idea of Zeners in that step setup. But admittedly I have not done much with them, which is why I am asking. I dont know if it wont work at all, if it may possibly cause some current loop I dont see and burn up, and I definely dont want it burning up my MCU.

DL324 did send me down a path I have been looking at. I found an interesting thing at http://www.bhabbott.net.nz/lvw.html using a TI TL431. It has an internal 2.5V VREF. Using the "Simple Low Voltage Warning" diagram on that link, I could set a voltage divider using a 5.6K for R2 and a 1.1K for R3 which would flop the VREF pin theoretically when the battery voltage dips below 15.22V.

lvw.gif
If all that is correct thus far, the part I am still trying to figure out is how to use this to send a high or low signal to my MCU that will not damage it. Still using that diagram(to an extent) I would get rid of the LEDs and replace them with a resistor, we will call that R4. I am still fine tuning resistor values, but it looks like if I used a 5.6K resistor for R1 and a 2K for R4(the ones that replaced the LEDs), with a 20V battery I would have 5.26V at pin 3 on the TL431, and down at 15V just before the TL431 switches I would have 3.94V. Then when the battery voltage drops below 15.22V, because of the R2/R3 voltage divider on pin 1, the device will go to ground and pin 3 will essentially be zero volts?

So does it seem like I am getting this figured out? If all that is correct I would simply tie pin 3 on the TL421 to my MCU I/O pin bus. I just need to tweak the R1 and R4 to prevent the voltage at that node from exceeding 5V when battery voltage is a full 20V.
 

Reloadron

Joined Jan 15, 2015
7,501
It would be nice if your micro-controller had analog input capabilities. Assuming you don't have that option I would let a simple small comparator circuit provide a logic input to your micro-controller. I would run the micro-controller and the comparator on 5.0 Volts. While there are all sorts of buck / boost devices since your micro-controller and a basic comparator circuit won't draw any current to speak of I would likely use a plane Jane 5 volt regulator like the old LM7805 as it is not like you will be dissipating any power to speak of. My guess is you are using DO (Digital Out) from your uC to drive your logic level MOSFETs which switch a higher voltage for your solenoids. I would use a simple comparator like the LM111, LM211, and LM311 devices. If I want a comparator I use a comparator. I would use maybe a 10K potentiometer to set Vreference and my Vinput I would just use a 4:1 voltage divider so 20 volts is now 5 volts and your lower limit of 15 volts becomes about 3.75 volts.

Something to think about is using hysteresis which a Google of Hysteresis in Comparators should explain. The idea is when a battery voltage drops to a preset level and we remove the load, in most cases that battery voltage will increase under no load so our micro controller just starts seeing yes, no, yes, no or a string of ones and zeros. Really depends on how you write your uC code.

Ron
 

-live wire-

Joined Dec 22, 2017
959
I recommend getting a buck/boost converter with a high efficiency. This will step the voltage up or down to one constant, andjustable voltage. Then, have some sort of undervoltage protection to not supply power to it when the battery reaches a dangerously low voltage. This seems like the best solution here.
 

Thread Starter

MechE74

Joined Jun 21, 2018
13
Thanks Ron. You have a pretty good grasp of what I have going on. You mention a 7805, Im using a LM2940 but 6 of one, half dozen of the other. No A/D conversion. No desire to add one either, although I guess I could incorporate a battery gauge if I did.. Yes using mosfets to drive the solenoid. I may use a buck converter to limit the voltage to the solenoid, but that's beside the point.

Its been a long day and things are getting difficult. I see what you are saying about using the voltage divider on the LMX11. I think I need to take a break for a bit and rest my head, but is there an internal vref on the LMX11, or do I have to drive one of the pins with a VREF to compare to?
 

Reloadron

Joined Jan 15, 2015
7,501
Yeah, I understand brain saturation leading to overload. :) Using a basic comparator circuit you set your voltage reference. I would just place a 10K pot in there. That allows you to set your reference. Comparators like those I linked to are pretty common as are their circuits. The LM2940 low dropout flavor is fine and like you said, six of one and half dozen of the other. If you want a cartoon (drawing) I can make you one.

Ron
 

Thread Starter

MechE74

Joined Jun 21, 2018
13
A very belated thanks to all, especially cructschow! I tried to mess around and "improve" on your layout, but couldn't. It worked too flawlessly.
Its all soldered in the proto breadboard and functioning exactly as planned. No trimmer pots, just 0.5% resistors and it trips right at 15.1V.

Thanks again yall!!!



2018-07-10 16_17_16-[ TimerBoard _] (C__DATA_Scott Stuff_4D_KiCad Board).jpg
 
Top