Wednesday, July 3, 2019

Raspberry Pi Portable Panadapter for the Xiegu X5105

An Inexpensive Portable Pandapter for the Xiegu X5105 and Other Amateur Radio Transceivers


WARNING: The RTL-SDR radio dongle currently doesn't work with the new Raspberry Pi4 and the Buster Raspbian release. The only solution right now is to either use a Raspberry Pi3B+ or purchase a NooElec NESDR XTR+ Tiny Extended-Range TCXO-Based RTL-SDR & DVB-T USB Stick (RTL2832U + E4000)

GOOD NEWS, however, because the issue has been fixed and should appear in the next Raspbian update?:

look towards bottom of post from RPi engineer 

 https://github.com/raspberrypi/linux/issues/3060


The Xiegu X5105 is one of the newer rigs introduced by Xiegu for ham radio enthusiasts. One of the neat features of this self-contained QRP transceiver is the presence of an IF output port on the left side of the radio. This is unlike the Elecraft KX2, which does not have this feature (and which costs 3X as much!). Even better, you can use open-source software to display the information!

From the rig's manual, you can see that the port hosts an SMA jack:


This port outputs a first intermediate frequency signal for use with software-defined receivers, such as an RTL-SDR USB dongle. Using this port, which provides a 70.455MHz signal, you can get a spectrum display of signals coming into the receiver and a waterfall showing where the signals are located.

The simplest method for using the X5105's port is to connect an SDR dongle to the X5105 via an SMA male plug to MCX RG316 cable. These are relatively inexpensive:


Plug the male MCX into the X5105's port, then attach the screw-on SMA connector onto your USB SDR dongle and insert it into your computer. You can then run a program such as gqrx-sdr, using the 70.455 frequency. As you turn the X5105's VFO, you'll see any available band activity on the display.

Building a Portable Panadapter


Thanks to Derek Copsey, a member of a Facebook Xiegu forum, I was able to easily assemble my portable panadapter in less than half a morning. You'll need:

- a Raspberry Pi 3B+
- a case
- a 3.5" LCD to plug into the Pi
- an SDR dongle
- instructions from W7QT's github page:

panadapter manual

Configuring Your Raspberry Pi Display


First, get your Pi running with the LCD (which runs less than $20 online). Most folks use the script LCD_Show, found here:

https://github.com/goodtft/LCD-show

After getting your display working, you'll need to calibrate your LCD. This is important if you want to accurate tap menu items from the desktop's uppermost pane. To calibrate, install the xinput-calibrator package. Run the program from either the desktop menu (Preferences) or from the command line of a terminal window.

You'll be shown a graphical screen, and asked to pen touch four different points on the display. When done you'll be presented with a line of values representing your LCD's touch boundaries, such as:

"258 3966 3774 226"

Enter these values (as root) into the file 99-calibration.conf under the /etc/X11/xorg.conf.d directory. Here is my Pi's file:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"

        Option  "Calibration"   "258 3966 3774 226"
        Option  "SwapAxes"      "1"
EndSection


Reboot your Pi and you'll find a bit more accuracy in your touch points!  Unfortunately, the developer of LCD_Show not only left out calibration, but also an important step in touchscreen configuration: Proper setup for emulating a right-click using a touch pen!

Here's how to get right-click emulation:

- edit /usr/share/X11/xorg.conf.d/10-evdev.conf to contain:

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
    Option "EmulateThirdButton" "1"
    Option "EmulateThirdButtonTimeout" "500"
    Option "EmulateThirdButtonMoveThreshold" "30"
EndSection


The next step is to install the software for your SDR dongle.

Panadapter Software Install


Follow the link to W7QT's install. I used the latest Raspbian release (Buster) at the time of this writing, and found a number of dependency errors using the Python script installs. I'd recommend using the apt-get approach, which are called 'install scripts' in the .pdf instructions

Next, get the rtl driver built and software installed. The steps outlined in the .pdf worked fine.  To start, you'll need to attach your dongle. Mine is an RTL-SDR (from the company's web page):



My version of this receiver was recognized as a Rafael Micro r820t under Raspbian Buster (not PIXEL!). You'll know when the dongle is ready for use (using dmesg to see kernel output), when you see:

usbcore: registered new interface driver dvb_usb_rtl28xxu

Next, run the panadapter package. The 3.5" LCD requires the 'FreqShow_Small' Python script. You'll be asked if you want to 'execute a script' via a dialog if you double-tap its desktop icon. Do so and you'll see the default screen as shown above in the title. The default frequency was a bit off for my SDR dongle, I had to touch the 'Set' button, then Clear, then tap in my X5105's IF frequency of 70.455. Being able to accurately tap the small 'buttons' (actually just words on the screen) and enter numbers is one reason to have your touch coordinates calibrated.

The required value for the IF (will be different for different rigs!) can be hardwired into the file 'model.py' under the FreqShow_Small directory:

self.set_center_freq(70.455000) # frequency in MHz of my 1st IF

Experiment with the different displays of the panadpater software. W7QT has done an excellent job of shoehorning a working program into a proper and compact display. Here's a video of my X5105 decoding CW with the panadapter, which is running off of a small lithium-ion battery with a 12V and more importantly, a 5V 3A USB port for the RPi 3B+ (and which will also work for the RPi 4!):




You can also adjust various display settings and if you click on the running display, it will enlarge and run full-screen - very nice! I also like that the adapter stores neatly away:


My Pi/LCD Panadapter is housed in a Pimironi Pibow PiTFT+:



Next, is another SDR client that works well on the Raspberry Pi. It requires a bit more configuration "out of the box" to work well, but the effort is worth it!

Making gqrx Work on a Raspberry Pi 3B


One of problems with Raspberry Pi 3B+ is a lack of CPU horsepower and RAM. This has been solved in the newer Raspberry Pi 4, especially the 2GB and 4GB versions. However, by properly configuring clients that require lots of CPU cycles, you can get acceptable performance with programs such as gqrx-sdr.

To get gqrx work under Raspbian doesn't have to be a black art. Conflicts between ALSA and Pulseaudio are legion, but here is how to get a working install:

Step One:


Install Pulseaudio using apt-get:

sudo apt-get install pulseaudio

Step Two:

Install gqrx using apt-get:

 sudo apt-get install gqrx-sdr

Step Three:


Reboot <-- This is important!

Step Four:


Attach your SDR dongle.

Step Five:


Run gqrx.

Step Six:


Select the correct attached Device, and critically, an Input rate less than the default. I found that 1200000 worked well. If the input rate is too high you will get 'stuttering' of the audio signal. This rate worked well for receiving commercial wideband FM radio stations using the stereo *mono* mode via the Pi's stereo audio jack (lower the gain settings in the receiver options tab and use the desktop's audio slider):



Step Seven:


To reduce CPU load, click the FFT Settings tab, then use a lower FFT size setting, such as 4096 (or lower), and a lower frame rate for the waterfall, such  as 15 fps, as shown here:



You can also reduce the windows size to display just the current frequency and part of the waterfall when you run the gqrx on your 3.5" LCD. This will make even a 15 fps waterfall run faster and reduce CPU load. And by using gqrx's View menu, you can get the window down to a bare minimum for a nice little radio display:


Here's the display on the LCD sitting on the desktop. I have ordered a 'mini' SDR dongle, so the entire package will be even smaller:


 So there you have it! Note that the gqrx program can also be used as a panadapter display if you select the 70.455 frequency after attaching your X5105 to the SDR's dongle.

Portable operations of the Raspberry Pi are possible with an inexpensive lithium ion power pack. Make sure to buy one with at least 3A output with a 5V USB port so you can use it with any new Raspberry Pi 4.

If you've wanted to try using a panadapter with your rig, there's no reason to shell out big bucks for a piece of hardware you may end up not using.  This approach provides a way to test the limits of portability and to provide a way to inexpensively experiment. You'll also get a little display that is portable in the field, also works as a wideband receiver, and can also be used to play music!

Here's a screenshot of my RaspberryPi 3B+ with gqrx streaming UDP audio via port 7533 (set it up in the Audio pop-up dialog at the bottom right of the client window). You can listen to the stream using VLC on OS X or GNU/Linux (substituting 'cvlc' under GNU/Linux):

#!/bin/sh
/Applications/VLC.app/Contents/MacOS/VLC --demux=rawaud --rawaud-channels=1 --rawaud-samplerate=48000 udp://@:7355 &





1 comment:

  1. Any updates on using the latest Raspberrian with the PANAdapter?

    ReplyDelete