Saturday 16 February 2013

PSK31 on the Raspberry Pi - Part 1

As I mentioned in my last post, I am a radio amateur and I'm interested in using the Raspberry Pi to operate using various digital modes, including PSK31. To do this requires an audio input to and output from the Raspberry Pi (see my previous post) and a suitable application to encode and decode the PSK31 signal, as well as a radio transceiver and antenna. The possibility of using the Raspberry Pi for operating PSK31 has intrigued me because it would offer a low cost, low power, silent and potentially mobile station setup - the only other alternative is to use a desktop or laptop computer.

If you do an internet search for "Raspberry Pi PSK31" you will get a few results, most of which bemoan the Raspberry Pi's lack of processor power for running "Fldigi" which is probably the most popular Linux application for PSK31. I have tried running "Fldigi" on the Raspberry Pi and whilst it does run, I feel that it is just too demanding on the modest resources of the Raspberry Pi.

Searching the repository for "PSK31" or "amateur radio" yields a few alternatives and I have been experimenting with some of these applications. The one I have had the most success with is called "LinPSK". To download and install LinPSK open a LXTerminal window and type the following and press Enter:

pi@raspberrypi ~ $ sudo apt-get install linpsk_

To make the USB audio device available to "LinPSK" you need to create a file called ".asoundrc" in the "/home/pi" folder containing the following text:

pcm.LinPSK_card {
       type hw
       card 1
       }
ctl.LinPSK_card {
       type hw
       card 1
       }
pcm.LinPSK_Play {
       type plug
       slave {
       pcm "LinPSK_card"
       }
}
pcm.LinPSK_Record {
       type plug
       slave {
       pcm "LinPSK_card"
       }
}


To save you having to type in all the above text, there is a file called "asoundrc" in the folder "/usr/share/doc/linpsk" which you can copy over to the "/home/pi" folder, edit and rename as ".asoundrc". If there already is a file called ".asoundrc" in the "/home/pi" folder then you should append the above text to the end of the existing file. Have a look at this post if you need help creating or editing files.

Once you have saved and closed the ".asoundrc" file the "LinPSK" application should have access to the USB audio device. The above procedure assumes that the on-board audio device is designated "card 0" and that the USB audio device is designated "card 1", but this should be the case as long as you do not have any other audio devices connected to your Raspberry Pi.

Connect the audio output from your transceiver to the input of the the USB audio device via a suitable isolating interface and tune the transceiver to a PSK31 signal. Launch the "LinPSK" application and maximize the window so that it occupies the whole screen. Click on the square button labelled "RX" located left of center. The waterfall on the bottom left of the screen should come to life. Click on one of the peaks in the waterfall and you should start to decode the PSK31 signal.


You may notice that I also have an LXTerminal window open. This is running "AlsaMixer" in the background so that I can adjust the level of the audio input to the Raspberry Pi. I found that the best setting for me was to turn the "Auto Gain Control" off and set the "Mic" capture control to about half way, but I suggest that you experiment with the settings and find what works best for you. Also note that the load on the Raspberry Pi's processor is quite acceptable (as shown by the small scrolling graph on the right hand end of the task bar) with LinPSK and AlsaMixer both running.

The LinPSK application may also be used for QPSK, RTTY and MFSK16. There is an extensive user guide for LinPSK available here, although it does relate to an older version of the application.

20 comments:

  1. Great! I tried the same in my Raspberry (Debian Wheezie), but I get "Unable to set hw parameters for input". Alsa is configured right, fldigi sees the card, but reception is impossible due to the limited performance of the Pi.

    I also checked the .asoundrc file, changed the default card to card 1, but still the same. Which Pi linux release do you use?

    best regards PA3EEP (see QRZ.com)

    ReplyDelete
    Replies
    1. Hi,

      I'm using the latest Raspbian "Wheezy" release 2013-02-09.

      Is the error message you are getting from LinPSK or fldigi?

      I'm using LinPSK and if the sound card setup as defined in the .asoundrc file is incorrect I get the message:

      "Unable to open Device LinPSK_Record: No such file or directory..."

      Make sure your .asoundrc file is correct AND that it is located in the /home/pi folder.

      73 de MI0IOU

      Delete
    2. Hi,

      I am 100% sure the .asoundrc file is correct. I also installed fldigi and I can select the LinPSK_Play and LinPSK_Record devices in Fldigi. As reported by others, fldigi works TX only, but I can see the waterfall.
      It looks like it fails the moment LinPSK tries to modify the hardware settings. I expect that possibily the difficulty is in the linux driver for my specific usb soundcard. So I tried two other usb audio devices, all with the same result.Therefore, I ordered the same usb sound card you seem to use at ebay, which will take a few weeks to arrive. Will let you know if it works.

      It would be nice to work you on PSK31 one day. I have a PSK20 home built QRP set, great little machine!


      Best 73's

      Peter PA3EEP

      Delete
    3. Hi Peter,

      It will be interesting to know if it is the USB audio device that is causing the problem. However, I have two different USB sound cards and they both work no problem, although I think they both use the same chipset.

      Hope to see you in my waterfall.

      73 de Tom

      Delete
    4. Same error here ( Unable to set hw param for input: Invalid argument)
      Using cheap USB headset, identified by RPi as
      usb-0c76_USB_Headphone_Set-00 (card 1).

      dmesg debug line is:
      input: USB Headphone Set as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.3/input/input1

      ALSA mixer selects it OK, but no luck with linpsk.

      After failure in linpsk, a new line is added to dmesg:

      Alignment trap: not handling instruction e1942f9f at [<410e2940>]
      [ 2089.523116] Unhandled fault: alignment exception (0x001) at 0xeaffffe6

      Hope this helps. Hugh G6AIG

      Delete
  2. Tom
    I just found your site yesterday and it is exactly what I was looking for.
    Thank you for all the great information. I am new to the RPI and programming.
    I have my RPI all setup with the soundcard dongle. I can get the LinPSK to just start to run then I get this message as you mention above. "Unable to open Device LinPSK_Record: No such file or directory..."
    I have rechecked the file and directory but can't find what I have done wrong.
    I'll eventually find it and I am looking forward to getting this system going on PSK. I have a very small monitor to use with the system to make a nice small portable PSK terminal.
    I'll let you know when I get it going or give up and need help.
    Thanks again for the great website.
    Larry Naumann
    n0sa

    ReplyDelete
    Replies
    1. Hi Larry,

      Thanks for your comment.

      It sounds as if there is a problem with your .asoundrc file, or that the file isn't in the correct folder. I still use the default login on my Raspberry Pi so my user name is "pi" and the .asoundrc file is located in the "/home/pi" folder. However if you use a different login (e.g. "xxx") then you would have to put the .asoundrc file in the "/home/xxx" folder.

      Hope you get it working. I would be very interested in hearing how you get on with using it as a mobile PSK terminal.

      73 de Tom

      MI0IOU

      Delete
  3. Tom
    I got it working on receive but it seems that there is a problem and I think it may be that the RPi just does not have enough computing power.
    It seems that when I am receiving signals my keyboard gets sluggish. I am using a 2 amp powered usb hub. If the keyboard is plugged into the hub, it is sluggish. If the mouse is plugged into the hub then it is sluggish. Maybe it is a hub isssue, I don't know. Also, when I hit the TX button to go into tx the LinPsk program shuts down. So, I have a digital decoder but no more.
    I have tried overclocking the RPi all the way up to 1Ghz with no improvement in performance.
    Larry
    n0sa

    ReplyDelete
    Replies
    1. Hi Larry,

      It does sound like an issue with your hub. The Raspberry Pi should be powerful enough to run LinPSK no problem. I found that keyboard and mouse become unstable if you are reaching the limits of the power supply, but with a 2 amp PSU on your hub, this really shouldn't happen. Hope you get it working soon.
      73 de Tom MI0IOU

      Delete
  4. Tom,

    Thank you for your fantastic comments regarding LinPSK. I haven't gotten a good decode yet but I'm sure part of that was the LID that was blowing out the band, and the fact that I had not messed with ALSA mixer yet to fine tune the setup yet.

    I am curious, perhaps I am missing something but I am trying to run this setup on a SMALL (7") monitor via composite that is only capable of 640x480 and I cannot resize the LinPSK window small enough (even with the "Maximize" botton) to allow me to see the waterfall. It cuts off just past the box for the transmit text. Any suggestions?

    Again, thank you for the comments.

    73 de Travis W9HDG

    ReplyDelete
    Replies
    1. Hi Travis,

      Although I have not run LinPSK on composite output, I have to say that when I have used it I've found the composite output from the Raspberry Pi to be disappointing, but I guess this is down to the limitations of composite video format rather than the Raspberry Pi itself.

      I'm not sure if there's any way for you to solve your problem of not seeing the waterfall without editing the source code of the LinPSK app, but you could try changing some of the paramaters in the /boot/config.txt file. There's some useful info on video settings at http://elinux.org/RPiconfig

      Good Luck!

      73 de Tom MI0IOU

      Delete
    2. Tom,

      I was doing some research and I thought you might find this interesting:
      http://linpsk.sourceforge.net/docs/en/index-3.html#ss3.3

      It details how to change the minimal resolution that LinPSK will use.

      Now to keep working on my setup. I am reimaging my SD card as I was running into corruption issues so I'm starting over. On the last image I was having a problem with alsamixer not detecting the input of my signaling so hopefully that will be resolved with the reimage as well.

      73 and thanks,

      Travis W9HDG

      Delete
    3. Tom,

      A quick update, the directions in that link are wrong, however I contacted DL1KSV and he said that what I am looking for is in the

      parameter.cpp file so I would have to modify that file and then recompile...

      73,

      Travis W9HDG

      Delete
    4. Travis,

      Thanks for the update. Let me know how you get on!

      Tom

      Delete
    5. Travis,
      Have you tried holding alt key and dragging the window around with the mouse. You should be able to position the window to see the waterfall. This may be inconvenient but at least you can make sure LinPSK will work for you.

      73,

      Andy W5AGW

      Delete
  5. Hi. I successfully installed LinPSK on the RPi, but I'm not having an luck with getting the sound device recognized. I'm trying to use my SignaLink USB with the Pi. Does anyone know of issues with attempting to use this device? What's really troubling is that when I click on the RX button in LinPSK, it immediately shuts down. Anyone have any thoughts on this?

    Thanks for the help.

    Aaron

    ReplyDelete
  6. Hi,
    I saw this a few days ago and it’s inspired me to order a pi that arrived this morning.
    Can you tell me how you’re connecting the audio in to the pi please? I brought one of these (https://www.modmypi.com/usb-sound-adapter?filter_name=usb) but I don’t think it’s anything close to what you’re using?
    Is there a link for somewhere (In the UK) I could get hold of the same model you’re using??

    ReplyDelete
  7. Thanks for posting this, here it is February 2015 and I used your post to get started with PSK31 on my RPi ! Mine is working great with a signalink USB over VNC this is great fun!

    ReplyDelete
  8. Raspberry Pi can be used as a SSB transmitter, see link:

    http://www.rtl-sdr.com/transmitting-fm-am-ssb-sstv-and-fsq-with-just-a-raspberry-pi/

    It will be nice to build a self-contained psk transmitter. Is it technically feasible?

    ReplyDelete
  9. I just installed LinPSK in my Rasberry pi3, but upon clicking on the RX button, I get,"Unable to open Device LinPSK_record. NO such file or directory. Please read the readme for configuration hints." Where is this readme file, and what do I do? I did perform the .asoundrc file procedure to place in the home/pi folder. The USB sound card, both play and record, is selected on the preferences/sound menu and on the alsamixer in the terminal window.

    Mike, WA9ZPM
    mikejkiley@att.net

    ReplyDelete