Pages

26/05/2018

Setting up an APRS Digipeater with an Orange Pi Zero, Direwolf, and a Tait 8105

Several members of my local club M0HSL are experimenting with APRS and Packet Radio, so I thought I'd dip my toes in the water. The most common method is to use a Hardware TNC device and a radio aimed at amateur use, but I like doing things in software where I can ( and I'm a cheapskate )

I have used Direwolf in the past with an RTL-SDR dongle to receive APRS traffic, so I thought I'd give it a go with a physical radio, a Tait 8105. Unfortunately it's a UHF model, but the setup and programming is identical between the UHF and VHF version.

To control the handle the audio and PTT, I am using a modified CM108 USB sound fob.






Programming the Tait 8105 for APRS use

The following assumes you have some experience with programming the Tait 8100 series radios, but the CPS is fairly self explanatory and includes an excellent help section. Use the following screenshots as a guide.

Channel Configuration

You will need to configure a channel on the radio for APRS, including the appropriate frequency, bandwidth and power. Rx / Tx Sig and Squelch can be ignored as we wont be using them. As I'm using a UHF radio for testing, I'm using 433.800MHz, but you should update this to 144.800MHz for VHF. As far as I know, there's little if any APRS traffic on UHF in the UK.


Channel Summary (Click to expand)

Channel Detailed View (Click to expand)

PTT Configuration

It's necessary to configure external PTT 1 to use audio supplied to the Tap In point on the back of the radio as its audio source:


Programmable I/O

The Tait 8100's have a very flexible programmable I/O for both control and audio. We need to expose the audio on the radio to the auxiliary connector on the rear, and be able to active the PTT. Direwolf recommends disabling squelch in order to be able to decode APRS packets reliably, so we tap the audio from a point before the squelch is applied.

Programmable IO - Audio (Click to expand)

Programmable IO - Digital (Click to expand)

Modifying the CM108 USB Fob

I've documented how to convert the CM108 USB Fob for use with a radio, in another blog post available here

Configuring the system 

Before getting started its necessary to remove and install some dependencies.

Preliminaries

Change to root:
sudo su

Remove pulseaudio:
apt-get remove pulseaudio*

Install dependencies:
apt-get install libasound2-dev automake libtool texinfo gawk screen

Tweaking the audio (Optional)

Whilst testing, I found the audio was a little low. Its rumoured the audio from the CM108B chip is lower than that of the original CM108, so I've added a 'preamplifier' to Linux's sound driver, ALSA. I'm not entirely sure if this is necessary or even works, and its especially important not to overdrive the audio when transmitting APRS, but here it is for posterity.


Edit asound.conf to add a preamp:
vim /etc/asound.conf

Add the following:
pcm.!default {
    type asym
    playback.pcm "plug:softvol"
    capture.pcm "plug:dsnoop"
}

pcm.softvol {
    type softvol
    slave.pcm "dmix"
    control { name "BOOST"; card 0; }
    max_dB 32.0
}

You should then be able to adjust the 'boost' using the following command:

amixer


Downloading and compiling hamlib

To get the latest and greatest hamlib, its necessary to compile it from the source. It's a slow process, but fairly straightforward.

Change directory, and download the source for hamlib:
cd /usr/src
git clone git://hamlib.git.sourceforge.net/gitroot/hamlib/hamlib

Then compile and install it by running each of the commands below sequentially. (Note, each make operation will take a long time. Now's a good time to grab a cup of tea):
cd hamlib
autoconf
./bootstrap
./configure
make
make check
make install

Downloading and compiling direwolf

Again, to get the latest and greatest version its necessary to compile it from source.

Download the source for direwolf, then compile and install it:
cd /usr/src
git clone https://www.github.com/wb2osz/direwolf
cd direwolf

Open the Makefile for editing:
vim Makefile.linux

Uncomment the following lines:
#CFLAGS += -DUSE_HAMLIB
#LDFLAGS += -lhamlib

Open .bashrc for editing:
vim ~/.bashrc

Add the following line:
export LD_LIBRARY_PATH=/usr/local/lib

Then reload it:
source ~/.bashrc

Then compile and install direwolf:
make
make install
make install-conf

Detecting  the CM108 'PTT'

The CM108 chip has several GPIOs intended for use with Volume buttons and status LEDs. The modified fob uses these GPIOs for signalling PTT and COS (Not used for APRS). Before we can use them, we need to detect the CM108.

First of all you will need to create a script to detect the device.

Change into your home directory and edit a file:
cd ~/
vim cm108-detect.sh

Add the following:
#!/bin/bash
# List the names for the HID raw devices.
# WB2OSZ, Feb. 2016
h=/sys/class/hidraw
for x in `ls $h`
do
         n=`grep HID_NAME $h/$x/device/uevent | gawk -F= '{ print $2 }'`
          echo /dev/$x $n
  done

Run it:
sh cm108-detect.sh

The script should add something like the following:
/dev/hidraw0 C-Media Electronics Inc. USB Audio Device

Testing the CM108

To test the PTT function on the PTT you need to operate two programs simultaneously. To do so, I use a program called https://www.gnu.org/software/screen/ that allows multiple 'windows' inside a linux terminal.

Start screen:
screen -S rigctl

Start rigctrld, using the correct path for your USB fob. For my system its /dev/hidraw0:
rigctld -p /dev/hidraw0 -P CM108 -vvvv -C ptt_bitnum=2

Press Ctrl + a + c to open a new screen window, then open rigctl:
rigctl -m 2

Switch the PTT on and off by entering T 1 and T2 respectively. Enter Q to exit. If you have a radio connected and another radio monitoring, you should hear the radio key up.
Rig command: T 1
PTT:
Rig command: T 0
PTT:
Rig command: q

To kill screen and the running processes, enter ctrl + a + \


Automating the  initialisation of the CM108 at boot

Lets create a script to automate this process:
vim /usr/local/bin/cm108-init

Enter the following:
#!/bin/bash
# Look for C-Media device and start up rigctld
# with option to use bit 2 for PTT.
# WB2OSZ, Feb. 2016
echo "Look for suitable device for PTT."
h=/sys/class/hidraw
d=""
for x in `ls $h`
do
 n=`grep HID_NAME $h/$x/device/uevent | gawk -F= '{ print $2 }'`
 echo " /dev/$x $n"
 if [[ "$n" =~ "C-Media" ]]
 then
 echo "Found suitable device /dev/$x"
 if [ ! -z "$d" ]
 then
 echo "WARNING! More than one found."
 fi
 d=/dev/$x
 fi
done
if [ -z "$d" ]
then
 echo "No suiable devices found for PTT."
 exit
fi
echo "Starting up rigctld with PTT on $d"
if [ `whoami` != root ]
then
 sudo chmod 666 $d
fi
# After it is working properly, you might want to take out –vvvv.
rigctld -p $d -P CM108 -vvvv -C ptt_bitnum=2

Create a systemd service file:
vim /lib/systemd/system/cm108-init.service

And enter the following:
[Unit]
Description=cm108-init Service
After=syslog.target network.target

[Service]
User=root
Environment=LD_LIBRARY_PATH=/usr/local/lib
ExecStart=/usr/local/bin/cm108-init > /tmp/cm108.log 2>&1 &
ExecStop=pkill rigctld

[Install]
WantedBy=multi-user.target

Make it executable:
chmod 755 /lib/systemd/system/cm108-init.service

Symlink it:
ln -s /lib/systemd/system/cm108-init.service \
/etc/systemd/system/cm108-init.service

Reload the service and enable the cm108-init service:
systemctl daemon-reload
systemctl enable cm108-init.service

Nows a good time to reboot:
sudo su

Once the Pi has rebooted, reconnect to the terminal.

Configuring Direwolf

Now create a config file for Direwolf:
vi /etc/direwolf.conf


Enter the following, editing the relevant sections to match your station and requirements:

#############################################################
#                                                           #
#               Configuration file for Dire Wolf            #
#                                                           #
#                   Linux version                           #
#                                                           #
#############################################################

# Consult the User Guide for more details on configuration options.

#############################################################
#                                                           #
#               FIRST AUDIO DEVICE PROPERTIES               #
#               (Channel 0 + 1 if in stereo)                #
#                                                           #
#############################################################

# You may need to update the "ADEVICE":

ADEVICE  plughw:0,0
ACHANNELS 1

#############################################################
#                                                           #
#               CHANNEL 0 PROPERTIES                        #
#                                                           #
#############################################################

# You will need to update your call sign, and potentially your PTT configuration

CHANNEL 0
MYCALL 2E0SIP-1
MODEM 1200
PTT RIG 2 localhost

#############################################################
#                                                           #
#               BEACONING PROPERTIES                        #
#                                                           #
#############################################################

# The following will beacon a location over RF every 30 minutes. You should edit your location, comment etc

PBEACON delay=1 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W power=50 height=20 gain=4 comment="Chelmsford MA" via=WIDE1-1,WIDE2-1

#############################################################
#                                                           #
#               DIGIPEATER PROPERTIES                       #
#                                                           #
#############################################################

# The following will digipeat packets recieved via RF back over RF. You should study the documentation and ensure you're using a suitable path.

DIGIPEAT 0 0 ^WIDE[3-7]-[1-7]$|^TEST$ ^WIDE[12]-[12]$ TRACE

#############################################################
#                                                           #
#               INTERNET GATEWAY                            #
#                                                           #
#############################################################

# Configuring the below section will relay APRS packets recieved over APRS to APRS-IS, so they will display on sites such as http://aprs.fi

# First you need to specify the name of a Tier 2 server.
# The current preferred way is to use one of these regional rotate addresses:

# noam.aprs2.net   - for North America
# soam.aprs2.net  - for South America
# euro.aprs2.net  - for Europe and Africa
# asia.aprs2.net   - for Asia
# aunz.aprs2.net  - for Oceania

# IGSERVER noam.aprs2.net

# You also need to specify your login name and passcode.
# Contact the author if you can't figure out how to generate the passcode.
 
# IGLOGIN WB2OSZ-5 123456

# Some might want to send an IGate client position directly to a server
# without sending it over the air and relying on someone else to
# forward it to an IGate server.  This is done by using sendto=IG rather
# than a radio channel number. Overlay R for receive only, T for two way.
# Remember to update the latitude and longitude etc.

#PBEACON sendto=IG delay=0:30 every=60:00 symbol="igate" overlay=R lat=42^37.14N long=071^20.83W
#PBEACON sendto=IG delay=0:30 every=60:00 symbol="igate" overlay=T lat=42^37.14N long=071^20.83W

Acknowledgments 

  • WB2OSZ - Direwolf Author, most of the above is from the excellent documentation they supply alongside Direwolf itself. 

1 comment:

  1. A lot of people will find this very helpful but it could use a little updating.
    Direwolf now has CM108/CM119 GPIO PTT built in so you don't need the complexity of hamlib.
    All you need to do is add "PTT CM108" to your configuration file and the rest is automatic.

    ReplyDelete