raspi-pico-aprs-tnc/README.md

128 wiersze
6.0 KiB
Markdown

2021-08-03 08:15:36 +00:00
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/eleccoder/raspi-pico-aprs-tnc">
2021-08-03 08:14:56 +00:00
2021-07-29 14:30:34 +00:00
# raspi-pico-aprs-tnc
2024-01-09 20:40:34 +00:00
A TX-only [TNC](https://en.wikipedia.org/wiki/Terminal_node_controller) (Terminal Node Controller) to generate the [AFSK](https://en.wikipedia.org/wiki/Frequency-shift_keying#Audio_FSK) (Audio Frequency-Shift Keying) audio tones for [APRS](https://en.wikipedia.org/wiki/Automatic_Packet_Reporting_System) (Automatic Packet Reporting System) messages using a [RP2040](https://en.wikipedia.org/wiki/RP2040) microcontroller on a [Raspberry Pi Pico](https://en.wikipedia.org/wiki/Raspberry_Pi#Raspberry_Pi_Pico) board.
2021-08-01 10:22:37 +00:00
2022-11-18 16:49:54 +00:00
![Signal Flow](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/img/signal_flow.png)
2022-11-18 16:53:14 +00:00
Block diagram showing the signal flow
2022-11-18 16:49:54 +00:00
2021-11-14 20:14:57 +00:00
An analog line-out audio signal will be generated by a band-pass filter connected to GPIO-pin 'GP0' which provides the binary PWM signal. You can probe it by a scope, listen to it by using an audio amp, or connect it to any RF transceiver to send it on the air (ham radio license required).
2021-07-29 14:35:37 +00:00
2021-08-02 21:29:34 +00:00
![AFSK scope screenshot](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/img/afsk_scope.png)
2021-08-01 15:32:05 +00:00
2021-08-03 08:05:40 +00:00
Image: Line-out signal (see [below](#Hardware)) probed by a DSO. We clearly see the 1200 Hz and 2200 Hz tones of the 1200 Bd 2-AFSK.
2021-08-01 19:51:42 +00:00
Both a static library `libaprs_pico.a` and a demo application will be generated by the build.
2021-08-01 15:18:36 +00:00
2021-08-01 15:31:05 +00:00
2021-08-03 20:54:20 +00:00
## Prerequisites
2021-07-31 23:01:17 +00:00
2021-08-01 19:51:42 +00:00
Your host platform for cross-compilation is assumed to be LINUX.
2021-07-31 23:01:17 +00:00
2021-08-01 15:31:05 +00:00
1. Install the Pico-SDK following the instructions given in the [Raspberry Pi 'Getting Started' Guide](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) (pdf)
1. Set the `PICO_SDK_PATH` environment variable to point to your Pico-SDK installation directory
2021-08-31 10:49:59 +00:00
1. Install the [pico-extras](https://github.com/raspberrypi/pico-extras) libraries:
```
cd $PICO_SDK_PATH/..
git clone -b master https://github.com/raspberrypi/pico-extras.git
cd pico-extras
git submodule update --init
2021-08-31 10:49:59 +00:00
```
2021-08-01 15:18:36 +00:00
2021-07-31 23:01:17 +00:00
## Hardware
2021-08-02 21:29:34 +00:00
We just need a simple band-pass filter to extract the analog AFSK-signal from the binary PWM signal:
2021-08-01 10:22:37 +00:00
2021-08-02 14:52:00 +00:00
![band-pass filter](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/img/band_pass_filter.png)
2021-07-31 23:01:17 +00:00
2021-08-02 21:29:34 +00:00
The line-out voltage can be as high as 2.7 V<sub>pp</sub> (~1 V<sub>rms</sub>) (at full-scale volume setting in the software and high-impedance load).
## Build the library and the 'beacon' demo application
2021-08-01 10:22:37 +00:00
2022-12-28 16:49:32 +00:00
NOTE: In case you want to allow the Pico to control the PTT (*Push-To-Talk*) input of your transmitter, set the appropriate `#define` parameters in `src/aprs_pico_beacon_demo.c`.
2021-07-31 23:01:17 +00:00
```
2021-08-04 17:47:20 +00:00
git clone https://github.com/eleccoder/raspi-pico-aprs-tnc.git
cd raspi-pico-aprs-tnc
2021-07-31 23:01:17 +00:00
cmake -S . -B build
cmake --build build
```
`build/lib/libaprs_pico.a` and `build/aprs_pico_beacon_demo[.uf2|.elf|.bin|.hex]` will be generated, as well as the testing application `build/aprs_pico_tone_test[.uf2|.elf|.bin|.hex]`.
2021-08-01 15:18:36 +00:00
## Run the 'beacon' demo application
2021-08-01 10:22:37 +00:00
2022-12-28 16:49:32 +00:00
The analog AFSK audio signal will be available at the filter's line-out. You can probe it by a scope, listen to it by using an audio amp, or connect it to any RF transceiver to send it on the air (ham radio license required).
But for testing the signal integrity, you can feed the signal into the soundcard of your computer and let decode its data content by [Dire Wolf](https://github.com/wb2osz/direwolf) - see down below.
2022-12-28 13:16:17 +00:00
2022-12-23 20:20:33 +00:00
### Flash the Pico
2021-07-31 23:01:17 +00:00
```
cd build
```
2022-12-28 16:49:32 +00:00
Flash `aprs_pico_beacon_demo[.uf2|.elf|.bin|.hex]` to the Pico board as you're usually doing.
2022-12-28 13:16:17 +00:00
2021-07-31 23:01:17 +00:00
2022-12-23 20:20:33 +00:00
### Test the 'beacon' demo application using *Dire Wolf* (on LINUX)
2022-12-21 21:35:41 +00:00
We can use the famous [Dire Wolf](https://github.com/wb2osz/direwolf) CLI software to decode the APRS data after sampling our APRS audio signal by means of a soundcard.
1. Connect the line-out of our circuit above to the microphone input of your soundcard of your (ALSA-supported) LINUX system.
2022-12-28 13:16:17 +00:00
2. Check if you can hear the typical APRS 'modem-sound' on your audio output device by monitoring the input signal (44.1 kHz, mono, WAVE):
2022-12-21 21:35:41 +00:00
```
2022-12-28 13:16:17 +00:00
arecord -f cd -c 1 - | aplay
2022-12-21 21:35:41 +00:00
```
3. Install [Dire Wolf](https://github.com/wb2osz/direwolf) on your system. Probably, you just have to run:
```
sudo apt install direwolf
```
2022-12-28 13:16:17 +00:00
4. Let's sample the APRS audio signal fed to the soundcard and forward the audio stream to *Dire Wolf* (44.1 kHz, mono, WAVE):
2022-12-21 21:35:41 +00:00
```
2022-12-23 20:20:33 +00:00
arecord -f cd -c 1 - | direwolf -
2022-12-21 21:35:41 +00:00
```
5. Enjoy the decoded APRS message:
![Decoded APRS message by Dire Wolf](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/img/direwolf_decoding.png)
2022-12-23 20:20:33 +00:00
### Audio file of the 'beacon' demo
2022-12-28 13:16:17 +00:00
Here is a [recorded audio wav-file](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/aprs_pico_beacon_demo.wav) (44.1 kHz, mono, WAVE) captured by the soundcard using:
```
arecord -f cd -c 1 > aprs_pico_beacon_demo.wav
```
2022-12-23 20:20:33 +00:00
You can replay and decode this file by:
```
cat aprs_pico_beacon_demo.wav | direwolf -
```
2022-12-28 18:57:20 +00:00
## Going on the air: RF-transmission with the *Baofeng UV-5* HT
2022-12-28 18:53:53 +00:00
2022-12-28 18:57:20 +00:00
If you actually want to RF-transmit the APRS signal, you can simply do it by one of the many cheap HTs, like the *Baofeng UV-5*. The complete schematic including PTT control looks like this:
2022-12-28 18:53:53 +00:00
![APRS-Pico with Baofeng_UV-5](https://github.com/eleccoder/raspi-pico-aprs-tnc/blob/main/doc/img/APRS_Pico_with_Baofeng_UV-5R.png)
2022-12-28 18:57:20 +00:00
Don't forget to set the appropriate `#define` parameters in `src/aprs_pico_beacon_demo.c` to configure PTT control.
2022-12-28 18:53:53 +00:00
2024-01-09 20:43:19 +00:00
## TODO
2021-07-31 23:01:17 +00:00
- [x] Send the APRS message on the console (USB or UART) rather than hard-coding
2021-08-01 15:18:36 +00:00
2021-08-01 19:51:42 +00:00
## Ingredients / Acknowledgements
2021-08-01 11:03:25 +00:00
2024-01-09 20:43:19 +00:00
- For `APRS Payload => AX.25 => AFSK (PCM)` conversion I'm using [my modified version](https://github.com/eleccoder/ax25-aprs-lib) of [fsphil's ax25beacon](https://github.com/fsphil/ax25beacon) project.
- For `PCM => PWM` conversion I'm using the `pico_audio_pwm` library from [pico-extras](https://github.com/raspberrypi/pico-extras) (NOTE: ATTOW, maturity seems to be rather alpha/beta).
- Basic PWM audio rendering with the Pi Pico has been spotted in the [pico-playground](https://github.com/raspberrypi/pico-playground/tree/master/audio).