A comb filter to remove AC Hum from mains-powered lighting in an optical receiver
(Original version)

To read about an updated version of this filter, click here.

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:
Barry and I had been exchanging emails for some time and when I received the hum-afflicted audio file above I thought again about several ways in which hum could be reduced:

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
Where:
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!

Comments:
What is required to remove the hum is NOT a filter for just twice the mains frequency, but a comb filter that removes energy at the "hum" frequency (e.g. twice the mains frequency) and the hum's harmonics.  What's more, it is desirable that the notches of the comb filter be very narrow - that is, they should remove only those frequencies in the immediate spectral vicinity of the hum's components while minimally-affecting others as to degrade the fidelity of the audio as little as possible.

One of the ways that this can be done is with a portable computer (e.g. laptop or so-called "netbook") running the appropriate program.  Real-time hum removal can be done with a number of DSP-type programs - many of which are aimed at the amateur radio community and these programs include:
There are several problems with using such a computer:
Figure 2:
Schematics of the hum comb filter for removal of 50/60 Hz related mains harmonics.
Click on the image for a larger version.
Schematic of the hum comb filter


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 simply 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 PIC16F88, with code modified from the original to operate at 100 or 120 Hz.  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 - a 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.  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.


Circuit description:

U101A forms a lowpass filter with a bit of gain (around 6dB) that removes much of the audio above 3-3.5 kHz:  Because the sampling rate of the PIC is about 10 kHz when in "comb filter" mode, frequencies higher than 5 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.

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 3-3.5 kHz 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 out a bit 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.

Comment:

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, in the case of a "50 Hz" mains filter is 10 milliseconds (actually 100 Hz.)  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."  When in "comb filter" mode the sampling rate is approximately 10 kHz.

Several pins of the PIC are used to select the various modes of operation and the different modes are selected depending on whether the pin is left open (and pulled up by a resistor internal to the PIC) 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.

Close-up
                    view of the prototype comb filter during its early
                    stages.
A version of the comb filter built by Barry,
                    G8AGN
Barry's comb filter in the box with the Audible
                    S-Meter

Four different algorithms are available:
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.

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.

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 120 Hz comb is not and a frequency error of +192 microHertz (about 16ppm) results - hardly enough to cause a problem and well within the tolerance range of the crystal itself!

Construction:

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 20 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, 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 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?

On my workbench I was able to test it using the audio files provided by Barry to verify that it did, in fact, work on 100 Hz mains - although I had to make a minor change:  It seemed that the field recording that Barry made was with a device that had a very slight (about 0.4 percent) sampling rate error and the comb filter's efficacy was initially rather disappointing.  Upon realizing that there was a slight difference and the 100 Hz mains interference was slightly off-frequency, I used the Audacity program to re-sample the audio to put the hum precisely on-frequency and was gratified to note that the filter worked quite well!  This warning serves to reiterate the importance of making sure that your sample rates are accurate - especially if you are going to re-process the audio files later and not use the same audio device for both record and playback!

Comments:

The next step was to conduct field trials.  Fortunately for me, Barry had immediate use for the comb filter on an upcoming outing and he reported that it worked very well as the following audio clip demonstrates:
As evidenced by the above clip there is very little evidence of hum caused by pickup of light from the 50 Hz mains - but Barry assures me that without the filter, the hum was pretty terrible!  In this example the "50%" algorithm was selected and figure 4 shows a spectral analysis of this audio and the multiple notches are very evident at 100 Hz intervals.  Since the "50%" algorithm had been used, these notches - and their effects on the surrounding spectrum - were at their worst, but as can be heard, the audio having passed through the filter sounds just fine considering the fact that it was recorded "speaker-to-microphone"!

What about an A/B comparison?  At the time of writing, neither Barry or I have had time to do in-field "A/B" comparisons with and without the comb filter or selecting amongst its various modes, but here is a demonstration recording that I'd sent to Barry during the prototyping and initial testing of the PIC's code:
Note that during the above clip the prototype board was connected with a maze of clip-leads:  During this test I was selecting different filter modes, albeit sometimes more successfully than others as can be heard by rapidly changing modes as the clip leads kept falling off!  Some day (soon) I'll re-do this demonstration clip to include the "50%" mode that Barry used above.
Figure 4:
This shows an averaged spectral plot of the audio from the file from the 87km test (above) after it had passed through the comb filter.  The "50% Feedback" mode was used, which has the widest notches.
Click on the image for a larger version.
A
                    spectral plot of the audio having passed through the
                    comb filter

Comments:

Final notes:

This comb filter has been shown to work in the field and as I get time to do so, I will do further testing and update this web page.  If you are interested in building a comb filter such as this, feel free to let me know via the email link at the bottom of this page.


Contact me for details about this updated version if you are interested in this filter.

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



Footnote:
  1. - Many narrowband optical filters have a fairly narrow angle of acceptance in which off-axis light is filtered differently than on-axis light in terms of filter loss and its wavelength and bandwidth characteristics.  In a very simple lens system of small f/D ratio, the angle at which light may hit the filter could be beyond its specifications and thus affect response.
  2. - The "Blur Circle" of the lens is the smallest point that can be focused.  For highly-accurate lenses made to sub-wavelength accuracy, this is the so-called "airy disk" and is limited by the small, but finite size of the wavelength of light itself.  For less-accurate lens systems, this is known as the "circle of confusion" or "blur circle."  Fresnel lenses - being comparatively inaccurate - can not achieve accuracy to produce a true airy disk, so the smallest spot size that they produce is that of the blur circle.  It makes sense, then, that if one were to focus the distant light source using one of these lenses onto a detector that was as large as the blur circle, one would - in theory - intercept all of the light that had been focused by that lens onto the focal plane.  Using a detector that is smaller than this causes some of the light to be thrown away while an unnecessarily-large detector implies that adjacent sources of light may also fall onto the detector - not to mention the fact that a larger detector can introduce more noise and capacitance effects than a smaller detector.  More on the relative sizes of blur circles produced by inexpensive, plastic Fresnel lenses may be found on the "Fresnel Lens Comparison" web page.

For more details of Barry's work, see G8AGN's Laser and LED pages where he and his friends have been doing optical communications experiments for several years now - first, with lasers, and more recently with high-power LEDsA video clip from one end of the January, 2011 87km 2-way contact - which was believed to be a UK distance record at the time -  may be seen here.


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/2011: