Monday, June 5, 2017

Configuring my SA9227 with PCM5102A 32BIT / 384KHZ USB3 Hifi Audio DAC on Linux

Configuring my SA9227 with PCM5102A 32BIT / 384KHZ USB3 Hifi Audio DAC on Linux


SA9227 with PCM5102A 32BIT / 384KHZ USB3 Hifi Audio DAC 
I was looking for a high end Audio DAC for Linux and found this unit. I wanted to generate IQ moderation for a transmitter and this module would work nicely. It Unfortunately it only works on USB3 so this one cant be used on raspberry Pi 3 :-( but works fine on my Ubuntu laptop.


Description

  • Input :5 V (USB supply),
  • THD+N: <0.005% (RL = 10 kω)
  • independence: >95 dB
  • DRC: >95 dB
  • USB sample rate:16-32BIT/32-284KHZ
I first tried it on a USB 2 port but got this error when connecting the Device to the usb2 port

/var/log$ tail -f syslog
Jun  5 21:32:03 anton-SATELLITE-P755 kernel: [101544.064132] usb 2-1.2: device descriptor read/64, error -32
Jun  5 21:32:03 anton-SATELLITE-P755 kernel: [101544.240155] usb 2-1.2: new full-speed USB device number 21 using ehci-pci
Jun  5 21:32:03 anton-SATELLITE-P755 kernel: [101544.312119] usb 2-1.2: device descriptor read/64, error -32
Jun  5 21:32:03 anton-SATELLITE-P755 kernel: [101544.488089] usb 2-1.2: device descriptor read/64, error -32
Jun  5 21:32:04 anton-SATELLITE-P755 kernel: [101544.664066] usb 2-1.2: new full-speed USB device number 22 using ehci-pci
Jun  5 21:32:04 anton-SATELLITE-P755 kernel: [101545.072135] usb 2-1.2: device not accepting address 22, error -32
Jun  5 21:32:04 anton-SATELLITE-P755 kernel: [101545.144111] usb 2-1.2: new full-speed USB device number 23 using ehci-pci
Jun  5 21:32:05 anton-SATELLITE-P755 kernel: [101545.552096] usb 2-1.2: device not accepting address 23, error -32
Jun  5 21:32:05 anton-SATELLITE-P755 kernel: [101545.552269] usb 2-1-port2: unable to enumerate USB device
Jun  5 21:32:05 anton-SATELLITE-P755 gnome-session[2394]: (gnome-software:2545): Gs-WARNING **: failed to call gs_plugin_refine on appstream: Error opening file: Permission denied


I then tried it on a usb 3 port  and got the following log.

Jun  5 21:49:55 anton-SATELLITE-P755 kernel: [102616.072168] usb 3-1: new full-speed USB device number 2 using xhci_hcd
Jun  5 21:49:55 anton-SATELLITE-P755 kernel: [102616.192175] usb 3-1: device descriptor read/64, error -71
Jun  5 21:49:55 anton-SATELLITE-P755 kernel: [102616.416205] usb 3-1: device descriptor read/64, error -71
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102616.632092] usb 3-1: new full-speed USB device number 3 using xhci_hcd
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102616.752241] usb 3-1: device descriptor read/64, error -71
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102616.976267] usb 3-1: device descriptor read/64, error -71
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102617.192119] usb 3-1: new full-speed USB device number 4 using xhci_hcd
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102617.192513] usb 3-1: Device not responding to setup address.
Jun  5 21:49:56 anton-SATELLITE-P755 kernel: [102617.396397] usb 3-1: Device not responding to setup address.
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.600038] usb 3-1: device not accepting address 4, error -71
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.712114] usb 3-1: new high-speed USB device number 5 using xhci_hcd
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.733859] usb 3-1: New USB device found, idVendor=262a, idProduct=9227
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.733864] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.733867] usb 3-1: Product: HD USB Audio
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.733869] usb 3-1: Manufacturer: XENRAN Audio
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.737019] input: XENRAN Audio HD USB Audio as /devices/pci0000:00/0000:00:1c.5/0000:05:00.0/usb3/3-1/3-1:1.0/0003:262A:9227.0002/input/input16
Jun  5 21:49:57 anton-SATELLITE-P755 kernel: [102617.737332] hid-generic 0003:262A:9227.0002: input,hidraw0: USB HID v1.00 Device [XENRAN Audio HD USB Audio] on usb-0000:05:00.0-1/input0
Jun  5 21:49:57 anton-SATELLITE-P755 mtp-probe: checking bus 3, device 5: "/sys/devices/pci0000:00/0000:00:1c.5/0000:05:00.0/usb3/3-1"
Jun  5 21:49:57 anton-SATELLITE-P755 mtp-probe: bus: 3, device: 5 was not an MTP device
Jun  5 21:49:57 anton-SATELLITE-P755 systemd-udevd[19211]: Process '/usr/sbin/alsactl -E HOME=/run/alsa restore 1' failed with exit code 99.
Jun  5 21:50:01 anton-SATELLITE-P755 gnome-session[2394]: (gnome-software:2545): Gs-WARNING **: failed to call gs_plugin_refine on appstream: Error opening file: Permission denied


This looked promising

I then checked if Alsa would see the device

sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [HD USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Audio [HD USB Audio], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

and the yellow was added as a new device to be used.

I could now use the normal Alsa audio controls with this device.

Sunday, June 4, 2017

Configuring my wifi dongle on the Raspberry Pi to connect to my network router.

Configuring my wifi dongle on the Raspberry Pi to connect to my network router.

Generic Wifi dongle used on my Raspberry Pi


I had to get my router details and had to configure the following configuration files.
I wanted to give my Raspberry Pi a spear static IP so I always know what it is on my network.

I edited the following files.

/etc/wpa_supplicant/wpa_supplicant.conf

I added the following at the end. I was using WEB encryption and shared key on my router.
Change the details in yellow for your router if you use web encryption with shared key.
use your favorite editor
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

#Configeration of the file /etc/wpa_supplicant/wpa_supplicant.conf
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
        ssid="MyRouter"  # your router ID
        key_mgmt=NONE
        wep_key0="0123456789123"  # or 13 characters, or a hexkey starting with 0x your key
        wep_tx_keyidx=0
        auth_alg=OPEN
}

Save and exit
And the change the following file

Edit the file as follows in the section configuring wlan0
I gave my Raspberry pi a spear static Ip on my network so always now what the ip is and don't use DHCP so I will not know what the Ip will be 
use your favorite editor

sudo vi /etc/network/interfaces
auto wlan0
allow-hotplug wlan0
#iface wlan0 inet dhcp
iface wlan0 inet static
address 192.168.1.205  #Static Ip
netmask 255.255.255.0 # Ip mask of network
gateway 192.168.1.254 # IP gateway of router
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Save

And reboot Raspberry Pi  sudo shutdown -r 0

ping your new Ip on Wifi network

ping 192.168.1.205

And it should now work.





Wednesday, March 22, 2017

Receiving NOAA weather satellite images with a RTL dongle and a Turnstile crossed dipole automatically.

Receiving NOAA weather satellite images with a RTL dongle and a Turnstile crossed dipole automatically. 
NOAA19-HVCT 2017-03-18 15:40 Taken with this system
What do you need to setup a automatic NOAA APT Weather station configuration.
The necessary licences for your region. FCC ...
Here is a Link to Automated NOAA weather satellite System In Bassonia South Africa.


Hardware requirement diagram.

How dose this system work?

  • The system consists of 3 shell scripts that tai 5 applications together.
  • The shell scrip will fetch the satellite TLE keps data from celestrack. http://www.celestrak.com/NORAD/elements/weather.txt
  • The NOAA satellite TLE data is then passed to the predict satellite positioning software.
  • The predict software calculate when the next satellite will be above your radio station.
  • The result of the calculations for the next 24 hours is then send to a scheduler program call "at".
  • The "at" scheduler will then start and stop the rtl_fm receiver at the required time, frequency and record the audio in the recording directory from the NOAA satellite.
  • The Audio files is not in the correct format for wxtoimg utility to convert it to images and need to be converted to the correct format using the SOX until.
  • The converted recordings is then passed to wxtoimg utility to generate the Satellite images.
  • The images is then exposed via a Apache web server with a php plugin to the internet.

Hardware

  • Raspberry PI and power supply
  • RTL dongle with USB cable and MCX connector adaptor.
  • RG58 Coaxial cable with connectors or better cable. Max 4m
  • Turnstile crossed dipole Antenna.
  • All Hardware and software is available from Giga Technology

Software

  • Predict - Utility to calculate satellite azimuth and elevation using TLE Kep elements
  • rtl_fm - SDR fm Demodulation Utility to decode your ATP Satellite signal to audio file.
  • Sox - To convert row Audio file into format for wxtoimg to convert to Satellite Image.
  • Shell script to calculate the schedule for enabling the rtl receiver.
  • wxtoimg - Utility that converts ATP Audio files into Satellite Images.
  • Apache server to expose the images to the internet.
Software Functional Block diagram


The following software need to be installed on Raspberry Pi or Linux server.

sudo apt-get install predict
sudo apt-get install rtl-sdr
sudo apt-get install sox
sudo apt-get install wxtoimg
sudo apt-get install git
sudo apt-get install apache2
sudo apt-get install php
sudo apt-get install libapache2-mod-php
sudo apt-get install php-mcrypt
sudo apt-get install php-mysql

Create a directory sh in hour home directory.
cd
mkdir sh
cd sh
Create a wxsat directory in your home directory
cd
mkdir wxsat
cd wxsat
Create a images directory in wxsat directory
mkdir images
Create a recordings directory.
mkdir recordings
Create a thumb directory inside the images directory.
cd images
mkdir thumb


cd to sh directory and download the following scripts from github using the git command below
cd ~/sh
git clone https://github.com/antonjan/noaa_weather.git
it will create a directory noaa_weather in the sh directory
Inside the directory there will be three scripts. (the index.php will need to be moved later)
noaa_sat_scheduler.sh
noaa_scheduler.sh
create_thumbnail.sh
index.php
Readme.me

You will need to change your stations GPS coordinates in the following files

Edit the file noaa_sat_schedule.sh and change the following details to your coordinates.
The last one is altitude in meters.

/usr/local/bin/wxmap -a -T "NOAA ${bird}" -H ~/wxsat/weather.txt -L "-26.17/-28.03/1700" -p0 -o "\$mapdate" ~/wxsat/noaa${bird}map.png
/usr/local/bin/wxmap -a -T "NOAA ${bird}" -H ~/wxsat/weather.txt -L "-26.17/-28.03/1700" -p0 -o "\$mapdate" ~/wxtoimg/maps/noaa${bird}map.png

and save the file.
Then you need update the predict program with your station coordinates.
Run the command sudo predict
Select the G to change your ground station position details.
and enter to get to next position. ESC to exit. ant then Q to exit.




Setup crontab to run the scrip at midnight
using the command sudo crontab -e
add the following at the bottom of the crontab file

1 0 * * * ~/sh/noaa_weather/noaa_scheduler.sh

You can run the script manually now to see if it works.
sudo ~/sh/noaa_weather/noaa_scheduler.sh
it should create schedules to run for the next 24 hours.
type the command sudo at -l witch should list the scheduled tasks
You should see something like this.
94 Thu Mar 23 02:13:00 2017 a root
95 Thu Mar 23 14:43:00 2017 a root
88 Thu Mar 23 05:30:00 2017 a root
92 Thu Mar 23 05:49:00 2017 a root
89 Thu Mar 23 17:53:00 2017 a root

There also should be at least 4 files in the ~/wxsat directory

noaa15.at
noaa18.at
noaa19.at
weather.txt

If you got here all went ok.
Connect the rtl dongle to your raspberry pi or Linux (ubuntu) computer.
Connect the coaxial cable to the Turnstile crossed dipole at wate for the first scheduled task as in the list above. sudo at -l

If you want to remove a previous task you can run the following command.
Make sure you always only have one task for the same time.
sudo atrm [task number]   EG sudo atrm 94

Go and look in the ~/wxsat/images  directory and your satellite images should be there for the day.
cd ~/wxsat/images

Ok now we need to get your image exposed on the Apache2 web server.

You now will need the full path to your wxsat directory.
cd ~/wxsat
pwd
/home/anton/wxsat
So in my case the full path is /home/anton/wxsat
Create a link between the apache server and you images.
go to directory /var/www
cd /var/www
sudo ln -s /home/anton/wxsat ./wxsat

if you goto you webserver on raspberry or linux you should see your images.
Take your browser on the Raspberry or linux server and goto http://localhost/wxsat/images
You will see a directory with file names of all the satellite images.
If you cant see the images you might have to make a small change to your apache2.conf file.

make sure you have the following in you /etc/apache2/apache2.conf file
change or add this

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Then restart Apache2
sudo systemctl restart apache2



Image file list

Ok So you want to see thumbnail images and the click on image to view full image the copy the file index.php from the git repository into your images directory.
cp ~/sh/noaa_weather/index.php ~/wxsat/images/

Ok check your image directory in your web browser again and it should now have index page with thumbnails. You can change the index.php content of this page to add your details.

http://localhost/wxsat/images

Thumbnail Image index page




Here is a Link to Automated NOAA weather satellite System In Bassonia South Africa.

My Satellite Antennas
Notes:
The following config files is used by default
(The wxtoimg and wxmap command line will look in both places for a config file)
  • /usr/local/etc/wxtoimg.cfg
  • ~.wxtoimgrc
Example of the config file.

#
# WXtoImg configuration file written by WXtoImg.
# "man wxtoimg" or wxtoimg.html for details.
# WXtoImg version 2.11.2 beta
#
#
Registration Name: WXtoImg Professional
Registration Email: Anton.janovsky@gmail.com
Registration Key: TRLQ-KGKH-7M7!-U96U-CBQ1
Signal Type: APT
Expert Mode: false
Status Info Size: 0
Large Pixmap Support: false
Prompt on Exit: true
Decode in Record: true
Scroll in Record: true
Direction: northbound
Sample Rate: 11025.00
#Resurs Sample Rate: 11025.0
#Meteor3 Sample Rate: 11025.0
#Meteor2 Sample Rate: 11025.0
#SICH1M Sample Rate: 11025.0
#SICH Sample Rate: 11025.0
#Okean Sample Rate: 11025.0
#NOAA Sample Rate: 11025.0
#Meteosat Sample Rate: 11025.0
#GOES Sample Rate: 11025.0
#GMS Sample Rate: 11025.0
#MTSAT Sample Rate: 11025.0
Set Sample Rate: false
Sharpen: 0.6
JPEG Quality: 90
AVI Codec: RGB
AVI Transparent: false
AVI Quality: 85
AVI Scale: 0.5000
Max Frames: 16
Frame Rate: 1.000
Image Format: JPEG
Anaglyph Image Format: png
Composite Image Format: png
Messages: normal
Resync: enabled
Noise Filter: 0
Noise Threshold: 44
Crop: disabled
Contrast: var
Illumination Compensation: none
Gamma: 1.40
Despeckle: 2.00
No Signal Fill: true
Audio Directory: /home/anton/wxtoimg/audio
Image Directory: /home/anton/wxtoimg/raw
Save Directory: /home/anton/wxtoimg/images
Map Directory: /home/anton/wxtoimg/maps
Thumbnail Directory: /home/anton/wxtoimg/thumbnails
Template for Audio: false
Filename Info: UTC YYYYMMDDHHMM
Temperature Units: C
Distance Units: km
Enhancement: HVCT
Auto Image Template: %s-%f-%e
Auto Image Enhancements: "-" "contrast -a" "contrast -b" "NO" "HVCT" "MSA" "MCIR"
Record Type: A
Record Name Format: %Y%m%d%H%M
BMPs for DA: false
Record Bits: 16
Record Level: 25
Record Delay: 60
Record Rate: 11025
Record Only Active: enabled
Record Elevation: 20
Record Above: 8
Record Disable Info: false
Record Add: -N
Record Device: 0
Record Modes: ARD
Recording Forces Location: false
Receiver Type: none
Receiver Port: /dev/ttyS0
Receiver Baud: 0
Rotor Type: none
Rotor Port: /dev/ttyS0
Rotor Baud: 0
Park Elevation: 90.0
Park Azimuth: 180.0
GPS Port: /dev/ttyS1
GPS Baud: 4800
GPS Use: false
GPS Set Clock: false
Pass List Hours: 168
Process Time: 300
Use Alternate Memory Model: false
Delete Audio After: 999
Delete Maps After: 999
Delete Raw Images After: 999
Delete Images After: 999
Flip Meteor 3: disabled
Map Build: enabled
Map Overlay: enabled
Map Population: 0
Map Antialias: true
Map Thick Lines: false
Map Land-Sea: enabled
Map Lakes: disabled
Map Rivers: disabled
Map Country Borders: enabled
Map State Borders: enabled
Map Ground Station: enabled
Map Grid: 10
Map Offset Northbound: 0
Map Offset Southbound: 0
Map Land Color: light-green
Map Lake Color: light-green
Map River Color: light-green
Map Country Border Color: yellow
Map State Border Color: yellow
Map Ground Station Color: yellow
Map City Color: orange
Map Grid Color: red
Ground Station: Johannesburg, South Africa
Latitude: -26.170
Longitude: 28.030
Altitude: 1700.0
NOAA\ 12 Is Active: false
NOAA\ 14 Is Active: false
NOAA\ 15 Is Active: true
NOAA\ 16 Is Active: false
NOAA\ 17 Is Active: false
NOAA\ 18 Is Active: true
NOAA\ 19 Is Active: true
Meteor\ 3-5 Is Active: false
Meteor\ 2-21 Is Active: false
Resurs\ O1-N4 Is Active: false
Okean-O Is Active: false
SICH-1 Is Active: false
SICH1M Is Active: false
GOES Is Active: false
GMS Is Active: false
MTSAT Is Active: false
Meteosat Is Active: false
NOAA\ 12 Frequency: 137.5000
NOAA\ 14 Frequency: 137.6200
NOAA\ 15 Frequency: 137.6200
NOAA\ 16 Frequency: 137.6200
NOAA\ 17 Frequency: 137.5000
NOAA\ 18 Frequency: 137.9125
NOAA\ 19 Frequency: 137.1000
Meteor\ 3-5 Frequency: 137.3000
Meteor\ 2-21 Frequency: 137.4000
Resurs\ O1-N4 Frequency: 137.8500
Okean-O Frequency: 137.4000
SICH-1 Frequency: 137.3800
SICH1M Frequency: 137.4000
GOES Frequency: 137.5000
GMS Frequency: 137.5000
MTSAT Frequency: 137.5000
Meteosat Frequency: 137.5000
NOAA\ 12 Priority: 1
NOAA\ 14 Priority: 1
NOAA\ 15 Priority: 1
NOAA\ 16 Priority: 1
NOAA\ 17 Priority: 1
NOAA\ 18 Priority: 1
NOAA\ 19 Priority: 1
Meteor\ 3-5 Priority: 2
Meteor\ 2-21 Priority: 1
Resurs\ O1-N4 Priority: 1
Okean-O Priority: 1
SICH-1 Priority: 1
SICH1M Priority: 1
GOES Priority: 5
GMS Priority: 5
MTSAT Priority: 5
Meteosat Priority: 5
NOAA 19 Catalogue Number: 33591
Auto-Decode: true
Alt Sensor: 0
MSA 1: 50
MSA 2: 50
MSA 3: 0
Atmospheric Compensation: false
Auto Save Options: true
Save Temperature Data: false
Check for New Version: true
Update Sat Info: true
Auto Record: false
Auto Update Keplers: false
Last Kepler Update: 0
Geometry: 1301x715+65+24
Pass List Geometry: 843x618+483+131
Help Geometry: 783x512+510+117
Own Colormap: true
Use UTC: true
Tearoff Menus: false
Image Set Background: false
Maximum Thumbnails: 25
Log Messages: false
Help Language: EN
Help Font Size: +0
Date Format: %Y-%m-%d %H:%M
Date Format with Seconds: %Y-%m-%d %H:%M:%S
Show All: false
Text Mode 1: 0
Text Mode 2: 0
Text String 1:
Text String 2:
Text Size 1: 26
Text Size 2: 18
Text on Movies: true
Text on Composites: false
Temp Scale: false
Temp Black: false
Projection: -
Projection Reference Latitude:
Projection Reference Longitude:
Projection Bound North:
Projection Bound South:
Projection Bound West:
Projection Bound East:
Projection Resampling: bicubic
Projection Scale: 1.000
Projection Min Fill: 0.1
Movie Projection Reference Latitude:
Movie Projection Reference Longitude:
Movie Projection Bound North:
Movie Projection Bound South:
Movie Projection Bound West:
Movie Projection Bound East:
Movie Projection Scale: 1.000
Auto Movie Template: %g-%e
Auto Movie Enhancements: "contrast -b" "MCIR"
Composite Projection Reference Latitude:
Composite Projection Reference Longitude:
Composite Projection Bound North:
Composite Projection Bound South:
Composite Projection Bound West:
Composite Projection Bound East:
Composite Projection Scale: 0.750
Auto Composite Template: %g-%@%Y%m%d-%p-%e
Auto Composite Enhancements: "MSA" "MCIR" "HVCT"
Composite Min Solar Elevation: 0.0
Web Page Template: /usr/local/lib/wx/template1.html
Web Page Enhancement: MSA,MCIR,veg,Pristine
Web Composite Enhancement:
Web Page Thumbnail Size: 20.0
Web Page Filename: index.html
Web Page FTP Publish: false
Web Page FTP Passive: true
Web Page FTP Host: myisp.someplace.net
Web Page FTP User:
Web Page FTP Passphrase:
Web Page FTP Directory: wxtoimg
Web Page Folder Publish: true
Web Page Folder: /home/anton/wxtoimg/web
Web Page Add All: false
Minimum Solar Elevation: 0.0
Exclude from Composites:
Exclude from Web:
Minimum Scan Lines: 0
Use MCIR if MSA fails: false
Kepler Host: www.celestrak.com
Kepler Login:
Kepler Passphrase:
Use Proxy: false
Proxy Host:
Proxy Port: 8080



ref:

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