Monday, November 20, 2017

SDR and ATC Transponders

Here is the skinny on my ATC transponder ADS-B phun and games. 

Get a SDR receiver for the princely sum of $25, including antennas and tripod here:
https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/




Mode A, C and S Transponders at Al Ain Airport

Ubuntu Linux

First try the Ubuntu repos for dump1090 if that is the Linux version you are using:
$ sudo apt install dump1090

and see if you are lucky!


Fedora Linux

Here is what I did to build Malcom Rob's version of dump1090 on Fedora 26:
According to legend, Malcom's is the best one and according to the below, it really is much better than rtl_adsb.

Get the rtl-sdr library, which includes a set of useful basic utilities, including rtl_test, rtl_fm, rtl_tcp and rtl_adsb:
# dnf install rtl-sdr

Get the development files, so we can build other software with this library:
# dnf install rtl-sdr-devel

Get and make Malcom's software:
# cd
# mkdir sw
# cd sw
# git clone git://github.com/MalcolmRobb/dump1090.git
# cd dump1090
# make

 

Test dump1090

Run it with the default settings:
# ./dump1090

and the output looks like this:
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
Found Rafael Micro R820T tuner
Max available gain is: 49.60
Setting gain to: 49.60
Exact sample rate is: 2000000.052982 Hz
Gain reported by device: 49.60

*5c89645ebfa547;
CRC: 000000 (ok)
DF 11: All Call Reply.
  Capability  : 4 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is on ground))
  ICAO Address: 89645e
  IID         : II-00

*5d8963c2b9d6d6;
CRC: 000000 (ok)
DF 11: All Call Reply.
  Capability  : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is airborne))
  ICAO Address: 8963c2
  IID         : II-00

*5d8963c2b9d6d6;
CRC: 000000 (ok)
DF 11: All Call Reply.
  Capability  : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is airborne))
  ICAO Address: 8963c2
  IID         : II-00

*0000019480b06c;
CRC: 8963c2 (ok)
DF 0: Short Air-Air Surveillance.
  VS             : Airborne
  CC             : 0
  SL             : 0
  Altitude       : 1500 feet
  ICAO Address   : 8963c2

*00050194ba3529;
CRC: 8963c2 (ok)
DF 0: Short Air-Air Surveillance.
  VS             : Airborne
  CC             : 0
  SL             : 0
  Altitude       : 1500 feet
  ICAO Address   : 8963c2


Old Transponder Modes

$ ./dump1090 --modeac --
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
Found Rafael Micro R820T tuner
Max available gain is: 49.60
Setting gain to: 49.60
Exact sample rate is: 2000000.052982 Hz
Gain reported by device: 49.60
*6041;
SSR : Mode A/C Reply.
  Mode A : 6041

*0130;
SSR : Mode A/C Reply.
  Mode A : 0130
  Mode C : 2400 feet

*6041;
SSR : Mode A/C Reply.
  Mode A : 6041

*0110;
SSR : Mode A/C Reply.
  Mode A : 0110
  Mode C : 2300 feet


Interactive Mode

To get a display as at the top of the page:
$ ./dump1090 --enable-agc --modeac --interactive --aggressive

 


Macintosh

I finally got ADS-B to work on my Macbook Pro with a combination of rtl_tcp and cocoa1090.


This is the best radio test tool I've ever bought and it is very useful for acceptance testing and fault finding of radio equipment in a laboratory, hangar, apron or helipad.  

Consider that a Keysight spectrum analyzer costs $30,000 and cannot do half of what this $20 hoosammawatzit does...


-. --- / .-- .. -. -.. --- .-- ... --..-- / -. --- / -.-. .-. -.--

Cheers,

Herman

Monday, November 13, 2017

Software Defined Radios With a Macbook Pro

I finally succumbed to the temptation and bought a couple of RTL SDR dongles.  These thingies are so cheap, they really open the art of amateur radio to the masses again. There are also some notes on the not so cheap, more advanced HackRF One dongle at the bottom of this article.


CubicSDR on a Macbook Pro

These gadgets are wide band digital receivers, which make them much fun.  Effectively, RTL-SDR with CubicSDR provides you with a wide band DIY Spectrum Analyzer that works from about 1 MHz all the way up to about 3 GHz.



Read all about RTL-SDR here:
https://www.rtl-sdr.com/

If you have no idea what to do with SDR toys, go here:
https://www.hfunderground.com/board/

or here:
https://amsat-uk.org/funcube/funcube-dongle-sdr/

or, of course here:
http://www.aeronetworks.ca/2017/07/cube-satellites.html

BTW, if you use Linux or BSD, skip to the bottom of the page.

Where to Buy an SDR Widget

Get your own RTL-SDR kit for the enormous sum of $26 here:
https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/

For a proper transceiver, you can get the HackRF wotzit at Sparkfun, but it costs a rather more hefty amount - about 10x more:
https://www.sparkfun.com/products/13001

Receiver Software

On my Macbook Pro, the CubicSDR program works like magic.  I can sincerely recommend using it:
http://cubicsdr.com/

There are a few things I would like to do with these SDR thingies:
  • Hook to my BitX40 radio to verify the HF performance at 7 MHz, 
  • Listen to ATC aircraft band radio at 118 to 136 MHz and 
  • Decode ADSB from ATC transponders at 1090 MHz.
  • Decode GPS at 1575.42 MHz
The receiver is wide band so things fold back, which makes it a bit confusing, but even the simplest antenna will pull in many FM stations.  I would recommend using a tuned antenna for HF listening though.

AM and FM Radio

So far I managed to tick off the BitX40 (and Abu Dhabi Classic!) with CubicSDR.  This should also work with the ATC voice radio band, I just haven't gotten round to trying it yet.

Get rtl-sdr With Macports

The CubicSDR program can do everything I want with this widget, but the command line utilities mentioned above can also be very handy, especially when you want to log data for later analysis.

The rtl-sdr package provides the following command line utilities:
  • rtl_adsb: a simple ADS-B decoder
  • rtl_eeprom: an EEPROM programming tool
  • rtl_fm: a narrow band FM demodulator
  • rtl_sdr: an I/Q recorder
  • rtl_tcp: an I/Q spectrum server
  • rtl_test: a benchmark tool
  • rtl_power: a spectrum analyzer
So, I used Macports https://www.macports.org/ and updated it, since I already have it installed:

$ sudo port -v selfupdate
sudo: port: command not found

Aargh...

Why is everything so clunky on my Mac?  I can add /opt/local/bin to the path, but that is also a security concern.

Let's try again, this time with the full path to the utility:
$ sudo /opt/local/bin/port -v selfupdate

and this time it worked.

Try to install the rtl-sdr package:
$ sudo /opt/local/bin/port install rtl-sdr
Error: The installed version of Xcode (7.3) is too old to use on the installed OS version. Version 8.2.1 or later is recommended on Mac OS X 10.13.

Bah, humbug...

Open the App Store, search for xcode and Get it all over again, which of course takes foreeever (TM)...  So I clicked the Caffeine coffee cup to keep the Mac from going to sleep and let it upgrade overnight.

Then try to install the rtl-sdr package again:
$ sudo /opt/local/bin/port install rtl-sdr
--->  Computing dependencies for rtl-sdr
The following dependencies will be installed:
 bison
 bison-runtime
 bzip2
 cmake
 ...
Continue? [Y/n]: y

...
Fetching - installing... getting somewhere now!

What hath god wrought?
$ ls /opt/local/bin/rtl*
/opt/local/bin/rtl_adsb        /opt/local/bin/rtl_power    /opt/local/bin/rtl_test
/opt/local/bin/rtl_eeprom    /opt/local/bin/rtl_sdr
/opt/local/bin/rtl_fm        /opt/local/bin/rtl_tcp


OK, let's test it.

Plug the widget in and:
$ /opt/local/bin/rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 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
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 0


ATC Transponders and rtl_adsb

So the test passes, now try to receive ADS-B data:
$ /opt/local/bin/rtl_adsb
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 1090000000 Hz.
Exact sample rate is: 2000000.052982 Hz
Sampling at 2000000 S/s.
*8d896c9399001756282f02516497;
*8d7609895839c7f3dc483eb47eca;
*aec00327548cc8385eb439daf3df;
*a00012113000020000080047fe32;
*a82001910201000000000028ab15;

...

OK, now to make it a little more friendly...

When all else fails, read the manual:
$ /opt/local/bin/rtl_adsb --help
/opt/local/bin/rtl_adsb: illegal option -- -
rtl_adsb, a simple ADS-B decoder

Use:    rtl_adsb [-R] [-g gain] [-p ppm] [output file]
    [-d device_index (default: 0)]
    [-V verbove output (default: off)]
    [-S show short frames (default: off)]
    [-Q quality (0: no sanity checks, 0.5: half bit, 1: one bit (default), 2: two bits)]
    [-e allowed_errors (default: 5)]
    [-g tuner_gain (default: automatic)]
    [-p ppm_error (default: 0)]
    [-T enable bias-T on GPIO PIN 0 (works for rtl-sdr.com v3 dongles)]
    filename (a '-' dumps samples to stdout)
     (omitting the filename also uses stdout)

Streaming with netcat:
    rtl_adsb | netcat -lp 8080
    while true; do rtl_adsb | nc -lp 8080; done
Streaming with socat:
    rtl_adsb | socat -u - TCP4:sdrsharp.com:47806


So, let's try again, this time verbose and with short messages also:
$ /opt/local/bin/rtl_adsb -g49 -V -S
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to 49.60 dB.
Tuned to 1090000000 Hz.
Exact sample rate is: 2000000.052982 Hz
Sampling at 2000000 S/s.
*7918f0d9ca82d6;
DF=15 CA=1
ICAO Address=18f0d9
*57052d75970122;
DF=10 CA=7
ICAO Address=052d75
*530c80731ead47;
DF=10 CA=3
...


Apparently, there are bazillions of planes in the desert sky, but if I look up, I cannot see any! 

Now I need to figure out how to list/map the planes with dump1090 or cocoa1090.

Cocoa1090 for ADS-B Transponders

For Air Traffic Control transponder ADS-B information, I experimented with Cocoa1090:
http://www.blackcatsystems.com/software/cocoa1090.html

Start the rtl_tcp server first and connect to the dongle, then run cocoa1090.


The frequency is of course 1.090 GHz, so a half wave dipole antenna needs to be 275 mm overall, or each 1/4 wave arm needs to be138 mm.  Grab a ruler and tweak the telescopic antenna that you got with the SDR for best results.

ADS-B for Linux Lovers

You need to do one of the following:
$ sudo apt install rtl-sdr
$ sudo apt-get install rtl-sdr
# dnf install rtl-sdr

You can get Malcolm Robb's dump1090 from github.  If you need to ask how, then you have to hand your Geek card back.

ADS-B for BSD Devils

All that FreeBSD devil worshippers need to do is:
# pkg install install rtl-sdr
# pkg install dump1090
# dump1090 --net --aggressive


Then, point a webserver at http://localhost:8080/ and watch...

The OpenBSD Calgary Cowboys are SOL though - it doesn't work fully.

Antennas

The RTL SDR wotzit works perfectly from inside my house with just a simple little dipole antenna.   It is very sensitive, so you don't need any fancy antennas, unless you want to do HF DX.


HackRF One

The HackRF One is a more advanced Tx/Rx dongle that works up to 6 GHz.  Get it from Great Scott Gadgets (https://greatscottgadgets.com/hackrf/) or Sparkfun Electronics.  It is not exactly cheap...


Once you have Mac Ports working, you can install rx_tools and gqrx to make it useful:
$ sudo port selfupdate
$ sudo port upgrade outdated
Go and get some coffee...

$ sudo port search gqrx

$ sudo port install Gqrx
Go and get some more coffee...

$ sudo port search rx_tools
Not found

Hmm, you need Linux for that one.  I think I need to buy me a new Macbook and put Linux on it!
(It can work on a Linux virtual machine on Virtualbox though).

The author of rx_tools published a good article here: https://medium.com/@rxseger/rx-tools-command-line-sdr-tools-for-rtl-sdr-bladerf-hackrf-and-more-rx-fm-rx-sdr-rx-power-2e74f59a9e79

La voila!


-. --- / .-- .. -. -.. --- .-- ... --..-- / -. --- / -.-. .-. -.--

Cheers,

Herman