Piaware 3 defaults to having the gain set to “-10”/AGC, is that the best option for a Pro Stick or should it be changed?
Each location is unique.
Look at this thread for adjusting the gain.
ads-b-flight-tracking-f21/gain-adjustment-t37172.html
I had to cut mine back to 38db. I live in NYC(lots of traffic) and have an excellent Antenna(DPD), Cavity filter and LMR400 Coax.
The Piaware 3 sdcard image lets you set the gain in piaware-config.txt (once you have worked out what value you want, of course…)
Any info on how to obtain best gain and ppm settings for our setups?
I once ran rtl_test on my old setup… trying to locate that info now. The 3.0.3 image does not have that installed by default.
Another package to add to the image I guess “sudo apt-get install rtl-sdr”
The PPM setting is mostly irrelevant for ADS-B (for the same reasons as a TCXO doesn’t help much - it’s a very wideband signal) unless your dongle is way off (>100ppm)
Use the method below. This code was originally written by BartJr and improved by lignumaqua
Please see following thread for details:
Gain Adjustment…
(1) Give following command to create a blank file “optimize-gain.py”
Note: it is not necessary to name the file optimize-gain.py. You can use any name of your choice, but it must have .py at the end
sudo nano optimize-gain.py
(2) Copy-paste the script code below in the blank file created above, save the file (ctrl+o), and exit (ctrl+x)
(3) Make the file executable:
sudo chmod +x optimize-gain.py
(3) Run the script:
sudo ./optimize-gain.py
(4) The results are displayed in the SSH terminal progressively as these are conducted.
The totals of the test are displayed in the terminal at the end of test.
You can copy everything from terminal and paste into a text file & save the text file.
This is the code to be copy-pasted in the blank file “optimize-gain.py”
#!/usr/bin/python2
import time, socket, subprocess, fileinput, os
measure_duration = 62 #seconds
ntests = 10
gains = "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".split()
#gains = "36.4 38.6 40.2 42.1 44.5 48.0 49.6".split()
#gains = "22.9 25.4 28.0 29.7 32.8 33.8 36.4".split()
gains.reverse()
results = {}
for i in range(ntests):
print "test", i+1, "of", ntests
for g in gains:
if g not in results:
results[g] = [0,0,{}] #msgs, positions, aircraft
for line in fileinput.input('/etc/default/dump1090-mutability', inplace=1):
if line.startswith('GAIN'):
print 'GAIN='+g
else:
print line,
os.system("sudo /etc/init.d/dump1090-mutability restart")
time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost',30003))
t = time.time()
d = ''
while 1:
d += s.recv(32)
if time.time() - t > measure_duration:
break
s.close()
messages = 0
positions = 0
planes = {}
for l in d.split('
'):
a = l.split(',')
messages += 1
if len(a) > 4:
if a[1] == '3':
positions += 1
planes[a[4]] = 1
print "gain=",g, "messages=", messages, "positions=", positions, "planes=", len(planes.keys())
results[g][0] += messages
results[g][1] += positions
for hex in planes.keys():
results[g][2][hex] = 1
print "
===Totals==="
print "Gain, Messages, Positions, Aircraft"
for g in gains:
(messages,positions,planes) = results[g]
print g, messages, positions, len(planes.keys())
Thanks. It’s difficult to pick out patterns from it as things fluctuate quite a lot.
I updated the script for the Piaware 3 config:
#!/usr/bin/python2
import time, socket, subprocess, fileinput, os, re
measure_duration = 62 #seconds
ntests = 10
gains = "-10 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".split()
#gains = "36.4 38.6 40.2 42.1 44.5 48.0 49.6".split()
#gains = "22.9 25.4 28.0 29.7 32.8 33.8 36.4".split()
gains.reverse()
results = {}
for i in range(ntests):
print "test", i+1, "of", ntests
for g in gains:
if g not in results:
results[g] = [0,0,{}] #msgs, positions, aircraft
for line in fileinput.input('/etc/default/dump1090-fa', inplace=1):
print re.sub(r'gain +-]?(\d+(\.\d*)?)', 'gain '+g, line),
os.system("sudo systemctl restart dump1090-fa")
time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost',30003))
t = time.time()
d = ''
while 1:
d += s.recv(32)
if time.time() - t > measure_duration:
break
s.close()
messages = 0
positions = 0
planes = {}
for l in d.split('
'):
a = l.split(',')
messages += 1
if len(a) > 4:
if a[1] == '3':
positions += 1
planes[a[4]] = 1
print "gain=",g, "messages=", messages, "positions=", positions, "planes=", len(planes.keys())
results[g][0] += messages
results[g][1] += positions
for hex in planes.keys():
results[g][2][hex] = 1
print "
===Totals==="
print "Gain, Messages, Positions, Aircraft"
for g in gains:
(messages,positions,planes) = results[g]
print g, messages, positions, len(planes.keys())
Hi all tried this and got fault any idea’s
pi@piaware:~$ sudo service dump1090-fa stop
pi@piaware:~$ sudo ./optimize-gain.py
File “./optimize-gain.py”, line 35
for l in d.split(’
^
SyntaxError: EOL while scanning string literal
@suffolk3000
Post your entire script. It looks very different to the script above.
pi@piaware:~ sudo service dump1090-fa stop pi@piaware:~ sudo ./optimize-gain.py
File “./optimize-gain.py”, line 35
for l in d.split(’
^
SyntaxError: EOL while scanning string literal
above is fault shown in pi
below is script im using
#!/usr/bin/python2
import time, socket, subprocess, fileinput, os, re
measure_duration = 62 #seconds
ntests = 10
gains = “40.2 42.1 43.4 43.9 44.5 48.0 49.6”.split()
#gains = “-10 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”.split()
#gains = “36.4 38.6 40.2 42.1 44.5 48.0 49.6”.split()
#gains = “22.9 25.4 28.0 29.7 32.8 33.8 36.4”.split()
gains.reverse()
results = {}
for i in range(ntests):
print “test”, i+1, “of”, ntests
for g in gains:
if g not in results:
results[g] = [0,0,{}] #msgs, positions, aircraft
for line in fileinput.input(‘/etc/default/dump1090-fa’, inplace=1):
print re.sub(r’gain ±]?(\d+(.\d*)?)', 'gain '+g, line),
os.system(“sudo systemctl restart dump1090-fa”)
time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((‘localhost’,30003))
t = time.time()
d = ‘’
while 1:
d += s.recv(32)
if time.time() - t > measure_duration:
break
s.close()
messages = 0
positions = 0
planes = {}
for l in d.split(’
‘):
a = l.split(’,')
messages += 1
if len(a) > 4:
if a[1] == ‘3’:
positions += 1
planes[a[4]] = 1
print “gain=”,g, “messages=”, messages, “positions=”, positions, “planes=”, len(planes.keys())
results[g][0] += messages
results[g][1] += positions
for hex in planes.keys():
results[g][2][hex] = 1
print "
===Totals==="
print “Gain, Messages, Positions, Aircraft”
for g in gains:
(messages,positions,planes) = results[g]
print g, messages, positions, len(planes.keys())
Script above has
for l in d.split(’
You have
for l in d.split(’
The single quotes are different. It may not show up in my text, however, I can see a difference in the two posts.
This can happen with copy and paste. I could also be just a font issue.
i understand i took this from page now pi here is full script off pi
for line in fileinput.input(‘/etc/default/dump1090-fa’, inplace=1):
print re.sub(r’gain ±]?(\d+(.\d*)?)', 'gain '+g, line),
os.system(“sudo systemctl restart dump1090-fa”)
time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((‘localhost’,30003))
t = time.time()
d = ‘’
while 1:
d += s.recv(32)
if time.time() - t > measure_duration:
break
s.close()
messages = 0
positions = 0
planes = {}
for l in d.split(’
‘):
a = l.split(’,')
messages += 1
if len(a) > 4:
if a[1] == ‘3’:
positions += 1
planes[a[4]] = 1
print “gain=”,g, “messages=”, messages, “positions=”, positions, “planes=”, len(planes.keys())
results[g][0] += messages
results[g][1] += positions
for hex in planes.keys():
results[g][2][hex] = 1
print "
===Totals==="
print “Gain, Messages, Positions, Aircraft”
for g in gains:
(messages,positions,planes) = results[g]
print g, messages, positions, len(planes.keys())
@suffolk3000
@jonhawkes2030
Are you usig correct script? There are following types of scripts
- Optimize Gain Script for: Piaware SD Card-Image
- Optimize Gain Script for: dump1090-fa on Raspbian
- Optimize Gain Script for: dump1090-mutability on Raspbian
- Optimize Gain Script for: dump1090 (Malcolm-Robb) on Raspbian
All 4 above listed scripts are here:
TWEAK 3, Post 38
Right with you now
many thanks for clearing that up i run several different scripts where I was going wrong
john