Wednesday, September 30, 2015

Gate current in a JFET! (The development of a very sensitive, speech-frequency optical receiver.)

Back in 2007-2008 I was working on a equipment "new" ham band - for me at least - the one that is now labeled as "...above 275 GHz" in the FCC rules.  As you might expect the most accessible portion of this infinity of electromagnetic spectrum is that portion containing visible light, and that is where I was directing my interest.

At this time "high power" LEDs were starting to appear on the market at reasonable prices, and by "high power" I mean LEDs that were capable of dissipating up to 5 watts, each.  What this meant was that from a single emitting die of rather small dimensions one could pump into it enough current and, with the good efficiency of the device, obtain a quantity of light that was suitable for long-distance optical communications.

To be sure, I was building on the fine pioneering work of others, including that of two Australians, Dr. Mike Groth (VK7MJ) and Chris Long (now VK3AML) who had determined that it was the noncoherent light produced by LEDs that offered the greatest probability of practical, very long-distance atmospheric optical communications.  (As a primer as to why this is the case, read the article Optical Communications Using Coherent and Noncoherent Light - link).

Optical receiver needed:

In the midst of producing the various pieces of equipment required for experiments in optical communications (e.g. optical transmitters, modulators, receivers, support equipment, etc.)  I was investigating the different circuit topologies of practical optical detectors.  My goal was not to achieve extremely high data speeds, but rather to use audio-frequency signalling (speech, tones) to start with and, perhaps, work up from there.

One of most common such detectors is the phototransistor - but I quickly dismissed that owing to its very small photoactive area and the fact that the various pieces of literature relating to weak-signal optical detection noted that they are very noisy in comparison to practically any other device owing to their intrinsic noise level.  (CdS cells - article here -  were not seriously considered because they are too slow to respond even for audio frequencies.)

One option was the venerable Photomultiplier Tube (article here) and while this was technically possible and, in theory, the best choice, it was ruled out because of its fragility (electrically and mechanically), its large size, and the need for a high voltage supply (around 1000 volts).

While these technical difficulties are surmountable I could not overlook the fact that available literature on these devices - and advice from the Australians, who'd actually used them - pointed out that there were but a few photomultipier tube types that have good sensitivity in the "red" end of the optical spectrum where there is also good atmospheric transparency - and even fewer of these rare types, in known-usable condition, available for a reasonable price on the surplus market!
Figure 1: 
The transimpedance amplifier in its simplest form. 
This circuit converts the photodiode currents
into a proportional output voltage.

The Transimpedance Amplifier:

This left me with the photodiode (article here) and the most commonly-seen circuit using this device is the "TIA" - TransImpedance Amplifier (article here).  As can be seen from Figure 1 this is very simple, consisting of just an operational amplifier with a feedback loop with the photodiode connected directly to the noninverting input.  In this circuit the photodiode currents are converted directly to voltage (hence the name) with the gain set by the feedback resistor with the added capacitor being used to assure stability, compensating for photodiode and op-amp capacitance.

This particular circuit has the advantage that it is very predictable and the frequency response can be determined by the combination of the bandwidth of the op amp and the intrinsic capacitance of the phototransistor.  To a degree, one can even increase the frequency response for a given set of devices by reducing the feedback, but this comes at the expense of gain and ultimate sensitivity.

In other words:  With photodiodes you can have high sensitivity, or you can have wide bandwidth - but not both!
Figure 2:
 A practical, daylight-tolerant TIA optical receiver circuit.  This has good sensitivity in both darkness and light and does not suffer from "saturation" in high ambient light conditions because of a built-in "servo" that self-adjusts the phototiode's virtual ground to offset photon-induced bias currents.  Because of this "servo" action this receiver does not have DC response like the circuit of Figure 1 with the low-end frequency being limited by the values of R104 and C106.
Click on the image for a larger version.

While very simple (there are even single-chip solutions such as the "OPT101" that include the photodiode, amplifier, and even feedback resistor in a clear package) there are some very definite, practical limitations to the ultimate sensitivity of this sort of circuit if the goal is to detect extremely weak, low-frequency currents.  When you get to very low frequencies, "1/f" noise (a.k.a. "flicker noise") becomes dominant from a number of sources and there are various other types of noise sources (thermal, shot, etc.) that can be produced by the various components.

As it turns out, this circuit - with practical op amps - has very definite limitations when it comes to trying to divine the weakest signals at low-ish frequencies (audio, sub-audio):  For an article on why this is so - and some of the means of mitigation, see the January, 2001 Electronic Design article, "What's All This Transimpedance Amplifier Stuff, Anyway?" - link by Robert Pease.

Figure 3: 
The VK7MJ optical receiver using TIA and cascode techniques - used as the "reference" optical detector.
The optional "daylight" circuit provides AC coupling to prevent saturation of the circuit under high ambient
light conditions at the expense of low-light performance.
Click on the image for a larger version.
One can construct transimpedance amplifiers using discrete components that outperform most of the integrated-circuit based designs and for a reference circuit I constructed and used one devised by Dr. Groth, VK7MJ and depicted in Figure 3.  In this circuit one may see the feedback path via R3/R4 with compensating capacitor Cf.  In this particular circuit Q1, the input FET, is rather heavily biased to increase its "bulk current" (a term used in the referenced Robert Pease article) with Q2 acting as a cascode circuit - link (e.g. current-based) amplifier with subsequent follower stages.  Additionally, the photodiode itself (D1) is reverse-biased, reducing its capacitance significantly and thereby improving high frequency response.  By hand-selecting the quietest JFETs one can obtain excellent performance with this circuit and since it is discrete, there is room for adjusting values as necessary to accommodate component variations and for experimentation.

This particular circuit is quite good across the audio range from a few 10's of Hz to several kHz, but above this range it is largely the capacitance of the photodiode that quashes the high frequency response.  Even though the photodiode's capacitance - and that of stray wiring and the JFET itself - may be only in the 10's of picofarads, at hundreds of k-ohms (or megohms) even small amounts of capacitance quickly become dominant - another good reason to implement the aforementioned cascode circuit and its tendency to minimize the "Miller Effect" - link to help optimize frequency response.

The K3PGP circuit and variations:
Figure 4: 
The K3PGP Optical receiver.
Click on the image for a larger version.

Building the above circuit as a "reference" I began testing on a "Photon Range" - a darkened room in my basement with a red LED affixed to the ceiling - where I characterized the various receiver topologies.  In this environment a small and adjustable amount of current (10's of microamps, typically) would be fed to the LED, modulated at an audio frequency, and the receiver under test would be placed on the floor below with its output connected to a computer in an adjacent room running an audio analysis program such as "Spectran" or "Spectrum Lab" to measure the signal-noise ratio at different frequencies.  Before and after each session I would measure the performance of my "standard" optical receiver - the VK7MJ circuit - and use it as a basis of comparison.

So-named after K3PGP (see his web site - link) was the next receiver to be tested.  This receiver is much more sensitive than the VK7MJ receiver - at least at very low audio frequencies (<200 Hz) and as may be seen in Figure 4 it is devoid of a feedback mechanism and the connection between the photodiode and JFET is made directly, with no external biasing components of any kind.

While a seemingly simple circuit, there is more going on here than one might first realize:  Without any feedback or any other components between the FET and photodiode the opportunity to introduce noise from such components or reduce the signal from the photodiode in any way is minimized:  In fact, when constructing this circuit there is the strong admonition that the photodiode-gate connection to the JFET be done in mid-air (and that one clean both components with alcohol to remove residue!) as leakage paths on circuit board material can cause significant signal degradation!

Effectively, the K3PGP circuit acts as a charge integrator with the energy slowly (in relative terms) bleeding off due to the leakage of the photodiode, photoconductivity, and the gate-source leakage currents of the FET itself.  While extremely sensitive at low frequencies - specifically those below 200 Hz - above this, the sensitivity and output suffers due to the rather long R/C constant associated with the high gate-photodiode leakage resistance and capacitance and, to a lesser degree, the Miller effect.  This circuit also functions only in total and near-total darkness conditions:  More light than that, the voltage across the photodiode reaches equalibrium while turning the FET "on", effectively quashing the signal.

Inspired by the above circuit I made the modification indirectly depicted in Figure 5, below:

Figure 5:
 The version "2.02" optical receiver, used as a test bed for various circuit configurations - see text.
For the "K3PGP" configuration the photodiode would be reversed from what is shown
in the drawing above and the anode grounded with nothing else connected at point "C".
Click on the image for a larger version.

This circuit was devised as a "test bed" and although not shown in the diagram, it was configured by connecting the cathode of the photodiode to the gate and grounding the anode and having no other photodiode-gate connections present - just as in the K3PGP receiver.

In this circuit one has a FET input and a cascode circuit - just like that of the VK7MJ circuit - to reduce the Miller effect, but this particular cascode circuit has a modification:  Q3 forms a current source, in parallel with the cascode, that supplies the bulk of the drain current for the JFET - several milliamps.  Because the amount of current provided by the current source - which has a high operating impedance and is largely "invisible" - is fixed (but adjustable by varying R4 to suit specific characteristics of Q1) and it is left up to the cascode to supply the remaining drain current - which varies depending on the gate voltage.  In this particular circuit, due to the "cascode action" the voltage at the drain of Q1 and emitter of Q2 varies very little while the cascode - which is allowed to bias itself at DC, but is bypassed at AC with C3 - produces the recovered modulation at the collector of Q2, greatly amplified.  From the collector of Q2, noninverting amplifier U1a amplifies the signal further and presents a low-impedance output.

In other words, it is mostly the K3PGP circuit, but with a cascode amplifier and much higher FET drain current:  By reducing Miller capacitance with the cascode the frequency response was to be improved somewhat and by increasing the drain current the noise contribution of the FET itself should be reduced as noted in the Pease article mentioned above.

In testing it was observed that this particular circuit was, in fact, several dB more sensitive than the original K3PGP circuit and also that the frequency response was slightly better - but not as much as one might first think, mostly owing to the fact that it is mostly the photodiode capacitance that is limiting the response rather than the Miller effect - but every little bit helps!

I then rewired the circuit using the "Standard Config" noted in Figure 5 which, if you draw in the lines, converts it into a TIA circuit like that of the VK7MJ design with both adjustable reverse bias of the photodiode and adjustable feedback.  In this configuration the performance at very low frequencies was reduced, likely due to the noise contribution of the feedback resistor, increased leakage currents from the photodiode at reverse bias and also signal attenuation caused by the feedback submerging the lowest-level, low-frequency signals into the noise.  At "speech" frequencies it was slightly better than that of the VK7MJ receiver - probably due to the higher JFET current or, perhaps, random component variances - and the frequency response was also comparable to that of the VK7MJ circuit, the parameters varying according to the amount of applied feedback and compensation.

Improving the receiver:

My goal was a circuit that offered the sensitivity of the K3PGP circuit, but usable speech response - the latter not being available from the K3PGP circuit due to the R/C rolloff.  A quick check revealed that this was the typical 6dB/octave rolloff so I reconfigured the circuit, again, as a K3PGP-like circuit and followed it with an op-amp differentiator circuit with a breakpoint calculated to compensate for the measured "knee" frequency (e.g. that at which the 6dB/octave rolloff of the K3PGP circuit) began - the result being that I now had a fairly flat frequency response.  Not unexpectedly, while the signal-noise ratio was quite good at the very low frequencies, it decreased fairly quickly as it went up as that energy was simply submerged in the circuit noise.

In staring at the circuit, with the grounded anode of the photodiode, I wondered about reverse-biasing the photodiode to reduce the capacitance - but if I did this, how would I keep the voltage at the gate from rising without needing to add another (noise generating, signal-robbing) component to clamp it to ground?  Knowing that the gate-source junction of a JFET was much like that of a bipolar transistor in that there would be an intrinsic diode present, I knew also that the gate-source voltage would limit itself to 0.4-0.6 volts, but how would the FET behave?

Using JFET Gate current for "good":

In doing a bit of research on the GoogleWeb I could not come up with any sort of useful answer to the "gate current" question, so I simply did it:  The photodiode was reverse-biased with the minute leakage and photoconducting currents being sinked by the gate-source junction.  As expected, the drain current increased noticeably, but the circuit worked extremely well, with both frequency response and apparent gain increasing dramatically!

Putting this "new" circuit back on the photon range I observed that although its low frequency (<200 Hz) sensitivity was somewhat worse than that of the K3PGP circuit, the higher speech-range frequencies (300-2500 Hz) were, on average, 10-12dB better than the VK7MJ circuit and approximately 20 dB better than the best, low-noise op-amp based TIA circuit that I'd built to date!

In analyzing the circuit, there are several things happening:
  • Reverse bias of the photodiode:  This reduces the capacitance - typically by a factor of 3-6, depending on the specific device and voltage applied.
  • The photodiode will produce current in the presence of light.
  • Being reverse-biased, the photodiode will also operate in a photo-conductive mode, passing current from the bias supply in response to light.
  • With the gate-source junction conducting, the reverse bias across the photodiode is maintained since the gate-source voltage will never exceed 0.4-0.6 volts.
  • As described above, the amplifier is connected in "cascode" configuration to minimize Miller effects.
  • There are NO other components or signal paths connected to the photodiode-gate junction that can contribute noise or attenuate the signals.
  • In parallel with the cascode circuit is a current source which provides a high-impedance current source to increase the JFET's bulk currents, further reducing its noise.
 About the gate-source conductivity of the JFET, two things surprised me:
  • The "diode action" of the gate-source clamping seems not to be a significant contributor of noise - at least at "dark" currents of the photodiode.
  • There is little or no documentation about using a JFET this way, anywhere else!

It is likely that the main reason that this doesn't perform quite as well at the K3PGP circuit at low (<200 Hz) frequencies is because of the intrinsic leakage current noise endemic to the reverse biasing of the photodiode:  At higher frequencies, it performed far better. 

In "photon range" testing it was difficult to tell at which frequencies the K3PGP receiver performed better.  My K3PGP exemplar was certainly better at, say, 20 Hz, but even at 100 Hz or 60 Hz it was a difficult call to make.  At such frequencies and under such conditions careful selection of the "quietest" photodiode and FET can make a significant difference and with most of these circuits, reducing their temperature - while somehow managing to avoid condensation - can help even more!
Later, I constructed a test fixture to analyze the gate-source voltage and gate-source current response of a 2N5457 JFET and plot this against the drain current - see Figure 6 below.
Figure 6:
 Gate-source voltage and Gate current plotted against drain current for a typical,
real-life JFET - not a simulation!  Note the logarithmic scale of the gate current. Note
also that the drain current continues to increase linearly with gate-source voltage,
even after the gate-source junction is conducting.
Click on the image for a larger version.
As can be seen, as the gate-source voltage increases, the drain increases linearly - even after the gate-source diode junction starts to conduct:  In fact, there does not appear to be any sort of inflection in the drain current curve when this happens!  Following the other line representing gate current we can see that once our gate-source "diode" starts to conduct it follows the classic logarithmic curve that one associates with diodes - which should not come as a surprise.

So, now we know what is happening.  At first glance, one might presume that with this diode in conduction that the logarithmic response would make the circuit unsuitable for general audio recovery - but this is not so:  At very low light levels the detector has lower than 1% harmonic distortion.

Putting this into practice:

The following circuit was developed for speech-bandwidth optical communications use:

Figure 7:  
Version "3" of the optical receiver.  This receiver must always be operated on its own, completely isolated power supply to avoid feedback.  V+ is 8-15 volts and is typically a 9-volt battery.  D4 and TH1 prevent damage should the applied polarity of the power source be accidentally reversed.  After Q1's drain current has been measured and adjusted, jumper "J1" is closed.
A version of this circuit by the author of this page also appeared in the an article published in the SPIE proceedings (#6878) which was presented at the 2008 "Photonics West" conference by Chris Long.
Click on the image for a larger version.
As can be seen, this looks very similar to the circuit of Figure 4 with the exception that the reverse-biased photodiode is connected to the JFET and that there is the added circuit, U1b, that forms a bandwidth-limited differentiator - the component values chosen to approximately correlate with the low-frequency "knee" of the BPW34 photodiode and also to cease its frequency boost above 5-8 kHz.  (The "Flat" audio output, uncompensated by the differentiator for the 6dB/octave rolloff, is provided for both very low frequency - below 200 Hz - and high frequency - above 5 kHz - signals to be applied to a computer for analysis.)

The circuit in Figure 5 - and minor variations of it - have been replicated many times over the years using different components.  The important considerations are that both Q2 and Q3 be low-noise, high-beta transistors such as the MPSA18 (or 2N5089) and that the JFET used for Q1 be capable of rather high drain current.  In the original design, the 2N5457 was specified as this device is better-characterized that many other, similar FETs and is capable of quite low-noise operation:  The more common MPF102, with its extremely wide variation of parameters, might be suitable if an appropriate device is "cherry picked" from amongst several based both on high zero gate-source voltage drain current and tested "noisiness".  A more modern JFET is the BF862 - available in surface-mount only - that is even better for this application than the 2N5457 and capable of much higher drain ("bulk") current to the point where utilizing its full potential might compromise battery life!

In a circuit such as Figure 7, above, the drain-source voltage will be much lower than one might initially expect - on the order of 0.2-1.0 volts for a JFET such as a 2N5457 and between 0.1 and 0.5 volts for the BF862 - but this is normal operation.  While the setting for Q3 current source circuit set via R5 (in Figure 7) at 120 ohms is suitable for most 2N5457 devices, the current may need to be reduced (e.g. R5 increased in value to 180 or 220 ohms) for some "lower 0 Vgs" current devices such as the MPF102.  In general, the higher the drain current, the lower noise contribution from the FET - but if you exceed the "magic" value and attempt to force too much current, the circuit will suddenly stop working:  Overall it is better to have a bit lower drain current than optimal and have a little bit more noise than to have too much drain current!  (Don't forget that the current source and the JFET itself will also change slightly with temperature.)

Interestingly, the circuit depicted in Figure 7 also works in daylight, albeit with some caveats:  When very high levels of light are present the photoconductivity will shunt the reverse bias to the gate-source junction, the frequency rolloff "knee" associated with the photodiode capacitance will shift upwards due to photoconductive shunting causing the audio to become "tinny" and the audio will become somewhat distorted owing to the different light-to-audio transfer curve that occurs under such conditions in which case the frequency response of the audio on the "flat" output is more suitable than otherwise.  In such situations one does not really need the high sensitivity of this type of receiver, anyway, and a typical TIA circuit with AC coupling such as that depicted in Figure 2 or Figure 3 could be used or one could apply optical attenuation in front of the detector to reduce the light level.

Practical use:
Figure 8:
An as-built "Version 3" optical receiver, constructing using
prototyping techniques and enclosed in a shielded, light-tight
enclosure using pieces of printed circuit board material.  For this
unit "feedthrough" capacitors are used for power and audio
connections to prevent the incursion of RF energy on
the connecting leads.
Click on the image for a larger version.

Entire web pages could be written (and have been - see the Modulated Light web site - link) about through-the-air, free-space optical communications over long distances (well over 100 miles, 160km) using both LEDs and low-power lasers, but even the most sensitive receiver - no matter the underlying technology - requires supporting optics (lenses!) in order to function properly:  It is through such lenses that 10's of dB of noiseless signal gain may be achieved, not to mention directionality and the implied rejection of off-axis light sources.

The circuits described on this page are likely to be suitable only for speech frequencies and low-rate data but this is, in part, due to the medium involved (the atmosphere) and method of transmission, but at the extreme distances that have been achieved with the above equipment (>173 miles, 278km) the signals are weak enough that only low-rate signalling techniques would likely be feasible under typical conditions at safe, practical optical power levels.

Additional web pages on related topics:
The above web pages also contain links to other, related pages on similar subjects.


Saturday, September 12, 2015

The most sensitive repeater on Earth?

It first glance it would seem be the height of hubris to make a claim about "the most sensitive repeater, ever, on Earth" - but the title refers, instead, to a rather technical question:  Just how "sensitive" could a narrowband FM receiver that was Earth-bound with "Earth-looking" receivers be?

Figure 1:
Some of the scenery along the Green River - one of the "wider" areas,
closer to the confluence, where coverage was a bit less of a challenge.
Click on the image for a larger version.
This question came up in the mid 1990's when I was faced with the challenge of providing some radio coverage for the Friendship Cruise, an event in which leisure boat owners would "put on" the water at Green River, Utah and go down, under power, to the confluence of the Green and Colorado rivers in Canyonlands National Park and then power up the Colorado River to the city of Moab, Utah - a total distance of approximately 180 "river" miles (290 km).

Unless you have been in this part of the U.S., it is difficult to appreciate how large and remote it is:  The area covered is larger than some U.S. states and several European countries, all with a total population of less than, say, 100,000 people.  What's more, even on "flat" ground - if you can find it - cellular telephone coverage is spotty at best and if you are within some of the narrow, deep gorges of the Colorado or Green rivers it is all but hopeless:  Even satellite telephones have been proven to be of limited use in some of these areas due to the restricted view of the sky!

So why did we care?

If there are several hundred people and dozens of boats on this hazardous river course over a period of several days, camping and boating in the wilderness, there is very likely "something" that will happen that will require that help be summoned.  Whether this is a mechanical breakdown, running out of gas, or some sort of health emergency the need is the same:  Help may be required.

To this end there were a number of "rescue boats":  Several patrolling the main group of boaters, one parked at the confluence to make sure that no-one managed take a wrong turn and go down "Cataract Canyon" (read about that set of rapids here - link) and a "sweep" boat at the end that makes sure that no-one is left behind.  Since the 1960's it was amateur radio that had been used as the basis for communications.
Figure 2:
One of the many types of HF antennas that have been
used over the years on the Friendship Cruise.  This
is a high-Q magnetic loop antenna, tuned for 75
meters.  A 2 meter collinear (5/8 wave over
1/2 wave) may be seen in the background.
Click on the image for a larger version.

Back in the heyday of the Friendship Cruise - in the late 60's and into the mid-late 70's - there were hundreds of boats on the river which meant plenty of breakdowns, people running out of gas, problems due to the imbibing of alcohol, and other "mishaps" - and the rescue boats coordinated exclusively via 75 meter HF.  To be sure, not all rescue boats were radio-equipped, but enough to "spread the word" if something were to happen.

This mode of communications worked well over the 100 mile or so range required since during the daytime, this band offers good, local coverage and the "straight up, straight down" nature (now called "NVIS" - link) of the daylight propagation was good for getting in and out of the narrow (1/4 mile, 400 meter deep) river gorges.  Other frequencies such as those around 10 meters and even VHF had been tried, but they barely got around the next bend in the river - let alone out of the canyon to... where?

Flash forward to the mid 1990's.  By this time HF rigs were much smaller than the tube-type rigs that had been used in the 60's and early 70's, but it was desired that VHF be used as it was easier to equip boats with that sort of gear - perhaps not all of the rescue boats, but at least some of them on which licensed hams would be carried.  Some of them carried VHF rigs and communicated successfully with temporary stations set up in strategic, high locations near-ish the river.  The problem was that there was no single location that offered good communications for both rivers over any reasonable distance.

By 1997 we decided to try something new.  A site on public land had been found that covered much of the course on the Colorado river and due to the "lay of the land" the geography was in favor of being able to get signals in and out of it over most of that portion of the course.  At around the same time, almost by accident, it had been discovered that a site called Panorama Point, administered by Canyonlands National Park, offered the possibility of covering at least some of the Green River:  In a case of serendipity I had been on a rescue boat the year before and a group of hams camping there just happened to stumble across our limited VHF activity and were kind enough to do occasional propagation checks as I moved along the course on the 'Green:  The results seemed promising.

Armed with that information a weekend was carved out for a Jeep trip to inspect Panorama Point and it was visited after a drive on a very rugged, high-clearance four-wheel drive road.  After arrival we did some exploring and a site was found for a separate receive station that was distant from the transmitter - and we even talked to another ham on 2-meter simplex in a location farther away than we expected it to cover.  Encouraged, we bounced again over the rugged roads and returned to the ranger station and reserved the site.  The head ranger for the district had no problem with what we wanted to do - as long as we didn't deface anything, did not bother any of the wild animals, and "packed out" what we packed in - so a special use permit was issued for the event.

Returning home, I knew that had some work to do!

At this point you may be asking yourself, "Self, what in the hell does this have to do with repeaters or sensitivity?"  Don't worry - I'm getting to that!

In analyzing the geography and taking advantage of an early topography-based propagation analysis program I determined that while the Panorama Point site had a high vantage point and was probably the very best site that existed to potentially cover the Green River, it likely did not have good radio coverage of the river itself over most of that same area - just the tops of the gorges through which the boats would travel.

This meant several things:
  • It would be necessary to radiate as much RF power as practical, blasting the landscape with RF in the hopes that at least some of it would find its way to the river at the bottom.
  • I would have to do everything that I could to extract the weakest-possible signal from the receive system to grasp the users' signals that bounced their way out of the very deep river gorges. 
  • It had to be portable.  This site was at the end of a rugged, high-clearance four-wheel drive road at an elevation of approximately 6200 feet (1890 meters) above sea level with absolutely no amenities.  Since everything for the repeater and our existence had to be crammed into as few vehicles as possible, we need to keep the bulk to a minimum!
Figure 3:
One of the GaAsFET preamplifiers, in place on a Yagi receive antenna.
These amplifiers are based on a WA5VJB design and use the (now old)
MGF1302 GaAsFET transistor.  It is estimated that they have a noise 
figure in the range 0.8dB or lower.
Click on the image for a larger version. 
Studying the maps I could see that the transmitter, located at the camp site, would be approximately 0.56 miles (0.9km) away from the receiver.  Our receive site had been carefully located out of sight of the transmitter, behind a rocky outcropping - but still have a commanding view of the river course to the north.  Between this bit of geography and the directionality of the Yagi antennas used for the receiver we calculated that we should have more than sufficient transmitter-receiver isolation to completely avoid "desense" without any need of lossy bandpass cavities in either the receiver or transmitter.

I constructed two mast-mounted GaAsFET preamplifiers (18-20 dB gain, somewhere between 0.5 and 0.8 dB noise figure) and a two-receiver voting controller, but I did so planning to "hedge my bets" as much as possible.  Already having a pair of 5 element Yagis and two identical VHF receivers, the plan was to marry everything together to construct a voting repeater.  The link back to the 2 meter transmitter site was via a low-power UHF transmitter (a slightly-modified HT - see Figure 6) and in addition to linking our receive site to our own transmitter, this same transmitter was received at the "other" site covering the Colorado River, thus linking the two repeaters together.

Having constructed these receive systems I decided to check their sensitivity and found that the 12 dB SINAD sensitivity was approximately 0.085 microvolts! This brought to mind the question:  "How sensitive could an Earth-based repeater using standard +/- 5 kHz deviation FM possibly be, in theory?"
Figure 4:
The receive site for the repeater, entirely solar-
powered.  While not obvious from this picture,
this site was on a narrow outcropping of rock
and surrounded on three sides by 1200-
foot (365 meter) cliffs!  Because there was also
rock and distance between it and the transmitter
site, there was excellent TX/RX isolation,
eliminating the need for lossy cavities/filters in
front of the preamplifiers.
Click on the image for a larger image.

For any receive system there is one fundamental limiting factor that imposes an absolute limit on how sensitive it can be:  Thermal Noise.   This thermal noise comes from two places:  The equipment itself, and the environment in which the receive system is used.

As it turns out, everything gives off noise - assuming that it is warmer than absolute zero - and the warmer it gets, the more "noise" it puts out.

For an example, consider a piece of metal.  At room temperature, it does not "glow" visibly, but if you were to heat it, it would begin to glow - very dull red at first, but as it got hotter, it would become closer to being "white hot."  As it cools again, its glow disappears once more to our vision.  Just because it may have cooled off to room temperature, don't think that it isn't still "glowing" - because it is!  As it turns out, any object that is above absolute zero does glow - not only at infrared wavelengths (as you may have seen in footage of police finding criminals in the dark using "heat sensitive" cameras) but also at plain radio wavelengths where it manifests itself as noise.

Keeping in mind that all warm surfaces "glow" at radio wavelengths, one can complete the analogy by likening a radio signal to a light source on this glowing surface:  If the surrounding surface is "glowing" more brightly than the radio signal, that radio signal is simply lost!

The magnitude of this noise can be calculated using this equation:
N = k * T * B
  • N = noise power in watts
  • T = temperature in Kelvin
  • B = bandwidth in Hz
  • k = Boltzmann's constant - which is approximately 1.38x10-23 (expressed in Joules per kelvin, or J/K)
When numbers are crunched, assuming a 300K (about 80 degrees F, 27C) temperature and a 15 kHz receiver bandwidth, we can calculate that in a 50 ohm system, as is used on a typical receiver, this is equivalent to a noise voltage of approximately 0.056 microvolts when using an isotropic antenna immersed in a 300k environment.  (Yes, that also means that there is an equivalent signal noise voltage of 0.056 uV - assuming the same detection bandwidth - coming out of a 50 ohm dummy load that is at a temperature of 300K:  It is through the use of the intrinsic noise of dummy loads that EMEers - those that engage in Earth-Moon-Earth communications -  can check the relative performance of their receiver/preamplifier system.)

The above example assumes that we are receiving a signal using an isotropic antenna, surrounded on all sides by matter that is at 300K.  While this isn't exactly the case in a "real world" scenario, it is a reasonable approximation of actual operation of a receive system in which the signals are emanating from the surface of the Earth and the numbers calculated above illustrate that our receive system is, in fact, limited by more than the fact that the signal is just getting weak:  The signal is, in fact, being lost in thermal noise being radiated by the earth itself, hence the nature of the title of this article!

But it gets worse!

If you have loss in front of your receive system, this is the equivalent of a noise source.  For example, 3dB loss in front of a theoretically-perfect preamplifier (e.g. 0 dB noise figure, lots and lots of gain) due to coaxial cable, a bandpass cavity, connectors or anything else will still cause the system consisting of that 3dB loss and preamplifier to have a 3dB noise figure:  Once you lose a signal due to loss and into the resulting thermal noise, it is gone forever and no amount of gain or type of amplification after this loss will bring it back! 

This is exactly why the preamplifier is located at the antenna as depicted in Figure 3:  The only losses ahead of the preamp are those of the matching networks of the antenna and preamp and the kludge of connectors required to mate the antenna to the preamp.  The losses in the coaxial cable after the preamp still matter, but are comparatively small contributors to the overall receive system noise figure.

Fig. 5 - This table shows approximate correlation of receiver sensitivity (12 dB SINAD, 1 kHz modulation, 3 kHz deviation, 15 kHz bandwidth) with receive system noise figure.
(This information derived from data published by E.F. Johnson Corp. as well as my own empirical testing of radio gear.)

12 dB
Noise Figure (dB)

12 dB
SINAD Sensitivity
Figure (dB
0.1 μV 3.4
0.3 μV 10.7
0.125 μV 4.6
0.4 μV 13.1
0.15 μV 5.7
0.5 μV 14.9
0.2 μV 7.6
0.75 μV 18.4
0.25 μV 9.2
1.0 μV 20.8
On a typical narrowband FM receiver, 12 dB SINAD turns out to correlate approximately with a noise voltage that is 60% of the signal voltage.  This means that in a 50 ohm receive system that is terrestrially based (that is, the antenna receives a signal originating from the Earth's surface) or in a test setup involving dummy loads/attenuators that are at room temperature the maximum sensitivity possible - no matter how good your receive system might be (using a standard 15 kHz FM voice channel) is approximately 0.09 microvolts (more or less) for 12 dB SINAD!  

With my receivers, having a "barefoot" (no preamplifier) sensitivity of 0.15 microvolts for 12 dB SINAD (approximately 5.7 dB Noise Figure) I calculated that the worst-case sensitivity, taking into account cabling losses and assuming a 0.8 dB noise figure for the preamps, that the overall system noise temperature was likely close to 95k, or about 1.23 dB.  Clearly this was "quieter" than the 300k noise from the Earth itself!  By changing the design of the preamplifiers I could have increased their gain and reduced the system noise figure even more, but doing this might have risked front-end overload of the receivers by also increasing the level of the (strong!) transmit signal, effectively reducing system performance.

Without cryogenic cooling of the entire planet (which would be really bad for most of us!) much better sensitivity than this was impossible to obtain with the aforementioned receive system!  Figure 5 shows the approximate relationship between noise figure and the sensitivity of a typical narrowband FM communications receiver.

I now knew that my receiver sensitivity was a reasonable match for the sort of "minimum usable" signals that one might experience in an "Earth-bound" receive system:  If I'd made my receive system completely noise-free I would have gained only a couple of dB at most since I was already very close to the absolute limit imposed by the noise environment of the Earth itself

The next obvious step in improving the receive system performance still more was through the use of directional, gain antennas.  Because the hub of activity on the rivers was toward the north we had the luxury of being able to use such antennas since there was no need for omnidirectional coverage.  By limiting the the "field of view" of the receive system with these directional antennas (5 element Yagis) and with the apparent signal gain provided, the absolute signal levels (which included the inevitable thermal noise of the Earth) were increased at the input terminals of the preamp, additionally overcoming deficiencies that might be present in the receive system, not to mention helping reject the strong transmit signal 600 kHz away off the back side of the beam.  With this configuration, pretty much all of the signal from the distant transmitter that was being intercepted by the Yagi was being presented to the receiver and there was really nothing more that could be done in practical terms to enhance it further.

Even with the preamplifiers and gain antennas, I still wanted to go another step further in improving the apparent sensitivity of the receiver system and this was done by using multiple antennas and receivers in a VOTING arrangement.
Figure 6:
The two matched receivers - RCA VHF TacTecs - the UHF link
transmitter - a slightly modified Yaesu FT-470, and the PIC-based
voting controller/solar charge controller.  These TacTecs have quite
good strong-signal handling due to the use of a moderate amount of
properly-distributed RF gain and a passive diode-ring mixer - somewhat
unusual to find in radios these days!  These TacTecs were modified
to bring out discriminator audio and the squelch "noise voltage" to
interface with the voting controller:  While the absolute squelch level
was fixed in the voting controller, the radio's squelch knobs still adjusted
the "noise voltage" gain and thus allowed, indirectly, the squelch of
each receiver to be adjusted.  The squelch threshold was adjusted
for an approximately 3 dB SINAD quieting audio signal:  While noisy, this
is still quite copiable to the trained ear if the transmitter's modulation
is adjusted properly!
Click on the image for a larger version.

As the name implies, a voting system compares the signal quality from two receivers simultaneously and selects the best one.  Because I was using a pair of identical receivers I had access to the "noise voltage" from the receivers' squelch circuits and made this available externally to the voting controller:  It was a simple matter of comparing the noise voltages of the two receivers to determine which one had the best, "least noisy" signal instantaneously and select it.

Because each receiver had its own antenna, and since the two antennas were physically separated from each other and pointed in slightly different directions, it was more likely that at least one of these receive/antenna combinations would intercept at least a fragment of the weak, refracted/reflected signal emanating from the distant canyon bottom.  The amount of "gain" that this sort of arrangement provides is difficult to quantify as it varies wildly with circumstance, but with these indirect, "bouncy" and multipath-laden signals emanating from the bottoms of distant gorges it is certainly positive!

Comparing to a "normal" repeater's receive system:

Let us consider the typical overall sensitivity of a typical amateur repeater.  Assuming that there is NO site noise at all (quite unusal for a busy, shared communications or broadcast site) and an intrinsic receiver sensitivity of 0.15 microvolts - a reasonable number - let us add up the various losses that might be found in a typical repeater system:
  • Feedline losses:  2 dB
  • Duplexer/cavity losses: 2 dB
  • Miscellaneous losses:  1 dB
This extra 5 dB would take the original 0.15 microvolts (approximately -123.5 dBm) to around 0.27 microvolts  (-118.5 dBm).  Compare this to the approximate sensitivity calculated for the Panorama Pointe repeater as being in the area of 0.085 microvolts (-128.5 dBm), we are around 10 dB down which means that the distant transmitter would need a 10-fold increase in power to "sound" the same in our receiver - and this does not consider the somewhat "intangible" gain afforded by the voting receiver system or the degradation due to "Earth noise" contribution.  (It is worth noting that at the signal levels and with the sensitivity of the "typical" repeater's receiver, the noise-temperature contribution of the Earth itself is barely detectable - if at all!)

If you remember further that with a "typical" repeater consisting of a single antenna and duplexer that it not uncommon to experience a bit of "desense" where some of the energy of the transmitter causes a decrease in sensitivity of the receiver, the situation gets even worse!

Consider that both the receiver and transmitter systems for this portable repeater system used Yagi antennas that offered approximately 10dBi gain on both receive and transmit.  When one takes into account the difficult nature of running full duplex on a Yagi with the possibility many "nonlinear" junctions causing a minute amount of energy to be produced and cause some desense - plus the fact that this had to be a "portable" repeater - one can chose to see why we chose to avoid the bulk, expense, loss, and awkwardness of any cavities at all and used a repeater with a geographically separated transmitter and receiver.

All of this leads to an interesting question:  Would an "ordinary" repeater, with its typical single transmit/receive antenna multiplexed with cavities and commensurate losses, plopped down at this location have provided useful coverage in this particular instance?

Based on the observed signal levels:  No, I don't think so!

* * *

This repeater system was used with minor modifications from 1997 through 2011, the most recent Friendship Cruise, and the software for the voting controller was modified to include charge control of the solar panels and to report some telemetry with the IDs.  On the transmitter side a 300 watt amplifier was typically used with a 5 element Yagi to blast well over 2kW EiRP of RF in the direction of the boats - all without "desensing" the repeater's receiver in the slightest even though the receive site was generally within the pattern of the transmit antenna!
Figure 7:
The transmit site.  The transmit antenna, a Yagi (a 7 element, in this
particular case) , was located atop a 25 foot (7.6 meter) mast located only
a few 10's of feet away from 1200 foot (360 meter) cliffs on two sides. It
was fed with approximately 300 watts of 2 meter transmit power, directed
toward the location of the activity on the river yielding well
over 2kW EIRP.  Power was provided by a bank of 100 amp-hour
lead-acid batteries that were recharged twice a day at 50-80 amps
with a generator.  In the foreground may be seen the UHF link antenna for
receiving the signal from our own receive site and the link from the "other"
repeater covering the Colorado River as well as a "backup" 2 meter Yagi
used during set-up and in case the main repeater system were to go off
line for some reason.  The transmitter itself was a Kenwood TM-733A
operating in "half-crossband" mode.  Because the ID was provided by the
controller at the receive site - and the main transmitter was relaying this
UHF link - everything was legal!
Click on the image for a larger version.

It is fair to say that the repeater worked phenomenally well!  In the few days that it was online for the event each year that it was used it was not uncommon for someone to stumble upon it while scanning, sometimes from long distances away, well outside the intended coverage area.  Even though it was intended to cover mainly the Green River it turned out that there were very few places on either the Green or Colorado Rivers that the repeater did not cover - or at least a "hot spot" could be found.

Because we were "stuck" out in the middle of nowhere at this site, many hours drive from "civilization" for 4-5 days we had plenty of time to observe how the repeater system worked.  As you can imagine, in the first couple of years that the voting system was used its behavior was carefully observed to see if it was really helping dig out signals and at times, the local speakers on the two receivers comprising the voting system were turned up while a distant station was transmitting.  It was often the case that one could hear the transmitting station fade out of one receiver - but not the other - as the signal bounced its way out of the deep river gorges and off the rocky rims above, this on two antennas that were about a wavelength apart and pointed in slightly different directions, proving the worth of the voting receivers while offering an eerie "stereo" type effect.  Not surprisingly, standing at the receive site and switching to the repeater's "reverse" (the input frequency) in such situations while listening on a handie-talkie using a large whip typically yielded either a barely detectable signal or nothing at all while the repeater happily relayed signals that were often full quieting!

One of the interesting aspects of this system was the difference in the "sound" of weak FM signals on this system.  On a typical FM repeater system a weak signal develops "popcorn" as the signal gets weak - a rather strong, staccato series of random noise pulses that appear on the audio as signals get weak.  While these receivers exhibited this same behavior when connected directly to an antenna, when configured as they were with this system using the GaAsFET, mast-mounted preamplifiers and "Earth noise" dominating this noise "popcorn" was almost entirely absent with weak signal seeming to disappear into a sea of steady, even "hiss" instead!

In the case of Earth-to-Space communications, great care is taken in the design of the antenna system to prevent it from "seeing" the "Earth noise" as much as possible.  If this is done it is possible to construct a receive system that will hear spacebourne signals that are much weaker than those that could possibly be detected from Earth-based sources.  In fact, with such systems it is not uncommon to be able to see a significant increase in "no signal" readings when the antennas are lowered to zero elevation and pick up "Earth noise" as compared to when they are pointed into space - unless they are pointed at the (noisy!) sun - but that's another topic altogether!
Another interesting phenomenon - not too unusual with voting receivers - can occur when two stations are "doubling" (e.g. transmitting at the same time) but just happen to be located such that each one is only getting into only one of the receive system's antennas.  Although it occurred only rarely, it was very odd to hear two completely different voices, both "full quieting" and with no obvious heterodyne, the syllables of speech being randomly interspersed as the voter switched between the two stations!

* * *

Alas, the Friendship Cruise has not been held for several years now as the combination of unprecedentedly low water flow rates in one or both of the rivers and the apparent waning interest has taken its toll.  For those that were involved in the amateur radio portion it was a fascinating exercise in several of the most important aspects of the hobby:
  • Being able to communicate for the public good for the safety and well-being of all of those involved.
  • To give those involved practical, real-world experience in operating out in the field under "less than ideal" conditions where there is absolutely no backup via the commercial or public infrastructure.
  • To try out new ideas and techniques to make communication work in a very challenging geography!
Now, isn't that what amateur radio is all about?

Monday, August 31, 2015

A PIC-based audio source for locking a VHF oscillator

Several years ago I decided to build a weather satellite receiver from scratch.  It is described here - link.

I didn't really need a weather satellite receiver, and I could have easily bought a kit somewhere else - or bought a second-hand one via EvilBay, but I just wanted to go through the exercise of throwing everything together and making it work using parts on hand - and I wanted to try out some ideas.

Locking a VCO to an audio DDS reference:
Figure 1:
The front panel of the VHF weather satellite receiver.
This receiver has been in continuous operation for several years, working
flawlessly in that time.
Click on the image for a larger version.

One of these ideas was to use a PIC to lock the VHF local oscillator.  On the face of it, this isn't unique - except that the PIC was to be the sole source of the precise frequency to which the PLL (Phase Locked Loop) for the local oscillator:  No divide-by-N chips here!

For this receiver the local oscillator operated 10.7 MHz below the receive frequency nominally at about 126 MHz.  Since I was already using a 100 MHz oscillator (a VCXO) that I'd pulled from some scrapped commercial satellite gear, I used a simple 3-transistor mixer/amplifier circuit to convert this to about 26 MHz (137 MHz - 10.7 MHz - 100 MHz) and this allowed me to use a 74HC4040 12-stage binary ripple counter to bring a representation of the local oscillator down to the audio range - about 6.3 kHz.

As it so-happened, I'd chosen the 100 MHz oscillator on purpose - mostly because it was free, but it also provided a nice, stable 20 MHz clock for the PIC by dividing its output by 5 using a 74F191 so both the down-conversion and the PIC's clock were referenced from the same source.

The goal was to provide a minimum tuning step size of at least 1 kHz, and because I'd already divided-by-4096, this meant that my audio-frequency step size was on the order of 1/4 of one Hz - but that was no problem since I was going to use DDS techniques in the PIC.

The DDS:

A DDS (Direct Digital Synthesis - see the Wikipedia article about DDS techniques here - link) circuit is fairly simple in operation:  Typically, one takes a register (called an "accumulator") and on every clock cycle you add to it a constant number (we'll call it a "frequency word") allowing it to "wrap around" once the accumulator's capacity is exceeded or, in other words, you do unsigned binary addition.

If you were to keep track of how often the accumulator overflows you'd notice that if you added a smaller number to it, it would overflow less often which makes sense since it would take more clock cycles to overflow!  What you might notice is that one can easily predict the rate at which it will overflow:

( (frequency word) / (maximum accumulator value) ) * clock frequency

Typically, the "maximum accumulator value" is the maximum number (plus one) that can be represented by the number of bits used by the accumulator (e.g. 8 bits = 256, 16 bits = 65536, 32 bits = 4294967296).

In my case, it was easy to make the PIC do 32 bit unsigned addition.

The last step is to take the upper-most bits of the accumulator and apply them to a D/A converter via a sine-wave lookup table.  To take a table that is "8 bits" in size (256 entries) one would take the top byte of our exemplar 32 bit accumulator, use those bits to point to a sine wave and then send the output of that sine wave lookup to the D/A converter.  Clearly, the more bits of lookup (e.g. the larger the sine wave table) and the more resolution that one has available for the D/A converter, the better!

Figure 2:
The PIC controller board that generates the precise audio frequency
based on a PIC16F88 and driven from a 20 MHz clock source.  This PIC
also drives the LCD and does the serial data communications,
receiving frequency tuning commands from the host computer.
Click on the image for a larger version.


The PIC that I used (a PIC16F88) can be clocked to 20 MHz and among other things it contains a PWM generator that can operate as a simple D/A (Digital-to-Analog) converter with as much as 10 bits of resolution.  As such, it has a 10-bit timer and with the PWM operating at (up to) 10 bits of resolution it will sample at up to 1/1024th of the clock frequency, or:

20 MHz / 1024 = 19.53125 kHz

Since we have 232 (4 billion+) counts in our 32 bit accumulator, and we clock it at as high as 19.53125 kHz, that means that our frequency resolution is about one four-billionth of 19.53125, or:

19.53125 kHz / (232) = 0.000004547 Hz - or about one five-millionths of one Hertz resolution!

There's one more step in generating a useful frequency output.  If one watches the MSB (most-significant bit) of the accumulator, we can see that it flips between 0 and 1 at the desired frequency, but we don't want a digital output:  Even if we did take the MSB which is, on average, at the desired frequency, it typically has a lot of phase jitter that makes it unsuitable for most frequency control purposes.

If, instead, we take the top several bits of the accumulator and feed them to a lookup table that has a sine wave and then outputting that value to a D/A converter, we get a more analog-looking signal with much less phase jitter:  The more bits we have, the better job we can do in representing a sine wave.

Now, remember that we divided our mixed-down local oscillator by 4096, so this means that our effective resolution would be reduced by that much, but if you do the math, that still means that we have - when multiplied by 4096 - a step size of 0.0186 Hz or so!

If you've been following along, you might noticed that I skipped several steps, so let me explain:

The idea was to divide down a representation of the 126 MHz local oscillator to audio and we did this by first subtracting 100 from it and then dividing-down the 26 MHz by 4096 to audio.  We would then generate a precise audio frequency at one-4096th of that 26 MHz frequency and using a PLL, lock our local oscillator to it!

Simple - almost.

The DDS technique is imperfect when implemented using hardware that doesn't have infinite resolution - and the PIC's hardware and software capabilities are rather limited - in my case, I managed to implement the equivalent of a 1 ksample sine wave with 10 bits of resolution.  (Actually, it was just 1/4th of a sine wave - which is enough if you flip the pieces upside-down and/or play it backwards in the right order as needed!)

So now I had precision audio generator that could output a reasonable facsimile of a sine wave at any frequency from about 5 milliHertz (including DC, if you want to be pedantic) to something less than 1/2 of the sample rate - about 9 kHz!  The PWM output from the PIC is really a bunch of samples of a 19 kHz variable duty-cycle digital waveform and it needed to be filtered a bit so I ran it through a simple op-amp bandpass filter - and then converted it back into a square wave - before passing it on to the a 4046 chip and into the edge-triggered phase detector.  In the 4046 this was compared with the converted/divided signal from my local oscillator and with the magic of the PLL, my VHF oscillator was nicely locked to the precise audio frequency from the PIC!


At this point, the imperfection of the DDS became apparent.

One of the satellite frequencies is 137.62 MHz with a local oscillator frequency of 26.92 MHz.  When this was divided by 4096, this yielded a frequency of 6.5723 kHz approximately.

If one takes a close look at the spectrum produced by any DDS-type synthesizer, a myriad of low-level (and some not-so-low-level) spurious signals will be generated because of rounding-off errors related to the finite resolution of the D/A converter, the size of the sine table, and the relationship between the desired frequency and the clock frequency.  As one approaches frequencies that are related to an integer sub-multiple of the higher order bits (e.g. multiples of 1/2, n/4, n/8, n/16, n/32, n/64, etc. of the clock frequency) these low-level spurs get closer and closer to those multiples mentioned above.  As these sub-multiples get "smaller", the amplitude of these spurious components decrease as well.

In the case of the 6.5723 kHz signal required to synthesize 137.62 MHz frequency, this was very close to 43/128ths of the clock frequency - or about 10.986 Hz off.  What this caused was a very low-level 11-ish Hz modulation of the generated frequency which, when effectively multiplied upwards by the 4096 division - which increased the apparent loop gain - appeared as a very obvious tone (more of a buzz, actually!) at the local oscillator frequency.

Normally, loop filtering would take care of this, but this rather low frequency (just 11 Hz!) could get through the filter too well - and further-slowing of the loop filter wasn't particularly attractive - but this is software and we can do sleight-of-hand to fix this!  What I did was to pick a slightly different clock frequency - 20 MHz / 896 = 22.32142857... kHz instead and this moved the spurious signals from the DDS far enough away that they were effectively removed by the loop filtering.

The end result was a VCO that would tune anywhere within the designed range in less than a second and have very low-level spurious signal content from the DDS!

Locking a VCXO to an audio DDS reference:

As it turns out, locking a VCO - essentially a free-running oscillator with an implied, wide tuning range - is a comparatively "worst-case" scenario when it comes to the minimization of things like "reference sidebands" - the frequency/phase modulation of the generated carrier from residual AC on the tuning line - owing to the very high loop gain involved which can arise from both the "tuning sensitivity" of the VCO itself and if high divisor ratios are used.  If one starts out with an oscillator with a comparatively narrow tuning range - such as a VCXO (Voltage Controlled Crystal Oscillator) - in which the tuning sensitivity can be orders of magnitude smaller - and the lock time may be longer, particularly if high divisor ratios are used since it may take some time for the phase fo the comparison signal to "slide" into alignment - it is much easier to keep those already low-level spurious signals down to levels that may be ignored in typical applications.

A practical implementation of this technique has been employed in the W7SP Synchronous/Voting repeater system operated by the Utah Amateur Radio Club (described here - link) in which the transmit frequency is referenced from 10 MHz OCXOs (Oven Controlled Crystal Oscillators) and held within 1-2 Hz of the intended frequency.  Using DDS techniques with 32 bit accumulators operating at approximately 3.2 kHz, the transmit frequency can be controlled - via the audio frequency - to a resolution of 0.0023 Hz at the two meter transmit frequency - an accuracy that far exceeds the accuracy and stability of the reference oscillators themselves!

Producing exact frequencies:

The difficulty with using DDS techniques arises when an exact frequency is desired, such as for a frequency standard - at least unless one is willing to crunch a few numbers and/or make a few compromises.  For example, since the typical DDS algorithm is based on binary counters and thus has denominators of 2n power, one will likely not end up with the precise frequency desired.  In our example, above, with a 32 bit counter, we can likely get the frequency to with a fraction of a Hertz, but not exactly where it should be.

There are several ways around this, including one or more of the following:
  • Extending the resolution of the binary counter used in the DDS with even more bits to get ridiculous resolution so that the resulting frequency is "good enough."  If enough processor time is available and 32 bits of resolution is not enough, 48 or even 64 bits of addition may be implemented to do unsigned math.
  • The careful selection of a clock frequency such that the divisors result in the exact frequency desired.  The difficulty here is that if it is an "exact" frequency that is desired, many reference frequencies - such as 10 MHz - are not "binary friendly", requiring a bit of clever math to come up with exact relationships with the target frequency.
  • Designing the DDS counter to use something other than a binary (2n) counter.  If, say, a 10 MHz clock is used, the software DDS may be implemented using counters that will roll over at 10n instead of 2n, driven by a hardware divisor set to a base-10 relatable value to yield exact frequencies.
  • Implementing "dithering" of the DDS count to achieve fractional tuning.  This involves switching between two or more frequencies at a specific rate to achieve a third, averaged frequency.
The last method, dithering, must be used with care as it will, by its nature, introduce spectral components that are necessarily lower in frequency than that of the reference being generated by the DDS - possibly very much lower if the fraction being represented by the dithering is complex - and these lower frequencies can greatly complicate effective loop filtering!  In most cases it would be more beneficial to simply extend the resolution of the software DDS (e.g. more bits) rather than implement dithering making this technique most useful if one us using a hardware-based DDS.

Final thoughts:

While there are definite limitations in using a DDS reference to lock a high frequency oscillator, namely the need to suppress the inevitable reference sidebands that result from the DDS synthesis itself by filtering, careful selection of reference frequencies and/or choice of the type of oscillator, but appropriate application of these methods can produce a reliable, versatile - even simple - frequency source.

Wednesday, July 29, 2015

A PIC-based audio comb filter to remove AC mains hum

If you have read the page - and realized that I had something to do with its content - you will know that one of my interests is Free-Space, through-the-air optical communications.

In our many experiments one thing that we have often run across is the presence of mains-related hum from the spillover and "glow" of city lights that can invade the audio.  In the tests that in which I have personally been involved this has not necessarily been a huge issue as our location (in the relatively sparsely western U.S.) is not completely saturated with such illumination.  Even when we have run tests across town we have been able to avoid paths that are "terribly" affected by such energy.
Figure 1:
The prototype comb filter.
Click on the image for a larger version.

Not so for some of the folks doing similar experiments in the U.K., one of the most densely-populated countries in Europe.  There, it can be difficult - particularly near populated areas - to find a location that does not have a "glow" of city lights on the horizon.

To be sure, there are at least two energy components within such glows that can cause issues:
  • The modulation of the lights themselves, typically at twice the AC mains frequency.  Because of the non-sinusoidal nature of the waveforms this "hum" contains many harmonics, and because the lighting overall may be from all three phases of the electrical grid, some of these harmonics can be quite strong!
  • A "hiss" caused by the thermal noise of such lighting.
While the former may be removed electronically owing to its being confined to discrete, narrowband frequencies, the latter (the hiss)  is entirely random and cannot be "notched" out in the same way as the hum or buzz of the lights:  Some sort of "noise reduction" software such as that used in modern HF transceivers could be implemented, but that is beyond the scope of this discussion - and the processors discussed here do not have the "horsepower" to implement such filtering.

Fortunately, the thermal noise generally follows the "1/F" profile - which is to say that it is more intense at lower frequencies and the energy rapidly drops off, being much less of a problem at the frequencies that we use for voice (300-3000 Hz) than at lower frequencies.  Because of the nature of human speech, our brains can typically do some "mental DSP" to reduce the deleterious effects of the noise as background noise is a fact of modern life, but the raucous noise from the buzz and hum of the harmonics is far more difficult to deal with!
Figure 2:
A typical spectra that contains "buzz" from urban lighting
superimposed atop speech from audio on an optical path in the U.K.
As can be seen, there is less energy at the mains
frequency (50 Hz) and harmonics with most of signal
power in"spikes" occurring at 100 Hz intervals.
Click on the image for a larger version.

The Comb filter:

As it turns out what we need to filter the hum/buzz and its harmonics is a "comb filter" which, as its name implies, filters out a base frequency and the harmonics.  What is also fortuitous is the fact that such filters are very easy to implement in a simple processor using fixed-point arithmetic.

The type of filter that is implemented in this case is an "IIR" (Infinite Impulse Response).  To "construct" a notch filter in software we need only do the following steps:

  • Set up a buffer that will delay the "audio" data put into it by the period of the base frequency of the comb filter.  If you wanted to filter out a signal that consisted of 100 Hz and its harmonics, this delay would be 1/100th of a second, or 10 milliseconds. 
  • Take the output of the delay and multiply it by a factor of n, where "n" <1.  If "n" is 0.75 for "75% feedback", you would reduce it to 75% of its original amplitude.
  • Take a copy of the original signal and reduce it by "1-n".  Taking the 75% example above, this original signal would be reduce to 25% of its original amplitude.
  • Invert either signal (it does not matter which) and sum the two together and put this result into the delay.
  • The output is taken from the delayed signal.
In the example above we have a filter that feeds back onto itself 75% of the delayed signal with a contribution of just 25% of the original signal - with one of the two signals "inverted" to cancel out their contribution and the result is a filter that has notches at 100 Hz, 200 Hz, 300 Hz, etc.  By varying the ratio - for example, less "original" signal and more feedback - one can make the notches increasingly narrow at the expense of the filter being able to respond quickly to changes.

Practically speaking the useful values for the above range from comb filters that have as little as 50% feedback (fairly wide notches - which impart a somewhat "hollow" sound on the audio and fast response) to as much as 93.75% feedback which has quite narrow notches but is quite slow to respond to changes:  Values outside this range have been empirically tested and found to be less useful in this particular application - particularly higher values of feedback which tend to excessively slow the response.  (Note that the relative response time is proportional to the "base" frequency of the filter, so a 1000 Hz comb filter would respond more quickly than a 100 Hz comb filter with the same amount of feedback.)

This filtering is all done in "C" using the CCS compiler.  While not as streamlined as straight assembly, I've worked with this compiler for many years and have learned how to tweak it to produce "reasonably efficient" code that isn't terribly less efficient in execution speed than assembly - plus it takes far less time for me to write and debug C than assembly and the additional bonus is that the "meat" of the algorithms are portable!

For this sort of filtering all that is required in the maths are shifts, adds and subtracts:  You may note that the ratios, above (50%, 75%, 93.75%) all consist of discrete inverse powers-of-two (e.g. 93.75% = 100 - (50% + 25+ 12.5% + 6.25%) - all being numbers that can be derived by doing simple right shifts of the data!

The circuit:

Figure 3, below, depicts the schematic diagram of the prototype comb filter:

Figure 3:
The schematic of the comb filter board.
Click on the image for a larger version.
In the circuit above the input signal is first low-pass filtered by U101A and associated components - this, to reduce the energy at and above 16 kHz, the Nyquist frequency.  The filtering in the above circuit isn't extremely "strong", but because the majority of energy is typically around the speech range of 300-3000 Hz - and the fact that the overall energy contained in the speech and noise tends to decrease with increasing frequency - it is adequate for such use.

The heart of the circuit is U102, a PIC16F1847 processor internally clocked at 32 MHz which yields a sample rate of approximately 32 kHz with full 10 bit resolution of the PWM generator, used for D/A conversion.  The processed audio output, in PWM form, is then integrated and low-pass filtered back to "baseband" audio by U101B which is also configured as a low-pass filter.  This filtering is not as "strong" as the input filtering since, in most applications, it is less important that the generated energy above the Nyquist frequency be removed to the same degree as the input filtering.

As can be seen in the diagram the input pins are used to select the various filter modes as follows:
  • 50/60 Hz - This selects the mains frequency to be filtered.  60 Hz is used in the U.S. and its possessions, parts of North and South America and a few other countries while 50 Hz is used in the rest of the world.
  • 1x/2x - This selects whether the "base" frequency of the comb filter is 50/60 Hz ("1x") or twice the frequency (100/120 Hz for "2x").
  • Bypass - When left open (high) the filter is bypassed, but pulling this line low will enable the filter.
  • Sel1, Sel2 - This selects the various types of IIR filters, each with different amounts of "feedback" as noted in Figure 3.
Also present is the "Clip" LED and related circuitry (D102, Q101, etc.) that will illuminate if the input audio is more than "half scale" (e.g. 6 dB below clipping).  If this LED flashes more than occasionally it is recommended that the input audio level be reduced, particularly if audible distortion is present.  The occasional flashing of this LED on brief signal peaks and/or noise pulses is acceptable and does not usually result in audible distortion.

So there you go:  Using a low-end PIC for DSP!