Need help with 555 pwm - Page 1
Forum section: electronics / beginners

author: LittleRain
author_rank: Contributor
timestamp: August 12, 2018, 07:20:34 am
content: I'm making a light for photography which consists of 100 LEDs, I want to be able to dim them, and would like to do this with a PWM signal.I followedthis tutorial,and the results I'm getting are less than stellar.I used the exact values for every component used in the tutorial, except for the diodes. Which I replaced them with the 1N4007, instead of the 1N4148.I'm also using 9v instead of 12v, tried both 12v and v5 as well, but 9v seemed to be the most stable on the scope.With a 50k pot, I was getting no dimming what so ever, I looked on my scope and noticed it was creating a square wave, but it was fluctuating heavily.So I just replaced it with a 1M, and it still barely dims, and is also fluctuating heavily.So when I say fluctuating heavily, this is what I mean. Lets say the pot is all the way CW, on average each cycle is around 300us, but constantly changes to larger and smaller amounts like 600us or 150us.Turning the potentiometer does change the duty cycle, but it with how unstable the cycle duration is it doesn't make a difference.Here are pictures of what I read on the scope, I had to pause them at just the right time to get this clean of an image.Green is the 555's output, and yellow is the 0.1uf capacitor.Pot Turned 100% CCW-8% duty cycle.-34us duraction, or 28.93khzPot Turned 100% CW-77% duty cycle-283us duration, or 3.5khz.I've been trying to find a different schematic, but all of the others seem like garbage. Funny thing is I actually came acrossand noticed he's using virtually the same circuit (He shows it at 7:43), so it gave me more hope with this one.Edit: Sorry I'm trying to post the video as just a link but its automatically embedding it.So long story short, its the duration of each cycle is horrible unstable, and turning the potentiometer is not dimming the LED's, most likely due to that turning the pot changes the cycle duration as well.Does any one have any idea of what could be wrong, or have any ideas on what I should try?I've spent all last night, and all of today trying to figure this out, its really burning me out.

author: iMo
author_rank: Super Contributor
timestamp: August 12, 2018, 07:47:32 am
content: The schematics usually works, the 1n4007 are a bit slower (much slower) diodes than the 1n4148. Try to use a 10-100k resistor (the one from pin 7 to Vcc), and/or increase the value of the timing capacitor (the one from pot's wiper to gnd). I would not go faster than 1kHz (1ms period) at this stage. Double check your wiring and diodes polarity. While turning the pot you have to see the duty changes nicely at pin 3 of the 555.PS: while "switching time" with 1n4148 is in nanoseconds, with 1n4007 we talk microseconds..

author: LittleRain
author_rank: Contributor
timestamp: August 12, 2018, 03:25:31 pm
content: Ok thanks a bunch, I'll give those a shot.I also have some 1n5818 and 1n519 diodes as well, I'm looking at the datasheet but don't really know what to look for. On the 4148 I see "Reverse Recovery Time," but don't see that in the 5818's. Do you think they are faster and more similar to the 4148?What do you think I should change the timing cap to, 1uf? I had to use an SMD capacitor because I didn't have any through hole ones, so swapping them is a b****.Edit: I also have a question about transistors. The one I'm currently using is the exact same in the tutorial, but I'll need a beefier one for the actual light. I'm looking at the BD237 which is rated for 2 amps, but I don't know exactly what to look for inthe datasheetfor how many volts it will take to trigger it. I see "Emitter Cutoff Current" which is 1v, does that mean anything 1v+ will allow the current to flow?

author: iMo
author_rank: Super Contributor
timestamp: August 12, 2018, 03:34:55 pm
content: Do it step by step..1. Let the 1n4007 be there, increase the cap by the 1uF by soldering it in parallel to the 100nF wired from pot's wiper to gnd (for timing purposes the smd multilayer ceramics are not the best choice, however) and look at the results. The PWM period shall drop aprox 10x.2. When still problems increase the 1k as I wrote above.3. When it works fine you may start to elaborate the diodes.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 12, 2018, 03:38:15 pm
content: @LittleRain:Yep, the first problem is most likely the diodes. The 1n4007 is a 1000V, 1 amp rectifier, while the 1n4148 is a small signal, fast switching diode. The characteristics of these diodes make them NOT interchangeable. You can substitute 1n914 which is an equivalent small signal switching diode for the 1n4148, but definitely lose the big rectifier diodes in your project. They are a lot more than "a bit" slower than the specified small signal diodes, and they have more capacitance as well.Next... If you are dimming 100 LEDs you probably need to use a larger switching transistor -- a mosfet -- between the 555 PWM circuit and your LEDs, instead of the 2n2222. The tutorial you linked appears to drive only a few LEDs.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 12, 2018, 03:42:01 pm
content: Quote from: LittleRain on August 12, 2018, 03:25:31 pmI disagree with the above, you should start with the diodes -- since that is the major difference between what your tutorial says and what you used.The 1n5818 diode is a Schottky diode, they are so fast that they don't even list a RRT. You should be able to use these instead of the 4148, although I haven't tested this myself. I would try this before any other changes --- but with only a few LEDs on the output. If you want to drive 100 LEDs you should still use a beefier output transistor.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 12, 2018, 03:44:25 pm
content: Re components: Take apart some old CFL light bulbs, you'll find lots of good stuff in there, like switching transistors, capacitors both electrolytic and poly film (Thru hole!) and etc. If you can find an old CRT TV or monitor to take apart... you are golden.

author: LittleRain
author_rank: Contributor
timestamp: August 12, 2018, 04:52:26 pm
content: Thanks for the fast reply guys.I was aware of the transistor being much to small for the LED's, a large portion of yesterday was looking up and reading datasheets for all the components. Really good that you mentioned it because if I didn't know it could have been bad. I had also made an edit in between my last post and shortly after yours about the mosfet.I had never thought about taking apart CFL bulbs, I'm not sure if I have any around, but luckily I have 2 boxes filled with circuit boards that I've got from taking apart PS2, old computers, humidifiers, motion detectors, vacuums, drills and various other old electronics. Next time for sure though.I'm going to go swap those diodes and report back.Thanks again.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 12, 2018, 05:16:17 pm
content: I think an N-ch mosfet, like IRF3205, will be much better than a bipolar transistor for this application.

author: tooki
author_rank: Super Contributor
timestamp: August 12, 2018, 05:31:09 pm
content: Try a different circuit. For photography, you’re going to need a much faster PWM speed than 1KHz, or you can get banding across the image with a moving-slit shutter, or inconsistent exposure between shots with a global shutter.I recently tried this circuit here with promising results:https://www.electro-tech-online.com/articles/simple-pwm-circuit-for-lamp-dimming-etc-improves-on-555-pwm-circuits.797/The PWM output then drives the gate of a MOSFET (standard n-channel), whose source is at ground, and drain is connected to the negative side of the LED strip, and then the positive side of the LED strip goes to V+.I was testing it at 12V for LED strips. I set it up with C1 at 1nF and R1 at 22K for about 20KHz and that worked quite well. Doubling the value of R1 or of C1 will halve the PWM frequency.At 20KHz, in quick testing, I couldn’t elicit any banding or inconsistency at any shutter speed, all the way to 1/8000s. My 1KHz under-bench lighting produced abundant banding at faster shutter speeds.(I have had one issue with the circuit, which is that there’s a nonlinearity at the top end — on the scope, it looks like the MOSFET sorta just ignores a few % duty cycle before turning on. But I suspect this has something to do with the MOSFET more than the PWM circuit itself. I might try putting a push-pull MOSFET driver in between to see what happens.)

author: iMo
author_rank: Super Contributor
timestamp: August 12, 2018, 06:06:09 pm
content: QuoteThe max current of a 555 (pin 3) is something like 50mA/10mA (L/H) with cmos variant (may be more with bipolar) - with a power Mosfet with a ~few nF input capacitance the driver will definitely be a must when sharp r/f edges are required..

author: LittleRain
author_rank: Contributor
timestamp: August 12, 2018, 06:56:57 pm
content: imo sorry I didn't see your step by step post, thanks for the help though.I guess It was lucky though, because I ended up doing the diodes and it works!Funny thing is, when I first started the project I thought the diodes would be the last thing to make any issuesDuty cycle has a range from 6 to 99%, as well. Even better than Daves.All The way CCWAll The way CWIn The Middlealsetalokin4017 Ok, I'll go with that one, why would it be better though? I can get 50 of the other ones for the price of 10 of the ones you.I'm probably going to order both, just to have the other for for future projects, but do you (or anyone else) think it will be an issue that its rated for 2 amps, if my circuit draws 2 amps?I was using an LED array calculator, and it says the LED's alone will draw 2000ma (100 RGB LEDS). And that's not including the PWM circuit, which I will need 1 for each colour.But lets say it did draw exactly 2 amps(The power supply I'm going to use is 12v 2a), would that potentially blow the mosfet(I would use a cap to prevent spikes.)?Tooki, I was thinking about that, but thought it would only affect video. And I just tested it with my phones camera, even doing slow motion video didn't see any jitter at all, not sure if it will be like that with my other camera though.

author: tooki
author_rank: Super Contributor
timestamp: August 12, 2018, 07:33:02 pm
content: Quote from: LittleRain on August 12, 2018, 06:56:57 pmThese are the things you learn as you get more involved in electronics: components aren’t perfect. They don’t behave like the theoretical descriptions. “Instant” to the human eye suddenly isn’t instant any more. Etc.Quote from: LittleRain on August 12, 2018, 06:56:57 pmIt depends on the shutter speed, nothing more. Whether it’s video or still doesn’t really matter — video is just series of still photos.Some examples, which in no way fully explain all situations:First let’s show an example of PWM that isn’t problematic. Suppose a 1/60 shutter speed, but 20KHz PWM. There will be 333.333 cycles of PWM during the single exposure, so a) no part of the image will go unexposed, and b) whether a given exposure happens to capture 333 or 334 cycles of PWM is irrelevant, in that 1/333 is such a tiny difference as to be wholly unnoticeable between exposures.Next, what about 1/60 shutter and (theoretical awful) 60Hz PWM. It’ll still work out, because the exposure will still capture one full PWM cycle.Now let’s look at 1/60 shutter speed, but 90Hz PWM. Now we run into trouble, because one exposure has 1.5 cycles of PWM. In a camera with a global shutter, some pictures will be brigher than others, because they had two cycles of light (full cycle, plus the first half of the PWM cycle, where it’s on), while others are darker (because it had one full cycle, plus the second half of the PWM cycle, where it’s off).But now, suppose you’re using a 1/200 shutter speed, and a 100Hz PWM at 10% duty cycle. Assuming that the shutter isn’t synchronized with the lighting (i.e. random), there’s a roughly 50/50 chance that the lighting will actually be on when the shutter is open. Some photos will be bright and others dark.Now, most cameras use a rolling shutter (especially at faster speeds), meaning that the entire image isn’t captured at the same time: it starts at the top or bottom and moves along to the other side, capturing line by line. The speed of the rolling shutter means that while any given pixel (or area of film, in analog) is exposed for the selected exposure time, different areas were exposed at different times. So if you have a pulsating light (like PWM), then a given line of the image may have caught anentire light pulse, part of one, or none at all! In a typical DSLR, the actual maximum speed of the shutters (the x-speed, or flash sync speed) is around 1/250 sec — the time in which one shutter curtain can open, the sensor be fully exposed, and then for the second curtain can close. This means that it takes roughly 1/500 sec for one curtain to open or close. This also means that 1/500 sec is the speed at which a moving slit (both curtains following each other to expose for less time) moves across the sensor.So if you are using, say, 2KHz PWM, this means that in the time the slit moves down the sensor, the light has pulsed 4 times, and your image could have 4 pairs of light/dark banding.Electronic shutters do something similar, but electronically, clearing and reading out the sensor pixels.I dunno how much you know about camera shutters, so this may have confused more than clarified. If you are confused, maybe youtube how DSLR shutters work (or slow-mo videos of them in action!!).Quote from: imo on August 12, 2018, 06:06:09 pmTake a look at the circuit in question — it doesn’t use a 555 at all!But it’s weird the way it behaves. Should I make a video of it?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 12, 2018, 08:34:57 pm
content: Quote from: LittleRain on August 12, 2018, 06:56:57 pmThe IRF3205 mosfet has a negligible on-state resistance in this application (saturated switch) and will not get hot nor waste power. No, as you can see from the data sheet, the IRF3205 is capable of handling many more than 2 amps. You will not want to design your circuits so that components are operating at the edges of their permissible parameters.

author: LittleRain
author_rank: Contributor
timestamp: August 12, 2018, 08:40:05 pm
content: Ah I see.And I meant the one I was originally looking at, its rated for 2 amps.

author: tooki
author_rank: Super Contributor
timestamp: August 12, 2018, 10:05:28 pm
content: Quote from: tooki on August 12, 2018, 07:33:02 pmUgh. It helps if you actually remember to add power supply decoupling caps and the pulldown resistor for the MOSFET...It’s working now.

author: romons
author_rank: Contributor
timestamp: August 13, 2018, 01:14:05 am
content: 555s are unstable if the power rail is unstable. The circuits don't have appropriate caps near the 555. Scope the power rail and see how much it is drooping. 100 LEDs is a significant load.Also, use a logic level NMOS instead of a bjt on the output. The bjt will need more base current than the 555 will want to supply.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: August 13, 2018, 02:40:14 am
content: Quote from: LittleRain on August 12, 2018, 08:40:05 pmRight. So if your 100 LEDs are on at full duty cycle of the PWM they will draw 2 amps (assuming the proper current limiting resistors are used.) So that's right at the max rating of that transistor. Like if your car's speedometer goes to 120 mph...Quote from: romons on August 13, 2018, 01:14:05 amThe circuit I posted has a bulk capacitor on the power rail, but sure, decoupling the chip's power input right close to the chip with 0.1 uF or so is always a good idea.And yes, the N-ch mosfet is something we agree on.

author: LittleRain
author_rank: Contributor
timestamp: August 13, 2018, 02:54:48 am
content: Quote from: romons on August 13, 2018, 01:14:05 amI forgot to mention I have only built a test circuit with only 2 LED's.I wanted to make sure that my PWM circuit worked before I etch a board.

author: tooki
author_rank: Super Contributor
timestamp: August 13, 2018, 10:20:48 am
content: Quote from: LittleRain on August 13, 2018, 02:54:48 amI would really suggest also trying the LM393-based circuit I linked, before spinning a board. It works better than the 555 circuits I’ve tried, in that it does better at the extremes of the adjustment range. 555 circuits tend to have a rather high minimum brightness setting (as you showed with yours at 6% minimum), this one works far better. This one goes from <1% to >99% duty cycle as configured at 20KHz.

author: iMo
author_rank: Super Contributor
timestamp: August 13, 2018, 12:04:29 pm
content: Quote from: LittleRain on August 12, 2018, 06:56:57 pmA pity you haven't read my postsQuote from: imo on August 12, 2018, 07:47:32 am

author: tooki
author_rank: Super Contributor
timestamp: June 10, 2021, 06:01:46 pm
content: Just a little update: the dimmer circuit tested above (as a soldered perfboard build in a little box velcroed under the desk) has been in service for almost 3 years now, probably turned on 70% of the time, and continues to perform spectacularly. Being able to dim it down to absolutely tiny levels of light means I can actually use my under-desk lighting (which is about 15W of LED strip) as a night light. No noise. Fast enough to work for recording slow-mo video and taking photos.Pix here:https://www.eevblog.com/forum/projects/9vdc-5vdc-smps-for-driving-leds/msg2912008/#msg2912008