# Pull up resistors

Discussion in 'The Projects Forum' started by campeck, Sep 15, 2010.

1. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
A couple of questions on pull up resistors for CMOS. In particular a TS339 comparator. I am confused about the leakage current. I assume since the resistor is tied high that it is going from resistor to the IC. But using this current how do you come up with the resistor value? What parameters do you need to know? And what is the math and why?

Thank you!

2. ### Ghar Active Member

Mar 8, 2010
655
72
I'm assuming you're talking about output leakage when the output is supposed to be high, right?

A comparator like this can only pull down, it's simply a transistor from output to ground.
When the transistor is turned off it still allows some current to pass through it though, should be on the order of microamps or less even. The TS339 datasheets I checked don't actually give a number.

Basically what that number does is it puts a maximum on the pull up resistor you can use.
With the leakage current and no load on the output you can say that:
Vout = Vcc - Ileak*Rpullup

If Rpullup is too large the leakage current will prevent Vout from going above some value.

It normally isn't a problem since the leakage is so small.

3. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
If you look in the datasheet, you will see that Vout will be around 400mV to 600mV when it is sinking 6mA current. That's pretty close to the LM339, which is a bjt comparator.

I usually shoot for 3mA to 4mA sink current for the LM339, LM393, and LM2903 comparators.

Basically, calculate: Rpullup = Vcc/0.0035 (3.5mA) and then select the closest standard value of resistance.
Standard value table: http://www.logwell.com/tech/components/resistor_values.html

For example, if the voltage on the high side of the resistor will be 7v, calculate:
Rpullup = 7/0.0035 = 2000. 2k Ohms is a standard value of resistance, so we lucked out on that one.

4. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
Ok so let's say a leakage of 1mA and a logical high is 4.5V and supply is 5V.
I would use a resistor of maximum 500ohms?

And sgt...his answer made a little more sense to me...yours is eluding me. haha. But I wan't it to make sense to me. badly. So lets see.

So when sinking 6ma when the 339 is on if you measure from ground to output you get .4v. That makes sense.

Ghar said to calculate it based on keeping the line high with the leakage current going into the device while off. So we have a fixed amount of current going into the device (?) so I calculate a resistor to drop a minimum voltage to keep it above a logic high to whatever circuitry it will be powering.

You are saying that while the device is conducting to limit the amount of current it is sinking(?)
You say use a 2k ohm resistor but this doesn't take into account the leakage current. Or where you taking it into account by saying you like to use 3.5mA on those particular chips?

Also right about that .4v in the datasheet is High Level Output Current. How does that work? I thought when high it was still sinking a leakage current and that's what Ghar said determines the highest pullup resistor for it.

5. ### Ghar Active Member

Mar 8, 2010
655
72
You really shouldn't run into leakage current problems except in very strange situations or if you're going for the absolute smallest power consumption.

The LM339 is rated as having a leakage of less than 1 uA over the full temperature range.

If you want your output from a 5V supply to stay above 4.5V.... the maximum resistor size is:
Rpu = (Vcc - Vout)/ Ileak
Rpu = (5 - 4.5) / 1u = 500 kilohms.

With 500 kilohms and say, a logic gate input of 10 pF, it will take you 5RC = 25us to charge up, limiting your frequency to less than 20 kHz if you were clocking something.

6. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
See that formula right there is good to have. Is there any other formula or consideration besides leakage current when picking one? any formulas to go with that?

I suck so bad at math I can't even see how you flipped your two formulas around to isolate the Rpu. It really aggravates me.

7. ### Ghar Active Member

Mar 8, 2010
655
72
Well you somehow correctly calculated 500 ohms for 1mA leakage so you can't be that bad.

The other considerations for picking a pull up are power consumption and switching speed, which I already hinted at, along with any other special requirements from the load you're driving.

For example if you were driving an LED in series with the pull up you'd want 10mA or so, giving you something like:
Rpu = (Vcc - Vf) / If = (5 - 2)/ 10mA = 300 ohms

You might want to add the non-zero pull down voltage of the comparator in there.

It's really a matter of figuring out your application and then deriving a valid equation... there's rarely "the equation for x" that works for everything. This is why many people just go with a standard middle of the road value like Wookie mentioned. Something in the few kilohm range should work pretty well in most situations.

8. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3

Well you had already given me the formula! I can put numbers into something and solve it.

That second part is what I can't do. And let me tell you...Nothing frustrates me more in life. seriously.

9. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
Ghar, that's the first bad advice I've seen you give. Other than that, you have a very good track record.

Don't expect the LM339, LM393, LM2903 to sink more than 6mA without problems.

You just gave an example that exceeded the minimum specifications, and will cause problems.

If you keep the max sink current within 3mA-4mA, you will be fine. The formula has already been given for that.

If more sink current is required, a buffer/voltage follower will be required.

10. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
Rpu =Vcc -(Vnzpd + Vf) / If = 5 - (.4v + 2)/ 10mA = 260 ohms

But that is just calculating an LED resistor. And I struggled with that for a long time a year or so ago. haha

now coupling that with some leakage current and turn on time requirements is where I would be in way too deep...

11. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
I suck at math, too. That's why I post every nauseating step of the calculations I use, because I figure any other "math rock" like me will understand them.

It takes a lot of effort to read the datasheets and figure out what you can actually get away with on a given component. A good "rule of thumb" is to de-rate the current by 50%; or just divide the max current rating by 2.

This works pretty well for transistors, if you follow the heat sinking requirements.

12. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
The TS339 says its output current is 20mA. Although that is confusing because I thought it only sank current? It also says output voltage. But I thought it doesn't output anything...

13. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
thank you.
I will have to pick this thread up tomorrow. I need to go to sleep.
Thanks guys.

14. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
Except you really shouldn't try to sink more than about 4mA from the output of that comparator.

Ghar made an honest mistake. I've made LOTS of honest mistakes on here.

If you stick with de-rating the sink capacity of the comparator by 50%, or about 3mA to 4mA, you won't go wrong.

15. ### Wendy Moderator

Mar 24, 2008
20,766
2,536
Gee Wook, you going to bring that up again.

16. ### campeck Thread Starter Active Member

Sep 5, 2009
194
3
So what is with the data sheet saying output voltage and current? does it mean sinking the output?

17. ### Ghar Active Member

Mar 8, 2010
655
72
That's what I get for inventing a calculation without thinking about it
I almost said 5mA and it would've looked like I did think but said eh, people like 10!

Thanks for catching it.

Last edited: Sep 16, 2010
18. ### marshallf3 Well-Known Member

Jul 26, 2010
2,358
201
Seems I once found a comparator that had a better sink rating, but why haven't they ever produced one that could handle a more reasonable current? I realize there's probably little money left in designing and producing discrete chips but you'd think at some point in time they would have made an OC comparator that could sink sufficient current to drive a 20 mA LED.