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


Note:  The described project is a semi-completed prototype, but it works as described.  While there are plans to more fully-develop this device, this will happen when time permits - or if someone bugs me enough to complete it!  If you are interested, programmed chips are available - see the contact information at the bottom of this page.

Why another Pulse-Width Modulator:

After constructing and using my previous Pulse-Width Modulator, I decided to build the future modulators using current-modulation techniques.  The reason was that the "current sink" circuit used is very easy to construct and offers excellent performance.  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, this ability was not really missed.

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 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 built something that was very simple, yet had a few nice features such as a tone generator.  Part of keeping the hardware simple involved the use of PWM.

The "mostly complete" optical transceiver (we ran out of time before we could get everything focused and aligned) 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?
Figure 1:
Graphics showing how PWM works.  These graphs are from the Luxeon link on the Modulated Light web page by Chris, VK3AML and Mike, VK7MJ.

Graphics showing PWM operation

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 absolutely precise.  What is necessary, however, 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.

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 usually works as the more sensitive optical receivers (and/or their following amplifier stages) don't have the frequency response characteristics necessary to reproduce the original PWM waveform.

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 (with the lowpass filter switched out) with digital audio devices - but the fact that this receiver starts 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.

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 - of if someone asks!

Like the previous PWM generator, 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 - if you really wanted to use one!

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 (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 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 then goes 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."  These 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 provide an additional 12dB of signal boost internally, providing approximately 25dB of overall 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 some annoying "pumping" as the background noise comes up during periods of quiet.  Unless one is using headphones and being somewhat careful, this can result in audio feedback in some cases.  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 a future revision of this modulator there will be 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:
The as-built prototype for the PWM - see text for a description.
Click on the image for a larger version.
As-built "simple" PWM
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 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.  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:  Usually, these do not come with a regulator board and 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 board built-in.

If you wish to use "ordinary" low-power LEDs - that is, common, epoxy-packaged LEDs used as indicators or in those "multi-LED" flashlights, these 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 (about 25 milliamps) one can dispense with the extra transistor, using only a diode to limit the current to the LED.  An example of how this might be done is shown on the right side of Figure 2, bottomNote:  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:  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 lens entirely and not getting radiated!  This lens was obtained from Edmund Scientific's Scientifics and came from one of their "Bags of lenses".  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-ratio - preferably smaller than 2.  The fact that it was slightly scratched and chipped was of no real importance in this application.  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.

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.  This is because the PCX and PMN lenses offer more convenient geometry in that there is likely to be less light reflected from the lens by the LED and the fact that PCX and PMN lenses may more easily be made to be "stronger" so that one may get the lens closer to the LED to gather more light before it is spread out.



"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.)  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-2010 by Clint, KA7OEI.  Last update:  20100104
Count since 201005: