# Some more circuit theory (PWM theory)



## cybhunter (Apr 12, 2013)

Since I have some down time between my classes and want to write some informative stuff, I would want to expand upon my other theory posting. This thread will explain the basis of Pulse Width Modulation (PWM) and why its used in solid state lighting

*How can the light output of a device be controlled?*
traditionally, blackbody radiators such as the incandescent light bulb were attached to variable resistors (known as Rheostats). Because of Kirchhoff Voltage Law (KVL), the sum of Voltage drop of the Rheostat plus the Voltage drop of the incandescent light bulb must equal to the supplying voltage. By adjusting the Rheostats resistance, the Voltage drop of the incandescent light bulb can be varied. As a side effect, a lower voltage drop on the incandescent light bulb results in the light emitted to be centered more towards the red end of the visible spectrum, while higher voltage drops tend to shift the light towards the blue end of the visible spectrum. At mains voltages (120-240 VAC), most of the emitted energy has wavelengths in the Infrared spectrum, hence the general knowledge that light bulbs are inefficient light sources.

Another method of changing the 'seen' light output is by varying the time that the light source is on in comparison to the time it is off. This is known as a 'Duty Cycle'.

*H**ow does this relate to LED Brightness?
*Since LED's work on the principal of conduction band, the PN junctions require a minimum voltage to excite the charge carriers. If the voltage is not sufficient, the charge carriers will not enter the conduction band and the LED will act as an open circuit. Instead of altering the voltage drop of an LED to vary the brightness, a more practical approach is to control its duty cycle.

*How can I control a LED's Duty Cycle?
*The process of controlling a circuits Duty Cycle can be by using Pulse Width Modulation. The implementation of a hardware based PWM circuit involves using a 555 timer chip, some resistors and a capacitor. 

http://www.williamson-labs.com/pu-aa-555-timer_slow.htm 
(link to a visual of a 555 timer chip in operation)

a 555 timer chip uses the process of comparing the Voltage on the capacitor with a voltage divider on the interior of the chip Pin 6 is tied into a comparator that when the capacitor is at least 2/3's of the interior voltage, it causes a JK Flip Flop to go into a logic low state (0 Volts). On pin 2, ff the voltage on the capacitor is at most 1/3 of the interior voltage, it forces the JK flip flop into a logic high state (3-X Volts). The voltage on the capacitor is determined by the product of the exterior resistors and the capacitor. This is known as 'tau' . When the math constant e is raised by -1/tau times the amount of time (in seconds), the Voltage can be determined. By changing the values of resistors, the amount of time required to meet these conditions of voltage values can be controlled (resulting in the ability of varying the Duty Cycle).
*
W**hat considerations must I factor in?*
The value tau (in radians per second) denotes the radian frequency, or in other words how many complete cycle per second. For those people more comfortable using degrees, 1 pi radian is equal to 180 degrees. If the wrong resistor and/or capacitor values are used, the pulsing effect becomes visible. Signs of this can include a ghosting effect if you scan your eyes across such an array (ie some LED taillights, or some DLP units that use a color wheel). The key is to have a frequency that is above what is known as the 'flicker fusion threshold'. As an example, 24 fps films is slightly above the flicker fusion threshold for most people. 

Another factor that must be considered deals with the (electrical) size of the controlled circuit. Typically 555 chips only can source at most 40mA @ 5 volts nominally. If an array rrequires more energy, a transistor has to be used. The usage of a transistor requires knowledge of the gain (found in the white paper of the device). Depending upon the gain, the resistor needed on the output of pin 3 of the 555 chip can be concluded.

As an example, if a transistor is set up in a constant current configuration, has a gain of 20, and the required current is 400mA, the resistor needed would be (5 volts from the 555 chip -0.7 volts of the base of the transistor)/(Base Current), [4.3 Volts]/[Base Current]. Since the gain is 20, and the output is 0.400 Amperes, the base current is [0.400 Amperes]/[20] or 20mA. plugging the 20 mA back into the first equation, the needed resistor would have a value around 215 ohms.

Hope this provides some more useful info
Joe​


----------



## SemiMan (Apr 12, 2013)

cybhunter said:


> Since I have some down time between my classes and want to write some informative stuff, I would want to expand upon my other theory posting. This thread will explain the basis of Pulse Width Modulation (PWM) and why its used in solid state lighting
> 
> *How can the light output of a device be controlled?*
> traditionally, blackbody radiators such as the incandescent light bulb were attached to variable resistors (known as Rheostats). Because of Kirchhoff Voltage Law (KVL), the sum of Voltage drop of the Rheostat plus the Voltage drop of the incandescent light bulb must equal to the supplying voltage. By adjusting the Rheostats resistance, the Voltage drop of the incandescent light bulb can be varied. As a side effect, a lower voltage drop on the incandescent light bulb results in the light emitted to be centered more towards the red end of the visible spectrum, while higher voltage drops tend to shift the light towards the blue end of the visible spectrum. At mains voltages (120-240 VAC), most of the emitted energy has wavelengths in the Infrared spectrum, hence the general knowledge that light bulbs are inefficient light sources.
> ...




I would imagine the value would be pretty much self-indulgent for you, not sure why you wrote this and even more really does not provide much in the way of value.


- We use PWM or brightness control for two reasons. The most critical is that it is the best way to keep the characteristics of the light output as consistent as possible independent of the light level. Secondary but also important is that it is easy to implement especially for achieving linear predictable results

- That said, in this community and elsewhere we often use linear dimming (especially with constant current) to take advantage of the general property of an increase in efficiency as current drops (to a point)

- There are already about 100+ 555 timer circuits floating around CPF (not to mention the above data) 

- Transistors are a) not constant gain across operating parameters, b) only bipolar exhibit simple current gain and c) Widely vary in gain from device to device. Describing the transistor implementation as you have is to encourage someone to build something that will not was intended. A 555 timer (no matter the brand) if ran on 5V will not output 5V at 20mA, more likely in the 3-3.5V range (at least 2 diode drops down) ... and most will sink 100mA on a 5V supply. 

- And really, a discussion of rheostats and why bulbs are inefficient


You know CPF is a welcoming committee, but we also encourage the use of the search function which would have revealed these topics covered (in more detail and in greater accuracy) many times.

Semiman


----------



## uk_caver (Apr 14, 2013)

I wonder, would many people bother using a bipolar transistor in a driver these days?
For low voltage/low frequency switching purposes, FETs seem much more like 'ideal components', with no inherent voltage drop to worry about, a low on resistance, a high impedance gate and limited gate capacitance.
As long as the resistance and threshold voltage are low enough, they can largely be idealised as a black box switch.

I definitely had a twinge of nostalgia with the 555 being mentioned - takes me back to my teenage years (I still remember reading the launch reviews for the CMOS version).

It does seem a bit strange to write about LEDs and then talk of 'voltage control vs PWM' as if they were the only alternatives, when LEDs are for the most part considered in terms of light output relative to current or light output relative to power, and where many (most?) PWM circuits are actually alternating between no current and constant current.

Even a driver using PWM seems likely to be a constant current driver when the duty cycle is 100%.


----------



## SemiMan (Apr 14, 2013)

uk_caver said:


> I wonder, would many people bother using a bipolar transistor in a driver these days?
> For low voltage/low frequency switching purposes, FETs seem much more like 'ideal components', with no inherent voltage drop to worry about, a low on resistance, a high impedance gate and limited gate capacitance.
> As long as the resistance and threshold voltage are low enough, they can largely be idealised as a black box switch.
> 
> ...




With the exception of cheap automotive circuits, I don't think I have ever done an LED driver that was not a true constant current whether I used PWM for dimming or not.

Cheap linear regulators are often bipolar to keep the absolutely lowest cost. Some of the switching regulators that are still on the market are still bipolar, but I don't think you will see any new designs that are. Do we consider an IGBT a bipolar or MOSFET? The FET part gives it low drive current, but the saturation of the bipolar transistor is still less than I*Rdson for these high voltage/current transistors. Newer MOSFETs are starting to catch up though.

I can't say the last time I used a 555 timer. I don't think I ever have professionally and with <$0.50 micros with built in oscillators and PWM unlikely I would though for the absolute lowest cost PWM I am sure one could find a reason.

Semiman


----------



## Steve K (Apr 14, 2013)

uk_caver said:


> I wonder, would many people bother using a bipolar transistor in a driver these days?
> For low voltage/low frequency switching purposes, FETs seem much more like 'ideal components', with no inherent voltage drop to worry about, a low on resistance, a high impedance gate and limited gate capacitance.
> As long as the resistance and threshold voltage are low enough, they can largely be idealised as a black box switch.



actually, I'm sketching out a buck converter to run from two AA cells, and (hopefully) drive a white LED at 1A. The intent is to use a BJT as the switch, since I'm not familiar with any MOSFETs with a Vgs around 1v or so. Have I missed some parts when I was looking around?


----------



## uk_caver (Apr 14, 2013)

Steve K said:


> actually, I'm sketching out a buck converter to run from two AA cells, and (hopefully) drive a white LED at 1A. The intent is to use a BJT as the switch, since I'm not familiar with any MOSFETs with a Vgs around 1v or so. Have I missed some parts when I was looking around?


For general low-current switching I normally use PMV30UN - typical low current Vgs(th) of 0.7V at 25°C, but the maximum currents I use them for are a few hundred mA.
There may be some heavier-duty devices with thresholds not too much higher.


----------



## Steve K (Apr 14, 2013)

Thanks for the suggestion! It's interesting to poke around the Philips site and see what they have. They have a pretty good variety of mosfets with fairly low Vgs's. This is one that looks like it might be close to what I'd want:
http://www.nxp.com/documents/data_sheet/PMPB33XN.pdf

now I need to look around for a package that could be easily hand soldered. :/


----------



## SemiMan (Apr 16, 2013)

Rds seems tolerable, 50mohm at 1.8V Vgs. Would be interesting to measure it at 1V. Gate charge is not exactly small which may impede you ability to switch it fast. You may be back into the BJT simply to get reasonable switching speeds ... or perhaps a hybrid.

Semiman


----------



## MikeAusC (Apr 16, 2013)

I couldn't recommend this to anyone as a way to help understand PWM - it's way too academic.




cybhunter said:


> . . . . Instead of altering the voltage drop of an LED to vary the brightness, a more practical approach is to control its duty cycle. . . . . .


 - there's NOTHING impractical about altering the voltage across an LED to vary its brightness - look at the popularity of 7135 circuits.




cybhunter said:


> . . . . The value tau (in radians per second) denotes the radian frequency, or in other words how many complete cycle per second. For those people more comfortable using degrees, 1 pi radian is equal to 180 degrees. . . . . .


 - good grief ! Who has ever used radians per second to describe duty cycle ???


It comes across as you trying to show off your knowledge by dumping in any technical term you've come across.


----------



## uk_caver (Apr 16, 2013)

It did seem odd for someone to talk about RC timing circuits while avoiding using the phrase '_time constant_'.

To be fair, the radians-per-second bit was talking about frequency rather than duty cycle.

Though I'm not sure what the '_tau in radians per second_' is supposed to mean, since tau as a symbol for time constant is measured in seconds, not anything-per-second, so the dimensions are all wrong.


----------



## arek98 (Apr 16, 2013)

Wow, while I understand most of terms (only because I had electronic course long time ago) I don’t see how this supposed to explain PWM to general audience.

And “PWM involves 555”, like this is an only way to do this :thinking:

Looks like attempt to impress not to explain, :fail:.


----------



## SemiMan (Apr 16, 2013)

Steve K said:


> Thanks for the suggestion! It's interesting to poke around the Philips site and see what they have. They have a pretty good variety of mosfets with fairly low Vgs's. This is one that looks like it might be close to what I'd want:
> http://www.nxp.com/documents/data_sheet/PMPB33XN.pdf
> 
> now I need to look around for a package that could be easily hand soldered. :/



That may be next to impossible for anything low voltage. You may need to get your hands on a development/eval board and cut it up unless you can find an SMT/through hole converter ... also unlikely. I do etch some of my own converters if in a hurry, but tend to just go to a board now for anything. The days of hand prototyping are behind us for many things, even simplish analog circuits.

Semiman


----------



## uk_caver (Apr 16, 2013)

Regarding surface mount components, I do use them quite a bit with stripboard, but I think that's only really feasible for 2 or 3-terminal devices.


----------



## RoGuE_StreaK (Apr 16, 2013)

Just dead bug it 

With the cheap PCB fab services available now, it's cheaper to get 10x custom-designed complete boards ($15 shipped for 5cm x 5cm) than to get one simple breakout. Yeah, not very DIY-friendly nowadays, no idea how kids are supposed to get into it.


----------



## Steve K (Apr 17, 2013)

I don't mind using sot-23-5 or such packages with copper-clad board. I just cut up the copper-clad board with a dremel, and lift the middle lead on the side with 3 leads. Dead bug is an option, but not one that I'm fond of. I've seen some fairly large prototypes built this way, but it was many years ago. With the small lead pitches nowadays, I don't think I could manage to solder 30ga wire wrap wire to them. And of course, for parts with pads in the middle that are supposed to be soldered to a heatsink, there's no way to get the heat out. I'd rather have sot-223 for my small power devices. 

PCBs are an option, but how good are they when you are still in the early phases of design? Or do you just leave a lot of spare pads and ways to break into traces? On the plus side, with free spice packages like LTSpice, it's easier to work out some concepts prior to putting together circuits. 
Who sells boards for $15?


----------



## ianfield (Apr 17, 2013)

uk_caver said:


> I wonder, would many people bother using a bipolar transistor in a driver these days? ************************************************************************************************************************ I frequently prototype with discrete components - mainly because I CBA ordering strange and esoteric chip.


----------



## ianfield (Apr 17, 2013)

Steve K said:


> actually, I'm sketching out a buck converter to run from two AA cells, and (hopefully) drive a white LED at 1A. The intent is to use a BJT as the switch, since I'm not familiar with any MOSFETs with a Vgs around 1v or so. Have I missed some parts when I was looking around?



I think you mean a boost converter - a buck converter only steps down. 2x AA gives slightly more than 3V - but not quite enough to fully drive a white LED.


----------



## ianfield (Apr 17, 2013)

arek98 said:


> Wow, while I understand most of terms (only because I had electronic course long time ago) I don’t see how this supposed to explain PWM to general audience.
> 
> And “PWM involves 555”, like this is an only way to do this :thinking:
> *************************************************** A search for PWM motor controller will sometimes find alternative circuits - one for the 555 and another for a 4069 - a bipolar 555 is better than the 4069 or CMOS 555 if you want high switching frequency - you need plenty drive capability to charge/discharge the MOSFET gate capacitance.
> Looks like attempt to impress not to explain, :fail:.


----------



## ianfield (Apr 17, 2013)

uk_caver said:


> Regarding surface mount components, I do use them quite a bit with stripboard, but I think that's only really feasible for 2 or 3-terminal devices.



A few strategically positioned SMDs add a fair bit of rigidity to "dead-bug" construction.


----------



## RoGuE_StreaK (Apr 17, 2013)

Steve K said:


> Who sells boards for $15?


Sorry I know we're getting way off track here. Seeed (and a few others) do 10x (that's ten boards) 5cm x 5cm double-sided boards for $10 ($1 each), and costs me about $5 shipped to Aus. CadSoft Eagle can be downloaded and used free for boards this size.
You could always design your own breakout boards rather than complete assemblies, but may as well go for semi-complete and add breakout pads if you've got the space.


----------



## Steve K (Apr 17, 2013)

ianfield said:


> I think you mean a boost converter - a buck converter only steps down. 2x AA gives slightly more than 3V - but not quite enough to fully drive a white LED.



yep... it was a typo. The plan is to use two AA nimh cells and boost it up to whatever a white XP-G needs. I've got plans to make it a current feedback hysteretic regulator of an unconventional design, delivering about an amp to the LED. A buddy did forward a link to a pretty good boost controller that can deliver almost as much current, but that's no fun.


----------



## Steve K (Apr 17, 2013)

RoGuE_StreaK said:


> Sorry I know we're getting way off track here. Seeed (and a few others) do 10x (that's ten boards) 5cm x 5cm double-sided boards for $10 ($1 each), and costs me about $5 shipped to Aus. CadSoft Eagle can be downloaded and used free for boards this size.
> You could always design your own breakout boards rather than complete assemblies, but may as well go for semi-complete and add breakout pads if you've got the space.



I may have to give that a try for some projects. It's a lot better price than I've seen other places, and it is just getting too hard to find new components in packages that have lead pitches or lead styles that lend themselves to manual soldering and homemade boards.

I'm not sure if it's entirely off-topic, but is a diversion. My personal thought is that the forum could use a bit more focus on electronics.


----------



## SemiMan (Apr 17, 2013)

Steve K said:


> I may have to give that a try for some projects. It's a lot better price than I've seen other places, and it is just getting too hard to find new components in packages that have lead pitches or lead styles that lend themselves to manual soldering and homemade boards.
> 
> I'm not sure if it's entirely off-topic, but is a diversion. My personal thought is that the forum could use a bit more focus on electronics.




There are not that many on here that are solid electronics people. The electronics forums is usually pretty thin.

Look at the Seeed site. Certainly cheap. Looks like minimum drill is 12mil (or metric equiv) which is not bad. Tolerances are not great, but at least you are getting HASL for that price.

If you have other really low cost option I would be interested. I generally pay about $100 for 2-3 days turns with about 50-60 square cm. I don't always need that fast though.

Semiman


----------



## RoGuE_StreaK (Apr 17, 2013)

OSH Park come highly recommended, but are quite a bit more expensive; $10 per square inch, 3x copies of the board (ie. $3.33/inch). But they are pretty purple and ENIG. Dunno turn around time.
http://oshpark.com/

A big plus with Seeed for me is that they'll cut any shape, and do internal milling for free.










What I find missing on this forum is any specific place to talk about optics, tossing about ideas for how to actually direct/harness the light. Unless I've overlooked it somewhere?


----------



## SemiMan (Apr 18, 2013)

RoGuE_StreaK said:


> OSH Park come highly recommended, but are quite a bit more expensive; $10 per square inch, 3x copies of the board (ie. $3.33/inch). But they are pretty purple and ENIG. Dunno turn around time.
> http://oshpark.com/
> 
> A big plus with Seeed for me is that they'll cut any shape, and do internal milling for free.
> ...




Milling/complex shape cutting at that price is certainly a nice benefit. If the turn was faster there would be 0 sense in ever hand prototyping! The planarity on the HASL looks pretty rough. Likely fine for hand soldering, but could be an issue for automated assembly. 

Was silkscreen included in that price?


Optics would be a good discussion, but likely even further beyond the average CPF users than the electronics side. Even professionally many just use off the shelf optics since optic design is not as well known.

Semiman


----------



## anuragwap (Apr 18, 2013)

If you want 2 sided boards, OSH Park's rate is only $5/sq inch for 3 copies of the board. I've ordered twice from OSH in the last 6 months and the turn around times were 15 and 21 days.


----------



## SemiMan (Apr 18, 2013)

anuragwap said:


> If you want 2 sided boards, OSH Park's rate is only $5/sq inch for 3 copies of the board. I've ordered twice from OSH in the last 6 months and the turn around times were 15 and 21 days.



It's the 15 - 21 days that kills me. I generally am looking for quick turn if running proto boards. Still for dev boards, test fixtures, etc. that could be tolerable at times. Their design rules are reasonable.

Semiman


----------



## RoGuE_StreaK (Apr 18, 2013)

SemiMan, yeah that includes double-sided silkscreen. Will upgrade to ENIG once I get the boards proven, got some 0.5mm pitch QFNs on there so it's a bit of a pain DIYing.

anuragwap yeah sorry I forgot they did 4layer as well, just posted the first figure I saw. When adding ENIG and a colour soldermask, the Seeed ones do come up a bit more towards this kind of price, still a fair bit less but OSH Park do have a reputation for quality. I don't think I'll be doing internal milling anymore so will have to investigate further.


----------



## SemiMan (Apr 18, 2013)

RoGuE_StreaK said:


> SemiMan, yeah that includes double-sided silkscreen. Will upgrade to ENIG once I get the boards proven, got some 0.5mm pitch QFNs on there so it's a bit of a pain DIYing.
> 
> anuragwap yeah sorry I forgot they did 4layer as well, just posted the first figure I saw. When adding ENIG and a colour soldermask, the Seeed ones do come up a bit more towards this kind of price, still a fair bit less but OSH Park do have a reputation for quality. I don't think I'll be doing internal milling anymore so will have to investigate further.




Are you doing this for a product to sell? It is not going to be cheap, but you can get a hand paste mask. I have done that for prototypes.

You don't need to go ENIG for production, just get better HASL. ENIG is not necessarily better.

I think I am going to try something through OSHPark and see how it turns out. I have some test fixtures that I have made that I want to turn into something a little more solid (hand built, partially etched). May even try to sell a few. It is a high / low current sensor and voltage interface board for using with LABJACK. I use Labjack and DAQFactory for test jigs. Super easy to program up systems for exercising and measuring systems.

Semiman


----------



## RoGuE_StreaK (Apr 18, 2013)

Yep _eventually_ for part of a product; I've previously experimented with DIY etched stencils, essentially the same process as DIY etching PCBs but with thin copper/brass/aluminium sheet. But seems new laser printer toner doesn't work like the old stuff did, so very difficult to get it fused to the sheet anymore. I've actually found a Chinese company on ebay doing laser-cut stainless for $30, so might go that route.

I aim to be going for a coloured soldermask and ENIG primarily 'cause it _looks_ cool, and want anyone who does disassemble my product to be impressed; yes, I know, shallow and vapid, but looks are a large factor of what I'm doing (well, _working on_ doing)


----------

