A "Mini" full-featured
Pulse Width Modulator
for high-power LEDs and laser diodes

For an updated version of this same design that allows for a somewhat simpler circuit design and (optionally) manual gain control, see the web page about the "Version 2/3 of the Mini Pulse Width Modulator." - link

Why another Pulse-Width Modulator:

Why is PWM better for driving laser diodes?

Laser diodes - unlike LEDs - have a fairly limited current range over which they will lase.  While the optical output of an LED is very strongly related to the current through it in a linear way, a laser diode is not:  Too low a current, the laser diode either does nothing or lights up like an LED without actually lasing while a little too much current will destroy the laser almost instantly!  This becomes tricky with analog modulation since it could well be that a voice peak could come along that is just a bit too high for the laser to survive.

The trick would be to finding the range of current over which a Laser diode will function.  The problem with this is that this current varies from device to device and even with the same device over temperature and you can never really be sure if you are in the "safe" range without testing it - and possibly blowing up the laser diode!  In addition to this problem, there's no guarantee that over this "window" of safe operating current the laser's light output will bear a linear relation to the current and this could cause significant distortion in the audio.

If you want to effectively modulate the light source, you need to be able to vary its current from a low level - where the light output goes pretty much to zero - to "full brightness" where the current is at maximum.  If your modulation doesn't go to these extremes, you are short-changing yourself in that the "modulation depth" is reduced and your laser link's performance will be diminished because you aren't using the full dynamics of the laser to convey the information.

Using PWM conveniently side-steps this issue in most respects:  You simply set the "on" current to a known, safe value and since the laser diode is either "on" or "off", you can safely utilize all of the laser's dynamic range.  What's more is the fact that since the laser itself is on or off, the linearity of its modulation is that of the PWM generator rather than the awkward, nonlinear current-versus-brightness curve of the laser!
After constructing and using my previous Pulse-Width Modulator I decided to build the future modulators using analog current-modulation techniques.  The reason was that the "current sink" circuit used is very easy to construct and offers excellent performance and the PWM circuit offered no great advantage over the current-sink version - except that the PWM circuit could easily drive Laser diodes.  Since there wasn't the need to routinely modulate laser diodes in our experiments - and since I already had a PWM unit to do this - there was little impetus to build yet another modulator.

Why go back to PWM again?  There was the need to construct a very simple, but full-featured modulator.  As it turned out, in late 2008 I received an email from Henry, KB7NIE, one of the members of a Tucson-based amateur radio group and this group's main interest was microwave frequencies.  Since some of their number are attached to the University of Arizona's optical department and/or have general interest in things optical, we got their attention - and an invitation to visit.

After several months everything came together and we paid them a visit and were given detailed tours of some of the microwave and optical facilities in the area (think telescopes - radio and optical.)  As part of the visit we demonstrated an across-the-valley optical QSO.

As part of the effort, we (Ron, K7RJ and I) decided to put together a very simple optical transceiver using foam-core posterboard, "page-magnifier" Fresnel lenses, and the necessary electronics.  Ron kindly assembled a "Version 3" optical receiver of his own layout and construction while I put together an LED modulator.  Not wanting to do just the same as before I decided to start from scratch, hardware-wise, and I built something that was very simple, yet had a few nice features such as a tone generator.  Part of keeping the hardware simple and versatile involved the use of PWM.

Unfortunately, we ran out of time before we could get everything focused and aligned - although a preliminary test with the transmit portion was done over a 7 mile/11 km path:  The unit was simply left with our host when we returned home so that he could, in the future, conduct tests and experiments of his own.

What is PWM?

Pulse Width Modulation (PWM) is widely used nowadays in low-power audio amplifiers and the so-called "1 bit" D/A converters and the operation is simple:
As it turns out, the linearity of a PWM generator could, in theory, be absolutely perfect:  The duty cycle is timed precisely using digital counters - which are - for practical purposes - absolutely precise.  What is necessary is that there be enough timer resolution in order to provide the needed resolution of duty cycles.

Take, for example, a 10 bit PWM converter.  Because 10 bits represents 1024 steps, it would be necessary that the original timing clock be 1024 times that of the sampling rate.  If, for example, our original clock were 20 MHz, one 1024th of that would be 19.53125 kHz.

Figure 1:
Diagram showing how PWM is produced and how it is detected and converted back to an analog form.

Diagram showing how PWM works.
In practical terms, the frequency response of the circuits in a typical highly-sensitive optical receiver are not able to respond at the PWM frequency so they tend to average out the PWM switching frequency and leave only the modulation, with the result being a voltage that is very close to the original analog signal applied to the modulator.  Again, this technique works provided that the optical receiver being used (and/or its following amplifier stages) don't have the frequency response characteristics necessary to reproduce the original PWM waveform:  This could be through design that intentionally reduces frequency response, or it could be the result of additional low-pass filtering.

Some caution should be exercised, however:  If the optical receiver does have the bandwidth to recover the PWM signal, or if there is a reduced (but still sufficient) response of the audio chain at the PWM frequency, this could play havoc with downstream audio devices in several ways:
While the above are possibilities, I have not experienced these effects when using my Version 3 optical receiver (even with the lowpass filter switched out) with digital audio devices - but the fact that this receiver is designed to roll off severely above about 7 kHz is, no doubt, a mitigating factor.  The caution here is that all equipment should be tried out before going out into the field for serious work to verify that there is compatibility.

Again, it should be noted that to detect a PWM signal, the receiver does not need to be able to respond to the switching frequency, but only to the rate at which the pulse width is being changed - that is, the audio modulated atop the PWM.  A "slow" receiver will simply integrate (or smooth) together the PWM waveform into a form that closely resembles the signal that was originally fed into the modulator in the first place.

A PIC-based Pulse Width Modulator:

Note that this is a prototype version:  I will add a few more feature to it as time permits - if someone asks!

Like the previous PWM modulator, this is also based on a PIC - but a different one:  The PIC12F683.  This is an 8-pin device and has a number of useful onboard peripherals, such as a 10-bit A/D converter, a hardware PWM generator and an on-board CPU clock - plus enough RAM and program memory to do some useful things.

The PIC is programmed to provide several important functions:
Circuit description:

Refer to Figure 2 for the schematics of the circuits described below.

PWM output:

The heart of the modulator is U2, the PIC12F683.  Starting with the output, the PWM signal is applied to the gate of Q2, a power MOSFET, which drives the light source by varying the duty cycle:  The higher the duty cycle (e.g. the more "on" time) the more light is output, and vice-versa.  It isn't really important what the light source is, as it could be a laser, a high-power LED or even a light bulb!

Since Q2 turns on the light source simply by grounding one end of it, all that is important is that the light emitter be driven appropriately:  In the case of an LED, one could simply use a series-connected current-limiting resistor.  For a laser - such as that from a laser pointer - one would connect the "minus" end of a laser module to Q2, while using the appropriate voltage supply (around 3 volts for a typical laser pointer) on the "positive" side of the laser.  In all cases it is recommended that C16 be present to make sure that the PWM signal and the modulated audio doesn't find its way into the unit's power supply!

Comment:  While you could use a light bulb, their filaments are comparatively slow to respond to audio, the result likely being rather muffled and weak audio.

The bottom diagram of Figure 2 shows how various light sources may be connected.

Mic preamp:

Moving to the other end of the circuit, there's Q1, wired as a amplifier with about 20dB of gain.  The sole purpose of this stage is to boost the audio level from a standard electret microphone (the sort used on computers and headsets) to a level that is high enough to be usable on a "line level" input.  Shown on the diagram is microphone that is "built in" to the unit, but there's also J1 to allow an external microphone to be used:  Through experience I have found that it is best to include a built-in microphone in the gear just in case one forgets to bring one along!  The output of the microphone amplifier goes to J2, a "line level" input which allows one to feed audio from a portable audio player or computer.  Because J2 is a "disconnect-type" jack, the microphone is disabled when a device is plugged into it.  Note the presence of R5 and R6, which are used to "mix" two audio channels of a stereo source together:  I have found that simply shorting "Left" and "Right" channels of audio sources together often results in objectionable distortion, as the two audio amplifiers used in computers and portable audio players often "fight" each other!

Automatic Gain Control (AGC):

The audio from the mic preamp and line input go to U1A, a variable-gain audio amplifier.  Using R8, the feedback resistor, along with R9, R10, R11 and R12, the U2 can adjust the audio gain of U1A as needed by appropriately shorting the related pins to ground or leaving them "open" and the resistor values have been chosen to provide over 13 dB of gain adjustment in steps of 4dB or less.  U2 keeps track of the audio input level and adjusts the gain as necessary to keep the audio level driving the PWM generator near maximum.  In addition to the 13dB of gain adjustment using U1A, the software in U2 can automatically provide an additional 12dB of signal boost internally, providing an overall range of approximately 25dB of overall automatic gain adjustment capability.

Figure 2:
Top:  Schematic of the "Mini" PWM LED/laser modulator.
Bottom: Interfacing the modulator with LEDs and laser diode modules.
Click on either image for a larger version.
Schematic of the "Mini" PWM driver
Interfacing LEDs and laser diode modules with
                    the modulator
An AGC circuit can be quite useful as it helps maintain an even transmitted audio level, even if one is close to or farther from the microphone. If signals are weak, having a "high" audio level prevents them from lost in the noise if someone talks too quietly.  The downside of an AGC circuit is that there can be annoying "pumping" as the background noise can come up during periods of quiet.  Unless one is using headphones and being somewhat careful, this can also result in audio feedback during "silent" periods (no talking).  It is important to note that having too-little audio is probably worse than having a bit too much - particularly if signals are weak!

Comment:  In the "newer" version of this modulator noted at the top of the page there arebe provisions to completely disable the AGC and allow the use of a manual gain control.  While one could replace R9-R12 with a potentiometer on this circuit, the "12dB boost" will still be present and would be very annoying!

Lowpass and highpass filters:

U1B, along with R7 and C10, comprise a simple lowpass filter designed to remove audio above about 3 kHz to prevent aliasing effects.  C9 and R18 form a simple high-pass filter network that also removes audio content much below 200 Hz to prevent overmodulation due to the user "popping" the microphone with consonants or from wind noise.

SW1, the "Mode" switch:

The modulator has two modes:  The "Audio" mode which, as you would expect, transmits audio from the microphone or "line input" and the "Tone" mode which is used to generate a variety of tones for alignment and testing.  Because the PIC has only 6 pins that can be used for inputs and outputs (the other two pins supply power!) it is necessary to "re-use" at least one pin - in this case, Pin 7.

When in "Audio" mode, SW1 does two things:  It sets a mid-supply bias (2.5 volts) on Pin 7 (through R18, using the voltage divider comprised of R19 and R20) so that the analog/digital converter can work properly, and it enables another mid-supply bias (5 volts) to provide a reference for U1A, U1B, and power for the microphone amplifier, Q1.

When in "Tone" mode SW1 re-routes R21, a potentiometer, through R18 so that instead of audio, a variable voltage (0-5 volts) can be applied to pin 7 to select the tone mode.  Additionally, the 5 volt mid-supply bias is removed from U1A and U1B to disable those stages as well as removing power from the microphone amplifier to prevent audio that may be being inputted from "breaking through" and appearing at pin 7.

"Tone" mode:

In "Tone" mode, sine waves are produced using digital techniques.  In this mode, there are three possible settings:
Please note:

The as-built prototype:

Figure 3:
Top Left:  The as-built prototype for the Simple PWM optical transmitter along with its LED and secondary lens - see text for a description.
Top Right:  To house the transmitter and its lens, a box was constructed using "foam core" posterboard held together with thermoset ("hot melt") glue.  Here, several sets of hands hold everything steady while the glue sets as the box begins to take shape.  Here, Clint (in the blue shirt) is being assisted by Ron, K7RJ (left) and Dr. Nofziger, WB8SVK (right).
Bottom Left:  In the lab, the box being assembled with the assistance of Elaine, N7BDZ.
Bottom Right:  Finishing touches on the box.
Click on an image for a larger version.
As-built "simple" PWM Requiring several hands at once to keep
                    everything together while the thermoset glue sets,
                    the box begins to take shape.
The box
                    being assembled in the lab in Tucson. Final
                    touches being put on the box containing the
                    "simple" PWM optical transmitter.
Figure 3 shows the modulator, complete with LED and secondary lens.  All of the circuits are mounted on a piece of foam-core board on a removable "back panel" for the simple enclosure (also seen in Figure 3) that we constructed for our Tucson friends - one similar to the "cheap enclosure."

In this picture one may see the main board to the right, mounted to some wooden rails that had been glued to the foam-core board as a substrate.  The small circuit board on the left is the microphone amplifier (Q1) and the jacks, switch and potentiometer may also be clearly seen.

Interfacing LEDs and laser diode modules:

See Figure 2, bottom for information on interfacing the modulator with LEDs and laser diode modules.

The LED used for the prototype was a Radio Shack #276-020 high brightness red "power" LED:  This LED is also known as the Liteon P/N: LTL912SEKSA and is capable of a continuous current of 70 mA.

A 68 ohm resistor was used in series with the 12 volt supply to limit the peak current to about 170 mA.  Since the average duty cycle of the LED is 50%, this averages out to about 85 mA.  In referencing the data sheet for the LED, it was noted that the "absolute maximum current" rating was 100mA, but since the copper to which the LED is mounted acts as a heat sink - and since it isn't expected that the LED will be powered up for thousands of hours - there should be no real problem.  If you are worried, change the resistor!

Almost any LED may be used and in general, one can select a peak current of twice the LED's rated average current and be fairly safe.  It should be noted that red (or infrared) LEDs are recommended over other colors as silicon photodetectors (such as photodiodes or phototransistors) are far more sensitive to red than other colors - not to mention the fact that red/infrared light is less-affected by atmospheric losses.

If a white LED is used remember that it uses a phosphor to convert some of the blue light produced internally by the LED to yellow and the "persistence" of this phosphor will "slow down" the LED's response.  This may cause the frequency response (the "highs") to suffer noticeably, possibly causing "muffled" audio.  Since silicon photodetectors are far more sensitive to the "red" end of the spectrum than the "blue" end, it will be primarily the yellow-red light from slowly-responding phosphor that the detector would see rather than the fast-responding blue LED - a fact that could further-degrade the audio response.

Figure 2, bottom also shows how to interface with a laser diode module such as one obtained from a laser pointer.  These modules typically contain a current regulator that establishes a "safe" current for the laser diode's operation and are designed to operate from a 3 volt source such as a pair of AA cells.

There are also some "raw" laser diodes - often with lenses - that are commonly seen at parts supply houses:  Sometimes these do not come with a regulator board and if they do not have a built-in regulator, they should not be connected as shown, without some sort of  external current regulator!  If you have one of these modules,you will need to consult the laser diode's data sheet or a web site such as Sam's Laser FAQ to find out to to drive these devices without blowing them up!  Again, if you remove the laser from a battery-operated device such as a pointer, it will probably have the necessary regulator circuit already built-in.

If you wish to use a single "ordinary" low-power LED - that is, common, epoxy-packaged LEDs, it can be driven to about 25 milliamps using U2 directly.  Because the maximum current of these LEDs (typically in the 25-35 mA range) is a good "fit" for the output current capability of U2 (also about 25 milliamps) one can dispense with the extra transistor, using only a resistor to limit the current to the LED and an example of how this might be done is shown on the right side of Figure 2, bottom.

Note:  It is possible to get more drive current (say, somewhere around 50mA) out of the U2 directly, but this current level exceeds the official ratings of the chip.  While this probably won't damage the chip, you are on your own if you exceed the chip's ratings by that much!

Secondary lens:

Also shown in figure 3 is a "secondary lens."  When using LEDs, this optical component is absolutely necessary for good transmission efficiency as it directs the LED's light toward the Fresnel lens and without it, most of the LED's light would simply be lost, having spread out over an area larger than the lens itself, "missing" the Fresnel entirely and not getting radiated!  This lens was obtained from Edmund Scientific's Scientifics and came from one of their "Bags of lenses" but there are other places through which lenses may be obtained - see the "Sources" web page.

There was nothing special about this lens except that it is was a fairly "strong" Plano-Convex type:  For practical reasons the lens used here should have a low f/D-ratio - preferably smaller than 2, and close to 1 is even better, still!  The fact that it was slightly scratched and chipped was of no real importance in this application, and for mounting, it was simply epoxied into a hole cut in a piece of glass-epoxy circuit board material with a hole saw.

To adjust "focus" and lateral alignment, some pieces of #12 copper wire were used to hold the lens mount as seen in figure 3:  The wire could be bent to precisely align the lens over the LED and the "focus" onto the back of the Fresnel lens was accomplished by moving the lens closer and farther away from the LED, soldering it in place once the final position was determined.  Once soldered, the lens was held quite firmly in place and would maintain alignment under normal handling conditions.

The "final position" of the secondary lens may be determined empirically provided that one knows two things:  The focal length of the primary (Fresnel) lens, and the size of that lens.  Simply put, one places a piece of paper at the focal length distance from the LED and adjusts the spacing of the secondary lens until the "spot size" of the light from the LED is the same size as the Fresnel lens.  Because the spot is round and inexpensive "page magnifier" lenses are rectangular, it is best if one adjusts the size of the spot to be slightly larger than the "small" dimension of the lens - but slightly smaller than the "large" dimension.  Once the spacing of the secondary lens to the LED is determined in this manner, one secures it into place by soldering, as described above and seen in figure 3.  For information on the "final" focusing - that is, the determining of the exact distance of the Fresnel lens from the LED, see the page, Optical enclosure - first version on this site, but in short, this is done simply by moving the nesting boxes in and out and the securing with screws and glue once the final position is determined.  The paraxial position (left/right, up and down) may be adjusted by moving the plate on which the LED transmitter is mounted so that the beam shoots out the the dead center of the lens.

In practical terms, the preferred lenses are "PCX" - Plano-Convex - (e.g. flat on the LED side, bulging out toward the Fresnel) or, even better, "PMN" - Positive Meniscus - (the concave side toward the LED) over more commonly-seen double-convex ("DCX") lenses due to more-favorable geometry.  Ideally, one would use the "strongest" lens PCX or PMN lens that you can find so that it is as close to the LED as possible to intercept the maximum amount of light.

Comment about the secondary lens depicted in Figure 3:
If you look at the upper-left image in Figure 3 (click on the image itself for a larger version) you'll note that the secondary lens is spaced some distance away from the LED.  If one does the math, it will be noted that more than half of the light emitted by the LED actually misses this secondary lens and spills out, past the secondary lens, around its edges.  With the lens shown, if we where to have moved it closer to the LED than we did, the "circle of light" would have been much wider than the Fresnel lens, and even more light would have been wasted.

What we really need, then, is a secondary lens that practically (or actually does) touch the LED itself to avoid this "spillover" - and this implies either:
  • A "Stronger" lens (e.g. one with a higher "diopter" rating or a lower f/D ratio) or
  • Multiple lenses
As noted above, a better lens would have been a Plano-Convex (PCX) or Positive-Meniscus lens with the flat (or concave) side toward and just (about) touching the LED to "capture" all of its light - but the trick is to know exactly how "strong" that lens should be.  The general rule-of-thumb is for a main lens (in our case, the Fresnel) with an f/D ratio on the order of 1.0-1.25 that the secondary lens's f/D ratio should also be in the area of 1.0-1.25.  The problem is that finding such a lens can be rather tricky, particularly if you don't have access to a wide variety of surplus lenses, so one could make do - albeit with a slight loss of efficiency - as follows:
  • Place a smaller, diameter and fairly "strong" PCX (Plano-Convex) lens or PMN (Positive Meniscus lens, if you can get it) right against the LED.
  • Place a much larger diameter lens between the LED and first lens and the Fresnel, adjusting that lens' distance for the appropriate size of the "circle of light" to match the "long" dimension of the Fresnel.
Using "found" (e.g. unknown) lenses and making them work can be a bit tricky, but you should still be able to get reasonable results!

A "Simpler" Foam Core enclosure using rigid "Page Magnifier" Fresnel lenses

If you look carefully at the pictures in Figure 3 you will see the the processes of the construction of another optical enclosure using black, foam core board and "hot glue" - this time, based around "rigid" page magnifier Fresnel lenses.  Similar to the other enclosure described on this page - See the page Optical Enclosure - Cheap Version it uses rigid lenses rather than the flexible, clear vinyl lenses described on that page.

Since this page was originally written, I did some testing on the optical qualities of various Fresnel lenses - and the results may be seen here:
Fresnel Lens Comparison
And there you will see that these inexpensive, rigid page magnifier lenses can actually work admirably in terms of optical performance, equal to or better than Fresnel lenses that come from other sources that cost several times as much!

The obvious advantage of these inexpensive, rigid, page magnifier lenses - aside from being cheap - is that they lend themselves to being easily built into an inexpensive, lightweight enclosure using the same foam core posterboard described in the aforementioned page - and since they are rigid, a picture frame is not required to hold them flat:  They will support themselves.  What is required is that they be installed flat and perfectly parallel to the rays exiting the enclosure - a precaution that is easy to manage at the time of construction with a bit of care.

Unfortunately, not a lot of photographs exist of the "build" depicted in Figure 3, but here are a few details worth mentioning:
At some point I hope to produce a web page showing the steps in making a simple, rugged foam core optical transceiver using the above methods, but if you have any questions, please feel free to ask them via the link found at the bottom of this page.

"How far will this go?"

The prototype was constructed using the Radio Shack LED mentioned above and briefly tested over a distance of a bit more than 7 miles (11km).

At the time we made some audio recordings at the "receive" end that demonstrate its performance.  These were "open mic" recordings (with some AGC effects of the digital audio recorder itself) so what you hear are the people on-site (7 miles from the transmitter) and the voice coming over the speaker via the LED communications link using THIS transmitter.
As you can hear, signals were excellent over the path.  Since the unit wasn't 100% complete, it was being hand-held rather than tripod-mounted so signals were varying.  Judging by the audio and the reports there was at least 30dB of link margin available on the path and even though the LED wasn't as powerful as the other optical devices used that evening, it was very conspicuous among the other city lights!  As you can hear from the audio clip, even though it was being captured by microphone from the receiver's speaker, audio quality is good and the unit's AGC is well-behaved.

Judging by the the excellent signals at that distance I have little reason to doubt that the unit built described as above, with a good-quality receiver (e.g. the "Version 3" mentioned above) along with a "page magnifier" type of Fresnel lenses for both receive and transmit, much longer distances may be easily attained in clear air:   Based in prior experience, I would guess that distances of well over 25 miles (40km) should be easily attainable with this LED - probably much more.

Future enhancements:

As time permits, I hope to revisit this circuit and make some enhancements and simplifications.  These include:
Even though it isn't "complete" - that is, I hope to add a few more features - programmed PICs are available:  If you have interest in this project, please feel free to contact me using the link below.

Return to the KA7OEI Optical communications Index page.

If you have questions or comments concerning the contents of this page, or are interested in this circuit, feel free to contact me using the information at this URL.
Keywords:  Lightbeam communications, light beam, lightbeam, laser beam, modulated light, optical communications, through-the-air optical communications, FSO communications, Free-Space Optical communications, LED communications, laser communications, LED, laser, light-emitting diode, lens, fresnel, fresnel lens, photodiode, photomultiplier, PMT, phototransistor, laser tube, laser diode, high power LED, luxeon, cree, phlatlight, lumileds, modulator, detector
This page and contents copyright 2009-2015 by Clint, KA7OEI.  Last update:  20150819
Count since 201005: