Gainmap
I’ve written a script which scans the airwaves at different gains and produces a heatmap image for each gain. These can be used to visually find the optimum gain; that is the gain which gives the greatest 1090MHz signal without introducing excess in-band noise or boosting nearby unwanted signals. This is akin to performing a digital camera ISO test and visually finding the optimum setting for a given scene which gives the best overall result without introducing needless noise.
The advantage with this approach over collecting numbers is that the results can be gathered quickly and interpreted intuitively, like fine-tuning a radio while listening to it. There’s no need to analyse positions vs aircraft since, by definition, the optimum levels already maximise signal for given noise. The disadvanatge with this approach is that there is some play around the optimum level for a given setup, and further testing a couple of levels up or down over a period of days or weeks could be useful.
My results
There are 29 images produced for each test and I’ve selected a few from each run which show what I’m looking at.
Pro Stick Plus with FlightAware external antenna indoors
Same again but including some nearby GSM 950-60 signals (UK) to see how they are affected.
You can see in the first test that maximum gain does not introduce significant noise around 1090MHz. In the second test at maximum gain you can see there is a slight ‘glow’ of noise around 1090MHz but nothing that is masking signals. The GSM signals are a touch brighter at maximum gain.
Conclusion
I would be inclined to leave the installation set to AGC since I’m not seeing noticeable in-band noise and the GSM signals are not impinging. If I wanted to test a bit deeper I could try reducing gain to something like 38.6, where the signal looks about the same, there is a touch less surrounding glow and the GSM signals are slightly weaker. It may give a slight improvement.
Pro Stick Plus with FlightAware external antenna indoors and Uputronics 1090Mhz SAW filtered bandpass preamp
Same again but looking at those nearby GSM signals.
You can see in the first test that increasing the gain increases the signal until it gets to around 20.7, and then in-band noise starts to increase significantly. How are those GSM signals affected? You can see in the second test that the filtering in the preamp does a great job of killing them so they are pretty much gone at that lower gain, and only just visible at the maximum gain.
Conclusion
Reducing the gain to around 20.7 should give maximum signal with minimal in-band noise, and the filtering is nicely taking care of nearby signals so I don’t need to worry about those at all.
Overall conclusion
With the standard Pro Stick Plus and external antenna on this setup I’d probably leave the gain set to AGC. Even if it goes to max there’s no excess noise to worry about. With the filtered preamp I could leave it set to AGC as long as AGC can intelligently make the same determination and reduce the gain to eliminate the noise. It’s not clear to me if it will do that or not. Therefore I’m inclined to manually set it to 20.7 and see how the stats pan out over a couple of weeks.
These visual results are consistent with statistical results I’ve seen mentioned by a couple of other people, where a high value was good without a preamp and a mid-range value was more suitable with a preamp.
It should be noted that after I installed the preamp, positions, aircraft and range all increased with AGC still set. If AGC is acting intelligently then this may be because it has detected the noise and lowered the gain to somewhere around that optimum value. But if AGC just sets the gain to max then that means I got an improvement despite the noise, and setting the gain lower should improve things even more.
Instructions
-
Follow the instructions in the Do I Need A Filter? thread to install
rtl-sdr
andpython-imaging
-
Perform a scan to get an idea of what’s around you
-
Edit
heatmap.py
withvi
ornano
, scroll to the end and use a#
to comment out the lines which overlay text on the images and save the file# shadow_text(draw, margin, img.size[1] - 45, 'Duration: %i:%02i' % (hours, minutes), font)` # shadow_text(draw, margin, img.size[1] - 35, 'Range: %.2fMHz - %.2fMHz' % (min_freq/1e6, (max_freq+pixel_bandwidth)/1e6), font)` # shadow_text(draw, margin, img.size[1] - 25, 'Pixel: %.2fHz x %is' % (pixel_bandwidth, int(round(pixel_height))), font)` # shadow_text(draw, margin, img.size[1] - 15, 'Started: {0}'.format(start), font)`
-
Use
vi
ornano
to create a script calledgainmap
with the following contents#!/bin/bash for g in -10 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 do echo "Toggling dump1090-fa service on and off..." sudo systemctl start dump1090-fa sleep 5 sudo systemctl stop dump1090-fa sleep 5 echo "*** TESTING GAIN $g ***" sudo rtl_power -f 1060M:1120M:100k -i 5 -c 50% -e 5m -g $g -F 9 > scan$g.csv ./heatmap.py scan$g.csv scan$g.png done
-
Make it executable with
chmod +x gainmap
-
Run it with
./gainmap
and wait 2.5 hours for it to complete. You will end up with 29 png image files, each with a filename of the gain that was used, egscan25.4.png
. Transfer them from your RPi to your computer using scp as detailed in the previously mentioned thread. On the Mac you can copy them to your current directory using (substitute xxxxx with your RPI’s IP address):scp pi@xxxxx:scan*.png .
-
Inspect the image files and find the gain where you are getting the best signal with the least noise.
Notes
- Plan the scanning for when you have a reasonably constant level of signals. You can see this on your stats page. Eg for me it starts getting busy from 6am and then is constant from around 9am to 8pm.
- If needed edit
gainmap
and change the gain levels to match those for your dongle. The ones included here are for the Pro Stick Plus. If in doubt you can just use integers since dump1090 will always choose the nearest value for your receiver anyway. - If needed edit the range in the
rtl_power
command to include any nearby areas of interest you identified from your initial heatmap scan. The range used here is 1060Mhz to 1120MHz, ie 1090MHz +/- 30MHz. This covers the area which picks up in-band noise from the preamp. - Remove all previous scans and images with
rm scan*.*
- In the script the starting and stopping of
dump1090-fa
gets around a problem where sometimesrtl_power
cannot access the receiver. Quick and dirty but it works. - If you’re using
dump1090-mutability
or something else then edit the file accordingly - You may find that some gain values produce images which exhibit moiré patterns. Since these seem to occur at very low gains you can ignore them in your assessment.
Please feel free to experiment and post your results.
Regards,
Chris