LM339 Pullup resistor value

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Kent, luketeaford, Joe.

Post Reply
artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

LM339 Pullup resistor value

Post by artparks » Fri Jan 15, 2021 5:26 am

I'm making a 4017 (baby-8) style sequencer with four channels and am using an LM339 to generate tidy clock signals from potentially messy inputs. While breadboarding I've been using a +5/-5 square LFO as a clock as it was a good candidate for something that would need "cleaning up".

What I noticed, however, is the gate being high or low on the input would affect the power on the 12v rail. Obviously the clock only cares about the leading edge, but halfway through the clock cycle the square would go low and at this point the voltage would drop on the power rail. The more channels I had running on the LM339, the more it dropped, up to about 30mv with all four running. For a 4017-based sequencer (and probably in general!) this is no good as the output of the sequencer is essentially just an attenuated voltage from that rail, so if it moves that much halfway through a clock cycle, you're going to hear it.

Initially I was using 3.3k pullups on LM339, I switched these out to 150k and, hey presto, it seemed to fix the problem. There's now perhaps a 1mv drop, but it's well within my tolerances. Can anyone explain what was happening to cause the voltage to fluctuate like this in the first place, and why using larger resistors fixed it? And also, is using resistors of that value likely to cause a problem - would it just mean the unit as a whole will draw slightly more current? Guidance I read elsewhere suggested pullup values in the low thousands, not 100ks.

FWIW the LM339 circuit is basically that used in the CGS gate sequencer here: https://sdiy.info/wiki/CGS_gate_sequencer

User avatar
guest
Super Deluxe Wiggler
Posts: 5602
Joined: Mon Aug 19, 2013 11:49 am

Re: LM339 Pullup resistor value

Post by guest » Fri Jan 15, 2021 5:52 am

when the LM339 output goes low, the 3.3k is connected between +V and ground, so if thats a 12V rail, thats 3.6mA being drawn. if you added another 3.3k for each channle, then thats 14.4mA for four channels. if theres a bit of resistance in your powerupply line, that extra current can cause a voltage drop. to get 30mV, youd only need about 2ohms of resistance, which long powerlines or bad connectors could easily provide. going to larger pullup resistors reduces this current, as the cost of speed of transition, which probably isnt an issue here.
openmusiclabs.com

artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

Re: LM339 Pullup resistor value

Post by artparks » Fri Jan 15, 2021 6:07 am

guest wrote:
Fri Jan 15, 2021 5:52 am
when the LM339 output goes low, the 3.3k is connected between +V and ground, so if thats a 12V rail, thats 3.6mA being drawn. if you added another 3.3k for each channle, then thats 14.4mA for four channels. if theres a bit of resistance in your powerupply line, that extra current can cause a voltage drop. to get 30mV, youd only need about 2ohms of resistance, which long powerlines or bad connectors could easily provide. going to larger pullup resistors reduces this current, as the cost of speed of transition, which probably isnt an issue here.
Interesting, thank you. I have several breadboards with their power rails dasiychained together - I noticed that the problem was at the worst on the boards at the end of the chain, ie those that had gone through several jumper wires. Presumably this would have been adding extra resistance and causing this exasperation?

User avatar
guest
Super Deluxe Wiggler
Posts: 5602
Joined: Mon Aug 19, 2013 11:49 am

Re: LM339 Pullup resistor value

Post by guest » Fri Jan 15, 2021 7:13 am

yes, thats correct. putting capacitors across the power rails can help some, but only for short durations of extra power draw.
openmusiclabs.com

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1968
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: LM339 Pullup resistor value

Post by devinw1 » Fri Jan 15, 2021 11:53 am

As guest mentioned, the transition speed will increase with a lower pullup, but will draw more current in the off state. 150k is pretty huge. That will make a pretty miserably slow transition, but for this maybe it is OK? The LM339 is not a particularly high speed comparator, but for example the transition time is listed as 1.3uS for a 5.1k pullup to 5V.

User avatar
MikeDB
Veteran Wiggler
Posts: 526
Joined: Fri Feb 08, 2019 8:28 am
Location: UK

Re: LM339 Pullup resistor value

Post by MikeDB » Fri Jan 15, 2021 12:16 pm

First consider feeding the comparators and pullups from a separate power cable. Also do you need a full 12V switched output ? If not either use the 5V line if present, or put in a 9V regulator on this new 12V line to isolate everything else from switching noise.

artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

Re: LM339 Pullup resistor value

Post by artparks » Fri Jan 15, 2021 3:49 pm

Does transition time refer to the steepness of the rising edge, or the delay in responding to changes on the inputs? Either way, I'm only using it to clock a sequencer at "musical" rates, so I doubt the sort of lag this might cause would matter much here.

I had it swinging 0-12v based solely on something I read about 4017s being fussy about being clocked by voltages much lower than their VCC, I may well be able to just use 5v, I've not tried. If I can keep the 12v in the module clean by regulating it to 5v then let the 339 mangle that "rail", that'd work fine - assuming it clocks OK.

User avatar
MikeDB
Veteran Wiggler
Posts: 526
Joined: Fri Feb 08, 2019 8:28 am
Location: UK

Re: LM339 Pullup resistor value

Post by MikeDB » Fri Jan 15, 2021 4:25 pm

Yes the 4017s need to be driven from the same rail as their Vcc so you would need to drive the 4017 from 5V as well

artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

Re: LM339 Pullup resistor value

Post by artparks » Fri Jan 15, 2021 4:45 pm

Hah, but then I'd have the messy fluctuating output from the 4017 again! I'll play around with some regulators and see if I can find a way of isolating a supply to be used only by the 339s and keep the mess solely in there. Or just give up and use 150k resistors because meh it works.

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1968
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: LM339 Pullup resistor value

Post by devinw1 » Fri Jan 15, 2021 5:06 pm

artparks wrote:
Fri Jan 15, 2021 3:49 pm
Does transition time refer to the steepness of the rising edge, or the delay in responding to changes on the inputs? Either way, I'm only using it to clock a sequencer at "musical" rates, so I doubt the sort of lag this might cause would matter much here.
yeah, the former. The capactive load seen by the comparator works in conjuction with the size of the pullup to determine the steepness and time constant that it takes the output to go from Low to High based on a step input.

User avatar
guest
Super Deluxe Wiggler
Posts: 5602
Joined: Mon Aug 19, 2013 11:49 am

Re: LM339 Pullup resistor value

Post by guest » Fri Jan 15, 2021 8:54 pm

in case it wasnt clear above, if your 4017 is running of 12V, your LM339 needs to go to 12V. if the 4017 is at 5V, then the LM339 should be at 5V. mixing the levels up can cause higher than normal current draw. the resistor only controls the rise time, the fall time will still be very fast. with a 150k pullup, your still only looking at ~10us rise times, so not too bad (depending upon how many chips your driving and trace length, etc).
openmusiclabs.com

User avatar
MikeDB
Veteran Wiggler
Posts: 526
Joined: Fri Feb 08, 2019 8:28 am
Location: UK

Re: LM339 Pullup resistor value

Post by MikeDB » Sat Jan 16, 2021 1:40 am

Another way to solve this would be to use a comparator with a CMOS output stage. They are rarer but there is the STMicroelectronics TS3702 for example. That would give you very fast rise and fall times and very little noise on the power supply lines so no regulators or special power lead needed.

artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

Re: LM339 Pullup resistor value

Post by artparks » Sat Jan 16, 2021 4:05 am

guest wrote:
Fri Jan 15, 2021 8:54 pm
in case it wasnt clear above, if your 4017 is running of 12V, your LM339 needs to go to 12V. if the 4017 is at 5V, then the LM339 should be at 5V. mixing the levels up can cause higher than normal current draw. the resistor only controls the rise time, the fall time will still be very fast. with a 150k pullup, your still only looking at ~10us rise times, so not too bad (depending upon how many chips your driving and trace length, etc).
So if I go down this route, when laying out the PCB is it worth trying to keep the pullup/339 output/4017 clock-in physically close together?
MikeDB wrote:
Sat Jan 16, 2021 1:40 am
Another way to solve this would be to use a comparator with a CMOS output stage. They are rarer but there is the STMicroelectronics TS3702 for example. That would give you very fast rise and fall times and very little noise on the power supply lines so no regulators or special power lead needed.
Thanks - that looks like a very nice solution, now to try and find a DIP version for the breadboard!

User avatar
cygmu
Super Deluxe Wiggler
Posts: 1661
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK

Re: LM339 Pullup resistor value

Post by cygmu » Sat Jan 16, 2021 4:52 am

I've used TLV3704 for this which is available in DIP. I seem to recall reading someone saying something negative about those parts somewhere recently but I can't find it now.

artparks
Learning to Wiggle
Posts: 43
Joined: Sun Feb 23, 2014 4:01 pm

Re: LM339 Pullup resistor value

Post by artparks » Sat Jan 16, 2021 5:14 am

There's a few (apparently obsolete) TS3704s on eBay in DIP. They're £5 though so I refuse to pay that for one IC that I'll probably just set fire to! I'll just use an adaptor for now... I assume that TLV3704 is the TI version of the TS3704? It looks very similar in spec, just costs a bunch more per chip.

User avatar
JimY
Wiggling with Experience
Posts: 384
Joined: Wed Nov 09, 2016 10:03 am
Location: Middle of Wales

Re: LM339 Pullup resistor value

Post by JimY » Sat Jan 16, 2021 6:05 am

Fortunately, the 4017 clock input has a Schmitt trigger so can tolerate slow rising edges. Other CMOS logic clock inputs aren't so lucky, it can jitter from slow rising edges. A 4013 D-type can double clock off a slow edge. It's a pity the outputs of the comparators are that way around, but I think that TTL logic was the target market and those normally clock on the falling edge and a high pull-up resistor value can be tolerated.

There should be no problem powering the comparator chip from a higher or lower voltage +supply than the counter has, but the output pull-up resistor must be terminated to the counter chip +supply. This is the advantage of the comparators having those "open-collector" outputs. Funnily enough, the current TI datasheet calls the output "open drain" while showing a BJT output in the device circuit. I'm pretty sure this is a typo. The old National Semiconductor datasheet has much better info than the TI one. An LM399 output can sink loads connected to as high as 30v while running on only 5v.

Post Reply

Return to “Music Tech DIY”