0 KA9Q‐Radio Setup Notes
Mark Jessop edytuje tę stronę 2024-11-12 07:24:42 +10:30

Last updated: 2024-11-09

ka9q-radio is a very high performance multi-channel SDR server and demodulator, written by Phil Karn, KA9Q. Use of ka9q-radio allows auto_rx to monitor the entire available bandwidth of a SDR, and decode all radiosonde signals detected within that bandwidth. It uses much less CPU than SpyServer, allowing a RPi4 to monitor the entire available bandwidth (8 MHz) of an Airspy R2!

Note: The ka9q-radio repository is changing rapidly, and updates may break compatibility with auto_rx. The latest known-working ka9q-radio commit is: 770f988955a0dfb380b71d4cf58529cc6f824e67 Please ensure you follow the setup instructions below carefully to obtain the correct commit.

Note: These instructions assume you already have some familiarity with configuring radiosonde_auto_rx. We recommend you start off with a basic single-RTLSDR setup as per the regular guide before trying this.

Acknowledgements

Big thanks to the following people for making this possible:

  • Phil Karn KA9Q for developing this marvellous software, enabling a high performance, open source networked SDR server.
  • Andrew Koenig and Clayton Smith for adding spectrum support, doing lots of small fixes, and helping test everything!

1. Hardware Requirements

At this stage, we're assuming you've probably already got an auto_rx station, and are looking to upgrade to a more capable receive system. If not, go check out the main guide for information on antennas, filtering, etc...

Host Computer

Known-working platforms include:

  • Raspberry Pi 4 (use Raspbian 64-bit)
  • Raspberry Pi 5 (use Raspbian 64-bit)
  • Zimaboard 432 (Intel Celeron N3450)
  • Most likely any old Intel machine (multi-core Celeron, i3, i5) you have lying around will handle this.

Receiver Hardware

We currently only support connecting to a single ka9q-radio server, so you need to be able to cover your entire frequency range of interest with a single SDR.

  • Airspy R2 - will cover the entire 400-406 MHz radiosonde band with one SDR. Suitable for use in Europe or countries where the entire 400-406 MHz range is utilised.
  • Airspy Mini - will cover 5 MHz of the band (so close!) with one SDR. Suitable for use in areas where only a portion of the band is used (e.g. Australia, where only 400-403 MHz is used).
  • SDRPlay RSP1A - not officially supported in ka9q-radio, but available in a fork. Will cover the entire 400-406 MHz band with one SDR.

Note that RTLSDR support is currently somewhat broken in ka9q-radio.

2. Software Installation

For this section, we assume you've already got a Raspbian or Debian-based system ready to go.

2.1. Installation of ka9q-radio

These instructions are based on: https://github.com/ka9q/ka9q-radio/blob/main/docs/INSTALL.md

Install package dependencies using:

sudo apt install avahi-utils build-essential make gcc libairspy-dev libairspyhf-dev libavahi-client-dev libbsd-dev libfftw3-dev libhackrf-dev libiniparser-dev libncurses5-dev libopus-dev librtlsdr-dev libusb-1.0-0-dev libusb-dev portaudio19-dev libasound2-dev uuid-dev rsync time git

Clone the ka9q-radio repository, and checkout the latest known-working commit:

git clone https://github.com/ka9q/ka9q-radio.git
cd ka9q-radio
git checkout 770f988955a0dfb380b71d4cf58529cc6f824e67
make -f Makefile.linux 
sudo make -f Makefile.linux install

Add your user to the radio group. This allows you to edit the contents of /etc/radio (where the ka9q-radio configuration files will live) without root.

sudo usermod -aG radio $(whoami)

FFTW Wisdom file generation (Reference: ka9q-radio/docs/FFTW3.md)

This needs to be run to ensure the FFT calculations used in ka9q-radio are run as optimally as possible.

This can take many hours to run, so set the fftwf-wisdom command going and come back in a few hours. Best to run this overnight.

cd /etc/fftw/
# For Airspy R2, run:
time sudo fftwf-wisdom -v -T 1 -o nwisdom rof500000 cob2400 cob1250 cob1202 cob1200
# For Airspy Mini, run:
time sudo fftwf-wisdom -v -T 1 -o nwisdom rof300000 cob2400 cob1250 cob1202 cob1200
# For SDRPlay, run:
# TODO!!!!!!
# Then, run:
ls -l nwisdom wisdomf 
# If wisdomf doesn't exists, then just copy nwisdom to it. If wisdomf exists, check that nwisdom is larger than it before copying over it.
cp -i nwisdom wisdomf

2.2. KA9Q-Radio Configuration

Refer the sections below for configuration settings for a range of known-working setups.

Create a file at the path specified (e.g. /etc/radio/radiod@airspy-autorx.conf ) and add in the content below.

Airspy R2

An Airspy R2 can provide approximately 8 MHz of usable receive bandwidth, and with KA9Q is operated in 'real' mode at 20 MHz.

We need to set the frequency in the ka9q-radio configuration to at least 600 kHz above the highest frequency of interest. E.g. to observe 400-406 MHz, set the frequency to 407 MHz.

Refer to the ka9q-radio documentation for details on Airspy-specific configuration options.

ka9q-radio - /etc/radio/radiod@airspy-autorx.conf

[global]
hardware = airspy
mode = fm
status = sonde.local
iface = lo
ttl = 0  
data = sonde-pcm.local

[airspy]
device = airspy
description = "auto_rx"
# The airspy frequency must be set at least 600 kHz above the highest frequency we wish to observe.
# Since the Airspy R2 can easily cover 8 MHz, we can just set this to 407 MHz to cover the 400-406 MHz
# radiosonde band.
frequency = 407m0
# If required, you can enable a bias-tee output to power a preamplifier.
#bias = true
# By default, KA9Q-Radio will use its own AGC to optimize the SDRs gain settings. If you want to set a 
# fixed gain setting, you can do so by uncommenting the line below, and setting a gain value between 0 and 21,
# which corresponds to the Airspy's 'linearity' gain settings.
#gainstep = 17

[telemetry]
freq = "401m50"

[manual-400]
freq = 0
ttl = 0

Enable using:

sudo systemctl enable radiod@airspy-autorx
sudo systemctl start radiod@airspy-autorx

Airspy Mini

An Airspy Mini can provide approximately 5 MHz of usable receive bandwidth, and with KA9Q is operated in 'real' mode at 12 MHz.

As with the Airspy R2, we need to set the frequency in the ka9q-radio configuration to ~600 kHz above the highest frequency of interest. E.g. to observe 400-405 MHz, set the frequency to 405.6 MHz.

Refer to the ka9q-radio documentation for details on Airspy-specific configuration options.

ka9q-radio - /etc/radio/radiod@airspymini-autorx.conf

[global]
hardware = airspy
mode = fm
status = sonde.local
iface = lo
ttl = 0  
data = sonde-pcm.local

[airspy]
device = airspy
description = "auto_rx"
# The airspy frequency must be set at least 600 kHz above the highest frequency we wish to observe.
# As the Airspy Mini can only observe ~5 MHz of spectrum at once, we can set this to either
# 405.6 MHz (405m6, to cover 400-405 MHz) or 406.6 MHz (406m6, to cover 401-405 MHz) depending on where sondes are prevalent in your local area.
frequency = 405m6
# If required, you can enable a bias-tee output to power a preamplifier.
#bias = true
# By default, KA9Q-Radio will use its own AGC to optimize the SDRs gain settings. If you want to set a 
# fixed gain setting, you can do so by uncommenting the line below, and setting a gain value between 0 and 21,
# which corresponds to the Airspy's 'linearity' gain settings.
#gainstep = 17

[telemetry]
freq = "401m50"

[manual-400]
freq = 0
ttl = 0

Enable using:

sudo systemctl enable radiod@airspymini-autorx
sudo systemctl start radiod@airspymini-autorx

SDRPlay

The SDRPlay implementation uses Franco Venturi's fork of KA9Q-Radio. This has been tested on a Pi 5 with an RSP1B. Note that SDRPlay support is not present in the main KA9Q-Radio repository, and will likely never be due to the closed-source driver.

ka9q-radio - /etc/radio/radiod@sdrplay-autorx.conf

[global]
status = sonde.local
hardware = sdrplay
mode = iq
#iface = lo
ttl = 0
verbose = 1
fft-threads = 4
data = sonde-pcm.local

[sdrplay]
device = sdrplay
description = RSP1B
samprate = 10000000
# LNA Gain reduction
# See SDRplay API docs or ka9q-radio sdrplay.c for LNA attenuator values
rf-gr = 0

# Min value 20, gain lowers as value increases
# Use this OR if-agc 
#if-att = 20

# Set this to 1 to enable IF AGC (preferred)
# Use this OR if-att
if-agc = 1
if-agc-rate = 0
if-agc-setpoint-dbfs = -10
if-agc-attack-ms = 10
if-agc-decay-ms = 500
if-agc-decay-delay-ms = 200
if-agc-decay-threshold-db = 5

# Frequency in Hz
# 402.44MHz chosen to place intermod product from 28.8MHz USB clock above 406MHz
frequency = 402440000

Enable using:

sudo systemctl enable radiod@sdrplay-autorx
sudo systemctl start radiod@sdrplay-autorx

Testing ka9q-radio

It should be possible to check ka9q-radio is running using:

control sonde.local

It'll probably ask you for a SSRC (channel ID). (Is this the best way? It would be good to just see some IF stats?)

ka9q-radio may also suggest that you run certain optimizations for the FFT library depending on sample rates that are unique to your configuration. Check the logs using journalctl and follow any fftw instructions mentioned.

journalctl -f -n 100 -u radiod@{your instance}

2.3. radiosonde_auto_rx Setup and Configuration

radiosonde_auto_rx can be setup as per the usual setup guides, either using 'native' or 'docker' approaches. Note that when running via docker some additional arguments must be used when starting up the container (see further below)

radiosonde_auto_rx's station.cfg file must be configured to communicate with the KA9Q-radio server - see below for a list of parameters to modify. Find these within your station.cfg file and update accordingly.

[sdr]
sdr_type = KA9Q
# Note - More than 10 channels should be quite achievable, but is pretty unlikely to be required in practice. 
sdr_quantity = 10
sdr_hostname = sonde.local
# Note - port is unused for ka9q-radio.
sdr_port = 5555

[search_params]
# NOTE: These frequencies must not exceed the available range of the KA9Q server's SDR, otherwise odd behaviour may occur.
# For an Airspy R2, we can cover the entire radiosonde band, so using a min of 400.05 and a max of 406.0 is fine.
# For an Airspy Mini, you will need to adjust these values to fit within the available range you have configured in ka9q-radio
#  e.g. 400.05 to 405.0 MHz
min_freq = 400.05
max_freq = 406.0

radiosonde_auto_rx docker startup

Note that if you are using docker, some lines (the dbus and ahavi lines) need to be added to the docker start command:

docker run \
  -d \
  --name radiosonde_auto_rx \
  --restart="always" \
  --device=/dev/bus/usb \
  --network=host \
  -v ~/radiosonde_auto_rx/station.cfg:/opt/auto_rx/station.cfg:ro \
  -v ~/radiosonde_auto_rx/log/:/opt/auto_rx/log/ \
  -v /var/run/dbus:/var/run/dbus \
  -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \
  ghcr.io/projecthorus/radiosonde_auto_rx:testing

Warning - we have had reports that this startup approach doesn't work on Debian 12, with connections to ka9q-server timing out. It has been confirmed to work under Ubuntu 22.04 and Raspbian bookworm.