📡 Radikant-ADSB-C 

Automatic Dependent Surveillance-Broadcast (ADS-B) library in C.
Device Screen

Radikant-ADS-C is a source agnostic ADS-B Library for tracking aircraft on 1090 Mhz 

Introduction

Radikant-ADSB-C is IQ source ignorant C library for demodulating and decoding Mode-S and ADS-B messages from raw SDR baseband samples so aircraft can be tracked offline with a laptop and SDR. It features a built-in I/Q demodulator with adaptive signal gating and fully decodes 56/112-bit frames, resolving CPR positions, velocities, and altitudes. Built with the Inversion of Control paradigm, it functions as a deterministic state machine that processes pushed samples synchronously and emits real-time aircraft updates via an event-driven API. In order to test the library a small antenna was build from scraps and tuned to the resonant frequency with a Vector Network Analyzer.

Antenna

FM%20Radio%20Analasysis%20

Figure 1 - Dipole Antenna from Scraps

ADS-B C operates on 1090 Mhz, I built a dipole antenna using scrap materials I had lying around. At 1090 Mhz, the wavelength (λ) is approximately 27.5 cm. Since a standard dipole is a half-wavelength long, each element needed to be roughly 6.8 cm. I intentionally cut the elements slightly long so I could trim them down later using a VNA to tune the antenna to the exact resonant frequency.

Vector network Analyzer

FM%20Radio%20Analasysis%20

Figure 2 - Calibrating the VNA

I set up the Vector Network Analyzer for a 500 MHz to 1.6 GHz sweep, keeping our 1090 MHz target roughly in the center. After also increasing the measurement points to 2004 for higher resolution, the antenna was ready to be tuned.

FM%20Radio%20Analasysis%20

Figure 4 - Tuning the Antenna

After trimming the antenna elements one millimeter at a time, I achieved a VSWR of 1.2, making the antenna resonant at 1090 MHz. During testing, I observed that the antenna is highly sensitive to nearby mass. In the worst-case scenario, moving the antenna around caused the VSWR to increase to 1.7. However, this still equates to an efficiency of approximately 93%, which remains entirely acceptable.

Library

After trimming the antenna elements one millimeter at a time, I achieved a VSWR of 1.2, making the antenna resonant at 1090 MHz. During testing, I observed that the antenna is highly sensitive to nearby mass. In the worst-case scenario, moving the antenna around caused the VSWR to increase to 1.7. However, this still equates to an efficiency of approximately 93%, which remains entirely acceptable.

A mock IDE window showing the final ADS-B main file with aircraft callbacks, in a Monokai theme.

FileEditViewProject
â–¶
â– 
adsb_main.c — RTL-SDR capture setup
static void on_aircraft(void *user, const adsb_aircraft *aircraft){
printf("\n>>>AIRCRAFT DETECTED: %06X <<<\n", aircraft->icao);
}
static void on_aircraft_update(void *user, const adsb_aircraft *aircraft, uint32_t changed){
printf("AIRCRAFT %06X MOVED: %.4f, %.4f\n", aircraft->icao, aircraft->lat, aircraft->lon);
}
static void on_aircraft_lost(void *user, uint32_t icao){
printf("AIRCRAFT LOST: %06X xxx\n", icao);
}
static void on_samples(unsigned char *buf, uint32_t len, void *user){
adsb_error_t err = adsb_push_samples(g_ctx, buf, len, g_clk.now_ms);
}
int main(void)
{
rtlsdr_open(&g_dev, 0);
rtlsdr_set_center_freq(g_dev, ADSB_FREQ_HZ);
rtlsdr_set_agc_mode(g_dev, 0);
rtlsdr_set_tuner_gain_mode(g_dev, 1);
adsb_config cfg;
adsb_config_default(&cfg);
cfg.max_aircraft = 100;
cfg.accept_surveillance = true;
cfg.sample_rate_hz = ADSB_SAMPLE_RATE_HZ;
cfg.format = ADSB_FMT_CU8;
cfg.use_magnitude_table = true;
cfg.stale_ms = ADSB_DEFAULT_STALE_MS;
cfg.timeout_ms = 30u * 60u * 1000u; /* 30 minutes */
cfg.max_bit_fixes = 2;
// Callbacks
adsb_callbacks cb = {0};
cb.on_new = on_aircraft;
cb.on_update = on_aircraft_update;
cb.on_lost = on_aircraft_lost;
size_t mem_req = adsb_required_memory(&cfg);
void *arena = malloc(mem_req);
adsb_init(&g_ctx, &cfg, &cb, arena, mem_req);
rtlsdr_read_async(g_dev, on_samples, NULL, 0, RTLSDR_BUF_LEN);
rtlsdr_close(g_dev);
free(arena);
return 0;
}

Figure 5 - Library Example Truncated

Notice how the on_sample function callback is RTL-SDR library callback that feeds the statemachine with push_samples. The other callbacks fired if the statemachine makes detections.

Tracking 12 Aircraft ----------------------------------------------------------------------------------------------------------- ICAO Callsign Squawk Alt(ft) Spd(kt) Hdg(deg) VR(fpm) Lat Lon Msgs Sig(dBFS) ----------------------------------------------------------------------------------------------------------- 8681BE SKY009 7371 18075 399.6 285.5 2176 35.61288 139.35579 149 -32 weak 71BA10 ABL163 3221 27875 408.7 275.2 1088 35.88258 139.42898 261 -32 weak 71C759 ESR606 3151 23075 394.9 284.7 1536 35.90309 139.66805 400 -31 weak 782243 CES272 6145 27375 387.2 248.8 1408 35.41415 139.68733 219 -32 weak 8623D6 ??? 1200 2150 ------ ------- ------- --- --- 617 -27 weak 8516E9 ??? 1200 2250 ------ ------- ------- --- --- 90 -28 weak 84B5EE ??? 2107 18575 380.3 272.4 2112 35.49765 139.18224 25 -33 weak 846BFA ??? 0450 8825 277.2 232.2 2560 35.41187 139.87238 7 -32 weak 846910 ??? 2341 13100 371.3 252.4 2048 35.34530 139.73990 40 -33 weak 861E92 ??? ---- 19575 446.5 9.8 2496 --- --- 8 -32 weak 71BF30 ??? ---- ------- ------ ------- ------- --- --- 1 -31 weak 861B64 ??? 0410 10750 335.4 357.1 1664 --- --- 7 -32 weak ----------------------------------------------------------------------------------------------------------- stats: samples=257949696 preambles=1952 frames_ok=962 frames_bad_crc=139 bits_repaired=138 phase_retries=5 pos_ok=65 pos_rejected=0 aircraft_created=3 aircraft_expired=0 noise_floor=257 --- AIRCRAFT 71C569 MOVED: 35.8495, 139.6258 --- AIRCRAFT 71C569 MOVED: 35.8495, 139.6258 --- AIRCRAFT 71C569 MOVED: 35.8495, 139.6258 --- RADIKANT ADS-B LIVE FEED (RTL-SDR, 1090 MHz) ---

Figure 6 - Library Example Truncated

A typical terminal output, recordered in Tokyo

Testing

FM%20Radio%20Analasysis%20

Figure 4 - Tuning the Antenna

Custom HTML here.