Help understanding my PWM circuit and changing frequency.

Thread Starter

Hardwyre

Joined Sep 23, 2010
11
Hi. I've sort of jumped into the world of self-made electronics this past year, and I just completed my first stand alone PWM. I like to think I'm pretty good at understand and following schematics (I successfully built a constant current PWM earlier before this 555 PWM), but when it comes down to it, I still don't really understand WHAT all is going on.

As such, when it comes to trying to get this 555PWM to get any more dim, I'm at a loss.

Here's the circuit:


I'm trying to get it to dim almost completely, but with P1 turned all the way, its still bright enough to read comfortably with in a dark room. Turned all the way the other way, it's as bright as an LED at 12v with a 470Ω resistor should be.

I've tried soldering a couple of 10k resistors on one side of the pot to test and see if a larger pot (100k? 200k?) would make a difference, but it didn't really seem to make it any dimmer.

Here's my parts list for this build:
LM555CN LM555CN - Timer
BD681 BD681 NPN Power Transistor
C470U25E 470uF 25V Radial Electrolytic Capacitor
1N60P 1N60P Germanium Diode
1N4148 1N4148 100V 200mA General Purpose Diode
C0001UT 0.1uF 35V Tantalum Capacitors
C010UC 0.01uF 50V Ceramic Capacitors
POT50K 50k Linear Taper Pot
R001K14W 1.0kohm 1/4W 5% Carbon Film Resistor

I'm using the germanium diodes since it sounds like those permit a wider % of duty range.

Edit: I just realized something while doing some reading, my 0.1uF capacitor (C1) is a Tantalum capacitor which is polarized. Should I be using a non-polarized 0.1uf cap (maybe ceramic) for this, or does it not matter? I have a 104-coded ceramic cap I can pull off an old power supply board I've been savaging for parts.

I figure if I can change the frequency, I can get the perception of a dimmer light; because as I understand it, the potentiometer controls duty cycle.

I could just put a switch in-line with the LEDs, but that would be more "stuff" attached the project, and I'd really like the lights to be controlled primarily by the pot. It doesn't have to turn entirely off, but be really dim.

Any help is greatly appreciated.

Oh, these PWMs are going to be used for a couple of projects; the current (haha ... eh, sorry) projects are:

1. Converting my Datsun 280Z's dash lights to LEDs
2. An RGB LED lamp for a girl I have a crush on - I figure by using a PWM on each of the colors, she can change the color of the lamp on a whim.
3. A really slow circuit for when I change the exterior lights and taillights on the above Z to LEDs, for use as a blinker circuit. I'd like to do some neat tricks with the brake lights (like maybe some sequential illumination tricks), but I think that's beyond me at the moment.
 
Last edited:

beenthere

Joined Apr 20, 2004
15,819
We can certainly help with your project #2, but #'s 1 & 3 are not things we give assistance with. Section 2 of our automotive guidelines -
2. Any homemade wiring modifications to signal or head lighting, or penetrations through the fiewall are not for discussion. The lighting function is to too critical for non-approved wiring and connectors. Many safety issues are involved. Preventing chafing in wires passing through driver-made holes is impossible to guarantee.
 

campeck

Joined Sep 5, 2009
194
If you talk about changing the exterior lights or blinking lights on your car. Your thread will be closed.

As far as PWM for your LED. Pick up a CMOS 555 and build this circuit by Bill Marsden (The 555 Master)
Works like a charm.
 

Attachments

Last edited:

Markd77

Joined Sep 7, 2009
2,806
Post #3 circuit is excellent, but if the component values of R4, 5 and 6 are not perfect it might not be possible to turn the LED fully on or off. I'd substitute R4 and R6 for 8K2 resistors to guarantee it will do both.
 

campeck

Joined Sep 5, 2009
194
Yeah I use potentiometers for R4 and R6 to adjust the high and low levels. Also if you make R2 1k I found it to be slightly more reliable over the adjustable range.
 

eblc1388

Joined Nov 28, 2008
1,542
As such, when it comes to trying to get this 555PWM to get any more dim, I'm at a loss.
The duty cycle of the PWM output by the 555 is indeed very small at the end of the control but you have forgotten that LED is an instantaneous light emitting device.

During that brief moment of small duty cycle, full 12V has been applied to the LEDs so they light up in full brightness, albeit in a brief moment. Compare that to the analogy of a photo flash. This will not happen with incandescent lamp bulb as the lamp filament takes time to warm up.

What you can try is to add a capacitor+resistor connection as shown in the image to the LED strings so as to average the PWM voltage that results.

I have no idea if this will really work but it won't hurt to try. You are free to try other values for the capacitor.

 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
<snip>
Oh, these PWMs are going to be used for a couple of projects; the current (haha ... eh, sorry) projects are:

1. Converting my Datsun 280Z's dash lights to LEDs
2. An RGB LED lamp for a girl I have a crush on - I figure by using a PWM on each of the colors, she can change the color of the lamp on a whim.
3. A really slow circuit for when I change the exterior lights and taillights on the above Z to LEDs, for use as a blinker circuit. I'd like to do some neat tricks with the brake lights (like maybe some sequential illumination tricks), but I think that's beyond me at the moment.
Please do not attempt 1) nor 3). Safety-related automotive lighting is nothing for amateurs to experiment with.

Read my $0.02 in the Automotive Guidelines thread:
http://forum.allaboutcircuits.com/showpost.php?p=262824&postcount=20

The entire thread begins here:
http://forum.allaboutcircuits.com/showthread.php?t=40361

The best thing to do is to have your vehicle's lighting systems professionally maintained as they were configured when delivered by the dealer, as at that point in time they met all legal requirements and safety standards; and as long as they are maintained that way, they will be "grandfathered" in as legal.
 

Thread Starter

Hardwyre

Joined Sep 23, 2010
11
Fair enough. Lets focus on #2 then since that's the project I have in front of me.

I wouldn't mind building a different circuit if I had the parts on hand, and hadn't already made a PCB for the existing one. So I guess my question is is there any way, with the existing circuit, to get to a 0% duty cycle?

The duty cycle of the PWM output by the 555 is indeed very small at the end of the control but you have forgotten that LED is an instantaneous light emitting device.

During that brief moment of small duty cycle, full 12V has been applied to the LEDs so they light up in full brightness, albeit in a brief moment. Compare that to the analogy of a photo flash. This will not happen with incandescent lamp bulb as the lamp filament takes time to warm up.

What you can try is to add a capacitor+resistor connection as shown in the image to the LED strings so as to average the PWM voltage that results.

I have no idea if this will really work but it won't hurt to try. You are free to try other values for the capacitor.

I'll have to find a smaller capacitor. I tried what you suggested with a 347uf cap and a 5Ω resistor and it made the whole range brighter.
 

Wendy

Joined Mar 24, 2008
23,421
The circuit shown in #3 will go 0% to 100% and keep a stable freq. A while back I showed how to boost the signal to drive the LED array your looking for in another thread for campeck.

I've got to go to work right now, so I'll have to get back with you.

The root article the schematic is here...

LEDs, 555s, Flashers, and Light Chasers
 

SgtWookie

Joined Jul 17, 2007
22,230
Try this:
1) Remove R1.
2) Disconnect the junction of the two 1N4148 diodes from pin 7 of the 555. You may need to cut the trace that runs to pin 7, or simply snip pin 7 off at the timer itself.
3) Run a jumper from the 555 pin 3 to where R1 connected to the junction of the two diodes.
4) Add a 20k to 24k resistor across C2 (from pin 5 to GND).

It STILL won't go completely off, but you will get a lower duty cycle.
Reducing C1 to 1nF - 10nF may help some. 10nF=0.01uF and 10,000pF.
 

Thread Starter

Hardwyre

Joined Sep 23, 2010
11
If you talk about changing the exterior lights or blinking lights on your car. Your thread will be closed.

As far as PWM for your LED. Pick up a CMOS 555 and build this circuit by Bill Marsden (The 555 Master)
Works like a charm.
The more I look at it, the more it looks like I really just need to get some LM339 ICs. Actually, the LM339's I saw on radioshack's site list it as a quad comparitor, so can I essentially run four separate circuits off of one IC? Also looks like on the 555 IC, pins 7 and 5 are completely ignored.. that's good, because if I remake this board, I cut off my 7 pin per SGTWookie's suggestions :).
Post #3 circuit is excellent, but if the component values of R4, 5 and 6 are not perfect it might not be possible to turn the LED fully on or off. I'd substitute R4 and R6 for 8K2 resistors to guarantee it will do both.
8K2 = 8.2k correct?
Try this:
1) Remove R1.
2) Disconnect the junction of the two 1N4148 diodes from pin 7 of the 555. You may need to cut the trace that runs to pin 7, or simply snip pin 7 off at the timer itself.
3) Run a jumper from the 555 pin 3 to where R1 connected to the junction of the two diodes.
4) Add a 20k to 24k resistor across C2 (from pin 5 to GND).

It STILL won't go completely off, but you will get a lower duty cycle.
Reducing C1 to 1nF - 10nF may help some. 10nF=0.01uF and 10,000pF.
Seems to have worked a bit. But since you've all been awesome and stand up so soundly behind the #3 circuit, I think I'm going to rip apart this one and get some 339 chips from radioshack, since it seems like I have everything else I need at the moment.

I read a few pages of Bill's, and wow, that's an awesome primer for understanding things a little better.
 

Thread Starter

Hardwyre

Joined Sep 23, 2010
11
Ahh... damn.. that's a PNP transistor in Bill's schematic isn't it? I don't think I have any of those on hand. Just a bunch of NPN.
 

Wendy

Joined Mar 24, 2008
23,421
Actually you could, it would become common emitter and have a lot less drive, that one LED would be about it. The other design would drive your array I think, use a Darlington and it would handle even more.

I can draw a much more powerful MOSFET version if you're interested.
 

SgtWookie

Joined Jul 17, 2007
22,230
See the attached.

U1a is wired as an astable multivibrator.

R1, R2, and R3, in conjunction with the LM339 output and the pullup resistor R4 cause the non-inverting input to toggle between roughly 1/3 and 2/3 Vcc; in this case roughly 4v of hysteresis.

The signal at "aout" is roughly a square wave. The LM339 has an open-collector output, which means that it can sink current, but cannot source current. This is why pullup resistor R4 is required; to source current.

The LM339 output can't sink much current without it's output saturation voltage rising significantly. To keep the saturation voltage low, you limit the current that the '339 output has to sink to below 4mA.
12v/4mA = 3k Ohms. I chose the next higher standard value of resistance.

C1 (10nF, or 0.01uF) is charged via R4 and R5, and discharged via R5. The waveform at the junction of C1 and R5 (labeled "tri") is roughly a triangle wave that varies between roughly 1/3 and 2/3 Vcc at about 220Hz.

R9, VR1 and R10 form a voltage divider. R9 and R10 have lower resistance than VR1 to ensure that the wiper of VR1 (the point labeled "ref") will have a wider range of output voltages than the triangle wave, so that 0% to 100% PWM can be achieved.

U1b compares "ref" to "tri". When "tri" is lower than "ref", the output goes high, otherwise it is low.

Since the output of the comparator cannot sink much current, and you only have NPN transistors, Q1 is used as a voltage follower to amplify the ~4mA current sourced from R6 to drive the base of Q2. R7 limits the current supply to Q2's base to ~36mA.

R8 is present to ensure that Q2 turns off quickly when Q1 stops sourcing current to Q2's base. It might work without it, but I suggest you keep it in the circuit.

You could add a number of LEDs to Q2's collector; as long as the total current requirement is <=500mA, it should work fine. If you use a 2N3904 for Q2, increase R7 to 1k and your maximum current will then be limited to ~100mA.

As shown, there will still be two unused LM339 channels. Ground the unused inputs, or they will cause problems.

Not shown is a 0.1uF (100nF) bypass capacitor across the LM339's power pins, which is required.

You can also use the other two LM339 channels to make two more PWM circuits; just duplicate everything from R6-R10, Q1, Q2 and VR1.
 

Attachments

campeck

Joined Sep 5, 2009
194
Dang wookie. I wish I had known to use the last comparator in the lm339 in my other project (high power RGB fader) as the astable multivibrator. Then I could have saved a 555 and board space. you can make a RGB fader with pots for control with one chip and 3 transistors like this!
 

Wendy

Joined Mar 24, 2008
23,421
Dang wookie. I wish I had known to use the last comparator in the lm339 in my other project (high power RGB fader) as the astable multivibrator. Then I could have saved a 555 and board space. you can make a RGB fader with pots for control with one chip and 3 transistors like this!
I'm not sure about saving board space, resistors and whatnot take space too. One 555 takes about the same space as 4 resistors, give or take. The flip side is you get to break up the resistors and put them where ever you want them, which might shrink total space used.

The big advantage of a 555 over Wookies scheme is the amplitude of the triangle wave of a 555 is relative to the power supply, the percentages stay the same. The % of PWM and frequency also stays the same. The 555 triangle generator could be tweaked using a CMOS 555 or changing the layout a bit (a standard 555 does have some problems in this reguard).

I'm not too sure using a comparator as the triangle wave has this characteristic. I wonder what the modulation percentage would be over the power supply range of 6V-15V (2V-18V using a CMOS 555), and whether the frequency would stay stable? This is a major advantage of simulations like Wook is showing, they give answers to questions like this quickly.

I read Wookie's circuit as using a 12V power supply.
 

SgtWookie

Joined Jul 17, 2007
22,230
Bill,
A 555 has a comparator inside it, and a voltage divider made up of three 5k resistors for BJT, or 100k to 300k or so for CMOS to establish the trigger and threshold values.

The circuit that I posted works essentially the same; as it is using resistive dividers too, just a tad bit differently.

I calculated resistor values based on a 12v supply. However, the same circuit would work over a wider range of voltages than one 555 based, as most 555's have a limit of 16v for Vcc, and the LM336 goes up to 36v.

Also, a bjt 555 timer would have a hard time with supplies less than 4.5v. This one would work down to 2v.
 

Wendy

Joined Mar 24, 2008
23,421
Actually a 555 has two comparators, and uses a 1/3 and 2/3 set points to set the hystersis. This is why it doesn't vary frequency with power supply changes. This is what made the 555 such a breakthrough. I don't know about digital chips, and how their hysteresis changes (thinking CMOS here), but I'm pretty sure an op amp hysteresis changes with power supply voltage, and not in proportion with the power supply. The comparator even more so, since it must have that pull up resistor.

Try varying your circuits voltage ±3 volts and see where the upper and lower set points are. You designed for 1/3 and 2/3 Vcc at 12V, but I'm betting they aren't there at 9V and 15V. With some Schmitt Trigger designs they will stop working all together (had that happen on a few personal designs).

For a fixed voltage setup this is OK, but I like making circuits work over the range if possible.

Matter of fact, I'm going to calculate it for myself.

**************************************

OK, I'm wrong. Here are the results I got.

....... ......Power Supply Voltages
...... .......... 9V . 12V .15V
Lower Set Point .3.0V 4.0V 5.0V
Upper Set Point .5.9V 7.9V 9.9V

I would put them pretty close to 1/3 and 2/3 set points. My mouth overflowth, and runnith ahead of my brain.
 
Last edited:
Top