Showing posts with label Repeater. Show all posts
Showing posts with label Repeater. Show all posts

Saturday, November 26, 2016

Creating a 2m Fm Repeater with a Raspberry Pi (B) and a RTL dongle.

Creating a 2m Fm Repeater with a Raspberry Pi (B) and a RTL dongle. (Don't use this application without the RF filter)

RTL dongles is available from Giga Technology and the filter will be available soon.



For the purpose of this configuration I expect your Raspberry pi to be connected to the internet.
How will this repeater work.
This configuration was done with the latest Raspbian Os for Raspberry Pi downloaded from here https://www.raspberrypi.org/downloads/
I used my original Raspberry Pi B+ and also repeated  this on a Banana Pi
 as I need a hard drive to compile gnuradio for later SDR use.

I will be using a rtl dongle to receive my input signal on 70cm frequency configurable on the amateur 2m or 70cm band. The receiver signal will then be demodulated and re transmitted with a DSP Library simulating a FM Signal using a GPIO pin on the Raspberry as an transmitter.

Get your Raspberry Pi on the latest patch/update.

sudo apt-get update
sudo apt-get upgrade
Go and get some Coffee as it might take long time to update ..zzz...... ;-) 

Install the SDR command line application to access rtl  USB dongle.
This rtl library allow you to demodulate the fm / ssb input

sudo apt-get install rtl-sdr-0.5.3-3 mplayer octave gnuplot gnuplot-x11


Download the Fm transmitter software from github using the following command

Install the rpitx python library using the following command. 

rpitx is the main software to transmit. It allows to transmit from:
  • IQ files *.iq (can be generated by external software like GNU Radio).
  • Frequency/Time files *.ft (generally used to easily implement digital modes)
Installation of rpitx

git clone https://github.com/F5OEO/rpitx git clone https://github.com/F5OEO/rpitx
cd rpitx # make sure to have access to the internet to download packages # or download and install them manually (libsndfile1-dev and imagemagick) 
./install.sh

Ok lets create some IQ files that will be used  to test the transmitter.

SSB Transmiiter
./pissb sampleaudio.wav ssbIQ.wav


A sample script testssb.sh is included.


FM modulation

pifm converts an audio file (Wav, 48KHz, 1 channel, pcm_s16le codec) to Narrow band FM (12.5khz excursion) and outputs it to a .ft file. Assuming your audio file is in your current working directory ./pifm sampleaudio.wav fm.ft

Connect a antenna to pin 4  long wire 40cm or longer depending on 1/4 lent of wavelength.
Pin Connection Diagram. Use coaxial cable to make connection
Here is a link with the filter details for the 2m Band


You could then transmit it on 100MHZ (please set a correct frequency to be legal) 
sudo ./rpitx -m RF -i fm.ft -f 100000 -l -c1


A sample script : testfm.sh is included.  add -c1 for pin 4 transmission in file

VFO
A VFO mode is provided to allows precise frequency resolution. For example to set a carrier on 100MHz (please set a correct frequency to be legal)sudo ./rpitx -m VFO -f 100000 -c1

Ok we got the Transmitter working Now lets get the rtl dongle working.
Follow my steps here http://zr6aic.blogspot.co.za/2013/02/setting-up-my-raspberry-pi-as-sdr-server.html

When you are complete with installation of rtl_sdr and have tested it wit rtl_test -t we can now check what audio devices the raspberry have.

sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  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 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Now we need to install some audio utility programs to pyp and convert audio signals
sudo apt-get install sox libsox-fmt-all
ok lets test to see if we can receive 2m band transmission.

Tune the the rtl dongle for a frequency of 145.500Mhz and transmit a test signal.

sudo rtl_fm -f 145500000 -M fm 

Transmit a mp3 file recording
sox -t mp3 zr6aic_CQ_mono.mp3 -t wav -r 48000 -c 1 - | sudo ./pifm - 145.5 -c1

Installing ffmpeg


# build and install x264
git clone --depth 1 git://git.videolan.org/x264 cd x264 
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl 
make -j 4
sudo make install

 # build and make ffmpeg
git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git cd ffmpeg
./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make -j4
sudo make install


Install the following utility classes to help with the audio manipulation
sudo apt-get install libav-tools sox oggfwd libsndfile1-dev
sudo apt-get install fftw3 libfftw3-dev

Install csdr
git clone https://github.com/simonyiszk/csdr.git 
cd csdr 
git fetch 
git checkout dev 
make && sudo make install

Testing transmitter with Audio file (pin4 = -c1)
(while true; do cat speech48000.raw; done) | csdr convert_i16_f | csdr gain_ff 700 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 145000 -c1

Putting the rpitx transmitter in TCP port listening mode (replace ip with Raspberry pi ip)
Sending audio from remote computer. (using mike from Linux computer)
arecord -fS16_LE -r48000 -c1 - | nc 192.168.10.128 8011

Testing RTL_fm (replace ip with your Raspberry ip)
sudo rtl_fm -M wbfm -f 98000000 | play -t raw -r 24k -es -b 16 -c 1 -V1 -
sudo rtl_fm -M wbfm -f 98000000 |nc  192.168.10.128 8011 -


Send rtl_dongle to transmitter (replace with your raspnerry ip)
sudo rtl_sdr -s 250000 -f 144300000 -p 0 - | nc -vv 192.168.10.128 8011
sudo rtl_sdr -s 4800 -f 144300000 -p 0 - | nc -vv 192.168.10.128 8011
 

Working RX with rtl dongle
sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 8000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 145300 -c1

Working TX with pin 4

sudo rtl_fm -s48000 -g 49.6 -l 0 -M fm -f 434400000 |nc  192.168.10.128 8011 -

here is repeater without sqaulse


How to make the Repeater to auto start when the Raspberry start boot up.

Create a file and edit it
sudo vi /etc/init.d/Repeater

Add the following in the file and save it

#! /bin/sh

# /home/pi/sh/run_repeater.sh

### BEGIN INIT INFO

# Provides:          SDR repater start script
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here


# Carry out specific functions when asked to by the system

case "$1" in
  start)
    echo "Starting SDR_repeater"
    # run application you want to start
    /home/pi/sh/run_repeater.sh
    ;;
  stop)
    echo "Stopping SDR_Repeater"
    # kill application you want to stop
    killall rtl_fm
    killall rpitx
    ;;
  *)
    echo "Usage: /etc/init.d/Repeater {start|stop}"
    exit 1
    ;;

esac

Make the file executable

sudo chmod 755 /etc/init.d/Repeater


Create a file in the /home/pi/sh/run_repeater.sh

Vi /home/pi/sh/run_repeater.sh

Add the Repeater script define above in this file so that it can auto start on boot time.


sudo rtl_fm -p 38 -s48000 -g 0 -l 3 -M fm -f 434400000 |csdr convert_i16_f | csdr gain_ff 12000 | csdr convert_f_samplerf 20330 | sudo rpitx -i- -m RF -f 145293 -c1&


Test the start and stop script.


Start the Repeater

sudo /etc/init.d/Repeater start

Stop The Repeater

sudo /etc/init.d/Repeater stop

Here is a video of the Test of the repeater ( I have changed the wires with a coaxial cable)


Video testing Fm demod and re mod cross band


What else can I do

Creating APRS transmitter
Setting up APRX rpitx with Raspberry Pi

aprs --callsign <callsign> --output - "<message>" | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -m RF -i - -f 144800 -c1

Repeater configured in a single line 
sudo rtl_fm -p 38 -s48000 -g 0 -l 0 -M fm -f 434400000 |csdr convert_i16_f | csdr gain_ff 12000 | csdr convert_f_samplerf 20330 | sudo rpitx -i- -m RF -f 145293 -c1


Specifications (measured with New Low pass filter board )

Here is some results of Power measurements at 145Mhz. (@50ohm) 

  • Voltage  1.3V
  • Power 32.7 mW  (15.1dBm)

Total power consumption on power supply when repeater is running

Measured  5.44 V  and  540mA  = Total watts   2.937Watts

Saturday, July 27, 2013

EchoLink on Ubuntu (Setting up Svxlink server and qtel)

EchoLink on Ubuntu. (12.04) (Setting up Svxlink server and qtel)

Svxling is a application that allows you to setup a Echolink link or a Echolink repeater on your server.
You will need to build a interface between your computer Serial port and Mic and line in and outputs of the available sound card on your server.
Here is a typical interface diagram. You can get this interface in prebuild format at http://www.giga.co.za/ocart/index.php?route=product/product&product_id=385&search=radio+digi
 

 
Computer to Radio interface.


Jingtong Radio interface.
Jingtong HT

I now use the Baofeng uv-5r and not the Jingtong due to the squelch not being stable.


Qtel is a Echo link client that allows you to connect to Echolink system as a client simulating a radio. Communication is done using VOIP from your client to Echolink system.

Here is the steps that you neet to take if you want to set-up Svxlink link or you could only install client Qtel see nr 4.

You will have to verify your call-sign on http://www.echolink.org/ with proof of your Radio amateur license documents. (The verification process can take 24 ours, so do it upfront and you need to verify your call sign for -L link and -R repeater options)

Ones this is done you will have call-sign and password required for the configuration below.

I would suggest you get a APRS servers password as well but is not required to get your Svxserver going. ( you could add the APRS functionality later.)
1) First add the Svxlink repository ref. to Ubuntu 
sudo add-apt-repository ppa:felix.lechner/hamradio

2) Update all repository config files for Ubutu.
sudo apt-get update

3) Install the Svxlink from the new repository configerd above.
sudo apt-get install svxlink-server

4) Install the qtel client.
sudo apt-get install qtel

5) Configure the Svxling server confugeration
sudo vi /etc/svxlink/svxlink.conf

6) Change the following fields in the /etc/svxlink/svxlink.conf file

LOCATION_INFO
     Example:
     LON_POSITION=09.02.20E
     Example:
     LAT_POSITION=51.02.22N

CALLSIGN
     Examples:
     CALLSIGN=EL-ZR0ABC # callsign for a link EL for link and ER for repeater.

PTT_PORT
     Examples:
     PTT_PORT=/dev/ttyS0 # this could be a USB serial port  /dev/ttyUSB0 ?? change this to your device

FREQUENCY
     Example:
     FREQUENCY=430.050 # tx-frequency is 145.550 MHz (Radio Frequency)


TX_POWER
     Example:

     TX_POWER=3 # tx output is 3 watts

ANTENNA_GAIN
     Example:

     ANTENNA_GAIN=5 # antenna gain is 5 dBd

ANTENNA_HEIGHT











     Example: 
     ANTENNA_HEIGHT=10m # 10 meters above the ground 
     OR ANTENNA_HEIGHT=90 # 90 feet

Save the file.

Now comes the difficult part where you need to define your audio device for TX and RX.

Run the Command sudo aplay -l  This command will display all the alsa devices that can play sound to ext Speak.

sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
Home directory /home/anton not ours.
card 0: Intel [HDA Intel], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

sudo arecord -l


In my case I only have one device "card 0: Intel [HDA Intel]"

You could properly use the device name Intel.

And to get the input device available on your computer run the command sudo arecord -l

sudo arecord -l









**** List of CAPTURE Hardware Devices ****
Home directory /home/anton not ours.
card 0: Intel [HDA Intel], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: V10 [FUNcube Dongle V1.0], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

In my case there was two devices and I wanted to use the same alsa device and above so it will be the "Intel" device
Defining alsa device by going to your home directory 
cd
now edit the asla config file .asoundrc in your home directory (create one if it dose not exists)

sudo vi .asoundrc    The Intel part in the file must be changed to have your computers interface card name from the above process.

#This configuration file is for alsa interface configuration.
# 1) Intel motherboard (1 stereo input and 1 stereo output)
#
#************************** pcm definition ************************************
pcm.Intel_card {# defining the card to be used
     type hw
     card Intel # this has to be done to force reboot to point to same card
}
#************************* control section ***********************************
ctl.Intel_card {#defining the control interface
     type hw
     card Intel # this has to the same as above
     }


Save the file.


Now edit the line AUDIO_DEV=alsa:pcm.Intel_card in the sudo vi /etc/svxlink/svxlink.conf file with the name U defined in the .asoundrc file U edited above ( in section Rx1 and Tx1)

Save the file.

Now you need to configure the echo-link connectivity details.
sudo vi /etc/svxlink/svxlink.d/ModuleEchoLink.conf

change the following fields.

CALLSIGN=CALLSIGN-L # your callsign

PASSWORD=your_verified_password #verify you callsign at http://www.echolink.org/

SYSOPNAME=your name and info

LOCATION=[Svx] Fq, your location town ....

DESCRIPTION="You have connected to a SvxLink node,\n"
            "a voice services system for Linux with EchoLink\n"
            "support.\n"
            "Check out http://svxlink.sf.net/ for more info\n"
            "\n"
            "QTH:     South of Johannesburg, South Africa\n"
            "QRG:     Simplex link on 145.550 MHz\n"
            "CTCSS:   My_CTCSS_fq_if_any RX only working on TX Hz\n"
            "Trx:     My_transceiver_type Jingtong JT-208\n"
            "Antenna: My_antenna_brand/type/model Mag mount 1/4 on house roof\n"

Save a file and you should be ready to start the server.

Before we start the server with start-up script lets check if there is any errors.

Run the command sudo svxlink




if all is ok you should see something like this.

SvxLink v0.13.0 (Apr 15 2012) Copyright (C) 2011 Tobias Blomberg / SM0SVX

SvxLink comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it in accordance with the terms and conditions in the
GNU GPL (General Public License) version 2 or later.

Using configuration file: /etc/svxlink/svxlink.conf
--- Using sample rate 48000Hz

Starting logic: SimplexLogic
Home directory /home/anton not ours.
Loading module "ModuleHelp" into logic "SimplexLogic"
        Module Help v0.7.0 starting...
Loading module "ModuleParrot" into logic "SimplexLogic"
        Module Parrot v0.7.0 starting...
Loading module "ModuleEchoLink" into logic "SimplexLogic"
        Module EchoLink v0.10.1 starting...
*** WARNING: The value of ModuleEchoLink/LOCATION is too long. Maximum length is 27 characters.
Loading module "ModuleTclVoiceMail" into logic "SimplexLogic"
        Module Tcl v0.3.0 starting...
Event handler script successfully loaded.
EchoLink directory status changed to ON
--- EchoLink directory server message: ---
To ensure security, each
callsign used with EchoLink
must be validated.  The
callsign you are using has
not yet been validated.

Several different validation
options are available.  To
begin, please go to
www.echolink.org and click on
Validation.


Debugging


1) if you get an error like this.

*** ERROR: The sample rate could not be set to 8000Hz for ALSA device "pcm.Intel_card". The closest rate returned by the driver was 44100Hz.
*** ERROR: Could not open audio device for receiver "Rx1"

Most build in sound-cards should be able to handle 96000 or 48000Hz
Change the sample rate by editing the config file

Try uncommenting the CARD_SAMPLE_RATE=48000 and change it to 8000 or 16000 or 48000 in the /etc/svxlink/svxlink.conf file (high value is better)

2) if you get an error like this.

open serial port: Input/output error
*** ERROR: Could not initialize TX "Tx1"
*** ERROR: Could not initialize Logic object "SimplexLogic". Skipping...
*** ERROR: No logics available. Bailing out...

This means the serial port defined above PTT_PORT=/dev/ttyS0 is wrong and you need to get the correct port. (If you are using USB serial port it could be something like /dev/ttyUSB0)

3) If you get an error like this.
*** WARNING: SvxLink can only handle WAV files with sample rate 8000: /usr/share/svxlink/sounds/en_US/EchoLink/name.wav

It seems that the Ubuntu install install 16 bit audio files by default.
You can check the files by running the command.
file  /usr/share/svxlink/sounds/en_US/Default/0.wav
This what you will get from the command conferming it is 16bit

/usr/share/svxlink/sounds/en_US/Default/0.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
I had to replace the files with this link https://launchpad.net/~felix.lechner/+archive/hamradio/+build/4783829

backup the existing wave files
Remove / uninstall the 16 khz files
sudo dpkg -r  svxlink-sounds-en-us-heather-16khz

Download the install file
Run sudo wget https://launchpad.net/~felix.lechner/+archive/hamradio/+build/4783829/+files/svxlink-sounds-en-us-heather-8khz_11.11-1~raring~ppa1_all.deb

Run the command
sudo dpkg -i svxlink-sounds-en-us-heather-8khz_11.11-1~raring~ppa1_all.deb

There should be now errors. (if there is errors tel me how you got it fixed below)
Normally you could just edit the /etc/svxlink/svxlink.conf file and fix the error.

My start up scrips did not work with the default instillation procedure as above and I had to add additional info in the script /etc/init.d/svxlink-server as follows.

4) If you get an error like this when you start up svxlink-server: 39: [: -eq: unexpected operator
It also means your PTT_PORT=/dev/ttyS0 is not set correctly.

I had to add the following lines.



Edit the file
sudo vi /etc/init.d/svxlink-server
add the following
LOGFILE=/var/log/svxlink # just below the PATH line

and changed RUNASUSER=svxlink to RUNASUSER=root 


Now lets start the Svxlink server.
sudo /etc/init.d/svxlink-server start

Check that the process is running.
sudo ps -ef | grep svxlink

We still need to adjust the audio levels for tx and rx.
run the alsa mixer to adjust the audio levels

run  sudo alsamixer   In my case I gad to set the Capture volume for the Audio from radio.

The log file will indicate if the level is set to high.


alsamixer (F5, F6, space bar, m, up, down selection keys )











Tail the log file for possible configuration errors when u start the server.

sudo tail -f /var/log/svxlink







To stop the server 
sudo /etc/init.d/svxlink-server stop

How to start Qtel client

sudo qtel

Linux Qtel Client

Qtel CLient













Client on windows

Echolink Client












Android Client
Echolink Station list




















Link connection screen
Connection view






























If the APRS server details, username and password is configured correctly you should be able to see your station on the APRS map.
What is nice is the fact that your APRS station details get updated with connection details as stations connect to your Svxlink server.


EL-ZR6AIC APRS























Please give me feedback on any mistakes.
more info is avalible at http://www.svxlink.net/?tag=svxlink-server-on-ubuntu-12-04

Wednesday, March 20, 2013

2M Band is now added to webSDR in South Africa so come and listen to the local ZA

2M Band is now added to webSDR in South Africa so come and listen to the local ZA

I have now added the 2M band to webSDR receiver system and Pieter-Tjerk has added the FM mode and it works fantastic.

Just click on band selection 2M modulations FM and decrees the bandwidth to about 12.5 khz.
Drag the yellow courser to the frequency you whant to listen.