Wednesday, December 30, 2015

Adding FM transmit to the mcHF transceiver

In previous postings I wrote about how FM reception - including squelch and subaudible tone detection - was accomplished on the mcHF.  As is often the case, it is usually more difficult to receive a signal than to generate one and this is arguably the case with FM as well.

In writing the code to generate FM I found the above to be true:  It was comparatively trivial to produce an FM signal, particularly applying "tricks" that I'd already done in the demodulation.

Producing the FM carrier:

One of the features that I added to the mcHF many code releases back was that of "Frequency Translation" in which the local oscillator was "off-tuned" from the receive frequency, + or - 6 kHz for the mcHF with the "baseband" signals for receive and transmit being shifted by 6 kHz (in the opposite direction) in software.

One reason that this was done was to improve the performance of the transceiver by removing its receive and transmit passbands from the immediate vicinity of the "zero Hertz hole" which not only improves frequency response, but it reduces other issues related to thinks like "1/F" noise and, perhaps most importantly, greatly reduces the likelihood that other receiver audio (e.g. audio amplifier energy) will find its way back into the microvolt-level audio paths via power supply and ground loops and cause feedback!

Applying this to transmit, we soon realize that if wished to produce a signal with a constant carrier, such as AM or FM, we would have to remove ourselves from this "zero Hertz hole" as it would be, by definition, impossible to produce a carrier in that hole as a the carrier is, in fact, represented by DC.  (For SSB, which purposely has its carrier removed, this "hole" is nearly irrelevant...)

This explains another reason why this feature was added:  The eventual addition of AM transmission (and reception) several revisions ago, but this same feature used once again for FM, but in a different way:  Via the use of DDS (Direct Digital Synthesis) techniques.

The use of DDS techniques has been discussed on this blog before - see the article "Generating low-distortion audio sine waves using a PIC and DDS techniques." - link.

Using DDS techniques to generate an FM carrier:

In this technique one generates a sine wave (or any other arbitrary signal, for that matter) by jumping through a "lookup table".  In the case of the mcHF, with its 48 kHz sample rate, if we wanted to generate a 6 kHz sine wave this implies that we would need to step through this sine wave table once every 8 samples.  This sounds easy enough - but how would one do this?

Take a look at this bit of code:

loop:
   accumulator = accumulator + frequency_word
   table_index = accumulator > (size of accumulator in bits - size of table index in bits)
   amplitude = sine_table[table_index]

To explain the above:

- The variables "accumulator" and "frequency_word" are both integers.  Let us presume 16 bits, unsigned, each, which means that each value would range from 0-65535.  Incremented past 65535, it would return to zero.
- "sine table" is a lookup table containing values mapped to a sine wave.  Let us presume that our sine table contains 1024 entries - a number that may be represented by precisely 10 bits.
- "table_index" is used to index the table.  It must be able to index all of the sine table (10 bits) so we will use a 16 bit value for this.
- "amplitude" is the result from the sine table.  This could be an integer or floating point value - whatever format your system ultimately requires.

To calculate the value of "table index" we need to take the top 10 bits of the "accumulator", which means that we can obtain by taking the accumulator value and shifting it to the right by 6 bits (e.g. size of accumulator in bits, minus the size of table index in bits, which are 16 and 10, respectively.)  By doing this we can see that as the value of "accumulator" increases, it also points farther along the sine table.  When the value of accumulator "rolls over" back to zero, the pointer into the sine table also resets back to the beginning.

To understand how the frequency is generated, let us now assume that "frequency word" is set to 1.  We can see that every 65536 times through the loop we will "roll" through an entire sine wave, but since our sample rate is 48 kHz, we know that the produced frequency will be:

48000 / 65536 = 0.732 Hz (approx.)

If we want to generate an arbitrary frequency, we would take the above ratio and use it to calculate the "frequency word" as in:

desired frequency / (48000/65536)

or, rewriting a bit:

(desired frequency * 65536) / 48000

or, reducing the fraction even more:

(desired frequency * 512) / 375

If we wanted to generate a frequency of precisely 6 kHz, the above equation would yield a "frequency word" value of 8192 - which just happens to be exactly 1/8th of 65536, which makes sense since we have already figured out that since 6 kHz is 1/8th of our sample rate of 48 kHz, it would therefore take 8 samples to produce such a sine wave!

Modulating our carrier:

We now know how to generate a carrier, but how to modulate it?

We know that FM is simply "Frequency Modulation", and we also know that by varying the value of "frequency_word" above, we can change the frequency, does this mean that if we superimpose audio on our value of "frequency_word" that we can modulate our signal?

Yes, it does.

Let us rewrite the above code a bit:

loop:
   accumulator = accumulator + frequency_word + audio[audio_index++]
   table_index = accumulator > (size of accumulator in bits - size of table index in bits)
   amplitude_I = sine_table[table_index]
   table_index = table_index + 256
   if(table_index >= 1024)
      table_index = table_index - 1024
   amplitude_Q = sine_table[table_index]

(Let us assume that "audio_index" is updated each time through the loop and represents one sample of the audio, also sampled at 48 kHz, to be modulated onto the carrier.)

Let us first take a look at the first line after the start of the loop where we added the term "audio".  Because our audio is already represented digitally as a numerical value that goes above zero for a positive voltage and below zero for a negative voltage, it would make sense that we could simply add this to our "frequency_word" value.

In other words (pun intended!) when the audio voltage increased above zero, our frequency would increase, but as it went below zero, our frequency would decrease - just as FM would.  What's more, because this is an exact numerical representation, our frequency change would be proportional to the audio applied - which is just want we want to occur for low-distortion, faithful representations of our audio.

Figure 1:
A demonstration of a typical FM signal modulated with a tone as
displayed on the mcHF's waterfall display.
(This picture doesn't have much to do with transmitting, but
I wanted to include some color in this posting!) 
There is another modification to the above code as well.  If you look, you will see that we do two look-ups in the "sine_table".  The first one is our original value, now called "amplitude_I" (In-phase) but we now see that we have taken our table index and added 256 to it which is precisely 1/4th the size of our sine table:  One quarter of a sine wave is, of course, represented by 90 degrees.  After "fixing" that value so that it is always lower than 1024, we look up into the sine table again and call this value "amplitude_Q".

What we have done here is generated two sine waves exactly 90 degrees apart from the same frequency synthesis operation.  As you will recall from your understanding of the "phasing" required to generate an SSB signal, you need both an "I" and "Q" signal for transmit and unlike the generation of quadrature audio for SSB which requires some fairly "hairy" math, we have handily done this for FM with almost no math at all!

Comment:  In reality one would employ modulus operators rather than "greater-than and subtract" or even logically "AND" the table index value with 1023 (decimal) after adding 256 to it, either being a much quicker operation for a computer than in the example shown above.

Additional audio processing:

As was mentioned in the discussion about the demodulator, for amateur radio purposes we don't actually want to transmit an "FM" signal, but really a "PM" (Phase Modulated) signal.  For our purposes, a PM signal is really an FM signal in which the audio is pre-emphasized at a rate of 6dB per octave - which is a fancy way of saying that a signal voltage that causes +/- 1 kHz of deviation with a modulation frequency of 1 kHz would cause +/- 2 kHz of deviation with a modulation frequency of 2 kHz.  As noted in previous postings, this is done to improve the overall signal-noise performance of the system as it boosts the "highs" in the audio at about the same rate as the noise increases on weak signals.

There are some practical issues with this pre-emphasis that must be considered.  If you were to start your pre-emphasis at 1 Hz, by the time you get to 2048 Hz would have pre-emphasized your audio by 66 dB or so (if I've done my math right) - a ridiculous amount, and any audio content that might be present at higher frequencies would be boosted even more!  Such high frequency content would also cause high amounts of deviation which, in turn, would greatly expand the occupied bandwidth of the transmitted signal - something that is neither necessary or neighborly!

Clearly, this implies that we must do two things:
  • Limit the frequency range over which we do our pre-emphasis
  • Filter the the audio to the desired range for speech communications
If we start our pre-emphasis at around 200 Hz, instead, we can see that by the time we get to 3200 Hz we need to boost only by 36 dB - a far more reasonable value than the 66 dB mentioned above!

For speech we need only reproduce audio from around 250 Hz to something in the area of 2500-2700 Hz.  Our low-frequency limit is imposed by our desire to include the encoding of "subaudible" tones on our transmitted signal and it is important that we remove a reasonable amount of energy in that frequency range so that spectral content of the human voice - particularly that of the adult male - does not encroach in that area and cause reliability problems with decoding on the receiving end.

Fortunately, such tools are already at hand!

Pre-emphasis:

We already met the differentiator algorithm in our receiver as it was used to reduce the low-frequency, subaudible tones from received audio.  This algorithm reproduced below.

loop:
  filtered = α * (old_input + input - old_filtered)
  old_filtered = filtered
  old_input = input

Where:
  "α" is the the equivalent of the time constant in that a "small" α implies an R/C circuit with a fast time-constant strongly affecting "low" frequencies.
  "input" is the new audio sample.
  "filtered" is the high-pass filtered (differentiated) audio

In the case of the receiver we used it as a high-pass filter with a cut-off below the speech range, but for transmit we can adjust the "knee" of this differentiator such that it is just above the speech range, instead.  As it turns out, an "α" value of 0.05 is suitable for our purposes.

Filtering:

Having done pre-emphasis, we still need to do filtering, but I'd already implemented a "transmit" filter on the mcHF for both SSB and AM and all I needed to do was redesign the filter to suit the FM audio characteristics.  I used MatLab and the filter designing plug in for this, but the "Iowa Hills" filter designer suite (free and easily found via a web search) could be used to produce suitable sets of coefficients.  As are most of the filters used on the mcHF, these filters were IIR since one can get a lot of "bang for the buck" in terms of good, "sharp" filtering with relatively few computation cycles.

With a fairly compact filter with fairly low computational overhead I was able to achieve >20dB of voice rejection in the upper frequencies used for subaudible tones and well over 50 dB of attenuation above 3200 Hz - much better than that achieved in a typical, analog FM transmitter.  At the low end, audio below 250 Hz was attenuated by at least 20dB with over 40 dB reduction for audio content below 200 Hz - this, to prevent "pollution" of the frequencies occupied by subaudible tones.

Comment:  Because I was using floating-point math, the order in which pre-emphasis or filtering is done is unimportant.  If fixed-point/integer math was used, instead, you would need to carefully analyze the signal path and the resulting values to assure that nothing "blew up" (e.g. exceeded the integer range or, at the other extreme, was so "small" that resolution was compromised and distortion/noise introduced) at the expected audio levels at all frequencies!

Limiting:

One necessary function employed in typical amateur FM transmitters is that of the limiter to "clip" the audio to an absolute maximum level.  This device improves overall intelligibility by allowing the designer to set the microphone gain to a somewhat excessive level, but the clipper forcing a maximum loudness.  The result of this is that somewhat low audio from soft-spoken users is boosted to promote intelligibility while those who have "hot" microphones and/or speak loudly do not cause excess amounts of deviation of the transmitted signal.

The mcHF does not have a clipper, per se, but it does have an audio compressor that was implemented many versions ago to improve usability on SSB.  Like a limiter, this device prevents the audio from exceeding an absolute maximum level and it also adjusts the gain upwards during quiet portions to reduce the "peak-to-average" ratio of the audio, thereby improving intelligibility.

I did experiment with both a "hard" and a "soft" limiter (or clipper) in software.  A "hard" limiter is one that sets an absolute ceiling on the amplitude of the signal present while a "soft" limiter, as the name implies, is less abrupt, more like the "knee" of a diode with some sort of logarithmic-like action.  Because they alter the waveforms, both of these methods generate harmonics and intermodulation products - the "soft" limiter being a bit less aggressive - which require that filtering be done.  Since we are low-pass filtering the audio, the higher-frequency harmonics outside the speech range will not contribute to the occupied bandwidth of the signal but the increased energy in the upper speech frequencies from harmonics of the lower-frequency audio components coupled with the pre-emphasis can somewhat broaden the signal.  Finally, because the signal is distorted by the clipping action, high audio levels that result in a lot of clipping are likely to result in audio that "sounds" degraded.

In comparing the sounds of the limiter/clipper to that of the audio compressor, I decided to use the latter as it was more "pleasing" to the ear and more versatile, overall since there are a number of available adjustments (e.g. the amount of audio into the variable gain stage and the decay rate of the variable gain stage.) As noted, I eventually decided not to use a clipper and used the already-existing compressor, instead.

Without either this compressor or a limiter, an FM transmitter would have the problem of their signal being "too wide" for loud-speaking operators and "too quiet" for those that were soft spoken - neither condition being desirable for communications!

Subaudible tone:

A desirable feature of a modern FM transmitter is that of the Subaudible Tone, discussed previously.  This signalling method consists of the generation of a low-level sine wave in the range of approximately 67 to 250 Hz that is superimposed on the transmitted audio which is used by the receiver to validate the presence of signal.  While this was traditionally used in commercial radio to allow several groups of users to "share" the same frequency, amateurs have typically used it as interference mitigation techniques to prevent the receiver - that of the repeater or the user - from responding to noise or signals for other sources.

For additional information about subaudible tone signalling, read the Wikipedia article - link.

Since it is just a sine wave, it is very easy to generate - and we already know how!

Re-using the DDS algorithm, above, we need only generate a single tone, unmodulated this time, and sum it with our transmitted audio.  We would of course, do this after we have done our pre-emphasis, filtering and limiting/compressing, placing this tone generator just before the DDS that produced our FM signal as the code snippet below illustrates.


[Filtering and limiting/clipping of audio already done]

if(tone_generator=TRUE) {
      tone_accumulator = accumulator + tone_frequency_word
      table_index = tone_accumulator > (size of tone accumulator in bits - size of table index in bits)
      tone = sine_table[table_index]
      audio = audio + (tone * amplitude)
}

[The code that follows is the DDS that generates the FM signal as shown above]

As we can see, only if the tone generator is turned on do we go through the loop - something that we'd do to save processing power.  Included in the above code snipped is an additional parameter, "amplitude" which would be used to scale the value from the sine lookup table such that it yielded the proper amount of deviation on the transmitted signal - typically in the area of 15-20% of peak deviation.

In the case of generating the audio tone we'd need to make certain that we had enough frequency resolution to accurately produce the tone, and as we already calculated we know that with a 16 bit counter at a 48 kHz sample rate our resolution is approximately 0.732 Hz. Assuming no sample rate errors, this would imply that we could generate the desired frequency to within half that resolution worst-case, or approximately 0.366 Hz.

This frequency resolution is adequate for generation of these tones, again assuming that there are no additional error sources related to sample rate, but if you were not satisfied with that amount of resolution it would be a fairly simple matter to increase the number of bits used by the accumulator and frequency word to improve the resolution, just as was suggested for the frequency modulation.

For the calculation of the frequency words, all that was required was that the code include a table containing the frequency, in Hertz, of each of the subaudible tones:  Since we already know the sample rate and the number of bits - and therefore the maximum counts for our accumulator - we can calculate, on the fly, the needed "frequency word".

Tone burst:

There is one more tone signalling scheme occasionally encountered on FM repeater systems, and that is the "tone burst", sometimes called "Whistle-up".  Although it has largely disappeared from use, it is reportedly used in some areas in Europe.

In this system a short burst of a specific tone, typically 1750 or 2135 Hz, is transmitted to "wake up" a repeater for use, and once this is done, it may be used normally.  Once the repeater has again become dormant, a timer expires and it will no longer respond to signals until it, again, receives a burst.

For a Wikipedia article that includes a section about single-tone signalling, look here:  link

This is generated in exactly the same way as a subaudible tone, namely with a bit of DDS code that looks just like the above!  From a purely practical standpoint, unless one absolutely needed to generate both a subaudible tone and a tone burst at the same time, one could actually use the same bit of code - provided that the amplitudes of the different tones (subaudible, burst) were taken into account.

Unlike a subaudible tone, a tone burst is typically transmitted only at the beginning of a transmission and for a fairly short period - perhaps one second.  While one could rely on the user to time the duration of the tone burst, on the mcHF the duration of the burst was timed by counting the number of interrupt cycles called to process the audio, making the process semi-automatic:  The user needed only activate push-to-talk and then press-and-hold the button that produced the tone and the rest would be completed automatically.

"DCS" codes:

Not mentioned previously there is one additional signalling scheme sometimes found on amateur frequencies, and that is "DCS" (Digital Coded Squelch) which consists of a binary signal with a base frequency of 134.4 Hz modulated with a specific bit pattern.  This signalling scheme is quite rare in the amateur radio community - and even rarer on HF (10 meter) repeaters where this radio is likely to be used - so there has been no serious consideration in its support


How well does it work?

Generating a sine wave with a low-distortion audio generator and feeding the modulated signal into a communications test set (a.k.a. "Service Monitor") - a device specially designed to analyze the quality of communications gear - the modulation was tested at several audio frequencies and found that the distortion was at approximately the level of detection of the instrument to at least +/- 5 kHz deviation.

Testing was also done using speech at various levels, including attempts to overdrive the audio input and on a spectrum analyzer the occupied bandwidth was observed to be contained within the expected bandwidth mask for both the "narrow" (+/- 2.5 kHz) and "wide" (+/- 5 kHz) deviation settings with no audible distortion present nor were there any unexpected spectral components outside the frequency range typical of such an FM signal - even though the "accumulator" of the frequency-modulating DDS is only 16 bits and the audio represented by it will have even lower resolution (e.g. on the order of 12 bits, maximum.)

At the present time I can't think of any additional features that would need to be added to the FM mode so it is, for now, "good to go."


[End]

This page stolen from "ka7oei.blogspot.com".

Thursday, December 17, 2015

Minimizing VHF (and HF) RFI from electronic ballasts and fluorescent tubes

Several years ago we started replacing the old, "iron" ballasts with T-12 fluorescent tubes at my work with T-8 tubes and electronic ballasts.  The program to do this was along these lines:
  • When a T-12 tube or ballast failed, immediately retrofit the fixture.
  • As soon as practical, retrofit those lights that are on all of the time, or "most" of the time.
  • Gradually retrofit other fixtures as needed/convenient.
The lamp sockets (known as "tombstones") for T-8 and T-12 sockets are, for all practical purposes, interchangeable.  (Yes, there can be some voltage rating differences...)  Since, in most cases, we were working with what had originally been 4-tube fixtures - two of which (e.g. one ballast) had been disconnected years ago to save energy (we didn't miss the extra light)  we had extra tombstones on-hand to replace those that were broken, discolored or damaged and in some cases we even replaced the bracket and tombstone with those of the brand new "official" T-8 variety.

Figure 1:
Typical "iron" ballast used for T-12 tubes.
Click on the image for a larger version.
We were also able to get T-8 ballasts of known-good brands (Advance, Triad, Sylvania, etc.) for very good prices from an number of sources - far lower than "retail" - and we were sticking only with these brands because we felt that they would offer good reliability and efficiency.  In the years since we have started, the majority of fixtures have been retrofitted and we have yet to replace even a single electronic ballast and we've only replaced a half-dozen tubes - most of those within a week or so of being installed - all of this while providing at least as much light with lower power usage and heat load.

Before we go on, here are a few "weasel words" of warning:
  • The devices discussed present hazardous/fatal shock hazards:  Do not even think about doing any such modification unless you have experience with such things.
  • There are no guarantees, expressed or implied, that the modifications will work for you, are suitable or will meet electrical code requirements in your area.
  • If you do such modifications you take any and all risks related to it, including damage to person or property, injury, fire, or liability.
  • All RF interference situations are unique:  There is no guarantee at all that even when performed as described that the steps described will mitigate problems that you might be experiencing.
  • Please use care and common sense!
  • You have been warned!

The rise of interference:

There is one place where we have had problems with the T-8 tubes and accompanying electronic ballasts and that is the electronics shop.

Soon after retrofitting the fixtures in the engineering shop we noticed that we had difficulty hearing local 2 meter and UHF repeater when listening in that room, the noise floor having risen up by 10-20dB - depending on frequency and exact location within the room - with 120 Hz modulated noise and the fact that it disappeared when the lights were turned off pointed directly to the cause.


Differences between magnetic and electronic ballasts:


For a typical 4-foot (approx. 102 cm) tube, good, old magnetic ballasts are, at least when powered from 120 volts, transformers that boost the voltage to that high enough to sustain conduction on each cycle of the 120 Hz sinusoid.  When starting up there are special windings that will activate the filament and/or boost the voltage such that this conduction - which is higher when the tube is "cold" (both physically and has not been lit) but when the current is established as the tube lights, these diminish. To limit the current through the tube to a safe value it is typical that there is a large amount of series inductance which, by virtue of its reactance, sets the maximum current consumed by the lamp.

For more general information about how fluorescent tubes and ballasts work, go to "Sam's F-Lamp FAQ" - link.

For various reasons (core, skin-effect, magnetic and resistive losses, etc.) these old "iron" ballasts are somewhat inefficient, but even so, this efficiency of the linear, fluorescent tube made the combination far more efficient than practically any other tungsten (incandescent) light source.  Nowadays, the skinnier "T-8" tubes are used along with electronic ballasts and these skinnier tubes can, for various reasons, produce at least as much light as the larger T-12 tubes, but in order to maintain such efficiency and to provide reasonable longevity they must be driven with an electronic ballast.

Unlike the old-fashioned "iron" ballast, modern, electronic ballast are essentially high-power oscillators that produce a lot of voltage (perhaps much as 1kV peak, open-circuit and while starting the tube) at a fairly high frequency - say, 30-60 kHz.  Using this higher frequency allows much smaller, lower-loss magnetics to be used and driving the tube with a higher frequency than that of the mains improves its "power to light" conversion efficiency even more.

Electronic ballasts and interference:

Even the old, "iron" ballasts with the fluorescent lamps could cause RFI (Radio Frequency Interference), largely due to significant nonlinearities in the conduction of the tube with respect to the applied voltage resulting in the generation of harmonics.  Furthermore, a malfunctioning ballast could generate interference in other ways, such as internal arcing. Typically, such interference, if present, occurred on the mediumwave (AM broadcast) frequencies and, occasionally, in the HF (shortwave) range and, most typically, either very short range - within a few feet/meters of the lamps themselves - or conducted via the power connections.  Usually, replacement of the defective tubes and/or ballast remedied this situation.

With electronic ballasts the situation is quite different.

With a high-power (10's of watts) electronic oscillator on-board there are already problems at hand:
  • With frequencies in the 10's of kHz, harmonics appearing in the mediumwave and HF are of much lower order.  In other words, the 30th harmonic of the switching frequency in an electronic ballast puts you squarely in them mediumwave range while the 30th harmonic from an iron ballast is still within the frequency range of hearing!
  • The rise/fall times of the waveforms from an iron ballast are quite slow in comparison with those from an electronic ballast which, by necessity of design, can be in the order of 100's or 10's of nanoseconds.  Having these high switch rates on the transistors inside the electronic ballasts puts energy squarely in the MF, HF and even the VHF or UHF range!
  • The length of a common 4-foot (1.2 meter) tube/fixture is commensurate to the wavelengths within the VHF/UHF range.  This means that the fluorescent tube itself is perfectly capable of acting as a radiator at many frequencies - not to mention various other parts of the fixture and contained wiring.
Unless one were to scrap the electronic ballast altogether and go back to using the old, iron ballast, if you experience interference issues there are a number of things that you will have to do.

Conduction of high frequency energy onto conductors and radiators:

In the case of our electronics shop the biggest problem appeared to be direct radiation of energy at VHF frequencies, apparently from the tube and connecting wiring.  One way to minimize this effect would be to reduce the harmonic energy emerging from the ballasts and finding their way onto the tube and wiring.

The most practical way to do this with minimal risk of deleterious effects (e.g. loss of efficiency, electric shock, fire, reduction of operational lifetime of the ballast and/or tubes) is to apply a bit of series inductance to the leads that feed the fluorescent tube.  While we are at it, we might as well apply some common mode filtering to the AC (mains) leads as well to minimize conduction of "grunge" that might find its way out via that path, as well.

Figure 2 shows the typical connection of the tubes and electronic ballast.
Figure 2:
Electronic ballast and typical connection to tubes.  In typical "room temperature" installations the filament heater is not used, except as a simple emitter of electrons:  In the example, above, "load sharing" is afforded by the individual, series capacitor for each tube and starting ionization for each tube is provided solely by high-voltage excitation from the ballast.
Not depicted, ballasts are available that have four wires to each tube to provide heater current for starting the tube(s) in cold environments, but most "indoor" ballasts have only a single wire connected to each end of the tube.
Click on the image for a larger version.

As can be seen, the tubes are in parallel with the output of the high-power oscillator, typically using a series reactance (capacitor) to limit each tube's current and to provide a mechanism for load-sharing and offer operational stability in the presences of the tubes' negative resistance characteristics.  Many electronic ballasts allow different numbers of tubes to be connected:  3-tube ballasts will allow 2 or 3 tubes while 2-tube ballasts will usually allow just one tube to be powered, and using these series reactances is a simple way of keeping the tube current more-or-less constant, despite the number of tubes connected - either at the time of installation or due to later tube failure.

Figure 2 also indicates something else:  On the wires marked "A" and "B" are carried the high-frequency currents from the ballast's oscillator.  As we discussed before, not only are these same currents very non-sinusoidal and contain many harmonics, but the tubes themselves tend to badly distort the currents, further-increasing the harmonic content on these leads.  Finally, at VHF and UHF frequencies, the very lengths of wires "A" and "B" and the tubes themselves, "T", can make them capable radiators in their own rights!

The distortion added by the tubes themselves is likely not significant one gets above MF and HF frequencies as the mechanism is generally too slow in its own right, but we still have the harmonics from the oscillator itself to contend with which can be carried, as current, by the ionization of the gas within the tube itself which will form an antenna and as we know, as long as there is some current flowing, we will have electromagnetic radiation.

Inductors used for reducing the harmonic content on the tube current:

Our best bet is to reduce the harmonic content on the tube current itself and the easiest way to do this with minimal intrusion and risk to the user is to insert a small amount of inductance onto the connecting leads "A" and "B".
Figure 3:
A pile of toroidal inductors pulled from some scrapped power supplies.
In the upper-left is a bifilar choke used for mains filtering, also found
in higher-quality switching supplies.
Click on the image for a larger version.

We had a number of junked switching power supplies in the "boneyard" and we pulled a pile of toroidal inductors (see Figure 3) from some of them and did a quick analysis.

The most common type of toroidal inductor is the sort typically found in PC power supplies, usually used for output filtering, wound in either a yellow or yellow-and-white core.  The permeability of these cores isn't extremely high, typically achieving somewhere in the area of 20-30 microhenries with 10-15 turns, but they are not particularly suitable for use much above the range of 100-200 kHz:  Higher than this they get quite lossy - but we don't really care too much about that since we are trying to quash this energy, anyway.

The "Yellow-White" cores appear to be "26 Mix" Iron Powder types that are specified for use from DC to approximately 800 kHz.  The aforementioned "Yellow" cores would have the color code for "6-mix", but when they were measured, their permeability was closer to that of "26 mix" indicating that whoever made them wasn't precisely following color convention!

The sizes (outside diameters) of these inductors varied, from approximately 1 inch (25.4mm) in diameter to over 2 inches (50mm).  If you were to translate these to "store bought" toroids these could equate to sizes from "T94-26" to as large as "T200-26" or "T225-26".

Another inductor that appeared to be useful was one that was simply painted light gray and it, too had permeability roughly equal to that of the yellow/yellow-white ones - that is, 10-20 turns yielded something in the area of 20-100 microhenries.  I've found no obvious reference to "light gray" painted toroids in the typical references so I don't know what "mix" they might be, but they appear to be vaguely similar to the "Yellow-White" ones in general properties.

When either the gray or the yellow/yellow-white inductors were broken, it appeared that they contained some sort of metallic powder, pressed and molded into shape and covered with paint. 

The third type of inductor, often used for filtering the the AC mains input, appeared to be some sort of very high permeability ferrite and putting 10-20 turns on these yielded hundreds of microhenries or even millihenries of inductance:  These are not suitable points "A" and "B" and should be set aside for now - but we will be using them later.  When broken these particular cores were either a black compound (e.g. ferrite) or, in a few cases, wound with some sort of thin, ferromagnetic tape as in the case of the red-cored inductors depicted in Figure 3.

Which toroids to be used where?

Let's take a look at a redrawn version of Figure 2:
Figure 4: 
A fluorescent ballast/fixture with added ferrite to minimize RFI by virtue of "isolating" the fluorescent tubes at
radio frequencies.
For "cold weather" ballasts that use filament current for starting, each "pair" of wires to each tube would be treated as a single conductor through L1-L3.
See text for explanations!
Click on the image for a larger version.
First, let us take a look at inductor L1 which is in series with the "common" lead "B" that connects to one side of both tubes.  With the inductors that we had we are able to put approximately 15 turns of the original wire into this core which yielded an inductance of 10-15uH (value not critical!)  In running the numbers we can see that at 30 kHz, a typical operating frequency of an electronic ballast, this inserts approximately 3 ohms of reactance into the circuit.  Considering that for a 32 watt, T8 fluorescent tube that the average current will be around 300 milliamps (see reference, here - link) we can calculate that if the current were perfectly sinusoidal (it is not!) the effective loss would be a volt.  Because this is a reactance, we would not experience I^2R losses in the same way that we would if we were dropping the same voltage with an ohmic loss (a resistor) but even if we were, this would amount to only 1/3rd of a watt or so.

If we were to translate this same inductance (15 uH) to the middle of the AM broadcast band (1 MHz) we would see a reactance of around 94 ohms - significantly higher than at the operating frequency, reducing the potential current through the tube, at that frequency, by a factor of around 30 which corresponds to 10's of dB reduction.  Since only a fraction of the oscillator's energy is at harmonics of this magnitude a negligible amount of power is being blocked by this inductance.

Taking this to an extreme, let us consider a frequency of 150 MHz with this same 15uH of inductance where we find the reactance to be approximately 14000 ohms - extremely high and, for all practical purposes, completely "blocking".  In reality the effective series resistance would not be nearly this high as not only would this particular core material ("26" mix) not be effectively offering such inductance at this frequency, but there would also be capacitive (shunt) coupling across the inductor/windings itself and between various conductors (wires) located under the cover of the ballast shield.  Nevertheless, the impedance would be significantly increased due to the inductance present and the core losses at this frequency.

Taking another look at Figure 4 we can see that we'd need to install similar filtering in the other leads connecting to the tubes as well (e.g. the "A" leads) and the similar math applies.  By installing such inductors in both leads we effectively "isolate" the tube at high frequencies by virtue of the series inductance while leaving the frequencies at which the tube is powered - around 30 kHz - virtually unaffected.

How do we know that this does not affect normal operation?  A bit of emperical measurement can (and did) verify this assertion:
  • A "Lux Meter" placed below the fixture showed no discernible difference in light output before and after modification.
  •  The added inductors did not get perceptibly warm:  If they did, this would indicate power loss!

A core not to use at points "A" and "B":

In an experiment I placed one of the high permeability ferrite cores (not one of the yellow cores) in place of L3:  It immediately got too hot to touch, indicating both high losses and a significant amount of inductance.  When checked on an inductance meter I found that approximately the same number of turns as I'd placed on this core when tested in the fixture (15 or so) yielded around 200 microhenries - a reactance of around 38 ohms at 30 kHz - a significant amount at 300 milliamps of tube current!

The upshot:  When trying an core, verify that it does not warm up by an appreciable amount before deciding to use it!

If it gets (noticeably!) warm after several seconds/minutes, it is not suitable and could pose a hazard due to heat:  This heat could, in theory, melt insulation which could pose an electrical/fire hazard or the heat itself could melt or cause combustion in its own right!

Don't worry - we still plan to use this core!


Additional modification:

Figure 5: 
Added inductances on the leads marked "A" in Figure 4,
above.  The inductor on the far left is a multifilar choke -
see the text below for an explanation.  There are actually three
small yellow/white toroidal inductors, one being obscured.
Click on the image for a larger version.
If you look at Figure 5 you will see, on the right side, the three, smaller yellow/white inductors (one is obscured.)  In this particular case this is a 3-tube fixture, the third tube used to provide extra light as it was placed over the workbench area.

Because it was directly over the workbench, it was typically much closer to the gear being used and tested which made the noise emitted by it a bit more problematic by proximity.  To reduce this noise still-further an additional inductance was added in the form of the large, yellow inductor on the left.  This particular core was taken from a scrapped PC power supply (almost all of them have such a device) and the three wires were wound, in parallel - keeping the same number of turns - through the core to fill it up to make, in this case, a "tri-filar" winding.  Doing this forced an additional series inductance on the "A" leads depicted in Figure 4 as "F1" but it forces the currents through the tubes to be equal - not too difficult a job considering that L1 and L2 (depicted in Figure 4) have already presented a high impedance (at high frequencies) on those leads already.

While doing the initial work on the first fixture to be modified, a Yaesu FT-817 - an all-band, all-mode amateur radio transceiver - was laying on the workbench immediately below it and it was noted that by grabbing a wire of the unmodified fixture I could couple some of the noisy RF (at around 144 MHz) into my body which would then be re-radiated as evidenced by the the noise from the FT-817 increasing.

As a rough indicator of the efficacy of the added inductances I observed that after installing L1-L3 I could grasp the wire "after" these inductors (on the "tube" side) and hear no difference, but if I did so on the "ballast" side of the inductors I heard the noise increase, indicating to me that they were doing their job in removing a significant amount of "grunge".  While I was doing this I noted that I could also hear "grunge" if I grabbed around the AC mains wires as well, indicating that some of this energy was being conducted via that route.  Being a commercial building, the mains input is routed via metallic conduit and it was noted by poking around in the "drop" ceiling and placing the antenna of the FT-817 near-ish the power conduit that relatively little of the noise was emanating from the conduit itself, but since I had a plethora of chokes on-hand I decided to try an experiment.

Using the high-mu (lossy) cores:

Using one of the same "lossy" ferrite cores that got hot when tested, I parallel-wound, in bifilar fashion, as many turns of the AC mains wire of the ballast as I could fit on the core.  As with the milti-filar core, above, it is important that these wires be kept parallel and that the exact same number of turns be used for each of the two mains conductors so that the "common mode" attenuation be maximized.

When wound in a bifilar fashion - and on leads that have only a residual amount of RF energy - we are using these ferrite cores in the manner intended with no fear of their getting hot:  Because both wires of the AC mains go through in parallel, their magnetic fields cancel and the core does not "see" it - it is only that small amount of RF energy that is not supposed to be there that is being blocked by the bifilar winding on the core!  It is important to note that in order for this type of winding to work, you must wind equal numbers of turns of both wires, preferably in parallel or gently twisted together:  It is by virtue of the equal inductance and coupling between these two wires that this sort of filter works.

After doing this I did the "grab" test with the wire again:  If I grasped the wire on the "ballast side" of the newly-added bifilar inductor I could hear an increase in the noise on the FT-817, but if I did so on the "mains" side I could not.  In other words, this choke was keeping the "grunge" from the ballast out of the mains.

While it may not have been particularly important on VHF/UHF to add this extra bifilar inductor on the mains power leads, it was pretty easy to do since I had the fixture "open" already - and I decided that every little bit helps!  Also, it is worth noting that on MF and HF that it will likely be via the mains power leads that the majority of noise will be conducted while at higher frequencies like VHF and UHF, the wavelengths are small enough that energy can be emitted directly from the lamps and fixtures themselves as their very size is a significant portion of a wavelength.

Efficacy of the modifications:  Did they work?

Of the 6 fixtures in the shop, only the two directly above the workbench where they are closest equipment under test now have both the small chokes in each of the leads in series with the tubes (e.g. L1 and L2).  All of them have an choke on the "common" side of the tube (L3), the common-mode choke on all of the tubes (F1) and the bifilar choke on the mains side (F2).

Did this modification have any effect?  The quick answer is yes and here are the ways that it was measured.
  • A portable HF/VHF/UHF all-mode transceiver with a whip antenna (an FT-817) was placed underneath/near the fixture, the distance of the plastic diffuser.  The "S-Meter" reading of the noise of the modified fixture was compared with an unmodified fixture with the same complement of tubes and ballast type/model and the modified (filtered) fixture was found to radiate far less than the unmodified one based on observations of the S-meter and audible noise.
  • Two spectrum analyzers were set up on the workbench in the electronics shop connected to small whip antennas and sweeping in the range of 100-200 MHz.  After all of the fixtures in the shop were modified, the amount of noise indicated on the analyzers was 10-20dB lower than before the modification, depending on frequency.  It was not completely gone, but significantly reduced.
  • Using a portable handie-talkie transceiver, several VHF (2 meter) repeaters were checked for receive signal quality within the shop before and after fixture modification.  All but the strongest were inaudible in the shop prior to modification, but all were easily audible afterwards.  A slight amount of extra noise is apparent when the lights are turned on, but there is no trouble in finding a location that provides a suitably noise-free signal for testing/monitoring now.

Final comments:

The addition of screening

Prior to the installation of the chokes in series with the lamps some experimentation was done with metallic screening of the fixture.  The particular fixtures that we are using are light-gauge Lithonia fixtures that have spot-welded seams and appear to be likely to provide a reasonable RF-tight seal on the back side:  It was via the open front, through the plastic diffuser that RFI was radiating - apparently from the tubes themselves.

In an experiment we decided to cover the front of the fixture with aluminum foil.  While blocking the light, it would serve to help us determine if this was a viable means of containing the RFI within the enclosure.  We placed, lengthwise, two parallel sheets of foil over the diffuser, but it happened that there was a very narrow (1/4" inch, approx. 6mm) gap between the two strips running along the long dimension of the fixture.

We noted that with the foil in place that the interference actually got worse until we bridged the narrow gap with small pieces of scrap foil in 3-4 places.  We surmised that the two pieces of foil were acting as independent radiators until we connected the two, at which point the noise level was reduced - but it was still significant.  Clearly, the foil itself was coupled to the the noise energy within the box and re-radiating a significant percentage.

We then bridged the foil to the steel box itself, causing a further reduction in noise - but the amount of reduction depended strongly on where, exactly, we made this connection.  If this was done in each corner of the box (e.g. four places) there was a significant reduction.

Practically speaking one would not use aluminum foil to provide such shielding as it would clearly block the light.  Aluminum window screen would also not be recommended as there is not guarantee that there is an electrical connection across its entire face as each wire is not "bonded" to its neighbor - plus it, too, blocks a significant amount of light.

This leaves the use of so-called "expanded metal" or "hardware cloth" - both of which are electrically-connected across their plane as options.  Of the two, the "hardware cloth" - typically galvanized steel mesh is, by far, the cheapest and least "light blocking" alternative - plus, it is possible to solder to the zinc coating with relatively little difficulty.  This material is available in different mesh sizes and for VHF/UHF frequencies the larger sizes (around an inch or several centimeters) would be adequate.

The problem would be providing a firm, electrical bonding of this screen to the case of the light fixture.  On the "hinge" side of the diffuser cover one would use very short, wide metal straps to make the connection to the case, but for best efficacy it would also be preferable to make a similar connection on the side opposite the hinge where the cover opens - but aside from the installation of "finger stock" or very short plug/receptacles, this is rather complicated to do!

About LED replacements:

I am aware of LED drop-in replacements for T-12 and T-8 fluorescent tubes, but has, for the time-being, dismissed these owing to issues of cost, reliability, efficiency, and "light quality" (e.g. color rendition or "CRI").  For an in-depth report on this subject see "Performance of T18 and T8 Fluorescent Lamps and Troffers and LED Linear Replacement Lamps" - link.  Since this report was published significant improvements have been made in LED efficiency, but similar issues - particularly those related to quality and longevity - remain unless one uses devices made by reputable manufacturers.

As far as EMI/RFI issues related to LED replacements for T-12 and T-8 tubes:  Based on reports in the amateur radio press and on forums such as the EEVBlog (examples here - link and another link) I would expect similar - or worse - problems to occur, depending on the manufacturer - as they would also have issues with high slew rates on switching regulators and/or semiconductor-related transients.  While it is very likely that common-mode mains filtering would also be recommended on these devices as well, it may be more difficult to remove noise along the entire length of a series or series-parallel fed array of LEDs that was nearly 4 feet (1.2 meters) long as this is a significant portion of  a wavelength at VHF/UHF frequencies and could easily radiate on its own right!

If you do wish to upgrade an existing "troffer" or similar fluorescent fixture to LEDs, I would strongly recommend that you obtain JUST ONE and carefully analyze it before you risk ruining your HF, VHF and/or UHF reception with little means of mitigation!


[End]

This page stolen from "ka7oei.blogspot.com".

Friday, November 20, 2015

FM squelch and subaudible tone detection on the mcHF

In a previous installment  ("Adding FM to the mcHF SDR Transceiver" - link) I described how the demodulation of FM signals was added to the mcHF SDR transceiver but being able to receive FM implies the addition of a few other features, namely that of squelch "circuitry" - of both "carrier" and "tone" types.

Determining the "squelch" status of a received signal:

One of the most obvious ways to determine the presence of a signal is to compare the signal strength against a pre-set threshold:  If the signal is above that threshold it is considered to be "present" and an audio gate is opened so that it may be heard.

This sounds like a good way to do it - except that it isn't, really, at least not with FM signals.

If you were listening to an FM signal on 10 meters that was fading in and out (as it often does!) one would have to set the threshold just above that of the background noise - or "open" (e.g. disable) it completely to prevent it from disappearing when the signal strength dove into a minimum during QSB.  If the background noise were to vary - as it can over the course of a day and with propagation - the squelch would be prone to opening and closing as well.

As it turns out, typical FM squelch circuits do not operate on signal strength as there are better methods for determining the quality of the signal being received that can take advantage of the various properties of the FM signals themselves.

Making "Triangle Noise" useful:

Mentioned in the previous entry on this topic was "Triangle Noise", so-called by the way it is often represented graphically.
Figure 1:
A graph representing the relative amplitude of noise with strong weak FM signals.  It is the upward tilt of the noise energy to which "Triangle" noise refers - the angle getting "steeper" as the signal degrades.  Also represented is a high-pass filter that removes the modulated audio, leaving only the noise to be detected.
From this diagram one can begin to see why pre-emphasizing audio along a curve similar to the "weak signal noise" line can improve weak-signal intelligibility by boosting the high-frequency audio on transmit (and doing the inverse on receive) to compensate for the noise that encroaches on weak signals.

As can be seen in Figure 1 the noise in a recovered FM signal increases as the signal get weaker - but notice something else:  The noise increases more quickly at higher frequencies of audio than it does at lower audio frequencies.  Looking at Figure 1 you might make another observation:  Because there is typically some low-pass filtering of the transmitted audio to limit its occupied bandwidth, there is no actual (useful) audio content above that frequency from the distant station, but the noise is still there.

High-pass filtering to detect (only) "squelch noise":

From the above drawing in Figure 1 it can be recognized that if we only "listen" to the high-frequency audio energy that passes through the "Squelch noise" high-pass filter all we are going to detect is the noise level, independent of the modulated audio.  If we base our signal quality on the amount of noise that we detect at these high frequencies - which are typically above the typical hearing range (usually ultrasonic, above 10 kHz) - we can see that we don't need to know anything about the signal strength at all.

This method works owing to an important property of FM demodulators:  The amount of recovered audio does not change with the signal strength as the demodulator is "interested" only in the amount of frequency change, regardless of the actual amplitude.  What does change is the amount of noise in our signal as thermal noise starts to creep in, causing uncertainty in the demodulation.  In other words, we can gauge the quality of the signal by looking only at the amount of ultrasonic noise coming from our demodulator.
Figure 2: 
An representation of an analog squelch circuit with hysteresis.  The high-pass filter removes the "program" audio modulated onto the carrier (e.g. voice) which is then amplified as necessary and then rectified/filtered to DC to derive a voltage proportional to the amount of ultrasonic noise present:  The higher the voltage, the "weaker" and noisier the signal.
The resulting voltage is then fed with a comparator that includes hysteresis to prevent it from "flapping" when it is near the squelch threshold.

An analog representation of a squelch circuit may be seen in Figure 2.  For the simplest circuit, the high-pass filter could be as simple as an R/C differentiator followed by a single-transistor amplifier, and the same sorts of analogs (pun intended!) could be applied in software.

After getting the mcHF FM demodulator to be functional I tried several different high-pass filter methods - including a very simple differentiator algorithm such as that described in the previous posting - except, of course, that the "knee" frequency was shifted far upwards.  The absolute value was then taken from the output of the high-pass filtered and smoothed and printed on the screen while the input signal, modulated with a 1 kHz audio sine wave and fed to a SINAD meter (read about SINAD here - link) while signal level was varied:  In this way I could see how the output of the noise detection circuit behaved with differing signal conditions.

In doing this testing I noted that a simple differentiator did not work as well as I'd hoped - likely due to the fact that unlike an analog circuit in which the high-frequency energy can continue to increase in intensity with frequencies well into the 10's or 100's of kHz, in the digital domain we have a "hard" limit enforced by Nyquist, stopping at 23 kHz or so on the mcHF with its 48 ksps rate.

With less high frequency spectral noise energy (overall) to work with it is necessary to amplify the output of a simple differentiator more, but this also brings up the lower frequency (audio) components, causing it to be more affected by speech and other content, requiring a better filter.  Ultimately I determined that 6-pole IIR high-pass audio filter with a 15 kHz cut-off frequency, capable of reducing "speech" energy and its second and third harmonics below 9-10 kHz by 40-60dB, worked pretty well:  In testing I also tried a similar filter with an 8 kHz cut-off, but it was more-affected by voice modulation and its immediate harmonics.

Comment:

If the FM demodulation is working properly the result will be a low-distortion, faithful representation of the original audio source with little/no energy above the low-pass filter's cut-off in the transmitter.  If the signal is distorted in some way - such as with multipath distortion, being off-frequency or with excess deviation, energy from this distortion can appear in the ultrasonic region which cannot be easily distinguished from "squelch" noise.
If this energy is high enough, the squelch can close inadvertently since the signal may be "mistaken" as being weak:  This is referred to as "squelch clamping" and is so-called as it is often seen on voice peaks of signals degraded by multipath and/or off-frequency.

Determining noise energy:

In short, the algorithm to determine the squelch energy was as follows:

loop:

   squelch_avg = (1-α) * squelch_avg + sqrt(abs(hpf_audio)) * α
   if(squelch_avg > MAX_VALUE)
      squelch_avg = MAX_VALUE

Where:
   α = "smoothing" factor
   hpf_audio = audio samples that have been previously high-pass filtered to remove speech energy
   squelch_avg = the "smoothed" squelch output

If you look at the above pseudocode example you'll notice several things:
  • The square root value of the absolute value of the high-pass noise energy is taken.  It was observed that as the signal got noisier, the noise amplitude climbed very quickly:  If we didn't "de-linearize" the squelch reading based on the noise energy - which already has a decidedly non-linear relationship to the signal level - we would find that the majority of our linear squelch adjustment was "smashed" toward one end of the range.  By taking the square root our value increases "less quickly" with noisier signals than it otherwise would.
  • The value "squelch_avg" is integrated (low-pass filtered) to "smooth" it out - not surprising since it is a measurement of noise which, by its nature, is going to vary wildly - particularly since the instantaneous signal level can be anything from zero to peak values.  What we need is a (comparatively) long-term average.
  • The "squelch_avg" value is capped at "MAX_VALUE".  If we did not do this the value of "squelch_avg" would get very high during periods of no signal (maximum noise) and take quite a while to come back down when a signal did appear, causing a rather sluggish response.  The magnitude of "MAX_VALUE" was determined empirically by observing "squelch_avg" with a rather noisy signal - the worst that would be reasonably expected to open a squelch.
Obtaining a usable basis of comparison:

The above "squelch_avg" value increases as the quieting of the received FM signal decreases which means that we must either invert this value or, if a higher "squelch" setting means that a better signal is required for opening the squelch, that same "squelch setting" variable must have its sense inverted as well.

I chose the former approach, with a few additional adjustments:
  • The "squelch_avg" value was rescaled from its original range to approximately  24 representing no-signal conditions to 3 representing a full-quieting signal with modulation with hard limits imposed on this range (e.g. it is not allowed to exceed 24 or drop below 3).
  • The above number was then "inverted" by subtracting it from 24, setting its range to 2 representing no signal to 22 for one that is full-quieting with modulation.
It is not enough to simply compare the derived "squelch_avg" number after scaling/inversion with the squelch setting, but rather a bit of hysteresis must also be employed or else the squelch is likely to "flap" about the threshold.  I chose a value of 10% of the maximum range, or a hysteresis range of +/-2 which seemed to be about right.

The final step was to make sure that if the squelch was set to zero that it was unconditionally open - this, to guarantee so that no matter what, some sort of signal could be heard without worrying about the noise threshold occasionally causing the squelch to close under certain conditions that might cause excess ultrasonic energy to be present.

The result is a squelch that seems to be reasonably fast in response to signals, weak or strong, but very slightly slower in response to weak signals.  This slight asymmetry is actually advantageous as it somewhat reduces the rate-of-change that might occur under weak-signal conditions (e.g. squelch-flapping) - particularly during "mobile flutter."  The only downside that is currently noted is that despite the "de-linearization" the squelch setting is still somewhat compressed with the highest settings being devoted to fairly "quiet" signals" and most of the range representing somewhat noisier signals - but in terms of intelligibility and usability, it "feels" pretty good.

Subaudible tone decoding:

One useful feature in an FM communications receiver is that of a subaudible tone (a.k.a. CTCSS) decoder.  For an article about this method of tone signalling, refer to the Wikipedia article here - link.

In short, this method of signalling uses a low-frequency tone, typically between 67 and 250 Hz, to indicate the presence of a signal and unless the receiver detects this tone on the received signal it is ignored.  In the commercial radio service this was typically used to allow several different users to share the same frequency but to avoid (always) having to listen to the others' conversations.  In amateur radio service it is often used as an interference mitigation technique:  The use of carrier squelch and subaudible tone greatly reduces the probability that the receiver's squelch will falsely open if no signal is present or, possibly, if the wrong signal - in the case where a listener is an an area of overlapping repeaters - is present - but this works only if there is a tone being modulated on the desired signal in the first place.

The Goertzel algorithm:

There are many ways to detect tones, but the method that I chose for the mcHF was the Goertzel algorithm.  Rather than explain exactly how this algorithm works I'll point the reader to the Wikipedia article on the subject here - link.  The use of the Goertzel algorithm has several distinct advantages:
  • Its math-intensive parameters may be calculated before-hand rather than on the fly.
  • It requires only simple addition/subtraction and one multiplication per iteration so it need only take a small amount of processor overhead.
  • Its detection bandwidth is very scalable:  The more samples that are accumulated, the narrower it is - but also slower to respond.
The Goertzel algorithm, as typically implemented, is capable of "looking" at only one frequency at a time - unlike an FFT which looks at many - but since it is relatively "cheap" in terms of processing power (e.g. the most intensive number-crunching is done before-hand) it is possible that one could implement several of them and still use fewer resources than an FFT.

The Goertzel algorithm, like an FFT, will output a number that indicates the magnitude of the signal present at/about the detection frequency, but by itself this number is useless unless one has a basis of comparison.  One approach sometimes taken is to look at the total amount of audio energy, but this is only valid if it can be reasonably assured that no other content will be present such as voice or noise, which may be generally true when detecting DTMF, but this cannot be assured when detecting a subaudible tone in normal communications!

"Differential" Goertzel detection:

I chose to use a "differential" approach in which I set up three separate Goertzel detection algorithms:  One operating at the desired frequency, another operating at 5% below the desired frequency and the third operating at 4% above the desired frequency and processed the results as follows:
  • Sum the amplitude results of the -5% Goertzel and +4% Goertzel detections.
  • Divide the results of the sum, above, by two.
  • Divide the amplitude results of the on-frequency Goertzel by the above sum.
  • The result is a ratio, independent of amplitude, that indicates the amount of on-frequency energy.  In general, a ratio higher than "1" would indicate that "on-frequency" energy was present.
By having the two additional Goertzel detectors (above and below) frequency we accomplish several things at once:
  • We obtain a "reference" amplitude that indicates how much energy there is that is not on the frequency of the desired tone as a basis of comparison.
  • By measuring the amplitude of adjacent frequencies the frequency discrimination capability of the decoder is enhanced without requiring narrower detection bandwidth and the necessarily "slower" detection response that this would imply.
In the case of the last point, above, if we were looking for a 100 Hz tone and a 103 Hz tone was present, our 100 Hz decoder would "weakly-to-medium" detect the 103 Hz tone as well but the +4% decoder (at 104 Hz) would more strongly detect it, but since its value is averaged in the numerator it would reduce the ratiometric output and prevent detection.

Setting the Goertzel bandwidth:

One of the parameters not easily determined in reading about the Goertzel algorithm is that of the detection bandwidth.  This parameter is a bit tricky to discern without using a lot of math, but here is a "thought experiment" to understand the situation when it comes to being able to detect single-frequency (tone) energy using any method.

Considering that the sample rate for the FM decoder is 48 ksps and that the lowest subaudible tone frequency that we wish to detect is 67.0 Hz, we can see that at this sample rate it would take at least 717 samples to fully represent just one cycle at 67.0 Hz.  Logic dictates that we can't just use a single cycle of 67 Hz to reliably detect the presence of such a tone so we might need, say, 20 cycles of the 67 Hz tone just to "be sure" that it was really there and not just some noise at a nearby frequency that was "near" 67 Hz.  Judging by the very round numbers, above, we can see that if we had some sort of filter we might need around 15000 samples (at 48 ksps) in order to be able to filter this 67 Hz signal with semi-reasonable fidelity.

As it turns out, the Goertzel algorithm is somewhat similar.  Using the pre-calculated values for the detection frequency, one simply does a multiply and a few adds and subtractions of each of the incoming samples:  Too few samples (fewer than 717 in our example, above) and one does not have enough information with which to work at low frequencies to determine anything at all about our target frequency of 67 Hz, but with a few more samples one can start to detect on-frequency energy with greater resolution.  If you let the algorithm run for too many samples it will not only take much longer to obtain a reading, but the effective "detection bandwidth" becomes increasingly narrow.  The trick is, therefore, to let the Goertzel algorithm operate for just enough samples to get the desired resolution, but not so many that it will take too long to obtain a result!  In experimentation I determined that approximately 12500 samples were required to provide a tradeoff between adequately-narrow frequency resolution and reasonable response time.

This is part of the reason for the "differential" Goertzel energy detection in which we detect energy at, above and below the desired frequency:  This allows us to use a somewhat "sloppier" - but faster - tone detection algorithm while, at the same time, getting good frequency resolution and, most importantly, the needed amplitude reference to be able to get a useful ratiometric value that is independent of amplitude.

Debouncing the output:

While an output of greater than unity from our differential Goertzel detection generally indicates on-frequency energy, one must use a significantly higher value than that to reduce the probability of false detection.  At this point one can sort of treat the output of the tone detector as a sort of noisy pushbutton switch an apply a simple debouncing algorithm:

loop:

   if(goertzel_ratio >= threshold)   {
      debounce++
      if(debounce > debounce_maximum)
         debounce = debounce_maximum
   }
   else   {
      if(debounce > 0)
         debounce--
   }
   if(debounce >= detect_threshold)
      tone_detect = 1
   else
      tone_detect = 0

where:

   "goertzel_ratio" is the value "f/((a+b)/2))" described above where:
      f = the on-frequency Goertzel detection amplitude value
      a = the above-frequency Goertzel detection amplitude value
      b = the below-frequency Goertzel detection amplitude value
   "threshold" is the ratio value above which it is considered that tone detection is likely.  I found 1.75 to be a nice, "safe" number that reliably indicated on-frequency energy, even in the presence of significant noise.
   "detect_threshold" = the number of "debounce" hits that it will take to consider a tone to be valid.  I found 2 to be a reasonable number.
   "debounce_maximum" is the highest value that the debounce count should attain:  Too high and the it will take a long time to detect the loss of tone!  I used 5 for this which causes a slight amount of effective hysteresis and a faster "attack" than "decay" (e.g. loss of tone).

With the above algorithm - called approximately once every 12500 samples (e.g. just under 4 times per second with a 48ksps sample rate) - the detection is adequately fast and quite reliable, even with noisy signals.

Putting it all together:

Figure 3:
An FM signal with a subaudible tone being detected, indicated by
the "FM" indicator in red.
If tone decoding is not enabled, the Goertzel algorithms are not called at all (to save processor overhead) and the variable "tone_detect" is set to 1 all of the time.  For gating the audio a logical "AND" is used requiring that both the tone detect and squelch be true - unless the squelch setting is 0, in which case the audio is always enabled.

Finally, if the squelch is closed (audio is muted) the audio from the FM demodulator is "zeroed".


* * *

In a future posting I'll describe how the the modulation part of this feature was accomplished on the mcHF along with the pre-emphasis of audio, filtering and the generation of burst and subaudible tones.


[End]

This page stolen from "ka7oei.blogspot.com".

Monday, November 9, 2015

Repairing the TUNE capacitor on the Heathkit HL2200 (SB-220) amplifier

Figure 1:
The front panel of the HL-2200 amplifier - which is really just a slightly
modernized version of the SB-220.
Click on the image for a larger version.
Earlier this year I picked up a Heathkit HL2200 amplifier (the newer, "brown" version of the SB-220) at a local swap meet for a reasonable price.  What made it particularly attractive was that it not only had a pair of new, graphic 3-500Z tubes in (Chinese-made, but RF-Parts Inc. tested/branded) but it also had a Peter Dahl "Hypersil" tm power transformer rather than the "just-adequate" original Heathkit transformer and an already-installed circuit that allowed the milliamp, low-voltage keying rather than the 100-ish volts of the original.

Obligatory Warning:
The amplifier/repair described on this page presents lethal voltages in its circuits during normal operation.  Be absolutely certain to take any and all precautions before working on this or any piece of equipment that contains dangerous voltages!
This amplifier was unplugged and the built-in high-voltage safety shorting bar operated by removing the top cover was verified to be doing its job.
DO NOT work on equipment like this unless you have experience in doing so!
 Problems with the amplifier:

While it was servicable as-is, it did have a few known issues, namely a not-quite-working "10 meter" modification (the parts are all there, apparently having been pulled from an old SB-220 or from the previous owner having obtained a "10 meter" kit) but my interest at this time was the tendency of the "Tune" capacitor of the output network to arc over at maximum RF output power.

Figure 2: 
Some "blobs" on several of the rotor plates of the TUNE capacitor.
 Click on the image for a larger version.
If I operated the amplifier in the "CW" position with just 2.4 kV or so on the plates (at idle) everything was fine, but if I switched to the "SSB" position with 3.2 kV (at idle) then the capacitor arced over, causing signal distortion and high grid current - not to mention a loud hissing and the smell of ozone.  In popping the cover (with the power removed and the shorting bar doing its job!) I could see a few "blobs" on some of the capacitor plates which meant that when this had happened to the previous owner, it had probably been in sustained operation - obviously long enough to cause parts of some of the aluminum plates to be melted, further decreasing the distance between plates and increasing the likelihood of even more arcing!

Figure 3: 
In the center of the picture, a rather serious "blob" on one of the stator
plates.
Click on the image for a larger version.
After having had this amplifier for several months and operating it only at reduced power I finally got around to taking a closer look at what it would take to extract the TUNE capacitor and effect a repair.  Even though it is slightly cramped, it wasn't that difficult to do:  Remove the front-panel knob,  the left-hand tube, disconnect the blocking cap from the TUNE capacitor, remove the rear screw and nut holding it down and loosening the front screw and nut and pulling out the capacitor.



Disassembling the capacitor:

Fortunately, the capacitors used in these amplifiers are constructed from lots of small pieces rather than, like some "high-end" capacitors, press-fit into finely-machined rods and brazed.  What this meant was that simply by undoing a few bolts and screws the entire tuning capacitor can be reduced to a large pile of spacers and plates!

Figure 4:  A pile of parts from the disassembled rotor.
The still-intact stator is in the background.
Click on the image for a larger version.
The capacitor itself was disassembled in a shallow cookie sheet that I also use for assembling SMD-containing circuits:  It was fairly likely that any small part will be trapped in this pan rather than wander off elsewhere, such as onto my (messy!) workbench or, even worse, disappear into the carpeted floor!  Because this capacitor has several small parts and many spacers I felt it prudent to take this precaution - particularly with respect to the small ball bearings on the main shaft and the single bearing at the back end of the capacitor:  These smallest of parts were carefully sequestered in a small container while I was working on the capacitor.

Once the capacitor was "decompiled" all of the plates were very carefully examined for damage and it was found that there were two rotor plates and just one stator plate with large-ish blobs and some very minor damage to one or two other plates.  As is the nature of these things, it was the blob on the stator plate that was the most serious as it was the "weakest link" in terms of breakdown voltage and was always the smallest distance between two points no matter the setting of the capacitor (rotor) itself.

"Fixing" the damage:
Figure 5: 
The most badly-damaged capacitor plates, with an undamaged stator plate
(upper-left) for comparison.  The surfaces show evidence of oxidation
due to arcing.
Click on the image for a larger version.

If the damage is comparatively minor, as was the case here, then the "fix" is fairly simple:
  • Identify all plates that have any sort of "blob" or sharp edges.
  • Grind down any raised surface so that it is flush with the rest of the plate.
  • Using very fine sandpaper, eliminate any sharp edges or points.
If the plates are hopelessly melted you have the option of finding another capacitor on EvilBay, making our own plates, or simply cutting away the mangled portion and living with somewhat reduced maximum capacitance:  It is unlikely that the loss of even one entire plate would make the amplifier unusable on the lowest band, and it is also unlikely that more than two or three plates would have sustained significant damage, either, as this sort of damage tends to be somewhat self-limiting.

Placing a damaged plate on a piece of scrap wood, a rotary tool with a drum sanding bit was used to flatten out the "blob" on each of the three damaged plates.  Once this was done the plate was flat, but it was not particularly smooth, the rather coarse sandpaper having left marks on the plate, so I attacked the plates that had been "repaired" with 1200 grit wet-dry sandpaper and achieved a very nice luster where the grinding had taken place.  I also took special care to "ease over" the edges of the plates to remove any sharp edges - either from the original manufacturing process (stamping) or from the grinding that was done to remove the blob:  This is important as sharp edges are particularly prone to leading to ionization and subsequent arcing!

Because many of the plates showed some oxidation I decided that, while I had the capacitor apart, to polish every single plate - both rotor and stator - against 1200 grit "wet/dry" paper and, in the process, discovered several small "burrs" - either from minor arcing or from the plate having been stamped out of a sheet of metal.  I also took the trouble of "easing over" all edges of the capacitor plates in the process:  Again, sharp edges or points can be prone to arcing so it is important that this be considered!

Once I was done I piled the plates into an ultrasonic cleaner containing hot water and a few drops of dishwasher soap and cleaned them, removing the residual aluminum powder and oxide.  After 2 or 3 cycles in the cleaner the plates were removed and dried yielding pristine-looking plates - except, of course, for the three that had been slightly damaged.

Reassembly:

Figure 6: 
A rotor and stator plate having had the "blobs" ground off, but not yet
having been polished with 1200 grit sandpaper.  A bit of lost
plate material is evident on the left-hand side of the round rotor plate
as evidenced by its assymetry.
Click on the image for a larger version.
I first reassembled the stator, stacking the plates and spacers in their original locations and making sure that none of them got "hug up" on the rods with the last stator plate to be installed being the one that had been damaged.  The rotor was then reassembled, the job being fairly easy since its shaft is hexagonal, "keying" the orientation of the plates.  Because there had been two plates that had been damaged, I placed these on the ends so they were the first and last to be installed:  There is one more rotor plate than stator plate which means that when fully meshed, the two "end" (outside) plates are on the rotor.  Even though I was not particularly worried about it, by placing the "repaired" plates at the ends it would be possible to bend them and increase the distance slightly if they happened to be prone to arc without significantly affecting the overall device capacitance.

Having degreased the bearing mounts and the ball bearings themselves I used some fresh, PTFE-based grease to hold the bearings to the shaft while it was reinstalled, using more of the same grease to lubricate the rear bearing and contact, aligning it carefully with the back plate and finger-tightening the screws and nuts.  Once proper positioning was verified, the screws and nuts holding the end plates in place were fully tightened.

Both the rotor and stator plates are mounted on long, threaded rods with jam nuts on each end and by loosening one side and tightening of the other it is possible to shift the position of the rotor and/or stator plates.  Upon reassembly it was noted that, unmeshed, the rotor plates were not exactly in the centers of the stator plates overall so the nuts on the rotor were loosened and retightened as appropriate to remedy this.  On fully meshing the plates it was then observed that the stator plates were very slightly diagonal to the rotor plates overall so the appropriate nuts were adjusted to shift the positions of those as well.  The end result was that the majority of the rotor plates were centered amongst the stator plates - the desired result, as the capacitor's breakdown voltage is dictated by the least amount of spacing at just one plate.
Figure 7: 
The reassembled TUNE capacitor with a slightly foreshortened
and "repaired" rotor plate at the far end.
Click on the image for a larger version.

Inevitably there will be a few plates that are closer/farther and/or off center from the rest and that was the case here so a few minutes were taken to carefully bend rotor and/or stator plates, using a small blade screwdriver, as needed to center them throughout the rotation.  When I was done all plates were visually centered, likely accurate to within a fraction of a millimeter.

The capacitor was reinstalled quite easily with the aid of a very long screwdriver.  The only minor complication was that the solder joint for the high-frequency end of the tank coil - the portion that consists of silver-plated tubing - broke loose from the rest of the coil, but this was easily soldered by laying the amplifier on its left side so that any drips fell there and not into the amplifier.

"Arc" testing:

After reinstalling the top cover, verifying that it pushed the safety shorting bar out of the way, and installing the many screws that held it and the other covers in place I fired up the amplifier into a 50 ohm dummy load and observed that at maximum plate voltage and with as much input and output power as I could muster, the TUNE capacitor did not arc!

One of these days I need to figure out why the 10 meter position on the band switch isn't making proper contact, but that will be another project!

[End]

This page stolen from "ka7oei.blogspot.com".