Packet Radio Interface for UV-B5
After many years my Yaesu VX-6R was beginning to pack it in so I picked up a Baofeng UV-B5 cheap on eBay. This week I made a computer interface for it and managed to send and receive my first AX.25 packets.
The UV-B5 has a Kenwood-style pair of 3.5 mm and 2.5 mm jacks (pinout). The PTT is triggered by joining the sleeves of each plug. To save time I decided I’d try using the VOX feature on the radio. This is supposed to automatically transmit when there’s audio input and stop when the audio stops. This has issues of its own, which I’ll describe further below, but it’s an easy way to get on the air.
I wound up using a variation on John Boiles’ design for connecting one to an iPhone. You can see that he used only one of the sleeve connections. This suggests that internally they are coupled with a capacitor—AC can pass between them, and bypassing the capacitor will trigger the PTT.
I skipped most of the components on the radio speaker output as they were only for the iPhone. I also found that if I had both plugs inserted at the same time the radio would constantly transmit. I fixed that by inserting a 1:1 transformer in the connection from computer headphones to radio microphone. The circuit below was my final working one. I think if I was building another one I’d just use two transformers.
The next step is to get the levels right. The radio-to-computer connection is pretty easy. I set the volume dial to halfway on the radio and tuned it to 145.175 MHz where there is plenty of APRS activity. On the computer I opened audacity, hit record and watched the incoming waveforms. I adjusted the gain on my sound card until the input signal was taking up most of the available space while still having plenty of clearance.
As you can see, the radio has an annoying loud click when the squelch kicks in. I allowed that to distort so that I get a good input level for the main part of the transmission.
The other direction is slightly harder to get right if you don’t have a friend with a radio handy. I ended up using a RTLSDR dongle to record my transmission. I slowly bumped up the audio output from my sound card until it was enough to reliably trigger the transmit with VOX set to 1 on the radio.
# Record some FM-demodulated radio rtl_fm -f 146.575M -o 4 > test.raw # Play it back later cat test.raw | aplay -r 24k -f S16_LE # Make a wave file if you need it sox -t s16 --endian little -r 24000 -c 1 test.raw -c 1 -t wavpcm test.wav
The SDR makes for a fairly noisy FM receiver but as you can hear my audio is pretty clear. I plan to get a second opinion from someone with a real radio.
Next is the matter of making my linux laptop act like a modem. I installed the soundmodem that everyone uses, written by Thomas Sailer. Unfortunately at the time of writing his website is down (mirror here) but the package remains in Debian under the name soundmodem.
I followed the instructions on George Smart’s excellent page to actually configure the soundmodem. There are four additional things I would say about these instructions which might make your life easier.
First of all, all these commands including
soundmodemconfig need to be run as root. If you’re running X as a non-privileged user, which you should be, you will need to set your
export DISPLAY=:0 # replace ‘user’ with the name of the logged in user export XAUTHORITY=/home/user/.Xauthority
Then you will be able to run the commands as root in a terminal and have the window appear.
The Effect of TxDelay
You might find yourself a little nervous about the PTT driver and the TxDelay setting. The process goes like this:
- Trigger the PTT (which does nothing, because we have no driver set)
- Wait 150 ms for TxDelay (time given to the radio to let its carrier settle down before we start sending data)
- Start sending real data
Since we’re relying on VOX it might seem as though we’re going to wait 150 ms for nothing, then suddenly have the first part of our message chopped off because the radio wasn’t ready yet. It turns out that somebody thought of this—the TxDelay period also outputs an audio tone, so it will trigger the VOX and work exactly the same way. You can hear this for yourself by setting TxDelay to a really long period like 2000 ms and listening to it through speakers.
In theory you could record your transmission and minimise TxDelay until you’re spending no more time than necessary activating the VOX. Personally I would rather get away from using VOX entirely.
The big problem with VOX is at the end of the transmission. VOX is designed to work with human speech. When we finish speaking it will keep transmitting for a moment to see if we’re really done, or just starting a new sentence. On a busy packet radio channel this is really inefficient use of airtime. We only have 1200 baud and we want to make the most of it. Although you can get away with some largesse for experimenting I think it would be rude to operate this way long-term.
KISS vs MKISS
I couldn’t find any way to use
axlisten to monitor traffic when I use the KISS configuration. It only appears to detect an interface if you actually have a real AX.25 interface running. That is, you need to see something like this when you type ifconfig:
sm0 Link encap:AMPR AX.25 HWaddr VK7NTK-1 inet addr:10.200.200.1 Bcast:10.200.200.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:256 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:102 (102.0 B)
All the tools I’ve seen seem to assume you have one of these interfaces so unless you know what you’re doing I’d recommend using MKISS. This does require you to specify an IP address. I put in some dummy values that wouldn’t interfere with anything just to make it happy (address 10.200.200.1, netmask 255.255.255.0, broadcast 10.200.200.255).
Avoiding TCP/IP Chatter
I had some software running in the background that wanted to automatically broadcast on this new interface when it went online. This is potentially useful if there are other people in the area also doing TCP/IP over packet radio. In my case there aren’t, so to avoid these transmissions I simply asked iptables to drop all those packets:
iptables -A OUTPUT -o sm0 -j DROP
Having worked through Mr Smart’s instructions I was able to run
soundmodem as root, then also run
axlisten -a -c and see lots of lovely APRS packets flying past. This is good.
I had hoped to connect to a local radio BBS but it seems to be offline. I’m hoping this isn’t permanent. In any case I have no ordinary packet radio nodes I can connect to right now.
APRS to the rescue—a position reporting system. It isn’t quite the same as “traditional” packet radio but it does use the same hardware and most of the same protocols. Furthermore, quite a lot of people in Hobart use it.
I downloaded Xastir (debian package “xastir”) which has built-in support for an AX.25 interfaces. Once I had soundmodem running I was able to create an interface in xastir, point it at
sm0, and start receiving packets. Soon I had lots of stations appearing on a map. Remember that xastir needs to be running as root too!
After setting up my station name
VK7NTK-1 and location, I selected “Transmit Now!” from the menu. Nothing happened. Well, that’s not quite true. I had
axlisten running in another window and I could see the outgoing packet there. It just didn’t go out my radio.
It turns out that VOX doesn’t work if you have the squelch off. This makes sense, because if you have a loud voice coming out the speaker it can’t tell the difference between that noise and you speaking. Therefore I had to turn on squelch.
You can hopefully see another problem here: squelch doesn’t work instantly. If a station has their TxDelay tuned to the perfect minimum, by the time my radio decides to open its squelch we might have missed the first few bytes and therefore won’t receive that packet. This is yet another reason that using VOX is a dumb idea. Triggering PTT with a switch will always work, and if I do that I can run with my squelch fully open.
Having turned my squelch back on, I could transmit!
My position was picked up and relayed to aprs.fi! It says that my packet was rebroadcast by the digipeater VK7RTC on Mt Wellington, then received by VK7ZRO who uploaded it. This at least proves that my interface is able to transmit intelligible data.
Clearly I need to do something about triggering PTT manually. I think a solid state relay powered by USB 5V will be the way to go. It’s possible to do clever things by blasting loud audio out the audio channel that you’re not using but I think I’d be happier doing direct control, even if that means I need a USB/serial adapter.
Somewhat more importantly, I need to find some people I can connect to. Hopefully they’re just hiding somewhere.