FlightAware Discussions

Gain Adjustment


#61

@caius,
I see your results and stats but which gain setting did you go with?
(What was it before you made the change?)

Jon


#62

I’m using 42.1 now. I put all the output of the gain script into a spreadsheet not just the summary - it’s a bit easier to see using all the data but it’s a bit big to post all of it here.

Previously, I was using maximum gain but there was something not quite right with the setup. I think that the psu supplying the amp wasn’t giving the correct output. It was giving 4.5V when disconnected, but dropped as soon as I connected it up. There were a combination of factors - PSU and external bias-t were removed and replaced with the the bias-t enabled dongle so there are now fewer connections in the antenna feed. That also means there is no pig tail to the dongle as it has an SMA socket instead of MCX. It’s possible that there was a less than perfect connection somewhere that was affecting things, as I’d had better results using the same antenna chain in the past however the way it is now is performing much better than it ever has in the past.


#63

@caius:
Which antenna you use?


#64

That’s with the Franklin spider that I made ages ago. It seems to perform slightly better than the sandpiper one.


#65

Oh, yes, I remember now. You purchased sandpiper one as you wanted an outdoor installation above chimney, and franklin-spider was in your attic.


#66

Yes, it’s still in the attic. I have everything I need to put it on the roof, but I haven’t got round to borrowing the cat ladder I need to get up there.


#67

Do you use the FlightAware stick, or a different make. Since moving my Aerial up I am getting 1000 - 1200 messages per sec most of the time (during the day) topping off at just under 1400 at very busy times. Got a slightly longer aerial cable, so trying to get it slightly higher up the pole, but think it will only be about 20cm (at most) higher, but less of the aerial will be obstructed by the pole. Once done (and looking at the results) I was wondering if a HAB preamp/filter would improve things anymore, however as the FlightAware stick has an amp already not sure it will help, or even may “overpower” the stick.

Also, (if I did go for one), do you think it could be powered from one of the Pi 3 USB ports (think the spec sheet says it only takes 56mA).

Thanks.


#68

Today when I ran the script on RPi B+/Jessie_Lite/dump1090-mutability v1.15~dev, I got following output. Any ideas how to fix it?

pi@raspberrypi1:~ sudo ./optimize-gain.py test 1 of 5 ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service. Traceback (most recent call last): File "./optimize-gain.py", line 28, in <module> s.connect(('localhost',30003)) File "/usr/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 111] Connection refused pi@raspberrypi1:~


#69

It can’t connect to dump1090. Either dump1090 didn’t start properly, or it wasn’t fully started when the script tried to connect.

The script is kind of dumb and doesn’t actually check if dump1090 is ready, it just waits 2 seconds after starting it, then attempts connecting to port 30003. You can try increasing that wait time from 2 sec to 3 or 4 maybe:


 time.sleep(2)


#70

@BartJr
Thanks. Will give it a try tonight.


#71

Received the same error as Tom. Abcd told me that the raspberry is setup for the FA1090 not the rasperian version hence the error. What can I do to fix this?


#72

Yep I had written the script for dump1090-mutabililty. For the stock FA dump1090, you need to change this line:


 p = subprocess.Popen(('/usr/bin/dump1090-mutability --net --gain '+g+' --oversample --fix --phase-enhance --quiet').split(),shell=False,
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)

to something like:


 p = subprocess.Popen(('/usr/bin/dump1090 --net --gain '+g+' --quiet').split(),shell=False,
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Also you should stop any existing dump1090 process before attempting the gain sweep.

sudo /etc/init.d/fadump1090.sh stop

or for the mutability version: sudo service dump1090-mutability stop

(and remember to start it back up again later)


#73

I had interesting results with mine:

Gain Messages Positions Aircraft
49.6 65703 3088 144
48.0 66775 3176 147
44.5 64939 2949 139
42.1 64286 2980 145
40.2 66542 3092 148
38.6 66325 2919 147
36.4 63005 2820 146

49.6, 48.0, and 40.2 are almost the same results, and 38.6 not too far off. When you break it down further, positions/AC is essentially the same, as well as the Messages/AC. But 44.5 gives the highest result for Messages/AC.

I am going to test the results of the different settings over the next few days to see what the long term real results are.


#74

Gain Optimization Script for Piaware 3.0.4
Since the configuration file of dump1090-fa in Piaware3 is different from configuration file of dump1090-mutability, for use on Piaware 3.0.4, I have modified the optimize script which was originally written by BartJr, and subsequently modified by lignumaqua.

Following changes shown in red were made:

for line in fileinput.input(’/etc/default/dump1090-mutability’, inplace=1):

if line.startswith(‘GAIN’):

print ‘GAIN=’+g

for line in fileinput.input(’/boot/piaware-config.txt’, inplace=1):
if line.startswith(‘rtlsdr-gain’):
print 'rtlsdr-gain '+g

  else:
     print line,

os.system(“sudo /etc/init.d/dump1090-mutability restart”)

os.system(“sudo systemctl restart dump1090-fa”)

Here is the full code for file optimize-gain-piaware3.py



#!/usr/bin/python2
import time, socket, subprocess, fileinput, os

measure_duration = 62 #seconds
ntests = 5
#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 = "20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4".split()
gains = "36.4 38.6 40.2 42.1 44.5 48.0 49.6".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

   for line in fileinput.input('/boot/piaware-config.txt', inplace=1):
      if line.startswith('rtlsdr-gain'):
         print 'rtlsdr-gain '+g
      else:
         print line,
#  os.system("sudo /etc/init.d/dump1090-mutability restart")
   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())


.


#75

A minor change to the code – remember the gain setting in the file, and restore it at the end.
changed formatting thanks to xcode on the mac…


#!/usr/bin/python2
import time, socket, subprocess, fileinput, os

measure_duration = 62 #seconds
ntests = 5
#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 = "20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4".split()
gains = "36.4 38.6 40.2 42.1 44.5 48.0 49.6".split()

gains.reverse()
results = {}

originalgain = ''			# stuff in the starting value form the file

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

		for line in fileinput.input('/boot/piaware-config.txt', inplace=1):
			if line.startswith('rtlsdr-gain'):
				print 'rtlsdr-gain '+g
				if len(originalgain) == 0:
					originalgain = line			# save so we can restore it at the end
			else:
				print line,
#  os.system("sudo /etc/init.d/dump1090-mutability restart")
		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())

# now restore the starting gain value

for line in fileinput.input('/boot/piaware-config.txt', inplace=1):
	if line.startswith('rtlsdr-gain'):
		print originalgain			# restore to where we found it
	else:
		print line,

os.system("sudo systemctl restart dump1090-fa")



bob k6rtm


Not listening on Port 30005- Rut Roh!
#76

Running 3.04 and getting this:

sudo ./gain3.py
test 1 of 5
Failed to restart dump1090-fa.service: Unit dump1090-fa.service failed to load: No such file or directory.
Traceback (most recent call last):
File “./gain3.py”, line 38, in
s.connect((‘localhost’,30003))
File “/usr/lib/python2.7/socket.py”, line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused


#77

@wnypoker
Have you
(1) burned Piaware 3.0.4 image on your microSd card.
OR
(2) installed Piaware 3.0.4 data feeder (add-on) to your microSd card which has Jessie & dump1090-mutability?

The modified script by me & bob are for case (1) which has built-in dump1090-fa.


#78

Hi,

Haven’t worked out the best script to adjust the gain, from all the posts all over the place that refer to gain adjustment but in a physical sense, have some basic figures on noise levels with a 1090 filter fitted or not. wihout the 1090 fliter fitted was averaging a -15.5 noise level and with the 1090 filter fitted it dropped/ went up to -16.5. Now which direction of travel is best for noise, a larger negative number is a better noise figure / smaller negative figure worse or is it the other way around??

Jeff


#79

Hmm I don’t think the larger negative number is good for noise level?? An update. Put the unit into -10db (agc) mode. Signal noise level hourly went from an hourly average of -17 to - 7. This is good ?? Running here the PI3 with USB Pro stick, FA 1090 filter, an inline sat masthead amp and power input, 7db small whip antenna. Now I am not sure that the inline Sat masthead amp is doing anything but it is currently raining here and I have a DPD ADS-B Outdoor antenna on its way from the states and when that is installed I will make some more tests regarding removing that in line sat amp. The big difference noted is the drop in noise level when I put it into the -10 state and put back in the FA 1090 filter.


#80

The dBFS values express a power level as a fraction of the maximum possible level: 10log10(power / max). dBFS = 0 is the maximum power. As values get more negative, they mean smaller power levels. A more negative value for noise is better, all other things being equal.