Showing posts with label afsk. Show all posts
Showing posts with label afsk. Show all posts

Thursday, April 19, 2018

Setting up my Raspberry Pi as an BACAR Balloon telemetry system using GPSD,CW,AFSK,RPITX and Direwolf

Setting up my Raspberry Pi as an Balloon telemetry system using GPSD, CW, rpitx, AFSK and Direwolf.

 
Bacar Balloon

I wanted to take part in a local BACAR Balloon experiment and wanted to send my GPS position via the APRS network and also send a CW beacon every 7 minutes. I got an opportunity to add my payload to a school project.



Raspberry TX Hat for 2m Band

So I decided to use the the 2m transmitting board form Giga technology plug it on the raspberry pi. this should give me about 32.7mW (15.1dBm)
Power is a bit low but its a good for now.

Balloon Telemetry System


BACAR launch details is available here.
http://secundaweather.co.za/blog/?p=2012

Learnings
  1. Power to Low (Working on model 2 with a power output of 100 to 900mw output.
  2. Need to record everything that hapens in Local log so you can recover more information that you would send with Telemetry.
 Hardware.
  1. Raspberry Pi 3
  2. Giga Technology TX PI HAT for 2M
  3. RTL dongle for RX
  4. Giga Technology USB GPS unit.
  5. Giga Technology Battery and Powersupply Boards.
  6. Temperature sensor
  7. Optional USB Camera for CCTV.
High Level Hardware configuration

Software.
  1. CW (CW tone generation for Beacon transmission)
  2. Direwolf. (AX 25 telemetry generation for Temperature and on-board sensors  board 1200 AFSK)
  3. rtl_sdr (SDR receiver software for incoming commands controlling transponder)
  4. rpitx (RF transmitter details)
  5. ALSA loopback (this is needed to send audio between direwolf cw and rpitx)
  6. gpsd GPS positioning server read by direwolf APRS transmission
  7. Kal (rtl dongle frequensy calibaration details)
  8. csdr DSP libraries  that can be used for SDR.
  9. Some shell scripts taing this all together. Download from github https://github.com/antonjan/Raspberry_Telemetry

Software Block Diagram



Lets install the software for the system.

sudo apt-get install cw
sudo apt-get install direwolf
sudo apt-get install rtl-sdr
sudo apt-get install gpsd
sudo apt-get install alsa-utils
sudo modprobe snd-aloop
sudo apt-get instal python
Install the csdir sdr libraries doing the following.

git clone https://github.com/simonyiszk/csdr
cd csdr
make 
sudo make install
Get the direwolf example configurations
git clone https://github.com/wb2osz/direwolf
Lets install aprs utility.
got home directory
cd
git clone https://github.com/casebeer/afsk.git
cd afsk

sudo pip install afsk
sudo pip install --allow-external PyAudio --allow-unverified PyAudio PyAudio
Lets test aprs util
aprs
You should see the following
usage: aprs [-h] -c CALLSIGN [--destination DESTINATION] [-d DIGIPEATERS]
            [-o OUTPUT] [-v]
            INFO
aprs: error: too few arguments


Lets check if alsa loop installed

sudo arecord -l
you should see this

card 2: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 2: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7



You cal also check it in the sound volume control

Right click on the Sound icon and select setting and you should see the following

Input Tab should have the loopback sound card


Output Sound Card should have loopback


Lets test CW

cw -h
You should see the help

Lets test gpsd

gpsd -h
You should see the gpsd help
Install the gps on USB port.

We now need to find out what is the usb port for your GPS device so we can run the following command.  sudo gpsd -D 5 -N -n /dev/ttyACM0
We assume here that your usb device is  /dev/ttyACM0
Run this command and then plug in and out your gps on usb port.
tail -f /var/log/syslog | grep ttyAC


You will the see something like this.

/dev/ttyACM0
Then run the command sudo gpsd -D 5 -N -n /dev/ttyACM0 replacing it with your GPS usb port.

gpsd:PROG: Changed mask: {ONLINE|TIME|LATLON|ALTITUDE|STATUS|MODE|PACKET|PPSTIME} with reliable cycle detection
gpsd:PROG: GPGSA sets mode 3
gpsd:CLIENT: => client(0): $GPGSA,A,3,08,27,16,09,,,,,,,,,4.12,1.97,3.61*0D\x0d\x0a
gpsd:PROG: Changed mask: {ONLINE|MODE|DOP|PACKET|USED} with reliable cycle detection
gpsd:PROG: Partial satellite data (1 of 4).
gpsd:CLIENT: => client(0): $GPGSV,4,1,14,01,64,012,08,03,05,014,,04,06,121,,07,69,274,18*72\x0d\x0a
gpsd:PROG: Partial satellite data (2 of 4).
gpsd:CLIENT: => client(0): $GPGSV,4,2,14,08,43,151,28,09,11,321,22,11,88,165,17,16,15,081,21*7E\x0d\x0a
gpsd:PROG: Partial satellite data (3 of 4).
gpsd:CLIENT: => client(0): $GPGSV,4,3,14,17,06,290,22,22,14,033,16,23,04,348,,27,14,129,08*7A\x0d\x0a
gpsd:CLIENT: => client(0): $GPGSV,4,4,14,28,16,230,11,30,40,230,21*75\x0d\x0a
gpsd:PROG: Changed mask: {ONLINE|DOP|SATELLITE|PACKET} with reliable cycle detection

There is also another utility that could give you the status of the gpsd service.

Ok lets make our gpsd configuration permanent.
Edit the following configuration file using your favorite text editor.
and change the usb interface to what was detected above

sudo Vi /etc/default/gpsd

# /etc/default/gpsd
START_DAEMON="true" 
GPSD_OPTIONS="-n" 
DEVICES="/dev/ttyAMA0
USBAUTO="false" 
GPSD_SOCKET="/var/run/gpsd.sock"

Lets restart the gpsd service

sudo systemctl stop gpsd.socket

sudo systemctl start gpsd.socket
You can now test if it works fine with the following command
sudo gpsmon
You should see the following if all is ok with gps connected.

This is the GPS details as read by GPSD














Lets test direwolf



direwolf -h
You should see the direwolf help screen in white inverse.


Ok lets check rtl_sdr. (the SDR receiving software)
Plug-in your rtl dongle and then run the following command.

sudo rtl_test

You should see some test results and gain parameters supported by your device.
Ok


Connect your ds18b20 temperature sensor.
One of the coolest things about OneWire and DS18B20 temperature sensors is that each sensor has its own embedded address so you can have many of them on 1 data wire. 




Configure the raspberry pi to read the temperature.
Edit the following config file
sudo vi /boot/config.txt


Add the following at the bottom of the file
dtoverlay=w1-gpio
Then reboot the pi
sudo reboot
We now need to load the device drivers for the temperature sensor.
sudo modprobe w1-gpio 
sudo modprobe w1-therm

Now check if the device was loaded

ls /sys/bus/w1/devices


you should see a directory like this below
28-000007602ffa
Go into this directory replacing the part in yellow with your directory
cd /sys/bus/w1/devices/28-000007602ffa
Now run the following command to get the temperature.
w1_slaveYou should see something lie this.
bd 01 4b 46 7f ff 03 10 ff : crc=ff YES
bd 01 4b 46 7f ff 03 10 ff t=27812

Ok its working.
We can now use a python script to read the readings
get the python code from github using the following command
git clone https://github.com/pimylifeup/temperature_sensor.git
goto the new directory that was created. temperature_sensor
cd temperature_sensor

Give the application executable writes by using the following command 
chmod 776  temperature_sensor_code.py

Then run the command
./temperature_sensor_code.py
You should see the temperature readings scrawling on the screen.
Ok we can stop it with CTRL C.
Ok now all seems to be working for the temperature readings



We now need to test the Radio transmitter.
Please note you need to have a Amateur Radio license to do this as you will be transmitting on the Amateur allocated frequencies.

Install the Raspberry Pi hat on the Raspberry Pi and then test the transmitter with the following commands.
Clone the following examples in your home directory from github
git clone https://github.com/antonjan/Raspberry_Telemetry.git

cd to the Raspberry_Telemetry directory.
Connect a 2m external antenna to the raspberry Pi Hat SMA connector.
run the following command
sudo ./Start_Carier_check.sh
Now check for a rf carrier on the following frequency
U can use a SDR dongle or HT (Baofeng) or spectrum analyzer if you have one.
The frequency can be changed by editing this file and changing the yellow value
vi ./Start_Carier_check.sh
sudo rpitx -m VFO -f 145300 -c1
Now that we have the transmitter tested we can start testing the telemetry.




Lets start doing some real time applications.

Now lets configure the APRS and CW telemetry to send sensor data and call sign. I suggest using 70cm up-link and 2M down-link not to overdrive the receiver front end. ( There is a diplex available from Giga technology)  
2m and 70cm Diplexer

  1. Sending APRS telemetry every minute with GPS and temperature readings.
  2. Sending a CW (morse code) with calsign and temperature reading every two minutes.
  3. Lets test a command to control the system. Replying with APRS got command.
  4. I wanted to send telemetry every minute but decided to make it a prime number just in case there is two telemetry transmissions disturbing each other so this would be helping to resolve this problem. (67 seconds)

Sending APRS telemetry every minute with GPS and temperature readings.


Download the following shell scripts
1) wget https://raw.githubusercontent.com/antonjan/Raspberry_Telemetry/master/sh/cron_aprs_gps_position.sh

2) wget https://raw.githubusercontent.com/antonjan/Raspberry_Telemetry/master/sh/crontab_bacar_cw.sh
3) wget https://raw.githubusercontent.com/antonjan/Raspberry_Telemetry/master/sh/crontab_bacar_aprs.sh
4) wget https://raw.githubusercontent.com/antonjan/Raspberry_Telemetry/master/telem-balloon_2.conf

Lets edit the file for your path.
vi cron_aprs_gps_position.sh
Fix the yellow with path to your direwolf file.
#load looback and start gpsd service for gps data.
sudo /usr/sbin/gpsd -D 5 -N -n /dev/ttyACM0 &
sleep 5
sudo /sbin/modprobe snd-aloop
sleep 2

#We now will write out the audio from loopback from direwolf to a wav file
sudo timeout 10s arecord -c1 -t wav -r 48000  --vumeter=mono -D hw:Loopback,1,0 -fS16_LE /home/pi/sh/direwalf.wav &
#We now will create a APRS audio withS position and send it to loopback device
sudo timeout 9s direwolf -c /home/pi/Downloads/direwolf/telemetry-toolkit/telem-balloon_2.conf

# we now wait for short wile
sleep 1

#we now convert the wav file in a format to transmit
sudo sox -v 0.3 -S /home/pi/sh/direwalf.wav /home/pi/sh/direwalf_sox.wav  rate -L -s 48000

# we now wait for short wile  
sleep 1
#we now convert the APRS audio file to a fm file for transmission.
sudo /home/pi/Downloads/rpitx_new/rpitx/pifm  /home/pi/sh/direwalf_sox.wav /home/pi/sh/direwalf_sox.wav.ft

# we now wait for short wile
sleep 1
#We now transmit the the APRS gps postion on the frequensy 144,801Mhz
sudo /home/pi/Downloads/rpitx_new/rpitx/rpitx -i /home/pi/sh/direwalf_sox.wav.ft -m RF -f 144801 -c1
Save the file

Lets send our first APRS GPS position.
Change the callsign in the  telem-baloon_2.conf to your callsign
Check that the paths in the telem-baloon_2.conf  and cron_aprs_gps_position.sh is correct in relation to the directory you check the code out.
run the script sudo ./cron_aprs_gps_position.sh and you should now send a gps position aprs message. If you change the frequency to your local packet  (APRS in SA its 144.8Mhz)frequency you should see the Balloon Icon on the APRS server.  https://aprs.fi/#!lat=60.169998&lng=24.94
You mite want to calibrate the TX frequency by changing the frequency in the script.
You can now add this script in a cron to send every 1minute ...

Here is an exsample just to send a message
sudo aprs --callsign NOCALL --output - "30mw Belloon Beacon de NOCALL" | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -m RF -i - -f 144325 -c1

Ok lets now send some CW as a beacon.

Lets create a text file with the cw message we want to send.
vi cw_text 
enter the following example

                               32mw balloon experiment de NOCALSIGN
save the file (including the space in front)

we now will be using a different script crontab_bacar_cw.sh
edit this script.
vi crontab_bacar_cw.sh
#This script will send a cw at 10 words per minute 
#Start GPS and alsa loopback
sudo /usr/sbin/gpsd -D 5 -N -n /dev/ttyACM0 &
sleep 5
sudo /sbin/modprobe snd-aloop

#now setup loopback to write to file


sudo /usr/bin/timeout 11s /usr/bin/arecord -c1 -t wav -r 48000  --vumeter=mono -D hw:Loopback,1,0 -fS16_LE /home/pi/sh/bacar_cw.wav &
# now send cw to loopback with cw_text.txt
sudo /usr/bin/timeout 10s /usr/bin/cw -s a -d hw:Loopback,1,0 -t 1000 -v 50 -f /home/pi/sh/cw_text.txt
sleep 1
#Now convert the file to format that can be converted to fm signal.
sudo /usr/bin/sox -v 0.9 -S /home/pi/sh/bacar_cw.wav /home/pi/sh/bacar_cw_sox.wav  rate -L -s 48000
sleep 1
#now create transmission file for rpitx
sudo /home/pi/Downloads/rpitx_new/rpitx/pifm  /home/pi/sh/bacar_cw_sox.wav /home/pi/sh/bacar_cw_sox.wav.ft
sleep 1
#now send your CW (morse code on 144.328 Mhz) Change frequency as requerd
sudo /home/pi/Downloads/rpitx_new/rpitx/rpitx -i /home/pi/sh/bacar_cw_sox.wav.ft -m RF -f 144328 -c1

Save the file and run and test.
sudo ./crontab_bacar_cw.sh

Now listen on the tx frequency and run the script and you should here the message "32mw balloon experiment de YOURCALLSIGN"

Saturday, October 11, 2014

Setting up my 30m APRS on HF using Quisk SDR, Soundmodem and Xastir on Linux.

Setting up my 30m APRS on HF using Quisk SDR, Soundmodem and Xastir on Linux.


Here is how I conferred my HF APRS gateway from a HF SDR. (30m Softrock SDR)

30m APRS hardware

1) Install QUISK  (SDR software) on on Linux.

2) Install Alsa loop. (loopback sound driver)
3) Install Soundmodem.  (AFSK Modem)
4) Install Xastir. ( APRS IGate and map viewer)




So lets begin.

1) Install QUISK  (SDR software) on on Linux.

The Quisk instillation need Python so you will have to install the following first.
Install the following packages.
sudo apt-get install python2.7, python2.7-dev, python-wxgtk2.8, fftw3-dev, libasound2-dev, and portaudio19-dev.

goto your Downloads directory. ( or you favorite directory)

cd Downloads
Download the Quisk application from if you want the latest version at http://james.ahlstrom.name/quisk/docs.html (quisk-3.4.4.tar.gz tar -xvf and then run quisk.py you need python ass seen above) or you could run the command  sudo apt-get install quisk


Here is the instructions if you get the latest version

 sudo apt-get install quisk
wget http://james.ahlstrom.name/quisk/quisk-3.6.18.tar.gz
unzip the quisk source code
tar -xvf quisk-3.6.18.tar.gz
there should now be a directory quisk-3.6.10
goto quisk-3.6.10 directory
cd quisk-3.6.10
Compile the quisk application
sudo make
sudo make install
you now need to create a configuration file for quisk to see your Softrock lite II sdr sound input IQ signal.
Create a text file with you favorite text editor and copy the text below and save it as 30m_aprs_quisk_conf_sdriq.py


#*****************************************************

# These are the configuration parameters for Quisk using the
# SDR-IQ by RfSpace as the capture device.

# Please do not change this sample file.

# Instead copy it to your own .quisk_conf.py and make changes there.
# See quisk_conf_defaults.py for more information.

from sdriqpkg import quisk_hardware             # Use different hardware file


# In ALSA, soundcards have these names:

#name_of_sound_play = "hw:0"
#name_of_sound_play = "hw:1"
#name_of_sound_play = "plughw"
#name_of_sound_play = "plughw:1"
#name_of_sound_play = "default"

use_sdriq = 1                                   # Use the SDR-IQ

sdriq_name = "pcm.sdrXonarD1Record12"
sdriq_clock = 66666667.0                # actual sample rate (66666667 nominal)
sdriq_decimation = 1250                 # Must be 360, 500, 600, or 1250
sample_rate = int(float(sdriq_clock) / sdriq_decimation + 0.5)  # Don't change this
name_of_sound_capt = ""                 # We do not capture from the soundcard
name_of_sound_play = "hw:0"             # Play back on this soundcard need s to be loopback device
playback_rate = 48000                   # Radio sound play rate
channel_i = 0                                   # Soundcard index of left channel
channel_q = 1                                   # Soundcard index of right channel

display_fraction = 0.85                 # The edges of the full bandwidth are not valid
#***************************************************************

Then save the file.
We now need to setup the ALSA sound system to map the alsa audio coming into the server to a friendly name "pcm.sdrXonarD1Record12" see above config file.
Run the command sudo arecord -l it will list all the ALSA audio input devices.

 sudo arecord -l
**** List of CAPTURE Hardware Devices ****
xcb_connection_has_error() returned true
Home directory /home/anton not ours.
card 0: D1 [Xonar D1], device 0: Multichannel [Multichannel]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: VT1708S Analog [VT1708S Analog]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
card 2: D1_1 [Xonar D1], device 0: Multichannel [Multichannel]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 3: M44 [M Audio Delta 44], device 0: ICE1712 multi [ICE1712 multi]
  Subdevices: 0/1
  Subdevice #0: subdevice #0


Please note I have multiple sound cards in my Linux server so you might not have as many interfaces listed as mine above.

Identify the your sound card in the list.

in my case it is :card 3: M44 [M Audio Delta 44], device 0: ICE1712 multi [ICE1712 multi]
You now need to configure the ALSA system to map the name of quisk to this card and you do it in the ALSA config file in your user home directory. (in my case it is /home/anton)

cd  to go to your home directory

pwd To list your home directory

/home/anton
edit the following ALSA audio mapping file with you favorite text editor .asoundrc  (note the dot in front of the name it means its hidden) I use VI as an editor


 vi .asoundrc

Add the following and change the names relevant your sound card name (RED)

#************************** pcm definition ************************************
pcm.sdrM44_card {# defining the card to be used
     type hw
     card M44 # this has to be done to force reboot to point to same cards
}

#************************* controller section ***********************************
ctl.sdrM44_card {#defining the control interface
     type hw
     card M44 # this has to the same as above

     }
#****************************** recording ***********************************
pcm.sdrM44Record12 { # input input 1 and 2
     type plug
     slave {
     pcm "dsnooper_M44"
     channels 4
     }
         ttable.0.0 1
         ttable.1.1 1
}



Run the quisk with your costume configuration  with the full path to the configfile

sudo quisk -c /home/anton/Downloads/quisk-3.6.10/quisk_conf_softrock_iq.py






Now we need to setup the ALSA loop back audio interface for Quisk to send the USB demodulated audio to Xastir or Fldigi or what ever modem device you are using.

2) Install ALSA loop. (Loopback sound driver)



To check if it is already installed in the ALSA device driver.
run the command sudo arecoed -l 

If you see the loopback devise skip this section below and go section 3

Compiling snd-aloop if needed

Update: it may not be needed any longer as of kernel 2.6.38 ...

It may well be that the ALSA Loopback kernel module was not included in your distribution's kernel package (it is the case in e.g. debian, as far as I know). This is no bother as we can easily compile it. Note that there is no way around since the loopback ALSA module is not part of the kernel baseline in general. So unless your kernel packager had done the following work, you will have to do it yourself ...
Warning: I tried alsa-driver 1.0.21 against 2.6.33.5-rt22 and while it compiled fine, it would not load at all, even when forced. So don't waste your time with this version combo.
Make sure you really don't have it installed. Better check that not :)
sudo modinfo snd-aloop
If modinfo reports nada, time to check that you have installed the kernel headers corresponding to your presently running kernel. I'll leave this to you as this is very distro dependent. In debian based distros, the package is called something like linux-headers-xxx and must match the installed kernel (package linux-image-xxx).
Time to make a backup of the installed kernel modules. Example:

cd
mkdir backup
cd backup
cp -a /lib/modules/`uname -r`/kernel/sound .


Prerequisite: you of course need a compiler and other tools. In debian based distros, you can check that you have a package called build-essential installed:
dpkg -l build-essential
If not, just get it:
sudo apt-get install build-essential

Now grab the alsa-driver source code (same version as your installed ALSA, in my case 1.0.23 which I will use in my description) from the The ALSA website, uncompress, untar it and cd to the alsa-driver top dir. Here is a command summary

cd
mkdir source
cd source
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.23.tar.bz2
tar jxvf alsa-driver-1.0.23.tar.bz2
cd alsa-driver-1.0.23


Now you have to configure the source package for compilation. To help you, look at what ALSA modules are currently loaded:
cat /proc/asound/modules

make
sudo make install

It will normally install all the compiled modules into the correct location of your kernel installation. Now check that the kernel knows about the loopback module:

~$ sudo modinfo snd-aloop
filename: /lib/modules/2.6.32/kernel/sound/drivers/snd-aloop.ko
license: GPL
description: A loopback soundcard
author: Jaroslav Kysela <perex@perex.cz>
srcversion: B85A5847D027749DCF96195
depends: snd-pcm,snd
vermagic: 2.6.32 SMP preempt mod_unload modversions CORE2
parm: index:Index value for loopback soundcard. (array of int)
parm: id:ID string for loopback soundcard. (array of charp)
parm: enable:Enable this loopback soundcard. (array of bool)
parm: pcm_substreams:PCM substreams # (1-8) for loopback driver. (array of int)


Now lets load it. But before that, shut down all audio apps (including firefox). Once done, do this:
sudo modprobe snd-whatever-module-you-need
sudo modprobe snd-aloop
sudo alsa force-unload



Now, see if it works: ~$ lsmod | grep aloop snd_aloop 4732 0
snd_pcm 57065 6 snd_aloop,snd_hdsp
snd 40404 18 snd_aloop,snd_hdsp,snd_pcm,snd_hwdep,snd_rawmidi,snd_seq,snd_timer,snd_seq_device

If all was ok then add snd-aloop in /etc/modules. (If you wish, you can give the loopback soundcard another name than "Loopback" in a modprobe option but I kept the default throughout the entire HOWTO and there is no need to change it.)
In case anything went wrong and you wish to go back to your previous ALSA installation, no problem:


sudo rm /lib/modules/`uname -r`/kernel/sound sudo cp -a ~/backup/sound /lib/modules/`uname -r`/kernel/ sudo alsa force-reload

there should be two new ALSA devicess 


This virtual sound card consists of 2 devices:
hw:Loopback,0
hw:Loopback,1
to see if the loop back connector is active run the command aplay -l or arecord -l


sudo arecord -l

**** List of CAPTURE Hardware Devices ****
xcb_connection_has_error() returned true
Home directory /home/anton not ours.

card 4: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]

  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 4: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

if you did see the above loopback then you are ok and we can just add the loopback configuration to the 30m_aprs_quisk_conf_sdriq.py file as above.

edit the file 30m_aprs_quisk_conf_sdriq.py
and make shore the it has the following.
name_of_sound_play = "hw:0"             # Play back on this soundcard need s to be loopback device
select the configeration button on quisk to see if the loopback is working fine.


Now we can configure Soundmodem and Xastir to decode our HF APRS....

3) Install Soundmodem. (AFSK Modem)

Instillation of soundmodem
sudo apt-get install soundmodem

We now need to configure the soundmodem and this can easily be done with guide.
sudo soundmodemconfig


Set up the ALSA audio driver and point it to the loopback interface we have configured above " plughw:Loopback,1,0"


Create a new channel by write clicking on the previous configuration that was created and selecting new channel.

Select KISS and then enter the serial device file /dev/soundmodem0

Select Modulator and set the bits 300 board  and Frequencies to 900Hz , 1.1 Khz and enable Differential Encoding.

Select Demodeluator and set the bits 300 board  and Frequencies to 900Hz , 1.1 Khz and enable Differential Encoding.

Now to test your configuration.
Select the diagnose menu and then the spectrum option and then tune the APRS frequency on the Quisk SDR so that the AFSK tones is in the center of pass band section in the spectrum display below. (Center frequency is 1Khz) You can also then check if you Radio audio frequency is flat. (Both peeks is the same high)


Move your mouse cursor over display to find frequency of display. ( wait for APRS message to be received on HF)

Adjust the Quisk SDR frequency until the APRS signal is across the 1Khz frequency. see above



That's it, your soundmodem is configured.

here is a copy of my soundmodem configuration file /etc/ax25/soundmodem.conf that was generated with soundmodemconfig application.

<?xml version="1.0"?>
<modem>

 <configuration name="HF_300Board">
<chaccess txdelay="150" slottime="100" ppersist="40" fulldup="0" txtail="10"/>
<audio type="alsa" device="plughw:Loopback,1,0" halfdup="0" capturechannelmode="Mono"/>
<ptt file="none" gpio="0" hamlib_model="" hamlib_params=""/>
<channel name="Channel 0">
<mod mode="afsk" bps="300" f0="900" f1="1100" diffenc="1" ifname="sm0" hwaddr="ZR6AIC-2" ip="10.0.0.1" netmask="255.255.255.0" broadcast="10.0.0.255"/>
<demod mode="afsk" bps="300" f0="900" f1="1100" diffdec="1"/>
<pkt mode="KISS" ifname="sm0" hwaddr="ZR6AIC-2" ip="10.0.0.1" netmask="255.255.255.0" broadcast="10.0.0.255" file="/dev/soundmodem0" unlink="0"/>
</channel>
</configuration>
</modem>


You will need some test audio so here is a video of a message that was recorded. Play it back and see if your modem is setup coorectely.

 

After your testing you will the close the soundmodemconfig Application and then run it as a soundmodem daemon in the background.

Close the soundmodemconfig application by clicking on the X on top.

then run the deamon sudo soundmodem&

4) Install Xastir. ( APRS IGate and map viewer)


Now lets setup the iGate of your APRS demodulated data to the internet
Install Xastir
sudo apt-get install xastir

run xastir

sudo xastir

Configure the Xastir to get the serial data from your sound modem
Select the interface menu


Now select the add  button and then then the Serial KISS TNC option

The TNC port has to be /dev/soundmodem0 as we configured in the soundmodem setup above

Then setup your internet APRS server details.

Save en setup your station detail.
Select file menu and then configeration.

Update your IGate details and station info see below.



Save your station configuration.
Now start Device 0 and Device 1 in the Interface menu and if all is well the interface will change to the up state.



If all the interfaces when up you should see your IGate on the internet. http://aprs.fi



Tuesday, May 7, 2013

How to do AFSK, PSK DTMF demodulation on Linux / Raspberry Pi using your RTL dongle

How to do AX25, AFSK, DTMF, POCSAG and PSK demodulation on Linux.

(RTL 2832U  receiver) Where can I get a RTL dongle http://www.giga.co.za


RTL 2832U


Using the programs multimon, sox, mkfifo, rtl_fm, git and RTL 2832U receiver you can demodulate the following modulations.

AX.25 (https://github.com/EliasOenal/multimon-ng/blob/master/README.md)
  • 1200 Baud AFSK
  • 2400 Baud AFSK (2 variants)
  • 4800 Baud HAPN
  • 9600 Baud FSK (G3RUH)
POCSAG
  • 512 Baud
  • 1200 Baud
  • 2400 Baud
Miscellaneous
  • DTMF
  • ZVEI
  • SCOPE

1) Download the following Library by using git
git clone https://github.com/EliasOenal/multimon-ng.git

cd to the multimon directory
cd multimon-ng
run the command make
mkdir build
cd build
qmake ../multimon-ng.pro
make
sudo make install

If you want to get this working on Raspberry pi you need to use the following

qmake --version qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory 
alias qmake="$(find /usr -name qmake | grep qt5)" 
qmake --version QMake version 3.0 Using Qt version 5.3.2 in /usr/lib/x86_64-linux-gnu


Command line options. (here is the help file) multimon-ng [options] [input_file]

sudo sudo multimon-ng -h
multimon-ng  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA
             (C) 2012-2014 by Elias Oenal
available demodulators: POCSAG512 POCSAG1200 POCSAG2400 FLEX EAS UFSK1200 CLIPFSK FMSFSK AFSK1200 AFSK2400 AFSK2400_2 AFSK2400_3 HAPN4800 FSK9600 DTMF ZVEI1 ZVEI2 ZVEI3 DZVEI PZVEI EEA EIA CCIR MORSE_CW DUMPCSV SCOPE

Usage: multimon-ng [file] [file] [file] ...
  If no [file] is given, input will be read from your default sound
  hardware. A filename of "-" denotes standard input.
  -t <type>  : Input file type (any other type than raw requires sox)
  -a <demod> : Add demodulator
  -s <demod> : Subtract demodulator
  -c         : Remove all demodulators (must be added with -a <demod>)
  -q         : Quiet
  -v <level> : Level of verbosity (e.g. '-v 3')
               For POCSAG and MORSE_CW '-v1' prints decoding statistics.
  -h         : This help
  -A         : APRS mode (TNC2 text output)
  -m         : Mute SoX warnings
  -r         : Call SoX in repeatable mode (e.g. fixed random seed for dithering)
  -n         : Don't flush stdout, increases performance.
  -e         : POCSAG: Hide empty messages.
  -u         : POCSAG: Heuristically prune unlikely decodes.
  -i         : POCSAG: Inverts the input samples. Try this if decoding fails.
  -p         : POCSAG: Show partially received messages.
  -f <mode>  : POCSAG: Disables auto-detection and forces decoding of data as <mode>
                       (<mode> can be 'numeric', 'alpha' and 'skyper')
  -b <level> : POCSAG: BCH bit error correction level. Set 0 to disable, default is 2.
                       Lower levels increase performance and lower false positives.
  -o         : CW: Set threshold for dit detection (default: 500)
  -d         : CW: Dit length in ms (default: 50)
  -g         : CW: Gap length in ms (default: 50)
  -x         : CW: Disable auto threshold detection
  -y         : CW: Disable auto timing detection
   Raw input requires one channel, 16 bit, signed integer (platform-native)
   samples at the demodulator's input sampling rate, which is
   usually 22050 Hz. Raw input is assumed and required if piped input is used.


how to decode a wav file

sudo ./multimon-ng -s SCOPE -t wav /tmp/message.wav (to read wav file) How to convert a wav file to row file using sox sudo sox foo.wav foo.raw
Now we want to take the received signal from rtl_fm and pyp it to the multimon
Create a fifo Pyp 
sudo mkfifo soundfifo.raw 
ls -al 
prw-r--r--  1 anton anton     0 2013-05-07 22:35 soundfifo.raw

You will see its not a normal file its got a prw in front of the file definition when you list the files.
Lets get multimon to start receiving audio from soundfifo.raw pyp.
sudo multimon-ng -a AFSK1200 -a SCOPE -t raw soundfifo.raw
 
And now send the audio from rtl_fm to the soundfifo.raw
Decoding live data from rtl receiver. (Tuning receiver to 144.800 Mhz packet frequency and demodulate that to 22.05kHz audio)
 sudo rtl_fm -f 144800000 -s 22050 ./soundfifo.raw (read my section on rtl if you want to install rtl utilities)


You should then see the scope screen below.
 

Multimon Scope Display
And your afsk1200 decoding will start in console and the scope display will show your audio.
Here is an example of hot to decode directly from rtl dongle sudo rtl_fm -d0 -f 144800000 -s 22050 - | multimon-ng -a AFSK1200 -t raw /dev/stdin

Hope this help...
REF: www.baycom.org/~tom/ham/linux/multimon.html, http://www.youtube.com/watch?v=GBmli8Vflig and http://www.ultratechie.com/2012/10/pigate/
https://github.com/EliasOenal/multimon-ng/blob/master/README.md