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

Wednesday, October 19, 2016

VHF 2m Low pass filter design for 146Mhz ideal for Raspberry Pi

VHF 2m Low pass filter design for 146 Mhz ideal for Raspberry Pi 

I wanted to use the Raspberry Pi SDR TX capabilities using the IO pins to generate RF.
The following was possible.
APRS
FM and SSB and CV
WSPR
SSTV....

There is a very nice library that will run on Raspberry Pi one B called rpitx witch can generate CW,SSB,FM SSTV...

The problem in using a Digital IO pin on the pi to generate RF signal would mean it will generate a squire wave signal witch has lots of harmonics. To solve the harmonic problem you will need to build a low pass filter.
Harmonic about 25 db down with now filter.




This harmonic would not be in regulation with rf transmission and would therefore need to create a low pass filter to remove the harmonics.

Here is a filter I build to get rid of the harmonics.

RFSim99 application.


Here is the Low pass filter spectrum analyzer curve on my LWT500,
The Harmonic level should be about 25 db below the carrier.

LPF Curve for 146Mhz (1 Harmonic down about 25db)


Here is some photos of the veroboard test filter I am now busy make a PCB for Raspberry Pi with a small 10db amp.


146 Mhz Low pass filter SMD components

Still need to replace the two wires with Coaxial cable.
This filter board with 7 stage low pass filter will be available soon. (60db)
3D model of 2m Filter board
I will still add a screenshot with the Filter attached later.
Boards has arrived. Assembly and testing will start. 


Saturday, September 10, 2016

Setting up my ARM Cortex STM32 Development environment on Linux (Ubuntu) 16.04

Setting up my ARM Cortex STM32 Development environment on Linux (Ubuntu)


I was looking for a ARM Cortex development environment that will run on Linux and found the GNU ARM Eclipse plugin for Eclipse.  ref: http://gnuarmeclipse.github.io/
As I was familiar with the Eclipse environment and as I was using Eclipse for my Java development it seems to be the best fit for my requirements. 
I had to do the following to install Eclipse.
dont install the default eclipse avalibe from Ubuntu repository as its to ould for this development you need at least vertion 4.5
download eclipse from here  http://mirror.ufs.ac.za/eclipse/technology/epp/downloads/release/neon/R/eclipse-cpp-neon-R-linux-gtk-x86_64.tar.gz
unzip eclipse-cpp-neon-R-linux-gtk-x86_64.tar.gz
Then run eclipse
sudo eclipse
Eclipse Environment
Then updated Eclipse to the latest release.
Select the help menu in Eclipse  help > 'Check for updates' and update.

Select all for update and accept the license.
Get some Coffee as this might take some time to install ;-)
You might have to restart Eclipse when its done.

When complete then select the menu  help > 'Install new software'

Click on add and add the following details.



Then select GNU ARM C/C++ Cross development Tools and click on Next.
Select all 


Select install to complete the plugin install.

Except the warning message and you might have to reboot Eclipse.
We now need to install the toolchain for the ARM processor.
do the following in command line.
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded

Now do the following in Eclipse
Then select Menu file > new project > 

Then select your Processor details and click next.


I wanted to do development using the STM32F401C-DISCO development board.
So now I need to add the part where I can deploy the Compiled code to the dev board.
Download the stmlink from here https://github.com/texane/stlink
Then unzip the file unzip stlink-master.zip
There should now be a directory stlink-master
cd to the directory cd stlink-master
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..

make
sudo make install
Then find out where is the comand st-flash
type st-flash 
reply is
st-flash is /usr/local/bin/st-flash
Then start Eclipse again and select the following menu
Run >External tools > External tools configuration



Here is what you need to configure so that Eclipse can see your STM32F401C-DISCO


When you are done with this and you test it will fail because the compiler creates a hex file and you need to change it to create a bin file for your Dev board.

Got to the menu Eclipse Menu project > propertie > settings >



Then start creating you first application.


Compile and then run the external tool configuration that was done above and your application should now run on the Dev board.
STM32F401C-DISCO dev board
Ok we can at least deploy our code to the Dev Board/
We now have to configure the debug capability so we can get feedback from board.
Install the following drivers.
sudo apt-get install libusb-dev libusb-1.0.0-dev libftdi-dev libftdi1
Download the following Eclipse debugger  nuarmeclipse-openocd-debian from this link.
There is a 32 and 64 bit vervion download the one for your operating system
https://github.com/gnuarmeclipse/openocd/releases

Then unzip the file tar -xvf  gnuarmeclipse-openocd-debian64-0.10.0-201601101000-dev.tgz
cd into the new created directory cd openosd
Then cd into the directory cd 0.10.0-201601101000-dev
Then cd to the bin directory  cd bin
Connect your dev board and the deploy an application with debugging.
Then test the openosd by running this command
sudo ./openocd -f board/stm32f4discovery.cfg
You should see a reply something like this.
GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.10.0-dev-00287-g85cec24-dirty (2016-01-10-10:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.904142

Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

The data coms led on the Dev board should now blink red green.
Stop the command by pressing CTRL -c

We now need to configure Eclipse to use the openosd.
 Start Eclips and go to the following menu.
Run>External tools>'External tools configuration'
OpenOCD configuration
Then run the command menu run > External tools > openocd
you should see something like this in the terminal if everything went ok.

Now select run menu > debug configuration >GDB Hareware Debugging
Browse for your project and select in the project pull down menu.
Select search project under the the Main tab and find your project.

Now select the debug tab
On terminal enter the following command  type arm-none-eabi-gdb  witch will return the path to the GDB
rm-none-eabi-gdb is /usr/bin/arm-none-eabi-gdb
Enter the path in the GDB command text box  /usr/bin/arm-none-eabi-gdb
and then select the Jtag device > and select GNU ARM Openocd.
Enter localhost for host name and port must be 3333

Then select debug to save.
There will then be a pop box asking you if you want to change to the Debug perspective, select yes and everything should then start debugging.



STM32 Emiliuater

There is a QEMU emulator that can simulate your hardware procesor and can be installed into eclipse.
Here is the Steps.
Download the GNU ARM Eclipse QEMU from the link below. (select the 32 or 64 bit version  .tgz)
https://github.com/gnuarmeclipse/qemu/releases

unzip the file
tar -xvf gnuarmeclipse-qemu-debian64-2.6.0-201607280535.tgz
cd to the directory that was created cd qemu
cd to your vervion directory inside the qemu  cd 2.6.0-201607280535/bin
run the command below in this bin directory.

sudo ./qemu-system-gnuarmeclipse --version

You should get a result like below

GNU ARM Eclipse 64-bits QEMU emulator version 2.6.0

Copyright (c) 2003-2008 Fabrice Bellard

Now configure Eclipse to use the QEMU

Start Eclipse and go to the following menu.
(Window -->) Preferences --> Run/Debug --> Launching --> QEMU
Set the name and binary path to the installed QEMU path done above.
My path was 
/home/anton/Downloads/qemu/2.6.0-201607280535/bin

QEMU Binary path configuration
We now need to install the QEMU Debugging plug-ins

Still need to add the External tools configure details.

Hope this has helped you getting your environment going :-)


I also found this video that basically explains what I didref :https://www.youtube.com/watch?v=HKX12hJApZM

Saturday, August 27, 2016

SDR Comparison

SDR Comparison

Name TypeFrequency rangeBand withChannelHost InterfaceWindowsLinuxMacEstimated price
AirSpy
Pre-build
24-1750 MHz
20 MSPS MSps ADC sampling, up to 80 MSPS 
1
USB
Yes
Yes
Yes using ports
US$199
SDRstick UDPSDR-HF1
Pre-built
0.1–30 MHz
80 Msps
1
1G Ethernet via BeMicroCV-A9
Yes
Yes
Yes
US$169
Apache Labs ANAN-10E
Pre-built
10 kHz – 55 MHz
122.88 Msps (14 bit ADC)
2
Gigabit Ethernet
Yes
Yes
Yes
US$995
Apache Labs ANAN-10/100
Pre-built
10 kHz – 55 MHz
122.88 Msps (16 bit ADC)
4
Gigabit Ethernet
Yes
Yes
Yes
US$1,649-US$2,449
Apache Labs ANAN-100D/200D
Pre-built
10 kHz – 55 MHz
122.88 Msps (16 bit ADC)
7
Gigabit Ethernet
Yes
Yes
Yes
US$3,299-US$3,999
SunSDR2
Pre-built
10 kHz – 160 MHz
160 MSPS
3/4
10/100 Ethernet, WLAN (embedded)
Yes
Yes
 ?
US$1,960
bladeRF
Pre-built
300 MHz - 3.8 GHz
80 kSPS - 40 MSPS
RX/TX (12-bit ADC/DAC)
 ?
USB 3.0 SuperSpeed
Yes
Yes
Yes
US$420
FLEX-6700
Pre-built
0.01–73, 135-165 MHz
245.76 MSPS (transceiver)
8/8
Ethernet
Yes
Yes
Yes
US$7,499
FLEX-6700R
Pre-built
0.01–73, 135-165 MHz
245.76 MSPS (receiver)
8/8
Ethernet
Yes
Yes
Yes
US$6,399
FLEX-6500
Pre-built
0.01–73 MHz
245.76 MSPS (transceiver)
4/4
Ethernet
Yes
Yes
Yes
US$4,299
FLEX-6300
Pre-built
0.01–54 MHz
122.88 MSPS (transceiver)
2/2
Ethernet
Yes
Yes
Yes
US$2,499
FLEX-5000A
Pre-built
0.01–65 MHz
48, 96, 192 kHz (transceiver)
2/2
1394a Firewire
Yes
No
No
US$2,800
FLEX-3000
Pre-built
0.01–65 MHz
48, 96 kHz (transceiver)
1/1
1394a Firewire
Yes
No
No
US$1,700
FLEX-1500
Pre-built
0.01–54 MHz
48 kHz (transceiver)
1/1
USB
Yes
No
No
US$650
Perseus
Pre-built
10 kHz – 40 MHz (87.5–108 MHz using FM down-converter)
80 MSPS
 ?
USB
Yes
Yes
 ?
US$1,199
SDRplay: Radio Spectrum Processor
Pre-built
0.1–2,000 MHz
0.5-12 MS/s and up to 8 MHz bandwidth
0/1
USB
Yes
Yes
Yes
US$149
ISDB-T 2035/2037
Pre-built
50–960 MHz
0.5-12 MS/s and up to 8 MHz bandwidth
0/1
USB
Yes
Yes
Yes
US$25
Soft66AD / Soft66ADD / Soft66LC4 / Soft66RTL
Pre-built
0.5–70 MHz
External ADC required (I/Q output)
0/1
USB
Yes
Unofficially
 ?
US$20
FUNcube Dongle
Pre-built
64–1700 MHz
96 kHz
0/1
USB
Yes
Yes
Yes
US$160
FUNcube Dongle Pro+
Pre-built
0.15–240 MHz, 420-1900 MHz
192 kHz
0/1
USB
Yes
Yes
Yes
US$200
FiFi-SDR
Pre-built
200 kHz – 30 MHz
96 kHz (integrated soundcard)
0/1
USB
Yes
Yes
 ?
€120
SDR-IQ
PnP
0.1 kHz – 30 MHz
66.666 MHz
1/1 ?
USB
Yes
Yes
Yes
US$525
WinRadio WR-G31DCC
Pre-built
9 kHz – 50 MHz
100 MSPS
3/3
USB
Yes
No
No
US$950
USRP B200
Pre-built
70 MHz to 6 GHz
56 Msps
 ?
USB 3.0
Yes
Yes
Yes
US$675
USRP B210
Pre-built
70 MHz to 6 GHz
56 Msps
 ?
USB 3.0
Yes
Yes
Yes
US$1,100
USRP N200
Pre-built
DC to 6 GHz
25 Msps for 16-bit samples; 50 Msps for 8-bit samples
 ?
Gigabit Ethernet
Yes
Yes
Yes
US$1,515
USRP N210
Pre-built
DC to 6 GHz
25 Msps for 16-bit samples; 50 Msps for 8-bit samples
 ?
Gigabit Ethernet
Yes
Yes
Yes
US$1,717
USRP X300
Pre-built
DC to 6 GHz
200 Msps
 ?
Gigabit Ethernet, 10 Gigabit Ethernet, PCIe
Yes
Yes
Yes
US$3,900
USRP X310
Pre-built
DC to 6 GHz
200 Msps
 ?
Gigabit Ethernet, 10 Gigabit Ethernet, PCIe
Yes
Yes
Yes
US$4,800
Cross Country Wireless SDR receiver v. 3
Pre-built
472–479 kHz, 7.0–7.3 MHz/10.10–10.15 MHz, and 14.00–14.35 MHz
External ADC required (I/Q output)
1/1
Crystal controlled two channels
Yes
Yes
Yes
US$80
Realtek RTL2832U DVB-T tuner
Pre-built with custom driver
24–1766 MHz (R820T tuner) (sensitivity drops off considerably outside this range, but can go 0–2,200 MHz (E4000 tuner with direct sampling mod))
2.4 MHz (can go up to 3.2 MHz but drops samples)
 ?
USB
Yes
Yes
Yes
US$8 - US$10
SoftRock-40
Kit
7.5 MHz
48 kHz
1
USB
Yes
Yes
Yes
US$21
SoftRock RX Ensemble II
Kit
180 kHz – 3.0 MHz, and 1.8–30 MHz operation
External ADC required (I/Q output)
1
USB
Yes
Yes
Yes
US$67
ZS-1
Pre-built
300 kHz – 30 MHz
10 kHz, 20 kHz, 40 kHz, 100 kHz
3
USB 2.0
Yes
No
No
€1,399
HackRF One
Pre-built
1 MHz - 6 GHz
8 Msps - 20 Msps
1
USB 2.0
Yes
Yes
Yes
US$299
HiQSDR
prebuilt modules & kits, pcbs
30 kHz - 62 MHz
48 - 960 kHz
 ?
10/100 Ethernet
Yes
Yes
No
US$650
US$1,400
KiwiSDR
Pre-built
0.1 - 30Mhz
30Mhz
4
Beagle black
yes
yes
yes
 USD 99
LimeSDR
Pre-built (full Open Source / Hardware)
100 kHz to 3.8 GHz
61.44 Msps (12 bit ADC)
 ?
USB 3.0, PCIe
Yes
Yes
Yes
US$299(USB) US$799(PCIe)