EE123 Lab2 - Real-Time Flight Radar App

Written by Miki Lustig and Frank Ong

In [ ]:
from __future__ import division
import numpy as np
from numpy import *
from numpy.fft import *


from rtadsb import rt_flight_radar

Task III: Play with the Real-Time Flight Radar

The function rt_flight_radar() in rtadsb.py creates a real-time flight position plot using your preamble detection function and an ADS-B decoder.

Decoding the packets is beyond the scope of this lab, but at a high level, the decoding is done by first identifying the useful packets containing location information. For our lab, we are only interested in long squitters with Downlink Format (DF) = 17, which can be identified by the first 5 bits. Once we have identified a DF-17 packet, we can identify the airplane type (ICAO address) from Bytes 2 to 4. The rest of the packet will contain the altitude, latitude and longitude information, which look like this:

[TC-] [-Altitude-] T F [----Latitude---] [---Longitude--]

01011 000 000011111111 0 0 10110011110111111 01001101110100110

The latitude and longitude are tricky to decode as there are not enough bits to encode all locations. Each ADS-B packet is further divided into even and odd packets and there is a complicated equation to combine one even and one odd packet to get the exact location...

If you are interested in more detail, you can take a look at these links:

Our ADS-B decoder heavily follows the dump1090 software for mode S decoding.

Copy and paste your detectPreamble function to the code cell below. Scroll down to the bottom and you should be able to run rt_flight_radar()! To receive the ads-b packets from planes, it is recommended you are outside during daytime. It is also recommended to use Chrome to view the map. Sometimes, some parts of the map become blank, but you can fix it by resizing your browser or refresh the page.

Information obtained from the flight radar will be printed on the command line. If a plane with position information is detected, it will be shown as a blue blob on the map. If a flight number is decoded, it will be shown next with the blue blob. It might take some time to detect a plane, but be patient. However, it might not be on the map because its position information is not received.

  • Run the flight radar until you see at least a plane on the map. You can check whether the plane is real by googling its flight number (if available).
In [ ]:
# Your detectPreamble and data2bit functions below:
In [ ]:
fs = 2000000; # 2MHz sampling frequency
center_freq = 1090e6 # 1090 MHz center frequency
gain = 49.6 # gain
N_samples = 2048000 # number of sdr samples for each chunk of data

pos_ref = [37.875219, -122.257939] # Berkeley's latitude, longitude for initializing the map

functions = (detectPreamble, data2bit)

# Run flight radar
stop_flag = rt_flight_radar( fs, center_freq, gain, N_samples, pos_ref, functions )
In [ ]:
# Run this to stop

stop_flag.set()

I hope you enjoyed the lab!