Amateur radio contesting time-lapse map

Mapping geocoded  contest log data using node.js and openlayers.

The goal was to make something that looks like the Reverse Beacon Network map, only for contest log files. I use RBN for testing antennas now. That map display gives you a pretty good idea of your actual antenna pattern.

Code is written in node.js (javascript) and html.

Part 1: Read a Cabrillo log file containing QSO: records. Look up each callsign, get latitude and longitude, and rewrite the file as json data, tagged with geo coordinates. I originally tried getting the data from hamQTH but it was not current, so ended up using the qrz.com xml callsign lookup. For callsigns “not found” I used the qrz.com dxcc prefix lookup to get general coordinates for the country. There are still a few bad/missing data issues to resolve. Like European stations with coordinates at the South Pole.

Part 2: Tried various mapping frameworks – like leaflet, arcgis, and openlayers. Wanted to use a great-circle projection (azimuthal equidistant) like the big ARRL world map. And may still figure this out. But working with map projections and coordinate transforms is way worse than doing a Smith Chart.  I ended up hacking a flight tracking example from openlayers.org and basically replacing airplanes with QSO’s. That is why the lines are animated from source to destination.  Also added a layer for day/night, and QSO/time status display.

It probably makes sense to get rid of the flight animation and just display the entire path in sync with the QSO data – with color code for each band (K1KP) – and speed control on the time lapse, etc., So you can get a better sense of rate and propagation.

It would be cool to have a website where you could upload a log file and generate maps.

Note: this project is not yet available

Files

local files:

generating data:

internetsensors/cabrillomap

put the cabrillo data in testdata.cbr (use QSO: records only for now) should be sorted chronologically.

run:  node index.js

the output file will be: geocab.json (which is used as input to the mapping program)

mapping

internetsensors/oltest

main.js = node source with ol mapping and data processing

index.html = web page for map

geocab.json = geocoded cabrillo json test data

to run, type: npm start

Then open: http://localhost:5173/ in a browser

Additional work / current issues

Some of the qrz.com callsign data has bad geo coordinates. In particular some of the records show a latitude of -89 and longitute -179 – need to check for these numbers and replace with dxcc coordinates.

There should be an argument on the node program to pass in the datafile. Also the program should clean up any non QSO: records, like the file header info and any X-QSO recs.

Also need to clean up the async/await stuff – currently there are several methods for handling state transitions.

mapping ideas:

As mentioned above, its probably a good idea to make a version of the code without the flight animation, and have various controls to stop/start the data playback to look at individual qso’s do speed control, etc.,

azimuthal equidistant projection: there are some links to examples in leaflet, and arcgis to handle complex projections. In documents, look at:  “map links for projection stuff.txt”

leaflet test version:

in the internetsensors/cabrillomap folder there’s a test file: cbworld1.html that works using websockets when you run the index.js file to generate test data. It uses a leaflet map, but the lines don’t adapt to great circle polar paths.

arcgis

I believe the arcgis examples are in internetsensors/projected geometries

And: internetsensors/pe-gs-projection

The former is a a very nice world projection with some point markers. The latter is an example that shows how to switch out various projections in realtime.

11 Km feedback delay

Using 40 meter SSB, Max/MSP, and Websdr to build a feedback delay from Maine to the Netherlands.

A Max patch plays an audio file into the transmitter in Maine. Then, using a websdr receiver in the Netherlands, the received signal is amplified and mixed back into the audio to be retransmitted. Effectively creating a feedback delay line.

Here is an example of what it sounds like on 40 meters.

http://www.pr0jex.com/longdelayline.mp3

This is the Max patch

The audio from Websdr is routed to the input of Max by creating a multi-output device (In Audio Midi Setup) combining “Blackhole 2ch” and external headphone output (for monitoring). The audio output of Max is assigned to the transmitter SSB input.

Patch not yet available. Local version is in max teaching examples.

Max/MSP text to Morse code generator

work in progress. not published.

I needed a text to morse code generator in Max for the Twitter streaming map project. There was an ancient one that used [mxj] but its kind of a pain to use that object. I thought it can’t be that difficult to write one? I didn’t really have any idea where to start. Something about the blank Max patch causes brain activity? I went through about 5 different approaches. Eventually came up with this pattern thing, from thinking about the lighted buttons on the tr-808 drum machine.

For example, the letter A is . _ (dot dash)

morse code has rules for spacing:

dot = 1
space between tones = 1
dash = 3
space between letters = 3
space between words = 7

If you think of a drum machine pattern, the pattern for letter A would be: 1 0 1 1 1 0 0 0  (with the 3 trailing 0’s for letter spacing)

I made a [coll] with all the letter patterns indexed by ascii codes.

Then just concatenate letter patterns, for a given block of text,  together into one big list and run it through [zl.nth] clocked by a [metro] and [counter]. the ones and zero’s turn an oscillator on and off.

local file: tkzic/internetsensors/twitter-stream2/morse5.maxpat

Hamlib C programming example on Mac OS

Hamlib provides a standardized computer interface for amateur radios.

I was able to get it to run in a C program on Mac OS Ventura.

Instructions

Install Hamlib using homebrew. ie,., brew install hamlib.

Download this sample C test code – testrig.c – from https://hamlib.sourceforge.net/manuals/1.2.15/_2tests_2testrig_8c-example.html or https://github.com/Hamlib/Hamlib/blob/master/tests/testrig.c

Change the SERIAL_PORT constant to the actual port name. Change the baud rate.

Lookup the hamlib code for your radio. https://github.com/Hamlib/Hamlib/wiki/Supported-Radios

For example, for the Elecraft K3, the code is 2043.

compile using this command:

gcc testrig.c -I /opt/homebrew/include -L /opt/homebrew/lib -l hamlib -o testrig

Type this to run the program:

./testrig 2043

Assuming 2043 is the rig number. If all is working, the program will set a bunch of stuff on your radio, changing frequency, mode, etc.,

Local files: tkzic/chatgpt/radio/ctest.c

notes: link to instructions for compiling hamlib manually: https://github.com/Hamlib/Hamlib/blob/master/README.osx

Using Web Serial API for Radio CAT interface

Work in progress…

An html example that sends and receives CAT commands with an Elecraft K4 connected to the serial port of the machine running the web browser.

The file was built using examples from this article by Francois Beaufort. https://developer.chrome.com/docs/capabilities/serial It’s an excellent resource for Web Serial.

The html file for this project is here: http://www.pr0jex.com/serial/index.html

But it won’t run from that server. It only runs locally.

Instructions

Download the index.html file from the link above. start a local web server, eg., “npx http-server” and enter the server address into a Chrome browser.

When you press connect, the browser will prompt you to select a serial port for the radio.  On my computer the K4 serial ports appear something like: cu2.usbserial-21100. There are 2 ports. Select either one.

Then press read. If you spin the dial on the K4, and it is autoinfo mode, you should see CAT commands in the read window.

enter a CAT command in the write window and press the write button. It is preloaded with “fa7;” which sets frequency to 7 MHz.

Press the disconnect button to end your session.

local files tkzic/webusb/serial2/index.html

 

Virtual serial port pairs in Mac OSx

I was unable to find any apps to create virtual serial ports for later versions of Mac OSx eg., Catalina.

There is a partial solution using the linux socat utility. It will create functioning vsp’s but the ports will not be detected by most apps, like Max/MSP.  I tried setting a symlink to files in /dev using tty. and cu. prefixes. eg., /dev/tty.x1. But apps that look for serial ports still couldn’t detect the vsp’s.

Instructions

  1. download and install socat using macports or brew. eg., “sudo port install socat”
  2. Disable SIP (system integrity protection). In Catalina, reboot holding cmd+r. Then type: “csrutil disable” into a terminal window. Reboot – Note: you probably don’t need to do this if you aren’t setting up a link in /dev – which so far doesn’t work anyway
  3. Run one of the following commands:

socat -d -d pty,raw,echo=0 pty,raw,echo=0

sudo socat -d -d pty,link=/dev/tty.x0,raw,echo=0,user=tkzic,group=staff pty,link=/dev/tty.x1,raw,echo=0,user=tkzic,group=staff

What works and what doesn’t

After setting up the ports, you can send data in one port and out the other, for example, type the following into 2 different terminal windows.

cat /dev/ttys004

echo “Hello World” > /dev/cu.x1

This works great. But, so far, using sym links – the ports don’t show up in any app that accesses serial ports. Still working on this…

Using socat you can also setup a serial/tcp pair – this may be a solution for some projects.

2021 WPX CW – TF/KA1IS

Amatuer radio station TF/KA1IS in Akureyri, Iceland – May 2021.

It is 1:52 AM: Sunset/Sunrise over Eyjafjörður.

  • Category: Single Operator, All Band, low power.
  • Claimed score: QSO’s: 882 Prefixes = 499 Total Score = 1,033,928 (34 hours).

Station:

  • Elecraft KX2
  • Elecraft KXPA100
  • 5 meter whip antenna with 4 elevated radials and loading coil for 40/80 meter bands

Building SoapySDR and CubicSDR with Linux

How to build SoapySDR and CubicSDR from source in Ubuntu 20.04

After unsuccessful attempts to compile SoapySDR and CubicSDR on Mac OS and Windows, I was able to get it running in Ubuntu 20.04.  The whole process took about 2 hours but could be done in less time if you know what you are doing.

It wasn’t really necessary to install CubicSDR to test SoapySDR. But CubicSDR is the only SoapySDR app that consistently works when it comes to devices, I/Q, files and TCP frequency control.

After completing this install I was also able to compile and run the SoapySDR example code here:  https://github.com/pothosware/SoapySDR/wiki/Cpp_API_Example

Build

There are excellent instructions at the CubicSDR wiki on github: https://github.com/cjcliffe/CubicSDR/wiki/Build-Linux

I also added the rtlsdr driver and the airspyhf driver. Instructions for rtlsdr are on the wiki. Instructions for airspyhf are below. You can add these drivers/libraries at any time, after SoapySDR is installed.

There were several missing libraries – described here.

hamlib

Hamlib is an option in CubicSDR. It was included because we’re using it to send frequency data to the devices via rigctld. You’ll need to install hamlib before you try to compile CubicSDR

Instructions and source code here: https://github.com/Hamlib/Hamlib

Instructions are somewhat vague. Here’s what I did.

Install libtool:

sudo apt install libtool

Clone the repository, build, and install:

git clone https://github.com/Hamlib/Hamlib.git
cd Hamlib
./bootstrap
./configure
make
sudo make install

airspyhf

airspyhf library code from Airspy. Instructions here: https://github.com/airspy/airspyhf

This is what I did, if I can remember correctly. You may need to install libusb, but if you have done all the stuff above you probably already have it.

git clone https://github.com/airspy/airspyhf
cd airspyhf
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON<
make
sudo make install
sudo ldconfig

SoapyAirspyHF

Now you can add the Soapy AirspyHF drivers. Instructions here:  https://github.com/pothosware/SoapyAirspyHF/wiki

git clone https://github.com/pothosware/SoapyAirspyHF.git
cd SoapyAirspyHF
mkdir build
cd build
cmake ..
make
sudo make install

 

Max8radio CubicSDR I/Q prototype

Another working prototype with Max and CubicSDR

Now working some better… The Max SDR patch is receiving an IQ audio stream at 96 KHz from CubicSDR and sending frequency data to rigctld daemon via a python script that recodes OSC to tcp data.

repository: https://github.com/tkzic/max8radio

Files:

max8sdr1.maxpat

py3rigctl2.py (python script)

Instructions:

Basically the same as instructions in the previous prototype here: https://reactivemusic.net/?p=19995

make sure to start the rigctl daemon before CubicSDR

 rigctld -m 1 4532 & 

And make sure there is some audio gain on CubicSDR

But… There is only one Max patch now and – after you start the rigcltd daemon, you need to run the python script in the max8radio folder like this:

python3 py3rigctl2.py

The most important thing is to start CubicSDR first before you run the Max patch. Make sure to get everything working correctly. Then start the Max SDR.

In CubicSDR make sure you only have one “modem” running – otherwise the IQ data stream will be a complete mess. Als0 make sure that the audio sample rate in CubicSDR is set to 96 KHz. It will revert to 48 KHz. everytime you load the program. You can use the ‘bookmarks’ from a previous CubicSDR session (lower left part of the screen) to load a previous session with the same parameters.

These are the necessary settings:

  • I/Q modem
  • Audio out: Existential Audio Inc. Blackhole 2 ch.
  • Audio sample rate: 96 KHz.
  • Rig Control Menu: enable rig and follow rig should be ‘checked’
  • Frequency should equal Center frequency and the V delta lock toggle should be on
  • Demodulator Gain level should be very low to prevent excess AGC (upper right corner)

Actually if you have loaded everything ok in a previous session, try this:

  • get the rigctld daemon running from the command
  • load CubicSDR
  • First thing: click ‘enable rig’ under rig control (this will probably load some crazy frequency like 145 Mhz
  • Then in the bookmarks (lower left) double click on your previous session, under ‘recents’ for example: 7007MHzI/Q – this should restore almost all the settings.
  • Then change the audio sample rate to 96 KHz if needed.
  • If the input to Max seems wrong, try clicking the S  (over near the top right)  to solo the modems. There may be more than one going.

Max settings

  • Set audio input to Blackhole 2ch @ 96 KHz. (to match output from CubicSDR
  • Click the ‘flip IQ’ toggle – for some reason CubicSDR sends out the I/Q signal flipped
  • The arrow key tuning and all other tuning methods should work now

Notes

One of the problems with CubicSDR is sometimes you’ll accidentally change something and all the settings go crazy.

note: I tried a new version of CubicSDR (2.6) from the sdrplay website. It would not detect any connected devices or audio drivers.

Once you get it working, the audio quality inside Max is excellent – using the Airspy HF+

Python3 tcp client for Max

Using OSC from [udpsend]

I needed a better way to send radio frequency data from Max to a rigcltd daemon (via tcp). This is the method of tuning SDR devices hosted by CubicSDR.

From the max8radio folder run:

py3rigctl2.py

The input is OSC frequency data, on port 8001, in the form: /F 7001000

(This would be for 7.001 MHz)

An OSC server in the python program listens for these messages and then reformats and sends them to a running rigctld daemon running in the background on port 4532

rigctld -m 1 4532 &

The frequency message going to rigctld would be in the format: F+ 7001000