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.

X API update

Attempts to use the X API (formerly Twitter) for projects with Max/MSP have been disappointing at best. Most of the API is behind a paywall now.  The cost is $5000 per month. to implement streaming API used in projects like this:  https://reactivemusic.net/?p=5786

The free tier only allows basic tweeting and user lookup. Search is not available.

I was able to find only one node example that actually worked in the free tier. By “Coding with Ado”. The code requests a token from X, and then you enter a timestamped pin number to continue. Making it worthless for programs and bots. https://youtu.be/G5ZW5j5cwHk?si=vbAtGa0bQ3T_tga9

A local copy of the source code for this is in tkzic/nodetweet3/index.js

Other options

Another option with X, is to use a service like Socialdata. https://socialdata.tools/

There service sits in the middle to handle X API calls. You are charged by the number of calls. It doesn’t offer streaming either, but you can simulate it by calling a search every few seconds.

Other social media options

There are API’s for other social sites like facebook, instagram, tiktok, etc.,

MBTA Boston train map

This post describes an update of a previous version. The old version can be found here: https://reactivemusic.net/?p=20329

Moving markers

In the previous version, all of the markers for each train line were deleted and redrawn in a group at the polling interval. In this version the train markers move to their new location when the data is polled.

The map is drawn using Leaflet. The moving marker library is from Ivan Sanchez https://www.npmjs.com/package/leaflet.marker.slideto

The project uses the MBTA JSON API, to query vehicle data for each train line. the geo coordinates of the trains are sent via websockets to the client map page.

This project is a work in progress and not available yet.

Files:

node server: internetsensors/mbtanode2/index.html

html map client: internetsensors/mbtanode2/mbtatrain2.html

Instructions

// to run, type node index.js at a command line.
// then open a web browser to: http://127.0.0.1:8124/
// type 'go' into the text box below the map, and press 'send' button
// in a few seconds the train markers will magically appear

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

Milford Graves Experiment

Milford Graves was one of my all time favorite musicians. His approach to percussion, and music generally, was unique in a way that defies explanation.

I sampled a bunch of clips of his drumming into Ableton live and then experimented with the Buffer Shuffler 2.0 device to see if I could randomize small slices, ie., several seconds each, of longer samples – without losing the “texture” of the original recordings.

Here is an example of what it sounds like:

This video shows a clip from David Murray’s “Real Deal” running through Buffer Shuffler using slices only about 2-3 seconds in length. The slicing rate is just arbitrary, since there is no warping or specific clock pulse.

Local files: tkzic/aardvark/milfordgraves1 project/milfordgraves1a.als

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.

MBTA API in Max

Sonification of Mass Ave buses, from Nubian to Harvard.

Updated for Max8 and Catalina

This patch requests data from MBTA API to get the current location of buses – using the Max js object. Latitude and Longitude data is mapped to oscillator pitch. Data is polled every 10 seconds, but it seems like the results might be more interesting to poll at a slower rate, because the updates don’t seem that frequent. And buses tend to stop a lot.

Original project link from 2014: https://reactivemusic.net/?p=17524

MBTA developer website: https://www.mbta.com/developers

This project uses version 3 of the API. There are quality issues with the realtime data. For example, there are bus stops not associated with the route. The direction_id and stop_sequence data from the buses is often wrong. Also, buses that are not in service are not removed from the vehicle list or indicated as such.

The patch uses a [multislider] object to graph the position of the buses along the route – but due to the data problems described above, the positions don’t always reflect the current latitude/longitude coordinates or the bus stop name.

download

https://github.com/tkzic/internet-sensors

folder: mbta

patches:

  • mbta.maxpat
  • mbta.js
  • poly-oscillator.maxpat
authentication

You will need  to replace the API key in the message object at the top of the patch with your own key. Or you can probably just remove it. The key distributed with the patch is fake. You can request your own developer API key from MBTA. It’s free.

instructions
  • Open mbta.maxpat
  • Open the Max console window so you can see what’s happening with the data
  • click on the yellow [getstops] message to get the current bus stop data
  • Toggle the metro (at the top of the patch) to start polling
  • Turn on the audio (click speaker icon) and turn up the gain

Note: there will be more buses running during rush hours in Boston.  Try experimenting with the polling rate and ramp length in the poly-oscillator patch. Also, you can experiment with the pitch range.

Soundcloud API in Max8

This post describes an updated project.

The earlier version can be found here  https://reactivemusic.net/?p=5413

This project is part of the internet-sensors project: https://reactivemusic.net/?p=5859

Note

2024/01/21: not working:

Soundcloud deleted my API credentials and is not accepting new requests. So there is really no point to using this project unless you have active credentials.

console.error() function crashes node. -fixed locally

Overview

In this patch, Max uses the Soundcloud API to search tracks and then select a result to download and play. It uses the node.js soundcloud-api-client https://github.com/iammordaty/soundcloud-api-client

For information on the soundcloud API http://developers.soundcloud.com/docs/api/reference

download

https://github.com/tkzic/internet-sensors

folder: soundcloud

files

main Max patch
  • sc.maxpat
node.js files
  • scnode.js

authorization

  • The Soundcloud client-id is embedded in scnode.js – you will need to edit this file to replace the worthless client-id with your own. To get a client ID you will first need a Soundcloud account. Then register an app at: http://soundcloud.com/you/apps

first time instructions

  • Open the Max patch: sc.maxpat
  • In the green panel, click on [script npm init]
  • In the green panel , click on [script install soundcloud-api-client]

instructions

  • Open the Max patch sc.maxpat
  • open the max.console window so you can see the API data
  • click [script start]
  • click the speaker icon to start audio
  • type something into the search box and press <enter> or click the button to the left to search for what is already in the box.
  • select a track from the result menu, wait for it to start playing