Thoughts on optimizing gain

The topic of gain comes up often enough and unlike some i don’t like the gain optimization script.
Aircraft fading in and out of view make short term number gathering not that useful.

The metric i like most for optimizing gain is the percentage of what dump1090 calls “strong_signals”.
Those “strong_signals” are messages that get close to getting clipped.

If you don’t care about some background you can scroll down to the next post for the HOWTO :slight_smile:

This is a clipped signal, the waveform coming into the analog to digital converter gets its largest and lowest values cut off.


(courtesy of wikipedia: Clipping (audio) - Wikipedia)

If too much is clipped it is harder to recognize the waveform. With dump1090 it’s not critical that we don’t clip at all though, because of how the 1s and 0s are encoded in the Mode-S downlink and the way dump1090 detects the bits.

Anyway suffice it to say if your gain is set too high and an airplane flies by relatively close and at low altitude, the messages might not be decoded anymore. (At high altitude due to the reception pattern of most antennas the plane signal actually gets much weaker as it flies directly overhead)
There is an intermediate stage where only some message of a plane get decoded because the others are too strong, so position updates might get slower before no position is detected anymore.
This phenomenon can be observed on your local map if your gain is set really high or a plane flies by really close.

Adjusting gain is mostly a topic for people with an LNA or the yellow or blue FA dongle.
Without amplification the rtl-sdr dongles typically won’t be sensitive enough for the maximum gain setting of -10 (AGC) to be a problem. So without amplification you can just use -10. But it doesn’t hurt to check anyway if you are curious.

I might add some more explanation on RSSI/dBFS here later.
Now in the next post on to checking the percentage of strong signals and changing gain.

Please check out this excellent post on gain by prog: Thoughts on optimizing gain - #71 by prog

17 Likes

HOWTO: gain

This guide assumes you have console access to your Raspberry Pi
(For Beginners - How-to SSH to RPi - Setup Putty in Windows)
and know how to change the gain.
(For Beginners - How to Set / Change Gain)

Use this command to get the percentage of strong messages:

awk "$(cat /run/dump1090*/stats.json| grep total | sed 's/.*accepted":\[\([0-9]*\).*strong_signals":\([0-9]*\).*/BEGIN {printf "\\nPercentage of strong messages: %.3f \\n" , \2 * 100 \/ \1}/')"

Percentages around 5 are what you should be aiming for.

If you live close to an airport even 10% or 15% can be an optimal value.

If you have very occasional helicopters / small plane that fly close by but most other traffic is far away you might need to go for 0.5 % or even lower to make sure the close by traffic is received.

This is just a guideline, experimenting until you actual start losing close by planes due to overloaded receiver is encouraged.

Now you adjust the gain.
After waiting at least 5 minutes you can check the percentage again using the command mentioned before.

If the percentage is too high for your taste, reduce the gain, if it is too low increase it.
If you are unsure of what you want just aim for 5 percent :slight_smile:

Repeat until the number is to your liking.

If you don’t care about losing messages from planes that are close to you and are just aiming for maximum range then you can go higher but i wouldn’t recommend it, you might not get any extra range by using a higher gain. (The noise is amplified with the signal, so if the noise is “louder” than the signal no amount of gain will make you receive that signal)

If most planes are far away and flying high and every few days a helicopter flies by very close and you lose it when it comes closer you will need to reduce the gain to accomodate seeing that helicopter and the percentages will be quite meaningless.

After you are done you can check back after a day or two to get a more precise percentage again using the command. The percentage is only reset when dump1090 is restarted.

11 Likes

Get an error

pi@piaware:~ $ cat /run/dump1090*/stats.json| grep total | sed ‘s/.accepted":[([0-9]).strong_signals":([0-9])./scale=3;\2100/\1/’ | bc | {echo 'Percentage of strong messages: ';cat}
-bash: bc: command not found
-bash: {echo: command not found
-bash: cat}: command not found

1 Like

pi@piaware:~ $ cat /run/dump1090*/stats.json| grep total | sed ‘s/.accepted":[([0-9]).strong_signals":([0-9])./scale=3;\2100/\1/’
scale=3;53205493*100/569287008

1 Like

pi@piaware:~ $ echo ‘Hi this is echo’
Hi this is echo

1 Like

pi@piaware:~ $ echo ‘scale=2;1/2’ | bc
-bash: bc: command not found

1 Like

pi@piaware:~ $ echo ‘scale=2;1/2’ | bc
.50

2 Likes

Besides bc, I always install mc on my Linux.

2 Likes

pi@piaware:~ $ cat /run/dump1090*/stats.json| grep total | sed ‘s/.accepted":[([0-9]).strong_signals":([0-9])./scale=3;\2100/\1/’ | bc | (echo 'Percentage of strong messages: ';cat)
Percentage of strong messages:
9.346

1 Like

So it looks using your method I need to drop gain a bit

1 Like

Try it, you can always check your range/numbers on flightaware and change it back if range is your primary concern.

2 Likes

Range is limited by the Mountains I have around me anyway, would like to increase a/c and message count. It looks like I get a lot of the SEATAC A/C Cut off as they come near me

2 Likes

Then go ahead and drop the gain :slight_smile:

(Aircraft normally fly in and out of your range while the signal strength decreases, so the plane count probably won’t increase)

1 Like

By default Piaware SD card image does not have bc. However if someone installs Performance graphs on Piaware img using JProchazka’s script, then the script installs bc & whiptail right at its start.

On my OrangePiPC/Armbian, I have used JProchazka’s script to install dump1090-fa, piaware, & graphs, so I already had it when I tried your command.

1 Like

Unfortunately the signal value is not very accurate, as we found out recently here. It’s just an estimate of how an original Beast receiver would behave.

1 Like

For messages not decoded by dump1090 directly the strong_signals number doesn’t exist anyway.
You’ll just have to continue trial or error. Anyway prog said he might add a command line switch to change that output. So you can at least check the dBFS in the local map properly :slight_smile:

1 Like

Not only what prog said, but obj also hinted that level measurement is to be taken with a grain of salt.

1 Like

I have revised the command to use awk instead of bc.
This should work on almost every linux install.

1 Like

Well so far I have not lost any distance. I need to run it a few days at the current setting to see how A/C counts and messages go. Being in the Pacific NW near Seattle, we have a lot of Rain which changes daily the counts. We are supposed to have clear weather for the next 5 days and will see how it goes. I’ve went from 47 to 40 on the gain and it appears I may have picked up a few more.

1 Like

What does the command say now?
7 is quite a bit of gain.

Normally the only useful comparison is with the same day of the previous week or even several previous weeks and even then a close airport landing south vs north might change the numbers.

1 Like