Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Battery sensor incorrect. Need correct D1 and D2 values

Status
Not open for further replies.

mik3ca

Member
I'm lost.

I thought I picked the perfect diodes. When I picked them up at the store, one was labelled 3.3V and one 4.3V so I figured by using them I'd get two ground outputs at the NPN collectors if the battery voltage is > 5 (4.3V + 0.7V) and I figured one of the two NPN collector outputs is ground if battery voltage is > 4 (3.3V + 0.7V). I got the 0.7V as the estimated voltage required to turn the NPN on.

I take out the voltmeter and run some tests and my theory seems a bit flawed. On a battery that's half-dying one NPN collector output reads about 3.2V and the other NPN collector output reads about 4V. On a good almost new battery, both NPN collectors read about the same voltage at 4V. I measured these voltages inverted style (+ve lead of meter to VCC and -ve lead of meter to NPN collector).

Now if I subtract the two from 5 to get the real, the experiment went wrong because all voltage values are under 2 which to the micro can mean logic low in every case.

I mean I could change the resistor but I don't want to go too low or I will blow up the diodes. I do think I need to change the diodes but I don't want to use too low of voltage or I might blow up the microcontroller since the battery I'm using is 7.2V which is what the resistor is connected to.

The microcontroller is connected to 5V supplied by a voltage regulator (LM2940) the 7.2V battery also feeds.

I want to detect when the voltage from the battery drops just below 5.5V (since LM2940 needs 0.5V for its own processing) and I also want to detect when the voltage drops just below about 4.5V since the microcontroller needs 4V minimum to run.

How do I go about calculating the optimal diode reverse voltage value or optimal resistor value? or better yet, which diode model numbers would best suit my application?

Here's my circuit for reference.

circuit.png


And I'm not concerned about battery detection speed, as long as I can get an accurate reading at least once a minute.
 
Zener diodes do have a leakage current when biased below the knee. That leakage current is likely enough to cause your transistors to go into partial conduction. You could try adding a 4.7k resistor from each base to ground.
 
Low voltage zener diodes are less accurate and less stable with temperature than higher voltage ones. Also, your question implies that you want an accuracy of 0.1 V. For a 3.3 V zener, that is less than 5%, a very difficult thing to achieve. Also, there are no pull up resistors on the collectors; the uC might have them internally, but you didn't say. Also, there are no pull down resistors on the transistor bases to assure that they turn off completely. As above, a little leakage current can mess up everything.

ak
 
I'm guessing that you can't just use a voltage divider and an analogue input pin to do this. Assuming digital only you could have battery to Resistor to I/O pin to Capacitor to ground, to measure the voltage you discharge the capacitor by pulling the pin low and timing how long it takes to recharge. If the pin can be damaged by too high a voltage then put a 5V zener across the capacitor. When done properly this can be fairly accurate.

Mike.
 
How about a TL431? Check out the data sheet for the voltage detection circuit.
 
Low voltage zener diodes are less accurate and less stable with temperature...
My circuit doesn't heat up and the voltage regulator on my circuit board is about 1cm away from the nearest zener. I doubt it will heat up ever when the board is powered with 7.2V, but then again, if the temperature rised by like 1 degree max, how will this affect accuracy?

Also, your question implies that you want an accuracy of 0.1 V. For a 3.3 V zener, that is less than 5%, a very difficult thing to achieve.
I guess I have to treat them like carbon resistors but in which reverse voltage accuracy is 5% from correct value at worst?

Also, there are no pull up resistors on the collectors; the uC might have them internally, but you didn't say.
I forgot what the values were but there has to be some since the only values on the pins are high impedance and ground (depending on the value I set in software).

Also, there are no pull down resistors on the transistor bases to assure that they turn off completely. As above, a little leakage current can mess up everything.

How do I calculate the perfect resistor value? because if I pick something too low then wouldn't the transistor be forced off?
 
Try a 1k resistor from each transistor base to ground.
That should shunt away the zener leakage current and give enough forward current so the zener voltage is near its rating. You can change their values to tweak the trigger voltage for each transistor.

You also need a separate resistor in series with each zener, otherwise the low voltage zener hogs most of the current.

Also make sure there are resistors from each collector to the plus supply.
 
You also need a separate resistor in series with each zener, otherwise the low voltage zener hogs most of the current.
Is there a way I can get away with it without separate resistors? I already did my PCB design and adding a resistor means redoing my complex PCB design with 1000+ connnection points.
And itll look funny to twist-tie the leads of a diode and a resistor together.

Also make sure there are resistors from each collector to the plus supply.

Wouldn't the GPIO resistances work since the GPIO pins output either a 100% ground or high-impedance?
 
is there a way I can get away with it without separate resistors?
Don't see how. :confused:
Wouldn't the GPIO resistances work since the GPIO pins output either a 100% ground or high-impedance?
Not likely.
Without a resistor going to a voltage, what will generate a signal at the transistor collector? A ground or a high impedance cannot generate a signal.
All a transistor can do is turn a voltage (current) on and off. It can't generate a signal all by itself.
I already did my PCB
Then you've learned a basic electronic's lesson.
Never build a PCB without breadboarding the circuit first. :arghh:
 
I'm pretty sure that port has internal pullups. I think they're around 150k.

Mike.
 
I'm pretty sure that port has internal pullups. I think they're around 150k.
If so, then you don't need any added resistors at the transistor collectors.
 
First you need two resistors. Other wise the higher voltage Zener will never turn on and conduct.
upload_2018-4-2_20-46-11.png

I'm pretty sure that port has internal pullups. I think they're around 150k.
I thought some of the pins have pull ups and some do not. (need to check)
Agree on the need for B-E resistors.
 
I guess then my answer is to twist tie a resistor to a diode and make two sets of that then. But is the 2.2K resistor value OK or does that need to change?

and the GPIO pins I'm using are from port P2 and digital only (not analog). Only ones on an 8051 that do not have pull-up resistors built-in are port P0.
 
If you have designed for through hole components then you could use 1206 diodes and resistors to bridge the through hole gap. Not ideal but should look neat.

Mike.
 
I searched 1206 and results were smd diode. I'm gonna try my twist-tie method. It should work considering that when solder is on the twist-tie end, the wire is extremely hard to move. I have done that kind of soldering before but not on a professional PCB and yes I'm doing through-hole technology especially when I have an amateur helping me with my project.
 
You don't have to actually twist the wires together. Teepee method: stand each component upright vertically in one hole each, gapped about 2-3 mm above the board. Solder the components to the board. Then bend them toward each other until their leads cross close to the bodies. Trim the excess wire lead down to 1-2 mm above the point where the leads touch. Solder. Much lower profile, cleaner look.

An alternate method is for both components to remain vertical. Bend the lead of one component over so that it crosses the lead of the other component. Trim and solder. For this method, neither component has to be gapped above the board.

ak
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top