A comb filter to remove AC Hum from mains-powered lighting in an optical or "natural radio" receiver
Updated version

The problem:

In late 2010, Barry, G8AGN and his friend Gordon, G0EWN were running tests using optical, through-the-air voice links near Sheffield, England.  Being a fairly large city, it was difficult to find a path that was completely devoid of extraneous sources of light so the received audio - in at least one direction - had a fair amount of AC hum from mains-powered urban lighting.  While the hum didn't completely cover the speech, it made it challenging to understand..

Listen to a portion of this exchange here:
Figure 1:
An averaged spectral plot of the audio file recorded by Barry, G8AGN, during a 66km optical path test showing the mains-induced hum.  While there is some energy at 100 Hz, the main "spike" occurs at 300 Hz with harmonics.  This is a result of lighting, as a whole, being fed by 3-phase power.  At the high-frequency end, the mains harmonics show up as being slightly low in frequency due to a minor offset in the sampling rate of the original recording.
Click on the image for a larger version.
Spectral graph of mains-induced noise as
                    received by G8AGN
Practical audio hum removal:

If, after you have tried optical methods of minimizing hum (e.g. filters, beamwidth, and off-pointing), another means to minimize the effects of hum from lighting would be to filter it from the received audio -  provided that the influence of the light that caused the hum isn't actually overloading the receiver itself!  If the receiver is overloaded by extraneous light, desensitization and/or distortion may result - in which case neither audio filtering or the use of subcarriers may help much!  Assuming that the receiver isn't being clobbered, filtering of hum is possible since the frequency spectra of such interference is typically very stable and well-defined.

The individual frequency components in the hum (or buzz) from interference due to mains-powered lighting can be expressed this way:
F = (2 * M) * N

F = A specific harmonic component of the hum
M = the mains frequency
N = Positive integers
In other words, the noise that one hears from the lights consists primarily of twice the mains frequency and harmonics of that "2x mains" component.

The reason for this is that the lighting itself, being operated form an AC source, it will produce light on both sides of the sinusoidal AC waveform effectively doubling the frequency.  Furthermore, AC power is distributed in three phases which means that taken as a whole, light from a city will also contain a very strong component at three times the "hum" frequency (e.g. 6 times the mains frequency) being radiated by the sea of lights - and what's more is that this won't be a pure sine wave, but a rather ragged waveform replete with harmonics, way into the audio spectrum as the plot in Figure 1 shows!

In order to combat this problem I put together some code for the PIC16F88, an inexpensive processor, that provided a highly effective means of removing the 100 (or 120) Hz energy and its harmonics.

For more information and some audio files demonstrating the older version, visit the "Hum Comb filter" page for the original version - link.

Figure 2:
Schematics of the updated hum comb filter for removal of 50/60 Hz mains harmonics.
The newer version using the PIC16F1847.  With this processor, the sample rate has been raised to approximately 32 kHz and the low pass filters have been reworked to have a 10-12 kHz cut off frequency -see text for additional details.
Click on the image for a larger version.
Diagram of the "version 2" hum/comb

A PIC-based DSP comb filter:

Another method of hum removal would be to have hardware dedicated to the task.  Fortunately, this can be easily done with a low-end microprocessor.  While this has the obvious disadvantage that you'd have to build this device in the first place, the circuitry itself is quite simple, consumes very little power, and it may be built at minimal cost.   This may be built in to the optical receiver system permanently or take the form of a small, self-contained box that can be inserted into the audio line when needed.

Originally designed to remove the "switching tone" from an RDF (Radio Direction Finding) unit the described device is based on a Microchip (tm) PIC processor, the PIC16F1847, with code modified from the original to operate at 100 or 120 Hz and again adapted from the older version of this software that removed harmonics of the 100 or 120 Hz energy.  The schematic is shown in Figure 2.

This microcontroller is an inexpensive - yet reasonably powerful - 8 bit device with a number of built-in peripherals, namely a 10-bit A/D converter used to digitize the audio and a 10-bit PWM generator that functions as a D/A converter.  With the appropriate firmware - and coupled with the appropriate input and output filtering and amplification - an effective comb filter may be implemented in software.

This filter has several modes that may be selected simply by pulling the appropriate pins of the chip to ground:
There is also a "clip indicator" LED that will flash when the audio levels are approaching half of the maximum input/output level (e.g. 6dB below clipping).  In normal operation it is acceptable for this to flash occasionally - or even frequently - but if it's on too much you may be overdriving it and should reduce the input signal somewhat to prevent distortion.

Newer version of the hum comb filter:

Using a different processor, the PIC16F1847, there is a newer version of this comb filter with the following enhancements:
Aside from the use of the 8 MHz crystal for the new version using the PIC16F1847, it and the old version are pin-compatible:  It is by grounding RB2 (pin 8) that the "1x" mode (e.g. the notches in the comb being space 50/60 Hz apart) is enabled.  Leaving this pin open (e.g. allowed to be pulled high by the PIC's internal pull-up) enables the use of the original "2x" mode where the comb notches are spaced 100/120 Hz apart.

Circuit description:

U101A forms a lowpass filter with a bit of gain (around 6dB) that removes much of the audio above 10 kHz:  Because the sampling rate of the PIC is about 32 kHz, frequencies higher than 16 kHz, being above the Nyquist limit, will cause aliasing.  In addition to U101A, the combination of R108 and C105 provide an additional pole of low-pass filtering while simultaneously meeting the input impedance requirements of the PIC's A/D input.  If desired, components "Ra" and "Ca" can also be included to offer somewhat better attenuation of higher audio frequencies.

Following the filter is a "centering" network consisting of R106/R107 that sets the DC reference of the A/D input at 1/2 of the PIC's supply voltage - which is also the mid-scale for the A/D converter.  Inside the PIC, numbers are crunched and a filtered version of the audio (or a replica of the input data if it is in "bypass" mode) is spat out using PWM.  Preliminary filtering of the PWM waveform is provided by R112/C110 and then further-filtered by U101B - another 10-12kHz lowpass filter with the resulting filtered audio being made available to the user via R117/C113.

A source of "clean" and stable power is provided by U103, a 78L05 regulator, and this is used to operate the PIC as well as provide a handy mid-supply reference for U101.  Q101, a general-purpose NPN transistor, is driven by pulses output on pin 9 of the PIC that provide an indication that the audio input and/or output has reached 50% of full-scale on the A/D input or D/A output (e.g. 6dB below full-scale):  D101, C106 and R109 stretch these pulses and when a possible "clip" condition occurs, illuminate D102, an LED.

As-built, the current consumption of the prototype was measured at about 13 milliamps when operated from 13.5 volts with the CLIP LED dark - far less than any laptop computer!  Practically speaking, a 9-volt battery could be used to power this device provided that a "rail-to-rail" op amp was substituted for U101.


Software description:

Internally, the PIC uses an "IIR" (Infinite Impulse Response) DSP algorithm.  In this particular algorithm the inputted audio is summed with delayed version of the output audio, the period of the delay being precisely that of the frequency of the comb interval, which is 50/60 Hz in the "1X" mode or 100/120 Hz in the "2X" mode.  By choosing the ratio between the "input" signal and the "delayed feedback" signal, various aspects of the filter can be modified - namely the "sharpness" (or narrowness) of the resulting comb "teeth." 

Several pins of the PIC are used to select the various modes of operation depending on whether the pin is left open (and pulled up by a resistor internal to the PIC or pulled high by an external device) or grounded.  Refer to the schematic in Figure 2 for the pin numbers and their associated names.
Figure 3:
Top:  The comb filter during its very early stages of prototyping.  The mode selection switch and "clip" LED are not yet installed.
Center:  Barry's version of the comb filter during prototyping
Bottom:  The comb filter installed in a box along with the "Audible S-Meter" used for peaking signals.
Click on an image for a larger version.

                    view of the prototype comb filter during its early
A version of the comb filter built by Barry,
Barry's comb filter in the box with the Audible

Four different algorithms are available using the Sel1 and Sel2 pins:
Bypass pin:

There is also another pin - "Bypass" - that, when left open, causes the PIC to ignore the states of Sel1 and Sel2 and echo the A/D input to the D/A output with no filtering effects at all - other than the op-amp input/output anti-aliasing filters, of course and in this mode the sampling rate is much higher - 19.53125 kHz.  When the Bypass pin is grounded, the algorithm selected by the Sel1 and Sel2 pins is enabled and when the state of the Bypass, Sel1 or Sel2 pins are changed, the PIC is reset and the new algorithm takes effect.

50/60 Hz pin:

The 50/60 Hz pin, when left open, configures the PIC to operate with a 100 Hz comb filter, intended for areas with 50 Hz mains while grounding  it configures for a 60 Hz mains (e.g. a 120 Hz comb.)  Note that changing this pin will not cause the PIC to reset and it will not switch to/from 50 or 60 Hz modes until it is either power-cycled or reset by a change of state of the Sel1, Sel2 or Bypass pins.

1x/2x pin:

This pin, when left open (or pulled high high) will cause the PIC to produce notches at 100 or 120 Hz (depending on the 50/60 Hz pin) but if this pin is grounded (pulled low) the spacing of the combs are 50 or 60 Hz - also depending on the state of the 50/60 Hz pin.

Being crystal-controlled, the frequencies of the comb filter are stable to the same degree as the 20 MHz crystal oscillator.  While the 50 Hz mains filter is "dead on" frequency - that is, 100 Hz is an integer divisor of 20 MHz - the 60/120 Hz combs are not and a frequency error of about +10ppm results - hardly enough to cause a problem and well within the tolerance range of the crystal itself:  It is likely that the power line frequency itself will be farther off than that!


The construction of the comb filter is not critical and can be accomplished by a reasonably-experienced experimenter.  As can be seen in Figure 3 different versions were built onto pieces of phenolic "prototyping" perfboard.

While there is nothing particularly sensitive about the overall layout it is recommended that interconnecting wiring be kept as short as practical - particularly around the microprocessor and its 8 MHz crystal.  Some care be paid to the layout of the ground bus to avoid the possibility of "ground loops" - especially if you include a speaker amplifier - although at such low power levels and with fairly high audio signal levels this is unlikely to be too much of an issue.  The most critical aspects of the layout have to do with the fact that capacitor C106 - the power supply bypass for the PIC - should be placed very close to the chip itself to minimize supply-voltage noise which could show up in the A/D conversion.

As shown in the schematic, this filter does not have an amplifier to drive a speaker as it is intended as a device to be place inline with other equipment, perhaps between a speaker amplifier and the optical receiver.  It may be built into its very own box with in/out connectors, or be incorporated directly into another box containing these other circuits.

Additional notes on construction:

Since my version of the filter is still in its prototyping stage it doesn't include several features that might be helpful were it to be used either as a stand-alone device or incorporated into another, larger system as Barry did.
How well does it work?

This version seems to work every bit as well as the older version which was capable of just 100 or 120 Hz-spaced notches.  When in the "2X" mode (100/120 Hz notches) 16 bit math is used internally and despite the calculations, the residual noise is fairly low when it is filtering.  Because the PIC16F1847 has "only" about 1k of RAM - and ideally, about 1.5k would be required to implement a 50 or 60 Hz spaced comb filter at a 32 kHz sample rate - the audio had to be "packed" in RAM using only 12 bits per sample, and 12 bit math was used as well.  With this lower precision there is a very slight degradation in the "1x" mode as compared to the "2x" mode in addition to that which might be expected by increasing the number of notches over the audio passband.

Having said that, the "1x" mode works as well - if not better than - the "2x" mode on the older version since the sampling rate is tripled compared to the old version!


Using this comb filter for other purposes:

One possible use of this comb filter is in the reception of VLF and near-VLF signals - that is, RF signals below 10 kHz.  At these frequencies one may hear Spherics such as "Whistlers" and other phenomenon often related to the "Dawn Chorus" and other Spherics.   One problem that plagues would-be listeners at these frequencies is the pick up of harmonics of AC line frequencies, but a filter such as this one is a simple, low-power alternative to using a PC. 

If you are planning to use this filter for applications in which the audio in put may contain significant energy above the Nyquist (e.g. above 16 kHz) - such as a receiver for "Natural Radio" you may wish to re-work it for better stop-band attenuation - particularly in the 20 kHz and up area where there are a number of very strong VLF transmitters.  For critical applications a low-pass filter with more poles - or a configuration that has much steeper stop-band response above 15 kHz such as an "Elliptical" filter - would be recommended:  Contact me if you have questions about this.

Another consideration is that this PIC has only 10 bits of A/D and D/A capability - a fact that limits the total dynamic range to something around 60dB at best.  If you do use this filter in that application it will be important that the audio input to the PIC (on pin 17) be kept as high as possible - but ever exceeding 5 volts peak-peak (e.g. from ground to +5 volts):  Practically speaking, the occasional excursion of peaks beyond this range will not likely cause noticeable artifacts, but one should pay attention to the CLIP LED.  If such a receiver has an AGC circuit, it should be possible to use the output of the CLIP pin to maintain a proper audio level:  The more active the CLIP pin gets (e.g. goes high), the more one would want to reduce the gain.  Note that the CLIP pin goes active if either the input or the output gets within 6 dB of clipping.


There is nothing in the processor's code that would prevent it from operating at frequencies down to a couple of Hertz - or even lower.  The low-frequency limitation of the circuit depicted in Figure 2 is due to the coupling capacitors (e.g. C101, C104, C109 and C113.)  In theory, it should be possible to configure the signal path to pass DC, but if you were primarily interested in such low frequencies and didn't care about frequencies above a few 10's of Hz you would probably be better off using a 50/60 Hz low-pass filter with notches tuned to remove the fundamental frequency and the first few harmonics.

What's at such low frequencies? One such phenomena is The Schumann resonance which is the tendency for the Earth's electromagnetic field to be resonant at a frequency (and harmonics) that correspond with the Earth-atmosphere system forming a cavity resonator that "rings" at approximately 7.83 Hz.

Audio examples of 60 Hz filtering:

If one does use this for "Natural Radio" reception it would most likely be at audio frequencies, directly rather than at frequencies that get converted down, as was done in the above examples.  Typically, signals would be detected using a special E-field whip antenna and then amplified and passed to an audio power amplifier stage for listening via a speaker or headphones.  If one were to use this circuit for that purpose, there are several things that you would have to do:

Additional features of this software:

Since the PIC16F1847 has quite a bit of RAM and code space - and since the DSP code took less than a third of that space - I decided to add several more features to the code, the modes selected by pulling pins not shown as being used in Figure 2 to the appropriate states.  At present, these additional modes are:

I'm working on adding other features, including:

Contact me for details about this updated version of software if you are interested.

I plan to make additional enhancements to this circuit/code in the future - stay tuned.

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:  laser pointer, laser, pointer, 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, laser voice, laser voice transmitter, laser voice communicator, laser communicator, laser transmitter, laser voice sender, laser pointer transmitter, laser pointer transceiver, laser pointer communicator, laser pointer communications, laser pointer voice communicator, laser pointer voice communications, 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 2011-2015  Last update:  20150820

Page count since 1/2014: