EEVblog #392 – 555 LED PWM Hack - Page 1
Forum section: electronics / general

author: EEVblog
author_rank: Unknown
timestamp: November 28, 2012, 11:50:56 pm
content: Dave.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: November 29, 2012, 12:24:02 am
content: Hi,The advantage of the single pnp output transistor that Dave chose is that it's base resistor is simply grounded by the open collector output of pin 7. All you really have to be aware of with pin 7 is Ic max and Vce Max. Couldn’t be any simpler.(maybe a pull up resistor for the base of the pnp, but it seems not to need it )Mr Smiley

author: IanB
author_rank: Super Contributor
timestamp: November 29, 2012, 03:09:41 am
content: "There's nothing wrong with a bit of heat shrink"Well maybe, but I'm not so sure. I believe a few of us would have a desire for a mounting arrangement with a little more polish. It's a fancy expensive instrument, it surely wouldn't hurt to have a nice looking box with a knob for the dimming control?

author: EEVblog
author_rank: Unknown
timestamp: November 29, 2012, 03:32:29 am
content: Quote from: IanB on November 29, 2012, 03:09:41 amOf course not, you can do whatever you want, and I support you. I'm happy with heatshrinkDave.

author: John Wilson
author_rank: Newbie
timestamp: November 29, 2012, 03:39:04 am
content: Quote from: Mr Smiley on November 29, 2012, 12:24:02 amOk, here's a perhaps stupid question for you. What would be required to use an NPN transistor?

author: SeanB
author_rank: Super Contributor
timestamp: November 29, 2012, 04:32:07 am
content: Use it in place of the PNP, and heatsink it, as it will then have about 5V drop across it due to the output stage drop of the 555 and the base current limiting resistor. The PNP is used because you can have the load connected to the ground and control the positive supply, with the transistor used as a saturated switch with low voltage drop.

author: IanB
author_rank: Super Contributor
timestamp: November 29, 2012, 05:36:51 am
content: So for my own edification, why wouldn't this work:Just curious about why a PNP does better than an NPN in this application?

author: Bored@Work
author_rank: Super Contributor
timestamp: November 29, 2012, 06:56:44 am
content: Putting that circuit in series with the constant current source constantly wacks the LM317 out of regulation. Every time the transistor turns off the LM317 will try to drive its output to the maximum voltage (to keep up the current) thereby losing regulation. When the transistor turns on again it takes the LM317 a little bit of time to regulate again, i.e. drive its output voltage down so the constant current is maintained.The result should be that you have current spikes going into the LEDs.Now, LEDs are typically specified to deal with certain current spikes, but still it doesn't increase the lifetime of the LEDs. I would assume that LED assembly is rather expensive, so having to replace it early will cost a bit of money.I would look for the current spikes and if they are significant either use a parallel PWM (stealing current from the LEDs by switching between on and shorting to ground), or adding a bit of inductance to limit the spikes.

author: LarsT
author_rank: Contributor
timestamp: November 29, 2012, 10:21:04 am
content: Perhaps a stupid question, but is there a reason a transistor was chosen instead of a mosfet in this project?

author: dr_p
author_rank: Frequent Contributor
timestamp: November 29, 2012, 11:43:22 am
content: Quote from: LarsT on November 29, 2012, 10:21:04 amSince someone had no signal diodes and resorted to using LEDs, maybe the FET basket was misplaced as well.)He measured 1.7V drop on the resistors so a total of 5.5-6V from the LM317. Drop some on 555 and there's enough voltage to drive a logic N-FET. But you'd have to use a pull down resistor I think.But what I don't get is why he didn't put this adaptation before the LM317, on the input. You would have PWM and then CC and I think it solves some possible problems. Looks maybe? (heatshrink would be visible on the bench)

author: LarsT
author_rank: Contributor
timestamp: November 29, 2012, 12:52:49 pm
content: Quote from: dr_p on November 29, 2012, 11:43:22 amThat's plausible.Would it be possible to use 1N4001 diodes in this circuit instead of leds?

author: IanB
author_rank: Super Contributor
timestamp: November 29, 2012, 03:16:22 pm
content: Quote from: dr_p on November 29, 2012, 11:43:22 amI wondered the same thing. But I think the answer is to have the brightness control within easy reach while looking through the scope. For that you need the control pot to be positioned close to the microscope head and not far away on the bench.

author: sniti
author_rank: Newbie
timestamp: November 29, 2012, 03:34:41 pm
content: Quote from: Bored@Work on November 29, 2012, 06:56:44 amWondered about the same thing. Another idea for the hack would be a currentregulator before the microscope (and the internal regulator). The internal LM317 would then work in current mode only when on maximum light setting, when using the regulator on the outside it would only drop the minimum voltage.But the LEDs seem to be easily replaceable, so it shouldn't be that big problem, if their lifespan is decreased a little (would be still better than on cheap LEDs). And a design without to much parts or a big heatsink has its benefits.. I'd only put in a second transistor to get 10 to 100 percent brightness.

author: AlphZeta
author_rank: Regular Contributor
timestamp: November 29, 2012, 03:37:18 pm
content: Not exactly the point of this hack. But wouldn't it be easier to just replace one of the current setting resistors with a pot in the LM317 CC circuit to achieve the CC adjustment (although I suspect that low value pot is hard to come by)?Of course, the mod wouldn't be as exciting then

author: somlioy
author_rank: Regular Contributor
timestamp: November 29, 2012, 04:08:58 pm
content: The circuit looks very similar to one I did earlier, except that I didnt have that cap on pin 5 and I hooked the base of the transistor to pin 3 together with the diodes. Is there any advantages doing it like you over my setup?

author: eV1Te
author_rank: Regular Contributor
timestamp: November 29, 2012, 04:21:20 pm
content: Quote from: Bored@Work on November 29, 2012, 06:56:44 amDid I miss something, I thought that was exactly what Daves circuit was doing? Breaking the CC output with an PNP or NPN before or after the LEDs shouldn't make a difference?

author: madires
author_rank: Super Contributor
timestamp: November 29, 2012, 05:26:23 pm
content: Quote from: Bored@Work on November 29, 2012, 06:56:44 amIMHO that LM317 constant current source is a bad design anyway. A constant voltage would be better suited since each LED has got a current limiting resistor. If LEDs fail the CC would increase the voltage (up to what the power brick delivers minus the voltage drop of the LM317) to drive the CC. But that higher voltage causes more current for the remaining LEDs.QuoteJust replace the CC with a CV :-)

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: November 29, 2012, 07:39:17 pm
content: Quote from: John Wilson on November 29, 2012, 03:39:04 amYou have three options if you want to use a npn transistor,1/ Calculate the required base resistor and drive it from the original Dave Cad drawing from pin 3 which if i remember correctly is a totem pole output.2/ Calculate the required base resistor for the npn power transistor, connect that between pin 7 and Vcc, then connect the power transistor base to pin 7, problem with that is that when the power transistor is on; when pin 7 is open you draw Ib through the power transistor. And when pin 7 is on, pulled low, you still draw Ib, but this time it's just dumped to ground and wasted.3/ A pnp driving a npn using pin 7. A pull up resistor from pin 7 to Vcc ( say 10K) a calculated base resistor from pin 7 to the base of a pnp transistor, the collector of the pnp connected to the base of the npn power transistor through a calculated base resistor for the power transistor and possibly a pull down resistor from the base of the power transistor to ground.

author: ivan747
author_rank: Super Contributor
timestamp: November 29, 2012, 09:18:02 pm
content: Quote from: Bored@Work on November 29, 2012, 06:56:44 amI would use the parallel PWM method. It also keeps the frequency the same. I don't like the idea of having a 555 connected to what is basically an AC source with a DC offset. It must be an EMI madness. Parallel PWM should reduce EMI because the current that goes trough the long wires is more or less constant.I will try some variations of this circuit during the weekend.Anyway, the circuit is very clever, thanks for the video, Dave.

author: EEVblog
author_rank: Unknown
timestamp: November 29, 2012, 10:14:51 pm
content: Quote from: Bored@Work on November 29, 2012, 06:56:44 amYes it does, but it's small.Remember the LED's all have 82ohm protection resistors, so absolute worst case with the regulated 9V DC plugpack is:(9V - LM317drop(say2V) - 3V) / 82ohm = 48mA(ignoring the transistor drop)In practice the actual voltage to the LEDs peaks at around 5.5V before it starts to recover to 4.5V, see attached.So peak current would be just over 30mADave.

author: EEVblog
author_rank: Unknown
timestamp: November 29, 2012, 10:22:33 pm
content: Quote from: IanB on November 29, 2012, 03:16:22 pmCorrect. Convenient location.At the base, or before would suck.Dave.

author: Ajmal182
author_rank: Newbie
timestamp: November 30, 2012, 07:48:34 pm
content: Hi Dave, Im actually trying to build a water level sensor circuit during my semester holidays using the sensor(190 Ohms) and an 1.91Kohm resistor in a voltage divider configuration and feed the voltage across the sensor to an opamp (gain =11). Im thinking of using the 555 timer to give a pwm output to the circuit, as in yours. I was wondering if I could feed the opamp output to pin 5 of the 555 to generate the pulse width at the output, using it with the transistor. Is there anything I need to change with the circuit? Im actually a first year electrical & electronic engineering student, so its a bit new to me

author: xDR1TeK
author_rank: Contributor
timestamp: December 01, 2012, 03:59:40 am
content: For the PWM, how a about using a charge-discharge relaxation oscillator? Can it be done with a single supply opamp?

author: ftransform
author_rank: Frequent Contributor
timestamp: December 01, 2012, 06:41:15 am
content: At first I did not like a hanging thing but I realized its probably for the best. That way you can adjust it and make absolutely certain you do not nudge the optics at all. Similar to how the adjustment knobs on a telescope are attached by a "limp noodle" which dampens the mechanical vibrations.I don't know how useful it is at 10x but it might be a useful consideration for optics which are not tightened into place or on a tripod with shoddy foundation.

author: r90s
author_rank: Regular Contributor
timestamp: December 01, 2012, 03:14:51 pm
content: I really like this site, yes really. It's provides you with education, drama, international intrigue, and never ending amusement in various topics.Dave cad......that's great! Thanks Dave

author: aluck
author_rank: Regular Contributor
timestamp: December 01, 2012, 05:30:33 pm
content: Wouldn't it be simpler to replace one of the resistors on LM317 with a resistor and a pot connected in series? It will become a nice regulated current source with just a couple of components.

author: T4P
author_rank: Super Contributor
timestamp: December 01, 2012, 06:32:35 pm
content: yeah but ... you need a fat pot as well as it having to be at the bottom

author: aluck
author_rank: Regular Contributor
timestamp: December 01, 2012, 11:17:06 pm
content: Put that pot on a long wire... nothing wrong here.Yes, I know, Dave doesn't want to void the warranty...

author: odokemono
author_rank: Newbie
timestamp: December 02, 2012, 12:17:27 am
content: Nice hack Dave. I gotta admit I was worried the 317 wouldn't like the pulsing but it behaved fine.You've convinced me to get a good camera. Mine has serious auto-brightness issues:https://sites.google.com/site/dannychouinard/Home/atmel-avr-stuff/cheap-led-lamp-micro-controller-upgradeVideo at bottom.Sort of same hack, different solution.Fun stuff!

author: EEVblog
author_rank: Unknown
timestamp: December 02, 2012, 02:57:03 am
content: Quote from: odokemono on December 02, 2012, 12:17:27 amI've never regretted spending $1600 on a decent video camera.Dave.

author: dentaku
author_rank: Frequent Contributor
timestamp: March 15, 2013, 02:14:16 am
content: Very beginner question...What's the cap between the 10k pot and ground?I don't understand the writing and the particular way he wrote it seems like some sort of shorthand or code.

author: c4757p
author_rank: Super Contributor
timestamp: March 15, 2013, 02:26:03 am
content: That's the timing capacitor. It's the same capacitor as is almost always on pin 2/6 on any 555 implementation. Timing is accomplished by repeatedly charging and discharging it between two thresholds.0µ1 means 0.1µF. The purpose of writing it that way is that decimal points are easy to lose if written sloppily. It's really common in EE.Edit: Sorry, misunderstood the question as being two questions. Hope you're not offended that I thought you didn't know its purpose

author: dr_p
author_rank: Frequent Contributor
timestamp: March 15, 2013, 09:36:57 am
content: FYI, the same rationality applies to resistors:120R = 120 Ohms0R1 = 0.1 Ohms2K2 = 2.2Kilo Ohms6M8 = 6.8Mega Ohms

author: dentaku
author_rank: Frequent Contributor
timestamp: March 15, 2013, 12:13:28 pm
content: Quote from: c4757p on March 15, 2013, 02:26:03 amIf I wouldn't have already built another 555 circuit recently I probably wouldn't have known what it was forThanks for the answer.I ended up using a tiny 104 capacitor which IS 0.1uF so I guess I figured it out.

author: xenocide702
author_rank: Contributor
timestamp: March 24, 2013, 10:05:09 pm
content: Been meaning to post this for awhile, finally got around to making an account.Thanks for the help! I got my scope and had this sucker within an hour or two. I happened to have an LED panel out of an old flashlight and some components lying around, so I hacked this thing up. A little hot snot onto the mount and we're good. It's not as much light as I really want, but I'll route a board for an LED ring later. You video really helped, I knew this configuration w/ the 555 existed, I just didn't know much about how it worked.

author: scratchypots
author_rank: Newbie
timestamp: May 30, 2013, 11:33:16 pm
content: I think it would be nice to add a toggle switch to bypass the PWM and revert the mod. This way you can have maximum lux, or a dimmer adjustable setting as desired.Thank you Mr. Jones for the great blog!

author: c4757p
author_rank: Super Contributor
timestamp: May 30, 2013, 11:37:16 pm
content: Quote from: scratchypots on May 30, 2013, 11:33:16 pmIt's been a long time since I saw this video, so I don't remember how it worked out for Dave, but I've used the exact same circuit before and IIRC, at the maximum end of the pot range, the duty cycle becomes too high for either the 555 or the switching transistor (I used a fairly large MOSFET with a high gate charge, though, and couldn't be bothered to figure out the "problem" - I called it a feature), and the load just turns fully on anyway.Of course, if your pot is too scratchy, you might have trouble slamming it hard up against the end stop for full resistance. I recommend newer ones.

author: SZA
author_rank: Newbie
timestamp: October 09, 2013, 03:46:51 am
content: 'm using a simiar circuit to generate a 50kHz PWM signal , can Any1 please confirm the formula used. And can we replace the 1k with a pot to achiving variable frequency.

author: Ivanko1
author_rank: Contributor
timestamp: December 24, 2013, 10:51:55 am
content: Why bipolar transistor, maybe mosfet will be better?

author: bjcuizon
author_rank: Frequent Contributor
timestamp: December 30, 2016, 03:09:27 am
content: Hi Dave,How would you know the output voltage of the LM317 if it is configured to constant current mode?I already know it has a reference voltage of 1.25V but I want to know its output voltage. Does it depend on the resistor or is it the same as the input voltage?Thanks.

author: Teza
author_rank: Contributor
timestamp: April 20, 2017, 11:33:58 am
content: I want to use this circiut with a frequency of 3 kHz, at maximum light.Having problems to find out how to calculate the needed values of the 1kohm resistor, 10 kohm pot and 0,1uF capasitor.Anyone that kan assist with some calculation examples please?I tryed the following, but I don't know if this is correct:

author: vince76
author_rank: Newbie
timestamp: November 21, 2021, 10:50:29 am
content: hi,what can cause the brighness of the leds be at maximum either way of the pot? ( the pot itself seems ok )In the middle is kinda workingthanks