Showing posts with label AGC. Show all posts
Showing posts with label AGC. Show all posts

Saturday, May 22, 2021

Characterizing the RTL-SDR Blog (Version 3) for HF reception using the "direct" input.

An inexpensive option for SDR (Software Defined Radio) reception on the HF (low frequency) bands is a device sold by "RTL-SDR Blog" - the current iteration being Version 3.  Originally intended for digital VHF/UHF TV reception - and that of FM broadcast - the hardware is also capable of tuning much lower frequencies.

Figure 1:  An RTL-SDR Blog V3 USB receiver "dongle".
Unlike most other inexpensive RTL-SDR dongles, this has - via a single SMA port - the ability to operate in "direct" mode where RF below the VHF frequencies is passed straight to the A/D converter rather than via a down-converter, allowing reception from (theoretically) a few hundred kHz to around 30 MHz.

How does it do this?

The typical RTL-SDR Dongle actually consists of two tunable devices:

  • The Rafael R820T.  This is simply a frequency converter, capable of handling an input signal from somewhere below 60 MHz into the GHz range and converting it to what we'll call an "IF" (Intermediate Frequency) which is much will likely be below 12 MHz.  In addition to having a programmable oscillator and mixer for frequency conversion, his device has some built-in filtering that provides some protection to strong-ish off-frequency signals, and it has an AGC (Automatic Gain Control) that can adjust the level being output from it to prevent overload of the A/D converter as well as some front-end attenuation control to reduce the likelihood of overload on the input.
  • The Realtek RTL2832U.  The down-converted output of the R820 chip is passed to this device, which consists of two 8 bit A/D (Analog-to-Digital) converters that are clocked at 28.8 MHz (meaning that signals above 14.4 MHz will be "aliased"), a USB interface, a (reported) 8051-type microcontroller and a digital frequency "converter" that is also capable of being "tuned" to produce a quadrature "baseband" signal that is output onto the USB port - the rate being programmable from around 250 ksps to 2880 ksps.  This device does NOT have an AGC or gain/attenuation control.

VHF/UHF operation:

Briefly, reception on the VHF/UHF frequencies is done the following way:

  • A simple high pass filter/diplexer passes only the VHF/UHF signals (e.g. those above approximately 40 MHz) directly to the R820T.
  • The filtering of the R820T is programmed for the desired characteristics at the operating frequency.
  • The frequency converter in the R820T is offset from the input signal to provide an output (IF) signal in the 1-14 MHz range - more likely somewhere between 3 and 6 MHz.
  • The level of this output signal may be automatically controlled by the AGC system of the R820T to keep it within the optimal range of the A/D converter.  Similarly, input gain adjustment on the R820T can prevent it from being overloaded by strong signals.
  • The tuner within the RTL2832U is set to about the same frequency being output by the R820T (likely in the 5-12 MHz range) so that it is within the range of output ("baseband") sample rate, and output via the USB port.

HF operation:

  • The signal to be received is applied via the RF antenna port and diverted from the R820T to a very simple low-pass filter/diplexer to an RF amplifier.  This diplexer's effect begins at approximately 22 MHz - See the discussion near table 1, below.
  • The output of from the RF amplifier is passed through additional filtering and applied to one of the two A/D inputs of the RTL2832U - typically the "Q" input.
  • The tuner within the RTL2832U is set near the frequency to be received so that it is within the range of the output ("baseband") sample rate, and output via the USB port.
  • Because the sample rate of the RTL2832U is 28.8 MHz, any signal above 14.4 MHz will also appear "below" it as well - see the discussion below.

There's a penalty to pay for simplicity:

For those familiar with receiver topology - digital or analog - several things the above description of the HF operation of the RTL-SDR dongle without proper measures (e.g. filtering, gain control) should give cause for concern - namely:

  • There is NO bandpass filtering at all.  Whatever is being intercepted by the antenna system will be input directly to the A/D converter via the preamplifier.
  • ANY signal applied to the antenna input - no matter the frequency - can contribute to overload.  Because the inputted RF goes into the A/D converter, a strong signal well away from where you are listening can cause overload.  For example, if you are listening to 14 MHz, a strong AM broadcast signal (e.g. mediumwave) could well be the culprit if you are experiencing overload.
  • There is no AGC in the HF ("direct") signal path.  Considering that the A/D converter is only 8 bits, this means that compared to even low-end shortwave receivers, the range of signal levels over which this device will operate is very narrow.  The lack of an "AGC" (automatic gain conttrol) means that there will likely not be enough gain when signals are very weak and overload of the A/D converter is likely if the signals are very strong.
  • The A/D converter's sample rate is 28.8 MHz.  What this means is that the Nyquist limit - the frequency above which the digitized output can no longer represent the input signal - is half this, or 14.4 MHz, uncomfortably close to the 20 meter amateur band, and entirely below the 17, 15, 12 and 10 meter bands - and this does not even consider the fact that the sample frequency is within the 10 meter band itself. 
What this means is that there are unsuppressed image responses all across the HF spectrum.  For any frequency you tune below 14.4 MHz, you can also hear any signal above 14.4 MHz, the frequency of which is calculated by subtracting its frequency from the sample rate (e.g. 28.8 MHz).  For example, 15 meter signals will also appear, spectrally inverted (e.g. USB = LSB) 7.80-7.35 MHz.  Image frequencies appear in table 1 - along with MDS and clipping values - below.

In other words, if you are tuned to any HF frequency, you are actually "hearing" TWO frequencies at the same time unless you have specific filtering to prevent such image response.  See the right-hand column of Table 1 (below) for the frequency at which you will see an image.

The above puts strict limits on the performance of the RTL-SDR dongle as an HF receiver and these realities must be considered when the configuring any system that might use them.

The usable dynamic range:

In theory, 8 bits of A/D sampling would indicate about 48dB of useful signal range, but the reality is more complicated than this.  Compared to the bandwidth of the narrow signals typically sought on HF, the overall sample rate of the A/D converter - and even the rate after the RTL2832U's converter has reduced the signal to the sample rate being sent to the USB port - are very much higher, effectively improving the bit depth via oversampling - and the fact that the HF spectrum is backgrounded with what amounts to white noise works to our benefit, helping to spread discrete, spectral artifacts that are the inevitable result of the imperfect signal acquisition.

This also works the other way:  Very strong, discrete signals (e.g. SWBC transmitters) can also cause mixing products which can find their way in other signals - particularly weak ones - but this effect may be minimized if one manages to keep the input level "high enough" so that at least several bits of A/D conversion are involved and also limited such that A/D converter overloads are minimized as much as practical - a balancing act that makes it difficult to handle both weak and strong signals at the same time.

All of this makes the actual, usable range a bit difficult to divine.  To this end, an RTL-SDR (V3) unit was put on the workbench, using the "HDSDR" program as a receiver, and its operation was analyzed by observing CW (unmodulated) signals on narrow (SSB) bandwidths.

Methodology:

Ideally, we would be able to determine the RF level at which the A/D convert clipped directly, but the HDSDR program does not provide a means to see the peak A/D level, requiring us to infer it by noting the level from a known-accurate signal generator at which the S-meter starts to decrease at the same rate that the signal level is reduced - and also by noting the disappearance from the waterfall many of spurious signal caused by overload.  Typically, this is about 3dB below the "maximum" S-meter reading.

For sensitivity, DL4YHF's "Spectrum Lab" program was used to measure the SINAD in a 500 Hz bandwidth set by the HDSDR program, the "minimum discernible signal" being equivalent, in this test, to 3dB S/N.

Table 1:  Measured signal levels for A/D clipping and MDS, along with corresponding image frequencies on HF.  Because the sample rate of the RTL-SDR is 28.8 MHz, ALL signals above half this frequency (e.g. 14.4 MHz) are, by definition, Nyquist images.  The far-right column is "apparent" dynamic range - see the discussion below.
Frequency (MHz)
Clipping (dBm)
MDS (dBm)
Image  (MHz)
Apparent DR (dB)
0.5
-17
-97
28.3
80
1.0
-24
-107
27.8
83
2.0
-27
-109
26.8
82
4.0
-27
-116
24.8
89
7.0
-29
-117
21.8
88
10.0
-30
-117
18.8
87
14.0
-30
-117
14.8
87
15.0
-30
-116
13.8
86
18.0
-30
-116
10.8
86
21.0
-29
-114
7.8
85
24.0
-25
-109
4.8
84
28.0
-14
-95
0.8
81
29.0
-16
-94
0.2
78
35.0
-16
-90
6.2
74
40.0
-2
-84
11.2
82

Discussion:

Table 1 tells us several things:

  1. As mentioned in the documentation found at the RTL-SDR Blog web site, signals below 2 MHz - and especially below 1 MHz - are rolled off by the "Bias Tee" blocking choke which has insufficient inductance at frequencies below the AM broadcast band.  To a degree, this effect can be mitigated by removal of the RF choke which will remove the capability to inject DC onto the cable.  This table includes the effect of this choke.
  2. The RTL-SDR has a low-pass filter to diplex the HF and VHF and above frequencies to separate signal paths, and the effects of this filter are becoming evident above 15 meters (21 MHz).  This also means that by itself, the RTL-SDR becomes "deaf as a post" on the 12 and 10 meter bands.
  3. Note that at the very low frequencies, the sensitivity appears to be somewhat reduced.  The effects of high-pass roll-off - likely caused by coupling capacitors and the input bias inductor - appear to be evident through at least 7 MHz.
  4. There is clearly no image rejection at all, considering that the sensitivity through 21 MHz is comparable to that below 14 MHz.  For example, 15 MHz WWV will also appear on a receiver program at 13.8 MHz, at the same apparent signal strength.
  5. Low-pass effects are evident by 24 MHz, most likely a result of the diplexer used to split the HF (direct) and VHF/UHF signal paths.  This limits sensitivity on the 12 and 10 meter amateur bands.
  6. With only 8 bits of quantization, additional noise will be generated due to the imprecise nature of the process.  This "noise" will show up as spurious signals and, less obviously, as a rise in the overall noise floor - depending on the nature of what is being digitized.  In short, the fewer the number of bits, the less likely it is that weak signals will coexist (and be audible) in the presence of strong signals.
  7. Across most of the HF spectrum, the RTL-SDR will overload signal at about -30dBm - which is approximately equal to an S-meter reading of "40 over S-9".  While this seems like a fairly strong signal, this power level represents the total amount of RF energy - no matter the frequency!
  8. Note that the power at which the A/D converter starts to overload is approximately -30dBm across much of the HF spectrum.  This represents the TOTAL amount of RF power required, at all frequencies combined, that will result in overload.
  9. Across much of the HF and MF spectrum (0.5-28 MHz) the apparent dynamic range is on the order of 80 dB.  This number should be taken with a grain of salt as it was measured in the absence of any other signals -  hardly a real-world equivalent.  Practically speaking, this number is indicative of the best possible performance under ideal conditions.

Points 7 and 8, above, should be considered very carefully in terms of its implications:

  • You cannot simply connect an RTL-SDR Dongle to even an "average" performing HF antenna and expect reasonable results as the total power from ALL signals reaching the receiver are likely to exceed the -30dBm signal level - particularly if you have any AM (mediumwave) transmitters anywhere nearby (e.g. within 20 miles/30km).
  • Particularly on the lower bands (80, 40, 30 meters) the signal levels of amateur and especially shortwave broadcast signals can, by themselves, exceed the -30dBm overload level - particularly in Europe and the eastern U.S. On some bands, the shortwave broadcast band adjacent to the amateur band (e.g. 41 and 40 meters) are too close to effectively filter out and it may be that an RTL-SDR is simply not usable on these bands when propagation favors reception on these frequencies. 
  • As seen in Table 1 (above) the RTL-SDR dongle becomes increasingly deaf on the higher HF bands (particularly 12 and 10 meters) making them unusable at these frequencies without additional amplification AND filtering.  What's worse is that the lower HF frequencies (e.g. below 10 MHz) are typically very noisy while the higher frequencies are quiet by comparison.  If you connect an antenna to the RTL-SDR dongle with no band-pass filtering and try to tune in, say, the 15 meter band, you will likely hear only noise (and signals) around 4.8 MHz, which will likely overwhelm any weak, 15 meter signals.
  • If you plan to use an RTL-SDR for HF reception and expect even mediocre performance, you should precede it with a band-pass filter for the frequency band of interest.  For the highest HF bands (15, 12 and 10 meters) the typical noise floor in a quiet location is around -120 dBm (in a 500 Hz bandwidth) - which is well below the noise floor of the RTL-SDR at these frequency meaning that a preamplifier (along with a bandpass filter) will be required for reasonable performance.
  • It's worth remembering that unlike an analog receive system, one cannot always use all 8 bits for digitization:  The signal input must be kept well below the "full scale" level (at and above which "clipping" will occur, causing distortion and signal degradation everywhere else) to accommodate for random fluctuations that are ever-present on signals input from the antenna.  What this means is that the A/D must be under-driven overall and that fewer bits are actually being used most of the time.  In order to maintain suitable margin, it's typical to drive the A/D converter at between 1/4 and 1/2 full scale, meaning that for 8 bits of A/D conversion, 2-4 bits are typically being used - and fewer, still, when the band is "dead" and signals are weak.

Conclusions:

  • DO NOT simply connect an RTL-SDR to your HF antenna and expect it to work as well as even a low-end shortwave receiver:  If it doesn't get overloaded by local AM broadcast (mediumwave) signals, it will get overloaded by strong shortwave broadcast signals when conditions are favorable on certain bands.  This isn't to say that you won't hear anything if you do so, but know that normal signal levels present on even an "average" antenna will be enough to overload the RTL-SDR dongle.
  • ALWAYS precede an RTL-SDR with a band-pass filter that is specific for the frequency range of interest. For example, if you are interested in 40 meter reception (7.0-7.3 MHz for ITU region 2) your filter should pass only frequencies in this range, and this filtering will prevent unwanted reception of signals at the image frequency around 21.8 MHz.   Unfortunately, the use of a band-pass filter precludes reception outside its design range, but this is necessary considering the limited capability of the RTL-SDR dongle in terms of handling both strong and weak signals at the same time and its unfettered response to unwanted images.
  • In some cases - even with a mediocre antenna - the signals in the desired frequency range may exceed the signal handling capability of the RTL-SDR and cause overload.  As noted above, a single signal stronger than -30dBm can do this, but so could a number of signals whose total power can exceed this.  Typically, this overload is manifest as intermittent distortion across the entire receiver as signals fade in and out.  In such cases, it might be beneficial to attenuate the signals reaching the RTL-SDR as the degradation caused by overload is more "destructive" across the entire receive frequency range than too-little signal.
  • Because of image response and roll-off, the HF port of the RTL-SDR is really not well-suited for 12 and 10 meter (24-30 MHz) reception.

Comment about HF upconverters:

Specifically to address some of these issues, there are upconverters available for the RTL-SDR that will upconvert the HF spectrum to VHF (typically in the 100-130 MHz range) to allow the use of that signal path, making use of the Raphael R820T converter.  This converter has the advantage of having a degree of band-pass filtering and the ability to use AGC (automatic gain control) on the signal path.

This method can be useful, but there are several caveats:

  • If frequency stability is of importance, the addition of the upconverter introduces two additional frequency stability issues:  Drift of the upconverter itself, and the fact that any existing drift in the dongle itself will be multiplied because of its operation at the higher frequency.  This can be an issue in environments where the temperature is not stable and/or when a frequency sensitive mode like SSB or (especially) digital modes are used.
  • If multiple bands and receivers are to be used, there may be the temptation to upconvert the output of the upconverter to VHF and distribute this signal to the receivers.  While this may work in many cases, it's worth noting that if the entire HF spectrum is converted, the total signal power level can be significant, potentially overloading the upconverter itself, any RF amplifiers that might be used at VHF, and/or the front end of the RTL-SDR dongles themselves.
    • While a "fix" might normally be to filter out just the HF band(s) of interest, this can become impractical if the 40 meter band (7.0-7.3 MHz) is upconverted to, say, 137 MHz where it can become difficult to make an effective band-pass filter at that frequency.
    • It is possible to filter for a specific HF band before the upconversion, but this means that each RTL-SDR would require its very own upconverter.  While effective, the cost of an upconverter for each band may be prohibitive.

* * *

Successfully using an RTL-SDR on HF:

As mentioned earlier, one must precede the RTL-SDR with a band-pass filter to obtain reasonable performance on HF - or any other frequency range where very strong and very weak signals will be simultaneously present at the antenna input:  Remember that, especially in the "direct" mode, all signals applied to the RF input - even those MHz away from where the receiver is tuned - will count "against" you in terms of the total amount of RF power that may be applied to the A/D converter before it clips/overloads.

To see some RTL-SDR based HF receive systems in operation - and to be able to directly compare them with higher-performance receivers using the 16 bit signal path, visit the Northern Utah WebSDR site at sdrutah.org (link).  This will take you to a "landing page" where you can select several receivers - specifically:
  • WebSDR #3:  This server uses RTL-SDRs for both the 80 and 40 meter bands.
  • WebSDR #1:  This server uses SDRPlay RSP1a receivers which have both an RF AGC and around 14 bits of A/D converter depth - plus external band-pass filtering.

Both of these systems use the same antenna for 80 and 40 meters and it is possible to directly compare signals between the two in side-by-side windows.  Generally, the 8 bit RTL-SDRs used on WebSDR #3 hold their own compared to those on WebSDR #1, and this is possible only because the WebSDRs are preceded with both band-pass filtering and AGC as described in the link below.

* * *

Additional resources:

  • An article on using band-pass filtering and AGC (Automatic Gain Control) to improve the performance of an RTL-SDR when used for amateur band service may be found here:  http://www.sdrutah.org/info/rtl_sdr_agc.htmlSeveral "test" receivers are currently in operation at the Northern Utah WebSDR that demonstrate the efficacy of doing this.


 This page stolen from ka7oei.blogspot.com

[End]

Monday, April 15, 2019

Applying outboard AGC and filtering to RTL-SDR dongles to maximize usable dynamic range on HF


An AGC system for RTL-SDR "wideband" receivers
operating in "Direct" (Q-branch) mode.

 A quick description of RTL-SDR dongles:

Figure 1:
An "RTL-SDR.com V3" USB-based receiver - one of the better,
"cheaper" options out there.
This unit has been programmed and marked with its own,
unique (to the system) serial number.
Click on the image for a larger version.
The so-called RTL-SDR dongles are ubiquitous and versatile because they can cover (more or less) from a few hundred kHz to over 1.3 GHz using various on-device signal paths - but all of these signal paths have in common one important limitation - The A/D converter is only 8 bits.

Despite these limitations, they are attractive because they are cheap - from $4 for the "bottom end" and cheapest devices (which are far noisier than they could be) to well over $50 for units with frequency converters and a few other bells and whistles - including band-pass filters.  The devices that we are using are just $20 and are the RTL-SDR dongles sold by "RTL-SDR Blog":  These units have thoughtfully-designed circuit boards that minimize extraneous, spurious responses and include a 1ppm TCXOs for decent frequency stability as well as providing separate signal branches for "direct" and "quadrature" signal paths for frequency ranges below 30 MHz and above around 60 MHz, respectively.

Ideally, the maximum range represented by an 8 bit A/D converter is around 48dB - and this is approximately what can be expected from these devices.  As with most things in the real world, the actual answer to the question of "what is the dynamic range" is more complicated.

In reality, noise produced by the device reduce the number of usable A/D bits and thus the dynamic range - but due to what amounts to oversampling and the contribution of the noise that is always present on HF - which can effectively "dither" the A/D converter, the apparent dynamic range can "seem" to be somewhat greater - perhaps well over 50dB, under some circumstances - but having 50-60 dB or so of usable dynamic range is not nearly enough for reasonable performance on the HF bands under a wide variety of signal conditions.
"But the Dongle already has an AGC!"

One advantage of using a dongle with an upconverter - a device that would, say, converter 0-30 MHz to the range of  125-155 MHz - is that it then places these signals within the range where the R820T chip can operate - and this chip does have RF filtering and a sort of AGC - at least by way of being able to have its gain adjusted by software.

Aside from the frequency drift issues related to this frequency up-conversion mentioned elsewhere, the problem with this is that the R820T chip really isn't that "strong" in terms of  its ability to handle widely disparate signal levels.  While the RTL2832 chip does have an AGC or sorts, the gain of both chips in the signal path must be carefully controlled to maximize performance.  Unfortunately, the precise nature of how these all work together isn't well documented and the general consensus seems to be that at HF, it doesn't work all that well.

While the built-in AGC can work, we decided to avoid combining the somewhat marginal performance of the R820T signal path and the unknown nature of the AGC operation with the already-marginal 8 bits of A/D conversion in favor of an external AGC system operating within the well-defined limits of the dynamics of these devices when they are operated in "direct" mode.


The problem:

In this specific case we are using the "Q" branch of the RTL-SDR dongle for direct reception of HF signals:  For the purposes of this discussion and to avoid the complication of a discussion about aliasing, we'll limit the frequency range to 30 meters (10.15 MHz) and lower - a range that encompasses what are, in the current low end of the sunspot cycle, the two most popular HF bands:  40 and 80/75 meters.

In some circumstances - and with careful adjustment of RF levels - the limited dynamic range of the RTL-SDR dongles is "almost enough" - but because HF conditions widely change, the "optimal" amount of signal getting into the dongle goes all over the map:  During the daytime on 40 meters, noise can be very low and there are very few truly strong signals, but in the evenings or mornings there can be very strong signals from high-power shortwave broadcast stations.  These disparate situations cause some problems:
  • If one adjusts the signal level going into the dongle to optimize being able to hear weak signals during the day (e.g. the background noise of the band driving the A/D converter to 10-15% full scale indication) it is likely that strong nighttime signals - both amateur and broadcast - will (more or less) saturate the A/D converter (e.g. put it into the range of "clipping"), degrading performance considerably.
  • If one adjusts the signal level into the dongle to accommodate the very strong signals (which is only a "best guess" as such signals can vary by 10s of dB) then the input level to the dongle under "quiet" band conditions will be so low that sensitivity will suffer and spurious signals can appear everywhere as too few A/D converter bits are being "tickled" causing images and intermodulation distortion.
As mentioned before, the A/D converter's 8 bits do provide roughly 50dB of overall signal-handling range, but using one of these devices on HF soon makes it clear that one must constantly adjust the input level to assure that that 50dB "window of usefulness" is in the right place.  Using 60 meters as an example again, a "quiet" band in a good location may yield around -107dBm of noise in an SSB bandwidth, but a powerhouse shortwave broadcaster's signal can be into the -35dBm range - nearly 70dB higher than the noise (and there may be more than one of these strong signals!) which represents a range of at least 70dB.  What's worse, taking into account the need to provide 10-15% of A/D deflection just on the background noise on a quiet band for the dongles to work properly (to avoid serious issues with quantization-related distortion) roughly half of the 50dB or so available to us is already "used"!


Applying an AGC (Automatic Gain Control):

Figure 2:
Inside the 4-channel filter and AGC gain block module.
The individual band-pass filters may be seen at the far end of the lid-mounted
PCB ground plane while the actual detection and control circuitry
is on the prototype boards in the foreground near the bottom of the picture.
Click on the image for a larger version.
Any RF-based digital direct-sampling (or analog!) receive system - to maintain optimal performance - must have its input levels constrained, which is to say that one must take into account both the lowest and the highest signal levels.  In some cases it is simply enough to amplify/attenuate the input levels so that the expected signals will always fall in that range - and this may be practical on VHF/UHF or microwave, but it is certainly not the case at HF.

Even if we were to use a higher resolution A/D converter, we would still want to do this to keep all of the input signals within the "sweet spot":  Direct sampling HF transceivers such as the Icom IC-7300 and IC-7610 must apply both "strong" band-pass filtering and input gain control to maximize their overall performance.  In general, the more signal we throw into the A/D converter, the better - as long as we don't overdrive it and cause (excessive) "clipping".

Such is the case with these RTL-SDRs:  For best performance, one must have BOTH "strong" input filtering centered around the frequency range of interest (the narrower the better!) and keep the signal levels in the "sweet spot":  A properly-designed AGC can do this.

In short, the signal path and method is as follows:
  • The signal comes from the antenna.
  • Bandpass filtering for the band of frequencies is applied.  The narrower the bandwidth and "sharper" the filtering, the better.
    •  Important:  One should never connect a receiver - particularly one with limited dynamic range - to an antenna without a band-pass filter that is designed to limitf the applied signals to the range of interest. (In other words:  Don't waste your time trying to make an RTL-SDR dongle work on HF without a suitable HF bandpass filter for the frequency range of interest - no matter which RTL-SDR dongle you use, filter out all but the frequency band in which you are interested.)
  • On the output of the filter is an electronic attenuator.
  • The signal level on the output of the filter (which is also being applied to the dongle) is measured.
  • If the signal level exceeds a set threshold, the amount of attenuation is increased to cause it to remain at/near that threshold.
In short, the above system prevents the combination of all signals from getting to the dongle from consistently exceeding a pre-set level.  In this way, one can run a bit of "extra" gain to get the best weak-signal performance, but prevent the system from being hopelessly overloaded when very strong signals appear.

A practical implementation:

To maximize performance of the RTL-SDR dongles used for HF reception at the Northern Utah WebSDR, a "prototype" module consisting of four bandpass filters and four AGC gain blocks was constructed - see Figure 2.

Bandpass filters for 90-80 meters, 60-49 meters, 41-40 meters and 31-30 meters were constructed "Manhattan Style" on pieces of glass-epoxy circuit board material as individual filter modules which were then secured to the main ground plane - a larger piece of PC board material mounted in the lid of a Hammond 1590D aluminum enclosure.  Three dividers - also made of circuit board material - provide shielding between each of the band modules.

Constructed on small pieces of phenolic prototype board are the circuits that detect the RF and derive a control current for the electronic attenuators.  These devices are mounted elevated above the ground plane and attached to the shield walls which provides good RF grounding and a DC return path:  Two smaller "walls" are located at the far ends to provide the two boards at the ends with solid attachment points.

Comment:
You can check out the device depicted in this article yourself - simply go to the Northern Utah WebSDR and listen on the "60 Meter" and "30 Meter" bands on WebSDR #1 and WebSDR #2, respectively, or to the "90/80 Meter" and "41/40 Meter" bands on WebSDR #3.  All four of these bands use RTL-SDR dongles with the described AGC device.
Figure 3:
Schematic of the gain control block.  See notes below if a "standard" DBM is used.
Click on the image for a larger version.
Circuit description:

Figure 3
shows the gain control block schematically.

The input signal passes through the band-pass filter (shown as a block) with its output connected to a doubly-balanced modulator module, U3.  These devices are nearly identical to standard diode-ring doubly-balanced mixers, except that they are optimized for operation as an attenuator or baseband modulator:  The attenuation through them is inversely proportional to the logarithm of the current applied to the "CTL" (control) port.  In this case I used the Mini-Circuits LRAS-2-75 modules, originally designed for 75 ohm systems, but they work just fine at 50 ohms as well - being chosen because they are some of the lowest-cost components of this type offered by Mini-Circuits Labs.  The "official" specifications of the LRAS-2-75 gives specifications down to just 10 MHz, but it works fine at 3 MHz with just an extra dB or two of insertion loss.

Figure 3 gives a list of other suitable devices - some of which are rated down to lower frequencies than the LRAS-2-75.  Figure 3 also mentions the use of a standard doubly-balanced mixer such as the Mini-Circuits SRA-1:  A standard mixer will also work "acceptably" in this role if that is all that is available - but they tend to do worse at overall higher signal levels and one should attempt to find a proper attenuator like the LRAS-2-75 or similar.  If a standard doubly-balanced mixer is used, make sure that it has a port that provides a direct connect to its internal diodes to which the bias may be applied:  While this is usually the "IF" port, some devices have this particular port otherwise designated.  The presence of the diodes can be easily checked by using the "diode" function of a DVM between the device ground(s) and the control pin, observing a 0.2-0.3 volt drop in both directions/polarities of the meter.

The output of the attenuator (U3) goes two places:  To the RTL-SDR dongle being used for reception, and to the input of U2, an Analog Devices AD8307 logarithmic amplifier.  This device's input impedance is quite high, so a 470 ohm series resistor (R6) is used to lightly "tap" the RF coming out of the U3 while causing minimal circuit loading.  Included across the input pins of U2 is a low-value capacitor - typically in the 33-56pF range (as noted on the diagram) that is connected very close to the device to quash its response at VHF/UHF while minimally affecting HF signals:  Without this capacitor, U2 can easily detect any local FM or VHF/UHF TV broadcast signal - or even local VHF/UHF amateur transmissions - and be somewhat "desensed".  Practically speaking, this may not be a problem - particularly when it is placed inside a shielded container, behind bandpass filtering - but this can be distracting when the circuit is on the workbench being tested.

The output of U2 is a logarithmic response of the total RF energy (after having been passed through the filter) being applied to its input, the voltage increasing by approximately 250 millivolts for every 10dB of increase in signal:  If reasonable construction techniques are applied, signals well below -70dBm can be measured.  Because the maximum signal level (e.g. A/D converter clipping) of the "RTL-SDR Blog" dongle is in the range of -40dBm, no additional RF amplification is necessary in front of U2.

Figure 4:
Two of the gain control modules with U2, the AD8307s being
partially obscured by the ferrite beads.  These
beads are used to decouple any stray RF from the
common 12 volt supply line powering the modules.
Click on the image for a larger version.
U1 must be an op amp capable of operating down to the negative rail in order for this circuit to function and the specified LMC660 is ideally suited.  The DC output of U2 is applied to U1a, one half of a dual op amplifier, wired as a unity-gain follower to set a low impedance point, and this DC signal is then applied, via R5, a 1 Megohm resistor to U1b, which is configured as an integrator by virtue of a 0.1uF capacitor placed in the feedback path with the threshold being set by R4, a 10 turn potentiometer.  If the integrated DC signal from U2 is above the threshold set by R4, the voltage output of U1b decreases, reducing the bias applied to attenuator U3 and increasing its loss, but if the signal is below the threshold, the voltage increases, decreasing the attenuation.  By this action, the combination of U1 and U2's action will prevent the average signal at the bandpass filter's output from exceeding the threshold level set by R4.

Whereas a typical AGC found in a receiver will have a fast "attack" and a slow "decay", we want this AGC to be comparatively slow to respond so that it will (hopefully) not be completely deafened by the occasional static crash.  In reality, allowing the A/D converter to hit full-scale on occasional peaks will have minimal apparent impact on reception.  In the absence of broadband static crashes, the cumulative power within the bandpass filter's range will change comparatively slowly over time and it is this that we wish to track.

In the DC path between the output of U1a and the "CTL" pin of U3 is a series LED which provides both a bit of logarithmic current response intrinsic to semiconductor diodes as well as providing a handy visual indication of the state of the circuit:  If the LED is lit, attenuation is low, but if it is very dim or turned off, more attenuation is being applied.  In testing, the photosensitivity of LEDs was simply a "non issue" and ambient light had no discernible effect on circuit operation - and even if it was at all noticeable, it will be placed in a metal box, anyway.

Resistor R3 provides current limiting to the diode while R2 provides a current sink:  The combination of R1 and C1 (located very close to U3) terminate the "CT" port (at high frequencies) at the nominal impedance of the RF portion - in this case, around 50 ohms.  Also included is U4, a 5 volt regulator:  This supplies power for U2 as well as provides a stable reference voltage for R4, the RF threshold adjustment:  It need not be exquisitely stable with temperature as several dB change of the AGC threshold with varying temperature is of no importance in this application.

Under normal "quiet" conditions the RF level going into U2 will be too low to exceed the threshold, causing the output of U1b to go to maximum voltage, biasing U3 to set minimum attenuation - it is only in the presence of stronger signal(s) that the gain reduction will occur.

Circuit calibration:


To calibrate the circuit, a signal generator is required, the procedure being as follows:
  • Pre-set the wiper of R4 (the 10 turn pot) to ground (zero volts at U1b, pin 5)
  • Set a signal generator it to a frequency within the passband of the filter and an RF level of around -20dBm.
  • Connect the input of the dongle to the signal generator and tune it to the frequency of the generator using software of your choice.  Make sure that the "direct - Q" signal path is selected since we are not using an upconverter.
    • If using SDR-Sharp, tuning in the signal (using AM is best) "hovering" the mouse over it on the waterfall display should give a dBFS reading.
    • If using the "HDSDR" program, the "dBFS" reading will appear on-screen in the receiver control panel.
  • Using the software, monitor the level of the applied RF signal's "dBFS" (dB with respect to full-scale).  Ideally, a full-scale A/D indication would yield a dBFS reading of around -6dBFS, but it seems that the internal scaling of the signals from an RTL-SDR dongle aren't scaled, so the reading may be in the -30 to -50 dBFS range.  Monitor the "dBFS" from the dongle while increasing/decreasing the signal and note the highest value.  The goal here is to determine the reading given by the program.
    • Ideally, one would like to be able to see the "recent-highest" reading of the A/D converter of the dongle, but this may not be available in the programs used with the dongle.
    • If adventurous, one can use the "librtlsdr" tool called "rtl_sdr" and dump the results to a file or a display program to monitor the raw A/D values.
    • If you operate a WebSDR using the PA3FWM software there is a utility that will directly read out the number that we want to look at:  Contact me directly for details.
  • Having determined the maximum-displayed "dBFS" level, connect the signal generator to the input of the bandpass filter and the RTL-SDR dongle to the output (e.g. J2 in Figure 3) with the frequency set to the center of the desired frequency range (usually - but not always - the middle of the filter's passband).  The amplitude of the signal generator is set for level higher than one would reasonably expect to see on the input - say -20dBm.
  • At this point the LED should not be illuminated and U3 will offer maximum attenuation.
  • Slowly increase R4 until the LED just starts to be illuminated.  Watching the "dBFS" reading, adjust R4 for a signal level that is about 6dB below the maximum reading that you'd previously obtained.  Ultimately, you will want to set the peak A/D output to between 1/4 and 1/2 of full scale which represents -12 to -6 dBFS, respectively.
  • If the circuit is working properly, any signal above that corresponding with the threshold should be limited at the set value by automatically setting U3's attenuation, but a total signal power level below the threshold should cause U3 to operate at minimum attenuation as indicated by maximum LED brightness.
    • If you are using a signal generator with a built-in "step" attenuator, changing signal levels may cause momentary "glitches" of high signal that may cause a momentary disruption in the A/D reading and slightly upset the AGC:  Simply wait for a few seconds after making an adjustment for the readings to settle after making a change.

Figure 5:
Two bandpass + attenuator (U3) modules.
The inductors/capacitors of the filter may be seen in the
middle of the individual boards while the attenuator (U3) is the
white object seen in the lower-right corner of each board.  U3 is wired
"dead bug" style in each case.
Click on the image for a larger version.

Observations in use:

So far, these devices seem to be working as intended.  Even with higher overall gain in the signal path than before (e.g. when band conditions are poor and/or there are no strong signals in the filter's passband) the RTL-SDR dongles have not been observed to show obvious signs of overload when extremely strong signals are present - this having been a problem previously.  Initially, the AGC threshold was set for -6dBFS (1/2 A/D scale) using a CW signal from a test generator.  In the weeks that followed, these receivers were monitored during high-signal conditions and it was noted that there had been no obvious problems.  The AGC threshold was later reset for -12dBFS (1/4 A/D scale) and an additional 6dB of RF applied to the receivers with no obvious degradation in performance in the presence of strong signals, but a slight improvement in weak-signal performance when the bands were "closed".

In looking at receiver stats, there are still instances of A/D "clipping" - but this is to be expected:  The AGC circuit integrates the level over time (perhaps a few seconds) and brief excursions well above the threshold level are to be expected, both from static crashes, but also coincident modulation peaks of several strong shortwave broadcast signals.  Because the "occasional" clipping typically has little apparent impact on the receive signals (particularly the narrowband signals on shortwave frequencies) this effect isn't usually noticed.

On some of the bands, a bit more RF signal is needed to optimize performance - that is, to "tickle" more A/D bits when signals are weak.  Previously, doing so would risk gross overload of that receiver when the band "opened" with strong signals, but the AGC block should minimize any such issues.

Not mentioned previously, this AGC system can skew the S-meter readings from the receiver somewhat.  In the presence of strong signals, the AGC will lower the overall system gain causing the readings to vary and appear low.  In theory, one could monitor the voltage being applied to bias the attenuator and relate this to the amount of attenuation and offset the S-meter readings, but this may be overkill in most situations!




The above article was posted (by me) as a technical article at the Northern Utah WebSDR (link).

While the circuitry could be integrated onto a small circuit board, this has not been done as the circuits are quite simple and easy to construct as depicted.

* * *

This page stolen from ka7oei.blogspot.com

[End]

Tuesday, January 27, 2015

Update on the mcHF transceiver - Adding features to the original code

For an follow-up article, see this link.

It has been a few months since I have posted anything on the mcHF transceiver  (my previous post may be found here - link) so unless you have been following the mcHF Yahoo group (link - membership required) you would be forgiven for thinking that I had abandoned work on it.

Figure 1:
The mcHF transceiver in operation, showing signals on 10 meters.
Click on the image for a larger version
Quite the contrary, a lot of features have been added to the code, starting with the fine foundation written by Chris, M0NKA based on version 0.0.181.  Considering that he pulled the disparate pieces together pretty much single-handedly, it is quite amazing what was there when I started!

Of course, this is open-source and the whole idea behind it is to allow multiple contributors:  It would be the height of hubris to think that just one person had a monopoly on good ideas, let alone the time to implement a fraction of them, so a group effort is key here.  Even if the majority of the group does not actually contribute directly to writing code, getting user-feedback is absolutely vital to knowing if one is going down the proper path and the detection and fixing of the inevitable bugs that creep in when work is done!

What is the mcHF?

I've had a few people ask me about this transceiver, wondering what it is, some apparently under the mistaken impression that it connects to a computer somehow like many SDR products.

This is, in fact, a completely stand-alone SDR transceiver capable of operating on all bands from 80 through 10 meters. *


RF goes in/out through a BNC connector, DC is applied, one listens to audio on a speaker or headphone, and "talks" with a microphone or an attached CW key/paddle/bug.  If so-desired, you can even connect it to a computer (or smart phone) and run some "sound card" digital modes like PSK31, RTTY, Olivia, WSPR, DV2 or SSTV if you like via its Line in/Line out jacks. **

The "heart" of this transceiver is the ARM Cortex M4 processor (made by ST) running at something under 200 MHz, a reasonably-powerful device, but not super powerful, which makes for some interesting challenges when one is trying to squeeze in various features - more on that in later posts.

* 160 meters is possible too, with just a bit of "hacking" - maybe just as simple as adding an outboard 160 meter low-pass filter.
** Because it is an SDR it should, in theory, be possible for the mcHF to run some digital modes stand-alone as well, but there is the problem of "too many desired features and too little time"!

Why did I do this?

You might think that I started this project knowing all about SDR and DSP.

You would be wrong.

The reason that I tackled this project was that I DID NOT  know all that much about SDR and DSP.  To be honest, I do have a programming and electronics background (but almost entirely self-taught) and I "knew" how SDR radios and DSP worked at the high level, but I'd really never gotten my hands dirty - so this was my chance to get myself drenched, not just my feet!

Not having worked with the Cortex M4 processor before or the CooCox programming environment, but being familiar with the "C" programming language in general (I've used it for many years in programming PICs and other things) I found Chris' source code to be fairly easy to follow, fairly well documented, and the programming software pretty easy to use and I was soon able compile my own code successfully - so I started adding features.

In the next few posts I'll describe the "behind the scenes" of a few of the features that I added.

* * * * *

Adding features - AGC:

As it happened, just as I got started with this project, Chris had other obligations that diverted his attention for a while, but he was happy to see progress being made:  He did make it open source, after all!

The first major change that I made was the implementation of an AGC in the receiver - something that had been missing from the beginning.

Admittedly, I had no pre-conceived notion as to how to do this in code and I purposely did not look at other open-source implementations, but since I knew exactly how an AGC circuit worked, so I simply wrote some code that emulated the rapid charging of a capacitor in the presence of a signal and the slow discharge in its absence and adjusted the "gain" of the audio path in the process simply by multiplying the "live" audio by the floating point number on-the-fly.

In a nutshell, it works like this.

In a loop, operating on each audio sample:
  • Take the absolute value of the pre-AGC, post-filter audio signal.
  • Multiply it by the current AGC value.
  • If the resulting value is above the AGC "knee" value, reduce the AGC value quickly (e.g. the AGC "attack") by an amount proportional to the current AGC value, but if it is below the AGC "knee" (e.g. the AGC "decay") increase the AGC value comparatively slowly by a proportional amount.   The rate of the "decay" is the AGC "hang" time.
  • Enforce limits to minimum and maximum AGC values.
  • Multiply the audio signal by the AGC value.
  • Use the linear AGC value to calculate the logarithmic S-Meter reading.

To my amazement, it actually worked the first time!

Not mentioned above is the fact that a bit of delay is added to the audio path, allowing the AGC correction to be applied "before" the signal was too high:  Doing this "look ahead" properly can completely prevent AGC overshoot when there is a (suddenly) strong signal in the passband.

Signal path gain control:

As often happens, tweaking the software leads to tweaking the hardware - which leads back to more tweaking the software.  Originally there had been an N-channel JFET across the RF signal path ("Q2" on the RF board) to provide a manual attenuation control.  The problem was that, due to an oversight it was not possible to completely bias this JFET to an OFF state as there was no way to apply a negative gate bias, so it was always causing a bit of signal attenuation (typically 6 dB) even when the attenuation control (and gate voltage) was set to "zero."

I'd also noticed that, while tuning around the bands, particularly 40 and 80, that some strong signals would cause terrible distortion so I put the transceiver on my service monitor and observed that its receiver would overload badly, with clipping of the A/D converter occurring at around -55dBm!

Ouch!

This transceiver uses a Wolfson WP8371 (which is very similar to the pin-compatible TI TLV320AIC23) which contains both a 16 stereo A/D and D/A converters.  In receive mode, the A/D converter takes the quadrature I and Q channels from the receive mixers and digitizes them, sends them to the MCU (processor) and then the D/A converter produces the receive audio.  In transmit, the A/D converter takes the transmit audio which is processed by the MCU and the I and Q channels are sent out via the D/A converter to the transmit mixers.

Upon inspecting the code I noted that the internal gain control of the codec was set to maximum which made me wonder if I could extend the dynamic range of the receiver with the codec's own gain control.

A bit of quick experimentation showed that by setting the codec gain to minimum the signal overload point of the receiver was raised from about -55dBm to around -19dBm - a significant improvement!

Note:  This "overload" level applied to signals within the A/D passband, +/- 24 kHz of center.  The "overload" level of signals beyond this range is approximately -5 dBm or so, the level at which the mixer, RF amplifiers and operational amplifiers started to compress/clip.  This is possible due to hardware-based "brick-wall" filtering within the codec chip that removes out-of-band signals beyond this +/- 24 kHz range plus the intrinsic low-pass filtering of the signal chain that attenuates signals that are much farther removed than that.

A bit more "hacking" at the code yielded the final result - an additional "AGC" loop wrapped around the main AGC loop:

  • The output of the A/D converter is monitored.  If the output exceeds 1/8th full-scale, the codec gain is reduced by one "step" ("several" dB) immediately.  At this same instant other places in the receive signal chain (e.g. audio, S-meter) are rescaled by the same amount to compensate.
  • If the output of the A/D converter never exceeds 1/16th full scale for "a little while" the gain is increased by one step.  In other words, when the strong signal(s) disappear, the gain is increased relatively slowly.  A lower threshold is used for the gain increase to add hysteresis and reduce the likelihood of constant "hunting".
  • If the output of the A/D converter is higher than 1/4 full scale, the bottom portion of the S-meter scale - which is normally white - is displayed in red to indicate a possible overload condition.  This does not indicate a malfunction, but is mostly for informational purposes and it could be useful if one decides to override the "Automatic" codec gain control and use the "manual" codec gain control instead.
  • Internally, the "front end" gain of the codec is tracked and this value is used to compensate, on the fly, those other values that require the input level to always be properly scaled with respect to the RF signal's input level.  Such parameters include the S-meter, spectrum scope/waterfall and the digitized audio from the A/D converter itself.  Where this not done the aforementioned items would "jump" as the codec's gain was adjusted, affecting their operation!
The upshot of the above is that on a "busy" band with strong signals one will occasionally see the bottom portion of the S-meter flash red, but it is extremely rare for the receiver to overload.  Even though reducing the gain of the A/D converter does reduce the ultimate sensitivity of the receiver, in practice this is almost never noticed since, on a very busy band where there are very strong signals, one would probably not "miss" an S-unit or two of sensitivity at the bottom end of sensitivity, anyway!  In other words, we are more prudently using our limited, available dynamic range!

This also meant that by changing the code and taking advantage of the hardware gain control built into the codec, the "iffy" JFET attenuator circuit could be completely eliminated as this new method of "attenuation" was much more effective, anyway!



The next time I write about the mcHF:  Implementing audio filters and fractional I/Q phase adjustments with limited processor horsepower - follow this LINK.

[End]

This page stolen from ka7oei.blogspot.com