User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Making sense of ADS-B checksums & bitfields

Tue Apr 02, 2019 9:49 pm

On a whim I wanted to check the RTL2832 dongle I'm using for a different project by running rtl_adsb. modes_gui seems buried in a long backlog of QT & Python updates so I thought it would be fun to write something (in C) that takes the output of rtl_adsb and plots it on maybe an Open Street Maps map. Putting planes on a dispmanx layer sounds about right. I can open rtl_adsb in a pipe and get data just like reading from a file.

So to start I begin with the checksums, because of course I want to toss packets that aren't right. This seems to be the best reference I can find https://mode-s.org/decode/book-the_1090 ... zi_sun.pdf But I can't figure out the bitfield stuff here. I know what bitfields are, I just don't know what MSG[i:i+24] is doing because I've never seen these written with colons before.

This is from the PDF (link above) by Junzi Sun
bitfields.png
bitfields.png (47.16 KiB) Viewed 3927 times

Does MSG[i:i+24] refer to a range of bits at offsets or what?

This (from a page at Microsoft) sort of makes sense:

Code: Select all


struct mybitfields
{
    unsigned short a : 4;
    unsigned short b : 5;
    unsigned short c : 7;
} test;

int main( void );
{
    test.a = 2;
    test.b = 31;
    test.c = 0;
}

the bits would be arranged as follows:

00000001 11110010
cccccccb bbbbaaaa
But I don't understand his use of the colon in there. Or the process really, should I set up a uint128_t to put this stuff in or use something like chars to represent bits? They'd be just local vars in a checksum checking function.

Real off-air data looks like

Code: Select all

*8da5b025991156079804a50769f4;
*8d89610a99454d8b2004a09d90f6;
*a122eb98abaf014c3128959589c1;
*dd16444a57976d2cf49a96a51391;
*8fa6ab27990a018a58acb1f522e5;
*8da2925a5887803a09fb30176990;
*8da7d7a65881f0535a40356ed11a;
*8da5b525991156079808b54f33f4;
*8da5b025213b4db60d0820f16b08;
*8da305aa587df075303d9e34ef47;
*8da3d7a29989d4124008b24f66cb;
*8d5aca6999511319a808b28edf49;
*8d7a0a6158a107df0e9283bd94c4;
*8da7d7a25881f7da8ca79014354c;
*8fa6ab27588da079d22f7b796497;
There are airplane positions, types, altitudes, etc. in there. which are actually sort of interesting when plotted on a map. I've had it running under Windows with a Delphi program written by a guy in Germany 10 years or so ago. I'd like it on my Pi with touchscreen running beside me so I can look over at it.

If more people were monitoring in diverse places, or at least recording, it might be helpful when there's a plane crash. A Pi with a dongle could to that, the more the better I think. Just record data then toss it in a week or so if there aren't any crashes.

See https://www.sprut.de/electronic/pic/pro ... sb_en.html for instance. But a $10 ZeroW and a $10 dongle could do what could be done with a bunch of specialized hardware 10 years ago. Image

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Making sense of ADS-B checksums & bitfields

Tue Apr 02, 2019 10:55 pm

Have a look at the ready built package at https://uk.flightaware.com/adsb/piaware/

The heavy lifting is done with https://github.com/flightaware/dump1090
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Wed Apr 03, 2019 12:24 am

OK, thanks, hadn't heard of it. Sprut does mention Flight Aware though. A network of machines sending reports to a central location to be redistributed makes a lot of sense. A little like Blitzortung does with lightning strike data. Too much load for a Zero though by their forums. Solar powered Pi running 24/7, that sounds about right. An excuse to buy another one. :)

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Wed Apr 03, 2019 11:06 pm

Yup, it works pretty much like Sprut's, not crazy about the CPU usage though.
piaware_ss002_800.jpg
piaware_ss002_800.jpg (151.13 KiB) Viewed 3860 times
(Resized small enough to post here)

Not as much fun as writing my own, but contributing data to FlightAware's database is probably a good thing. Takes 30 - 50% CPU (with Firefox) on a Pi 3B, sort of needs to run on its own Pi. I'm just using the cheapie antenna that came with the dongle but I'm at 1600 feet/ 485 meters elevation. I'm about 150 airline miles north of New York City, that's on the edge of my coverage range.

Installing all this on my Pi with the 7 inch touchscreen, getting the screen to not blank, might be about right. It's fun to watch for a while but not all the time. It's a commercial product, I'm not crazy about that either. Much rather contribute to a .org.

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 8:15 am

Cut your antenna down to 68mm (roughly quarter wavelength for 1090MHz) and you'll double the number of aircraft you'll receive.

Also look at getting multilateralation (MLAT) working by updating your personal Flightaware page with your LAT, LONG, elevation and antenna elevation. You need your Raspberry synced to a time server as time-of-day is crucial to MLAT.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 9:53 am

DougieLawson wrote:
Thu Apr 04, 2019 8:15 am
Cut your antenna down to 68mm (roughly quarter wavelength for 1090MHz) and you'll double the number of aircraft you'll receive.


Nah, I've got one of these around, I just didn't go look for it. Image
From Sprut's page, made for 1090 MHz. It has 3 halfwave sections with phasing loops between, gives a fair bit of gain over a simple quarterwave. I modeled it in NEC, made a bigger 832 MHz version. The phasing loops can be round or hairpin shaped but the wire in them needs to be the same 130 mm (halfwave) long. They give a 180 degree phase shift, see https://www.sprut.de/electronic/pic/pro ... sb_en.html
DougieLawson wrote:
Thu Apr 04, 2019 8:15 am
Also look at getting multilateralation (MLAT) working by updating your personal Flightaware page with your LAT, LONG, elevation and antenna elevation. You need your Raspberry synced to a time server as time-of-day is crucial to MLAT.
Why does MLAT care about my LAT & LONG, since the planes LAT & LONG are already in the data packets? Oh, maybe for the time synch part. If you look at FlightAware's coverage maps there are already plenty of receiving stations in most parts of the world. I do have NTP running but only over WiFi. If I remember right with the collinear antenna at my location I can follow NYC <--> Boston <--> Albany flights which is maybe unique.

Oh well. Instead of FlightAware look at https://opensky-network.org/ and https://www.adsbexchange.com for starters, they're non-commercial. I think there are more, I just did a quick search. FlightAware seems to want the BEAST format/protocol which I don't think rtl_adsb does. But Dump1090 requires librtlsdr (and a zillion other things) so if you've got that you've already got rtl_adsb as part of the package. OpenSky seems current, not sure about the other. Both are donation-supported.

What really started this is that I was getting i2c errors from my dongle so I fired up rtl_adsb to see if it was working. Supposedly they usually come from low voltage but my dongle was plugged into my Dell laptop. I have a DrOK across the room.

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 2:32 pm

MLAT uses triangulation between your station, the aircraft and any other station (or stations). The ground stations need to have a known LAT, LONG, elevation and a good clock - that makes it easier to calculate the LAT, LONG & elevation for the moving aircraft.

The FlightAware folks are doing WAM on the cheap, because they've got a large number of volunteer ground stations.

https://en.wikipedia.org/wiki/Multilateration
https://en.wikipedia.org/wiki/Wide_area_multilateration
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 3:56 pm

Hmm, probably like these folks do with lightning strikes http://en.blitzortung.org/live_lightning_maps.php I think they expect microsecond accuracy or so. That's all done by triangulation and it's just an impulse so timing is everything. No numbers like on planes or positions in the reports. But the detections get timestamped too, you don't instantly find out about a strike on the other side of the world, it may take seconds.

NTP is probably accurate enough but I don't seem to have it installed, my clock's getting set some other way. My internet connection is through a cell phone, I don't trust it not to have random delays. The phone switches towers, my IP changes, it's pretty chaotic. The time probably gets set through the phone, then sntp, I see in /etc/dhclient.conf it's requesting ntp and sntp server info when it connects.

But with planes, other than entertainment value you could mostly send in a daily tarball. Assuming crashes are detected some other way, and the data is for later analysis only. If there's a crash. But then they use it for predicting late arrivals and stuff like that too.

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 3:59 pm

I've removed timesyncd from my ADS-B Raspberry and put NTP back in. It's currently sync'd to a stratum2 NTP server and that's good enough for FlightAware.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 04, 2019 10:13 pm

I haven't dealt with NTP in a long time, except installing the Debian package seems to set it up nicely. OpenBSD has their own simplified adaptation of it. When I started trying to use it it was pulling a time/date over shortwave radio from WWV or CHU (audio connection to a sound card) decoding the beeps. There was a radio type clock, mostly only worked at night. Not sure I ever got it working. Listening to the radio signal and hitting enter on the beep worked better usually (manual date command). Dialup internet days so that was unreliable too. The internet was an odd curiosity here, now it's an accepted and relied on thing, but I pay the $60 cell phone (unlimited data) bill.

On to playing with my new Chinese ads1115 board in a ZeroW. No, I don't want to use Python. Came with no docs or software from Aliexpress for $5. Adapting something I found on the web. I2c connection.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 05, 2019 10:19 pm

OK, I'm going to steal the checksum routine from dump1090, it's open source after all. I was never into checksums and crypto, all that stuff.

Code: Select all

From dump1090.c

uint32_t modesChecksum(unsigned char *msg, int bits) {
    uint32_t crc = 0;
    int offset = (bits == 112) ? 0 : (112-56);
    int j;

    for(j = 0; j < bits; j++) {
        int byte = j/8;
        int bit = j%8;
        int bitmask = 1 << (7-bit);

        /* If bit is set, xor with corresponding table entry. */
        if (msg[byte] & bitmask)
            crc ^= modes_checksum_table[j+offset];
    }
    return crc; /* 24 bit checksum. */
}

// ----------------- the table ----------

uint32_t modes_checksum_table[112] = {
0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
0x682e0a, 0x341705, 0xe5f186, 0x72f8c3, 0xc68665, 0x9cb936, 0x4e5c9b, 0xd8d449,
0x939020, 0x49c810, 0x24e408, 0x127204, 0x093902, 0x049c81, 0xfdb444, 0x7eda22,
0x3f6d11, 0xe04c8c, 0x702646, 0x381323, 0xe3f395, 0x8e03ce, 0x4701e7, 0xdc7af7,
0x91c77f, 0xb719bb, 0xa476d9, 0xadc168, 0x56e0b4, 0x2b705a, 0x15b82d, 0xf52612,
0x7a9309, 0xc2b380, 0x6159c0, 0x30ace0, 0x185670, 0x0c2b38, 0x06159c, 0x030ace,
0x018567, 0xff38b7, 0x80665f, 0xbfc92b, 0xa01e91, 0xaff54c, 0x57faa6, 0x2bfd53,
0xea04ad, 0x8af852, 0x457c29, 0xdd4410, 0x6ea208, 0x375104, 0x1ba882, 0x0dd441,
0xf91024, 0x7c8812, 0x3e4409, 0xe0d800, 0x706c00, 0x383600, 0x1c1b00, 0x0e0d80,
0x0706c0, 0x038360, 0x01c1b0, 0x00e0d8, 0x00706c, 0x003836, 0x001c1b, 0xfff409,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};

/*
   For dump1090 source do
     git clone https://github.com/antirez/dump1090.git
  There are forks, not sure which is the original/official one.
*/
Compiled and running, but of course it's not that simple. Project for tomorrow. The raw data from rtl_adsb and the checksums look like:

Code: Select all

*a8001a28cc902030a08804347712;
	1011438
*8da3cd58588da7feda9b8805c3ad;
	8677868
*8dc00b98f8230002004ab8a83a29;
	9663423
*aa003123c909bf42d0808bbb1bee;
	13346125
*8e38da6ba5458c39765b8d73b92f;
	4431775
*f005c44e8810596c1a41c7795120;
	10551836
*a2003f489505da00f0088edecde9;
	9459514
*a0001510a62a3330de67c96b6a54;
	12963241
*ac000bd8588d007f0409a3a4f4e2;
	1429117
*8dc03c0c991d800098048738444b;
	15568542
*85e00b80234cb5b7df6c60eeb281;
	15385026
*8dc00b80589502962e79cc90c8fd;
	5794422
*ed1a3efe79dbe927304767ca6def;
	8764500
*a8008a989eaa05372004006c5f40;
	8434195
I think I have to at least trim off the leading * and trailing ; before I checksum it, haven't done that yet.

OK Dump1090 isn't bad but I'll skip the Piaware. Except I need a Google Maps API key to make the port 8080 output work. All that is stuff I'd like to get rid of, I don't want to rely on a network connection (at best). Dump1090 is a nice little C program, the rest goes too far. I was looking that up and saw mention of Open Street Maps in an earlier version. I don't need to download a map more than once, I'm not going anywhere.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Sat Apr 06, 2019 10:16 pm

This page http://www.radartutorial.eu/13.ssr/sr24.en.html goes into a lot of low level detail
Image

Also see https://mode-s.org/decode

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Mon Apr 08, 2019 1:54 am

Having fun. I don't think the ads-b designers had working in C in mind so there's this 112 bit binary number and sometimes you seem to need odd groupings of bits. Which can change depending on earlier bits in the message. So I treated each hexadecimal digit individually and put them all into an array of chars, 1 bit per char, so it looks like this:

Code: Select all

*8d780a1599422b80e80455d25d6c;
000101111110000100000101100010111001100100100100010011010001000001110001000000101011101101110100101101110100

*a8000ba0b46a0738a003ff8a9987;
010100010000000000001101010100001101001001000101000011101100000101010000000011001111111100010101100110010001

*eba293349092e40956e005df32ce;
011111010101010010011100110000101001000010010100011100100000100110110100011100000000101101111111110001000011

*8d780a155cbf0517cc239e4a4391;
000101111110000100000101100010111011001111011111000010111000111000110011010011001001011100100101001011001001

*caeced251285fa94d53f0178de51;
001101010111001101110111010010111000010000011011111101011001001001111011110011110000100011100001011101111011

*d022c52e5a903f8a00a19540bc28;
011100000100010000111011010001111011010110010000110011110001010100000000010110001001101100100000110100110100

*8da44588b90a17811888951b76a1;
000101110101001000101011000100011101100100000101100011100001100010000001000100011001101110001101111001010101

*8d4cc27f9901ac22880e17cf7f3f;
000101110010001100110100111011111001100100001000010100110100010000010001000001111000111000111111111011111100

*8d782a1599422b80e80415d25c6c;
000101111110000101000101100010111001100100100100010011010001000001110001000000101000101101110100101100110100

*e97f5bb2d72b3f5bd1d3d039e554;
011110011110111110111101110101000111111001001101110011111011110101111000011111000111000011001001011110111011

*a28579b8c4e38f90fddeb13dfabc;
010101000001101111101001110100010011001001111100000111111001000011110111011101111101100011000111111101011101

*cca3ee93ea26fc4c011e0c3c0add;
001100110101110001110111100111000111010101000100111100110010001100001000100001110000001111000011000001010111

*cd680a155cbf00816bb98044bcda;
001101110101000100000101100010111011001111011111000000000001100001001101110110010001000000100010110100110111
I counted 480 of these messages in a minute just now, using the antenna that came with a dongle. Speed counts so I''m working in C, it's what I'm most familiar with anyway lately.

That was using rtl_adsb, with dump1090 --raw I get messages of both lengths. Dump1090 also tries to do a bit of fixing trashed messages. And I got 590 in a minute.

Code: Select all

*8dac2c92f8210002004ab880f59f;
000101110101001101000011100101001111000101001000000000000000010000000000001001011101000100010000111110111001

*8da2dac79991fb86180c1147406d;
000101110101010001110101001111101001100110011000111111010001010010000001000000111000100000101110001000000101

*8da2dac758a107f86686ae14f9ce;
000101110101010001110101001111101011000101011000000011101111000101000101000101010101011110000010111110010011

*5dc02e9469c0ca;
1011011100110000010001111001001001011001001100000011

*8da2dac7234cb5f4c34da09ec51d;
000101110101010001110101001111100100110000100011110110111111001000111100001001110101000010010111001110111000

*8da2dac7f8230002004ab8ce740c;
000101110101010001110101001111101111000101001100000000000000010000000000001001011101000100110111111000100000

*5da2dac72255a6;
1011011101010100011101010011111001000100101110110101

*8da2dac79991fb85f81011b6454e;
000101110101010001110101001111101001100110011000111111010001101111110001100000001000100011010101001010110010

*8da2dac758a107f86286c221a240;
000101110101010001110101001111101011000101011000000011101111000101010100000101000011010001001000010101000010

*5dac2c92e38890;
1011011101010011010000111001010001111100000100011001

*5dac2c92e38890;
1011011101010011010000111001010001111100000100011001

*5da2dac72255a6;
1011011101010100011101010011111001000100101110110101

*5dc02e9469c0ca;
1011011100110000010001111001001001001001001100000011
Gertz's parity paper https://www.ll.mit.edu/sites/default/fi ... -15318.pdf

FAA mode-s (aka ads-b) spec (700+ pages) https://faaco.faa.gov/index.cfm/attachm ... load/58990

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Mon Apr 08, 2019 7:05 pm

If you're interested in dump1090 without Google (and there have been plenty of privacy, etc. issues with them) see https://forum.flightradar24.com/threads ... dev-on-RPi

I haven't tried it yet. It uses Open Street Maps. The direct Github link is https://github.com/mutability/dump1090 and it's written into the instructions how to make a deb file for Pis. Also mentioned is that there's a problem using it under Stretch. Maybe that's what the deb/synaptic route installs. I'm on my amd64 Debian laptop at the moment.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Tue Apr 09, 2019 1:14 am

That's what I wanted really, not to spend a year reinventing Dump1090.
dump1090_osm_apache.jpg
dump1090_osm_apache.jpg (138.25 KiB) Viewed 3571 times
This is maybe an older version that works with Open Street Maps. Just got it working, not sure what the extra lines are for or really why there are so few planes. This fork is from https://github.com/mutability/dump1090

At first it wasn't showing planes, turns out you have to use a command line option to tell it where to put its json files. Interesting, it works by drawing on a CSS layer then making that layer visible and turning off another one. The old plot while out of site trick. There's a plane selected just to see what happens, it brings up more information about it.

It is reasonably set up to make a deb, I didn't do that here because I didn't know what I'd have to change to make it work and I didn't want to update debs forever. Read the readme files. Plane colors are by altitude, outline colors are by how it read the position (ads-b or mlat). This is also using the Apache server I already had installed. The C program writes json files which are loaded by Javascript files. This isn't on a Pi but the program's designed to be Pi-friendly. This is on my old Dell Latitude D530 laptop circa 2008 under amd64 Debian.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Tue Apr 09, 2019 1:23 am

Works better when the antenna isn't lying on the floor. But this is a laptop, I have to put it all down when I stand up.
dump1090_osm_apache2.jpg
dump1090_osm_apache2.jpg (150.04 KiB) Viewed 3567 times

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Tue Apr 09, 2019 5:02 am

OK, I installed it on a Pi, and I don't have the ugly extra lines. Picture tomorrow when I bring up my adsb antenna. Quite efficient, I see about 15% CPU usage on this Pi 3B. From my notes:

Code: Select all

Having given up on the debs (they built but wouldn't install because I once
had dump1090-fa installed).  Get the files, cd into the dir, type make.  If
you have the prerequisites (see the readmes) it will probably work.  I see

-rwxr-xr-x 1 root root 398420 Apr  8 23:56 dump1090

Don't do make install, just live with it where it is (or move it).  You can
write some handy script or alias to start it later.  It's easy to delete it
to uninstall and it shouldn't conflict with anything there.

Plug in a dongle and type ./dump1090 and you should start to see activity. 
ctrl-c to stop it.

It's worth doing ./dump1090 --help at least once, or 
./dump1090 --help > dump1090_help.txt

Set up a directory where to want the data to end up.  Then do something like:

./dump1090 --write-json /var/www/html/dump1090/data

I'm not sure you need all of it but copy the public_html directory to about
where you have the json going.  My json goes into a "data" subdir of where the
rest of it goes.

The file you want to load in your browser is gmap.html 
file:///var/www/html/dump1090/gmap.html aka
http://127.0.0.1/dump1090/gmap.html if you have a web server running

After a few seconds the map should load, it will probably be somewhere
weird.  Just click and drag to your part of the world.  Bookmark it in your
web browser.

Apparently you don't actually need a web server at all.  Or Google.

Make a little file like

#!/bin/bash
cd /usr/src/misc/adsb/dump1090_mut/non-deb/dump1090_mut/dump1090
./dump1090 --write-json /var/www/html/dump1090/data --quiet

chmod +x on it, make a symlink to it somewhere in your path.

Reboot (if you want).  In a terminal run your script to start dump1090. 
Open your web browser and go to the bookmark.  It should be just like you
left it.
Actually it's worthwhile to put your latitude and longitude into config.js where it says DefaultCenterLat and DefaultCenterLon. It defaults to somewhere in Europe so I had to drag all the way across the Atlantic, a few times. You can even make a headless server without X, I just installed (via ssh) and it's serving maps over wifi. Haven't tried it on a Zero yet, it would need a powered hub to run the dongle probably. Around 300 ma I think it was.
Last edited by ab1jx on Thu Apr 11, 2019 4:29 am, edited 1 time in total.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Tue Apr 09, 2019 6:11 pm

This one I posted on Facebook. I'm on my laptop, the dongle's on a Pi. I'm getting it over wifi from the Pi across the room. It's not right on my phone though, some screen size issue. Maybe it's an Android Firefox issue. I don't see the map on the phone, maybe it can't do CSS layers. It works on a Kindle, so I've got a household adsb server over wifi.
dump1090_fb.jpg
dump1090_fb.jpg (180.5 KiB) Viewed 3192 times
Last edited by ab1jx on Thu Apr 11, 2019 2:12 am, edited 1 time in total.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 11, 2019 12:28 am

I was playing with antenna ideas (that's why I got my ham license after all). I modeled Sprut's collinear in NEC, I don't remember what the gain is, about 4 db I think. But the termination of the bottom is sort of an ugly solution. So I thought what happens if you just mirror the top part, and it looks good. The impedance becomes about 370 ohms but the gain goes up to about 8 db.
double_collinear.gif
double_collinear.gif (13.36 KiB) Viewed 2613 times
Don't take my word for it, try this NEC file:

Code: Select all

CM Generated by vcw, by ab1jx
CM Double collinear for 1090 MHz
CM Halfwave = 0.130000 Wire radius 0.000914 Hairpin height 0.012700
CE
GW 1 7 0.000000 -0.005000 0.000000 0.000000 -0.135000 0.000000 0.000914
GW 2 7 0.000000 -0.135000 0.000000 0.058650 -0.135000 0.000000 0.000914
GW 3 7 0.058650 -0.135000 0.000000 0.058650 -0.147700 0.000000 0.000914
GW 4 7 0.058650 -0.147700 0.000000 0.000000 -0.147700 0.000000 0.000914
GW 5 7 0.000000 -0.147700 0.000000 0.000000 -0.277700 0.000000 0.000914
GW 6 7 0.000000 -0.277700 0.000000 0.058650 -0.277700 0.000000 0.000914
GW 7 7 0.058650 -0.277700 0.000000 0.058650 -0.290400 0.000000 0.000914
GW 8 7 0.058650 -0.290400 0.000000 0.000000 -0.290400 0.000000 0.000914
GW 9 7 0.000000 -0.290400 0.000000 0.000000 -0.420400 0.000000 0.000914
GW 10 3 0.000000 -0.005000 0.000000 0.000000 0.005000 0.000000 0.000914
GW 11 7 0.000000 0.005000 0.000000 0.000000 0.135000 0.000000 0.000914
GW 12 7 0.000000 0.135000 0.000000 0.058650 0.135000 0.000000 0.000914
GW 13 7 0.058650 0.135000 0.000000 0.058650 0.147700 0.000000 0.000914
GW 14 7 0.058650 0.147700 0.000000 0.000000 0.147700 0.000000 0.000914
GW 15 7 0.000000 0.147700 0.000000 0.000000 0.277700 0.000000 0.000914
GW 16 7 0.000000 0.277700 0.000000 0.058650 0.277700 0.000000 0.000914
GW 17 7 0.058650 0.277700 0.000000 0.058650 0.290400 0.000000 0.000914
GW 18 7 0.058650 0.290400 0.000000 0.000000 0.290400 0.000000 0.000914
GW 19 7 0.000000 0.290400 0.000000 0.000000 0.420400 0.000000 0.000914
GE
FR 0 1 0 0 1090 0
EX 0 10 2
RP 0, 37, 72, 1000, 0, 0, 5, 5
EN
The best way to deal with 370 ohms I haven't decided. Not all baluns have ferrite, but if it does it needs to be good at 1090 MHz which most TV baluns probably aren't. You can make non-broadband baluns without ferrite but you'd probably want to use a pre-amp and have a high impedance input circuit. Then again I don't take impedance matching in receive circuits very seriously anyway. Use a good low noise transistor like https://m.onsemi.com/product?part=BC550C with a noise figure down around 1 db. I've got a few somewhere.

I used the 130 mm as a half-wavelength and it does seem about right, I did calculations from 1070-1140 MHz but this peaked at 1090. My simple collinear is made with #13 galvanized electric fence wire and a tunafish can. Oh, those don't have to be 40 mm circles, they just have to use up 130 mm or a half wavelength of wire. That makes the signals come out of the straight 130 mm sections in phase. Mine are bent in a sideways U.

BPF420 is what I bought for this a couple years ago, I just found them https://www.alldatasheet.com/datasheet- ... FP420.html I was planning to use this circuit https://www.lll.lu/~edward/edward/adsb/ ... remap.html

Having worked on UHF TV amplifiers, I think it's reasonable that a loop of wire a cm high placed in close proximity on a PCB to another one that it couples to might be all that's needed for a balun. That's not very precise or scientific, that will take more research. Another thing to consider is where the antenna's going to be used. There are precipitation drawbacks to being outdoors, an attic gets hotter than most active electronics can survive. Lightning and power spikes, maintenance are also considerations. A compromise might be to use a couple meters of 300 ohm twinlead in the attic then put the preamp just below the attic floor. Then something like RG-6 coax carrying RF down and DC power up. You can get rtl2832 dongles now that have a built-in bias tee which would feed 5 volts up the coax to the pre-amp, just about perfect. Really I'd want about the same thing on a general purpose discone feeding a different dongle. Plenty of choices at Nooelec https://www.nooelec.com/store/ but not cheap.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Thu Apr 11, 2019 6:35 pm

This is what I was thinking of about baluns. This is from the 2009 ARRL Radio Amateur's Handbook. A balun can be made using coax cable but only for specific frequencies since you need to use 1/4 or 1/2 wavelength and that corresponds to a single frequency. In this case 1090 MHz is all we want anyway.
baluns.gif
baluns.gif (25.6 KiB) Viewed 2442 times
Actually balun means balanced to unbalanced rather than impedance transformation, but they're often used together, like we want here. So looking at part D which is what we want, we should use 130 mm of coax. Except there's an effect called the velocity factor https://en.wikipedia.org/wiki/Velocity_factor because radio signals travel slower through plastic of the coax than they do through free air. RG-174 (convenient to work with for small things) has a velocity factor of 0.66 according to http://www.hamradioexpress.com/pdfzips/ ... ndards.pdf So you multiply 130 mm by 0.66 to get 85.8 mm. (I hope I don't have that backwards) Or about 3 3/8 inches. That's the length of the upper U in part D. The coax on the bottom can be whatever you were planning to use. RG-6 is good and cheap (cable TV wire) but much of it is steel so you can't solder to it. RG-59 or 58 you can. You can get F fittings for both RG-6 and RG-59 and connect them that way.

If you're going to put the dongle near the antenna you're likely to need a pigtail to adapt the MCX or SMA connector on the dongle to a BNC or F fitting, there are a few at https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/ I bought 2 or 3 years ago on e_bay for $2-3 each, mine adapt to BNC fittings. But you could wire a mating connector on the balun instead of the coax at the bottom if you plan ahead.

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 12, 2019 10:59 am

That mirrored collinear... is that similar to a Franklin antenna?

That's what I've been tempted to try making, although I've literally just started with this ADS-B stuff. I might as well put my amateur license (M0WZF) to some use too for once.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 12, 2019 2:31 pm

I'm trying (not very hard) to find out what a Franklin antenna is but I think it's just a collinear, and it was used for AM broadcast (650 KHz - 1.6 MHz). Franklin: https://www.oldradio.com/archives/stati ... dio019.htm It was apparently a 2 element collinear. Which at that frequency is about all that's practical.

What I have in mind actually comes back to this collinear from an old ARRL Antenna Handbook.
collinear.jpg
collinear.jpg (13.25 KiB) Viewed 2166 times
The antenna on the Sprut page is half of one (sort of). There's a guy in Australia doing amateur radio astronomy with some of these. I never got very far trying to model one for some reason, maybe I was playing with variations on it too much. But by mirroring the Sprut antenna it just reconstructs a collinear.

A couple things I never understood about that old diagram were how to feed it, because that diagram shows the central U being connected then it looks like some sort of tapped feed on that. And what's at the bottom of the U sections. The important thing about them is to use up 1/2 wave of wire, it's just a phasing delay. They can be (in a horizontal antenna) a piece of twin lead or ladder line hanging down.

Well actually it's not quite the same thing, the Sprut antenna has 3 radiating half waves, this has 2 per side. But take 5 * (1/2 wave) and put it each side of the feed point, with appropriate bends. I tried modeling one with 10 sections and it didn't look very good. My NEC file is generated by a little C program so it's easy to make what-if changes like that.

I'm thinking of using cable ties or electrical tape to bind the radiating half waves to a piece of fiberglass rod (sold as an electric fence stake here for $3 each). Then some sort of clamp made of a couple pieces of blank circuit board to hold together the wires at the feed point because the center conductor of RG-174 is pretty tiny wire and easy to accidentally break.

Playing with this stuff is more fun than actually being on the air. I haven't done that in years but I renewed my license at the 10 year point just in case.
Last edited by ab1jx on Fri Apr 12, 2019 9:27 pm, edited 1 time in total.

User avatar
pi-anazazi
Posts: 558
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 12, 2019 2:46 pm

This sounds fun!

Would this be a thing:

https://www.amazon.de/dp/B00HXF8WLY

?

Which raspi do you use?
Kind regards

anazazi

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 12, 2019 3:29 pm

pi-anazazi wrote:
Fri Apr 12, 2019 2:46 pm
This sounds fun!

Would this be a thing:

https://www.amazon.de/dp/B00HXF8WLY

?

Which raspi do you use?
That's the exceedingly cheap and nasty (aka crap) antenna that came with my RTL-SDR receiver (I got one for free with the receiver). It's too long for ADS-B on 1090MHz. You need to trim it down to 68mm.

My receiver is connected to a headless 3B running Raspbian Stretch with the piaware stuff added in.

The discussion on here is about making an antenna with higher gain (which relates to being able to read the ADS-B signal from more aircraft at a longer distance from your receiver).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
ab1jx
Posts: 868
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Making sense of ADS-B checksums & bitfields

Fri Apr 12, 2019 4:25 pm

DougieLawson wrote:
Fri Apr 12, 2019 3:29 pm
It's too long for ADS-B on 1090MHz. You need to trim it down to 68mm.
Rather than trim it down, if the tip comes out, just cut a new tip out of some kind of wire (paper clip straightened out?). We have some interesting stuff in the 850 MHz range https://www.radioreference.com/apps/db/?sid=736 so you'd really want a few different tips, you could label them by putting on little tape tags.

But really the resonant frequency is just where the capacitive reactance = the inductive reactance. You can use a little whip antenna at 2 MHz or below, but the impedance goes through the roof. Active antennas usually have something like a FET with a high impedance input which can deal with it. Car radio antennas in the US are about 30 inches which is 1/4 wave on FM (88-108 MHz) but way too short for AM (650-1600 KHz). The AM frontend is just made expecting a high input impedance.

I'm using Raspi 3Bs. It would be nice to have this run on a ZeroW, haven't tried that yet. You'd need an OTG adapter but as long as it's headless without keyboard or mouse, the power supply just needs to run the ZeroW and dongle. I'd worry about it missing some messages though because it was busy.

Return to “C/C++”