Soundmodem update

So I had some initial success with the Raspberry Pi and using soundmodem as a software TNC for APRS packet radio. The success seems to have been short-lived.

I am able to decode packets from test wave files that I’ve been using, but the APRS over the air does not appear to be working! For a short period of time, I was able to decode APRS packets with little problems, and then when I moved the Pi to a more convenient location on my work bench (requiring a power-cycle) everything stopped working.

No Pi for you!

No Pi for you!

Troubleshooting is what I do for a living, so I’ve been through all of the standard check-lists – I’ve even verified drive levels, etc. and have been left without any success! What really gets me is that even with a full-fledged computer which has MIPS to spare, I am no longer able to decode any real-world packets.

I’ll be scoping the AFSK output of the radio to check the “flatness” of the 1200 and 2200Hz tones (they should be of similar amplitude, ideally). If the AFSK signal turns out to be okay, I’ll really be confused ..

Well, fingers crossed for now …

Posted in General, Operating | Tagged , , | Leave a comment

Raspberry Pi & Soundmodem – It works!!

It is a bout time for an update on my Raspberry Pi APRS project.

and a messy desk!

Two raspberry pi computers, a 32″ display, and a messy desk!

(Part 01)

Many months ago I was working on getting a Raspberry Pi working for APRS work. I was experiencing a ton of issues with getting soundmodem to decode aprs signals that were known to be good (ie. ideal recording played back as an MP3 file, no RF involved).

Raspberry Pi (Model B) in a clear protective case.

Raspberry Pi (Model B) in a clear protective case.

Most recently, I have managed to get the Raspberry Pi and soundmodem to play nicely with a USB soundcard (the Creative SB1140)! Finally some success – some of which I attribute to a more polished distribution.

In my previous attempts, I tried advanced commands such as setting the dwc_otg.speed=1 flag in (/boot/cmdline.txt) which did not solve the issue(s).

I installed a new image of the Wheezy Raspbian distro (2013-09-25-wheezy-raspbian.zip), and so a software update was in order. To facilitate the update, I logged into the shell and issued the following commands:

sudo apt-get update
sudo apt-get upgrade
SSH shell connection to Raspberry Pi

SSH shell connection to Raspberry Pi

It should be noted that you do not need to connect the Raspberry Pi to an external display to complete this work – yes it may be easier, however, there is another way! You can connect to the Pi by using an SSH client such as Putty. All you need is the local IP address of the Pi (as a tip, log in to your router and look for the clients listed in the DHCP table).

Once the core operating system was updated, I installed some of the components which would be needed for operating an APRS gateway:

sudo apt-get install screen build-essential python-serial sqlite3 python-dev soundmodem libax25 libax25-dev ax25-tools ax25-apps libax25-dev

The above command downloads and installs ~47Mb of binaries and takes some time to complete. Once the desired software was installed, I had some fiddling to do with how the system recognizes the USB sound card.

To eliminate as many variables as possible, I told the system to ignore the on-board sound card (output only, so useless) by modifying /etc/modules as follows:

sudo vi /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.
#snd-bcm2835
snd-usb-audio

Next, I modified /etc/asound.conf as follows:

sudo vi /etc/asound.conf

pcm.dmixer{
type    dmix
ipc_key 1024
slave   {
pcm     “hw:0,0”
period_time     0
period_size     1024
buffer_size     8192
rate    48000
}
bindings        {
0       0
1       1
}
}
pcm.asymed      {
type    asym
playback.pcm    “dmixer”
capture.pcm     “hw:0,0”
}
pcm.dsp0        {
type    plug
slave.pcm       “asymed”
}
pcm.!default    {
type    plug
slave.pcm       “asymed”
}
pcm.default     {
type    plug
slave.pcm       “asymed”
}
ctl.mixer0      {
type    hw
card    0
}

Next, a basic soundmodem configuration is established. This is the core of the software TNC so take some time to learn the ins and outs of this configuration file.

sudo vi /etc/ax25/soundmodem.conf

<?xml   version=”1.0″?>
<modem>
<configuration name=”AX25″>
<chaccess txdelay=”250″ slottime=”100″ ppersist=”40″ fulldup=”0″ txtail=”100″/>
<audio type=”alsa” device=”plughw:0,0″ halfdup=”1″ capturechannelmode=”Mono”/>
<ptt file=”none” hamlib_model=”” hamlib_params=”” gpio=”0″/>
<channel name=”sm0″><mod mode=”afsk” bps=”1200″ f0=”1200″ f1=”2200″ diffenc=”1″ inlv=”8″ fec=”1″ tunelen=”32″ synclen=”32″/>
<demod mode=”afsk” bps=”1200″ f0=”1200″ f1=”2200″ diffdec=”1″ inlv=”8″ fec=”3″ mintune=”16″ minsync=”16″/>
<pkt mode=”MKISS” ifname=”sm0″ hwaddr=”NOCALL-05″ ip=”44.128.0.2″ netmask=”255.255.255.0″ broadcast=”44.128.0.255″ file=”/dev/soundmodem0″ unlink=”1″/>
</channel>
</configuration>
</modem>

Be sure to replace the NOCALL-05 with your own call-sign to ensure that the APRS packets conform to regulations! The txdelay=250 and txtail=100 are to add a time-delay for VOX operation – these values could be tweaked if you are using a hardware PTT.

Raspberry Pi GPIO (general purpose input / output) header & serial adapter.

Raspberry Pi GPIO (general purpose input / output) header & serial adapter.

Speaking of hardware PTT – it is a somewhat common problem when working with a Pi that a USB to serial adapter may malfunction. It would be advisable to use one of the GPIO pins of the Pi in order to toggle the PTT for your radio.

I may use a GPIO to serial adapter which was purchased on eBay for less than the cost of the materials. It is simple enough to use the GPIO pin directly, just be aware that the Pi is not able to source a large current so it would be prudent to use a transistor to drive an optocoupler for galvanic isolation of the Pi from the radio.

Edit the axports file to include a statement for soundmodem and your callsign(with SSID – ie. -05). This file assists in setting up an AX.25 port which acts as a network adapter. We will use this functionality later to produce AX.25 packets which we can use / listen to in order to verify functionality and to set output levels.

sudo vi /etc/ax25/axports

# /etc/ax25/axports
#
# The format of this file is:
#
# name callsign speed paclen window description
#
sm0     VE3BUX-05       1200    255     2       VHF APRS (1200 bps)
#1      OH2BNS-1        1200    255     2       144.675 MHz (1200  bps)
#2      OH2BNS-9        38400   255     7       TNOS/Linux  (38400 bps)

Next I modified the alsa-base.conf file found in /etc/modprobe.d so that it was as follows:

sudo vi /etc/modprobe.d/alsa-base.conf

# autoloader aliases
install sound-slot-0 /sbin/modprobe snd-card-0
install sound-slot-1 /sbin/modprobe snd-card-1
install sound-slot-2 /sbin/modprobe snd-card-2
install sound-slot-3 /sbin/modprobe snd-card-3
install sound-slot-4 /sbin/modprobe snd-card-4
install sound-slot-5 /sbin/modprobe snd-card-5
install sound-slot-6 /sbin/modprobe snd-card-6
install sound-slot-7 /sbin/modprobe snd-card-7
# Cause optional modules to be loaded above generic modules
install snd /sbin/modprobe –ignore-install snd && { /sbin/modprobe –quiet snd-ioctl32 ; /sbin/modprobe –quiet snd-seq ; : ; }
install snd-rawmidi /sbin/modprobe –ignore-install snd-rawmidi && { /sbin/modprobe –quiet snd-seq-midi ; : ; }
install snd-emu10k1 /sbin/modprobe –ignore-install snd-emu10k1 && { /sbin/modprobe –quiet snd-emu10k1-synth ; : ; }
options snd slots=snd_bcm2835,snd_usb_audio
options snd_usb_audio index=0
#options snd_bcm2835 index=-2
# I commented the above line out as I found it was ineffective at blocking the snd_bcm2835 from being loaded
# Prevent abnormal drivers from grabbing index 0
options bt87x index=-2
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2

The intent in the alsa-base.conf file is to preemptively load the USB sound card, blocking the built-in one from taking index=0 (the default device).

Audio test bench for soundmodem testing.

Audio test bench for soundmodem testing.

So by this point, all should be going well and your system will likely work just fine. We can now start testing by recording and playing back audio handled by the USB sound card. For my initial tests, I simply plugged the USB sound card’s mic jack into the speaker output of my computer and played some audio. I recorded the incoming audio as follows:

arecord -vv ~/testaudio.wav

You can then play back the audio to check your levels by issuing the following command:

aplay ~/testaudio.wav

If you wish to adjust the levels, simply run:

sudo alsamixer

Press F5 to display all “devices” associated to your USB sound card. Using the arrow keys, select the parameter you wish to change and exit by pressing “ESC”.

To check that soundmodem will handle AX25 network traffic, issue the following commands:

sudo screen -dmS sm soundmodem
sudo /sbin/route add -net 44.0.0.0 netmask 255.0.0.0 dev sm0
ping -i 5 44.128.0.1

You should now hear the familiar sound of packtets, provided you are monitoring the output audio of the USB sound card using a speaker or headphones. To see what soundmodem is doing in the background, you can “attach” to the screen as follows:

sudo screen -r sm

To exit the screen without killing the soundmodem daemon, press Ctl-A then while holding Ctl, press D

If you have local APRS traffic, by all means connect your radio to the sound card’s input (mic) jack and try to decode the packets. You can see any decoding by running the following command:

sudo axlisten -a -c

You should see something similar to the following:

AX.25 test packets from audio recording

AX.25 test packets from audio recording

If you do not have local APRS traffic which is frequent enough to use for real-world testing, you can download and play any audio file containing APRS (or packet) data. Here is a good resource that I used: WA8LMF Test CD

We will now install and configure dixprs. Start by creating the install directory, and then populate it with a configuration file.

sudo mkdir /usr/local/dixprs
sudo vi /usr/local/dixprs/config.txt

In the config.txt file, you will need to modify it to suit your particular details. Be sure to change the callsign, latitude and longitude at a bare minimum!

[GENERAL]
# Mandatory parameters
# Your callsign with SSID
CALLSIGN=NOCALL-5
# Degrees; West is negative, East is positive
LONGITUDE=-75.00
# Degrees; South is negative, North is posittive
LATITUDE=45.00
# Optional parameters
# Station height abvove the see level in meters; no default
#ASL=
# Owner name and contact; no default
#OWNER=
# Spool directory to import packets; no default
#SPOOL= # Station symbol; default is S#
#SYMBOL=
# UDP port base number; default is 31110
#UDPBASE=
# Beacon frequency in minutes; default is 30
BCNTIME=30
# Beacon text; %v replaced with actual version string; default is %v
# Used as default for ISGW and RADIO
BCNTXT=Raspberry Pi Soundmodem APRS gateway
# Select km/mi on monitor and in DX list; default is y (km)
#METRIC=<y/n>
# Max number of digis passed for local stations
# Used as message gating condition for gating to Rf
# Default value is 2
#LOCALHOPS=
# Range in km within messages gated to Rf
# If defined, checked after hop count (local) check
# No default
#MSGRANGE=
#################################################################
#
# IS gateway settings; remove this section to disable GW #
#
#################################################################
[ISGW]
# Mandatory parameters
# Domain name of IS server to connect
host=noam.aprs2.net
# Optional parameters
# Port number; default is 14580
#PORT=14501
# Filter; default is r/@/150
# @ is replaced with station position
FILTER=r/@/30
#################################################################
#
# WRB server settings; remove this section to disable it #
#
#################################################################
[WEBSERVER]
# Mandatory parameters
# WEB server port, no default
port=9999
################################################################# #
#
# Radio port configuration settings; repeat section for #
# multiple ports #
#
#################################################################
[RADIO]
# Mandatory parameters
# Interface type
INTERFACE=AX25
# Device; as listed by ifconfig; it is nbot the ax.25 port name!
DEVICE=sm0
# Optional parameters
# Modem speed, default is 1200
#SIGNALRATE=1200
# Enable/disable NWS WX bulletin and object gating from IS to Rf
# Disabled by default
#GATENWS=<y/n>
# Enable/disable BOM WX bulletin and object gating from IS to Rf
# Disabled by default
#GATEBOM=<y/n>
# Descripton of port; no default
#DESCRIPTION=
# Via used to send locally generated packets; default is WIDE1-1,WIDE2-2
#AXVIA=
# Digipeaters processed with WIDEn-n algorithm; default is WIDE1,WIDE2
#WIDEN=
# Blacklisted stations; they are not digipeated, not gated; default is NOCALL,N0CALL
# PHG string, do not mix with range; no default
#PHG=
# Range value in miles, do not mix with PHG; no default
#RNG=
# Enable/disable transmission; change it to PTTON=1 to enable trasmission; default is no
#PTTON=<y/n>
# Gate locally generated frames to IS gateway; default is no
# Useful for rx-only radio ports
# Experimental, use carefully
#GATELOCAL=<y/n>
# Gate digipeated frames to IS gateway; default is no
# Experimental, use carefully
#GATEDIGI=<y/n>
# Beacon text; %v replaced with actual version string; default is %v
#BCNTXT=
# Enable/disable digipeater; default is enabled
#DIGIPEATER=<y/n>
# Modem/TNC setup parameters 0…255; no defaults
# Use to setup modem/TNC by DIXPRS
#TXD=
#PPERSIST=
#SLOTTIME=
#TXTAIL=
#DUPLEX=
# Below these are the traffic shaping settings for gating messages
# From IS to Rf
#
# For advanced users only; do not change if you do not know how
# traffic shaping works and if you do not have good reason !!!
# Traffic shaping high treshold, default is 0.75
#TRAFFICHIGH=
# Traffic shaping low treshold, default is 0.5
#TRAFFIClow=
# Traffic shaping transmission delay, default is 5.0 sec
#TRAFFICDELAY=
# Comma separated list of addresses to send receveid/transmitted frames
# in hostip:port format. No default.
#UDPCC=

The following steps are a one-shot quick and dirty installation of the dixprs software package:

cd ~
mkdir pyax25
cd pyax25
wget https://sites.google.com/site/dixprs/downloads/pyax25.tar.gz
tar -xzvf pyax25.tar.gz
./compile_ax25.py build
sudo ./compile_ax25.py install
sudo rm -rf pyax25
cd /usr/local/dixprs
sudo wget https://sites.google.com/site/dixprs/downloads/dixprs-2.2.2.tar.gz
sudo gzip -d dixprs-2.2.2.tar.gz
sudo tar -xvf dixprs-2.2.2.tar
sudo rm -f dixprs-2.2.2.tar
sudo chown -R pi:pi /usr/local/dixprs
sudo chmod 755 *.py
sudo chmod 644 *.txt
cd ~

With dixprs installed, test the package as follows:

/usr/local/dixprs/dixprs.py -c /usr/local/dixprs/config.txt

Now be aware, if you are still streaming your test audio to the Pi, the decoded packets may be sent out to the APRS tier2 servers if your connection is working! This may be a bit annoying for those who rely on actual RF-gateway tracking (ie. you are mis-reporting positions for anyone whose callsigns are decoded).

Well, this is a ton of information as it is, so I will leave it here for now. My immediate plans are to add GPS receiver functionality and to dabble with aprx again (software that I have used successfully in the past).

Posted in Operating, Project | Tagged , , , , , | 12 Comments

Interface v0.20 laid-out

Having recently explored the signal integrity issues in the Interface v0.11, I’ve re-tooled the board to use the TY-311P transformers in v0.1 which meant a total redesign of the layout. In the most recent version, I’ve grouped the components in functional blocks which in principle should reduce any digital noise in the analog side of things.

Sound Card Interface v0.20

Sound Card Interface v0.20

It is a bit of a shame to go with such large (by comparison) transformers, however, they afford 1.5kV isolation and have a very flat frequency response from 300Hz to 3.5kHz.

Frequency response of TY-311P transformer being swept from 300Hz to 3.5kHz in 500ms at 1.9Vpp

Frequency response of TY-311P transformer being swept from 300Hz to 3.5kHz in 500ms at 1.9Vpp

When examined on the DS2202, the difference in amplitude was found to be ~10mV on the peak, so this can be extrapolated to be ~20mVpp or roughly 1% which is quite acceptable.

The transformers are 600Ω:600Ω impedance which is a great match for a radio such as the FT-857D which has a 600Ω data output, and is well within the microphone input range of 200-10kΩ (with 600Ω being the nominal). Matching impedances so closely should serve to avoid the production of any harmonic content due to any non-linearity in the circuit.

Basic transformer based signal isolation

Basic transformer based signal isolation

In addition to changing the transformer itself, I’ve added the provision to decouple any DC bias from the microphone circuits of both the sound card and the radio.

Electret microphone circuit

Electret microphone circuit

Most modern microphones are of the electret (or condenser) variety. An electret microphone works by biasing a FET (field effect transistor) in a common source configuration. As the schematic suggests, a voltage on the gate will allow a proportionate flow of electrons thru the device, acting as an amplifier.

Although there may not be a DC bias on the output, it is best not to make this assumption and add the provision of decoupling the signal using a capacitor to prevent possible damage to the transformer due to circulating current. In the event the radio and/or sound card are DC blocked at their outputs (as suggested by the above schematic), the DC block can be shorted with a piece of jumper wire at virtually no loss to the signal in question.

Once I have this new version of the sound card interface rolled out and field-tested, I will begin the fabrication process for the all-in-one board where the USB sound card is built-in to the interface. This is just a warm-up project!

 

Posted in Project | Tagged , , , , , , , | 2 Comments

More testing …

I thought that I would do a little more side-by-side comparison between the transformer and the capacitor methods of signal isolation. My test bench consisted of:

  • DG1022 function generator
  • DS2202 oscilloscope
  • Sound Card Interface v0.11
Testing the sound card interface

Testing the sound card interface

Fldigi reference waveform showing 1.9Vpp amplitude

Fldigi reference waveform showing 1.9Vpp amplitude

As I found that there was a direct voltage saturation type effect of the DA102MC transformer in previous testing, I decided to measure a baseline peak-to-peak signal level to compare against. I ran Fldigi and measured the output of the audio output using the oscilloscope and found that at 100% volume, a SoundBlaster SB1140 will output 1.9Vpp which is what the DG1022 will be set to for the comparison tests.

Comparison of inductor (transformer) and capacitor isolation methods

Comparison of inductor (transformer) and capacitor isolation methods

Using a 1kHz tone at 1.9Vpp on both channels (phase aligned), the resulting waveforms were visualized.

The blue trace was the resulting output from the transformer. The signal was found to be 896mVpp which is down from the injected 1.9Vpp.

The red trace was the output from the capacitor isolators and had the output voltage decreased (using the on-board 10kΩ potentiometer) from a maximum of 1.9Vpp to 832mVpp for a closer comparison.

I used the external trigger output of the DG1022 to ensure consistent triggering and to show the phase difference. This is one of the times I wish that I had forked out the extra money for a 4-ch oscilloscope – oh well :).

In any event, I will be looking at a replacement SMT transformer as it is apparent that at a typical 100% output from a USB sound card the transformers are not able to handle the full-swing of audio at 1.9Vpp. More to follow on this …

Posted in Project | Tagged , , , , , , , | Leave a comment