An AGC system for RTL-SDR "wideband" receivers operating in "Direct"(Q-branch)mode. |
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 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 1ppm TCXOs for decent frequency stability as well as providing separate signal branches for "direct" and "quadrature" signal paths.
Ideally, the maximum range represented by an 8 bit A/D converter is around 48dB - and this is approximately whatcan be expected from these devices, but 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 considerations of the device reduce the number of usable A/D bits and thus the dynamic range, this noise coming from the device itself and other devices in the signal path - but due to what amounts to oversampling and the contribution of the noise that is always present on HF, the apparent dynamic range can "seem" to be somewhat greater - perhaps in the 50dB range, under some circumstances.
"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 doeshave 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.
"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 doeshave 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 directreception of HF signals: For the purposes of this discussion, we'll limit the frequency range to 30 meters (10.15 MHz)and lower - a range that encompasses what are, in the current sunspot cycle, the two most popular HF bands: 40 and 80/75 meters. Operating in this range avoids the issues with aliasing mentioned above: Read the page RF Downconverter for RTL-SDR receivers for a more thorough description of the issues.
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 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. "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 to few A/D converter bits are being "tickled".
Applying an AGC (Automatic Gain Control):
AnyRF-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 thelowestand the highestsignal levels. In some cases it is simply enough to amplify/attenuate the input levels so that the expectedsignals 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 andinput gain control to maximize the 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 "clipping".
Such is the case with the RTL-SDRs: For best performance, one must have BOTH"strong" input filtering centered around the frequency range of interest (the narrower the better!)andkeep the signals in the "sweet spot": A properly-designed AGC can do this.
In short, the signal path and method is like this:
- 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 limits the bandwidth of 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.)
- On the output of the filter is an electronic attenuator.
- The signal level on the output of the filter (which is 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.
A practical implementation:
To maximize performance of the RTL-SDR dongles used for HF reception at the Northern Utah SDR, 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" 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 voltage 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.
Figure 3: Schematic of the gain control block. Click on the image for a larger version. |
Figure 3shows 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" 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 at least 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 what is available. 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. 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 and be somewhat "desensed". Practically speaking, this may not be a problem - particularly when it is placed inside a shielded container - 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 energybeing 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 -40dBm, no additional RF amplification is necessary.
mustbe 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 which 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 this threshold, the voltage output of U1b decreases, turning off 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 RF output from exceeding the threshold level set by R4. Whereas a typical AGC 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. 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.
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 signals that the gain reduction would typically 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. 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.)
- At this point the LED should not be illuminated and U3 will offer maximum attenuation.
- Slowly increase R4 until the LED juststarts to be illuminated. Watching the "dBFS" reading adjust R4 for a signal level that is about 6dB below the maximum reading that you'd previous obtained. Ideally, one would 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.
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 carrier, but although there hadn't been any obvious problems, the AGC threshold was be reset for -12dBFS (1/4 A/D scale) on a future site visit.
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 and brief excursions well above the threshold level are to be expected, both from static crashes, but also coincident modulation peaks of multiple, strong shortwave broadcast signals. Because the "occasional" clipping typically has little apparent impact on the receive signals (particularly the narrowband types one has on shortwave frequencies) this effect isn't 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.
The above article was posted (by me) as a technical article at the Northern Utah WebSDR (link).
This page stolen from ka7oei.blogspot.com
[End]