Giter VIP home page Giter VIP logo

rpitx-app-note's Introduction

Application note on using rpitx

The recently released rpitx by Evariste, F5OEO allows us to transmit an RF signal over GPIO18 (pin 12) of a Raspberry Pi. The software can accept an I/Q signal as an input, so now a Pi can be used as a general purpose SDR transmitter.

This document is about using GNU Radio and csdr with rpitx.

Table of contents

...and actually you may distrub some important radio communication services. Please don't do this! You can get into trouble! You have been warned.

In addition to the squre wave output, the spectrum is also affected by the PWM-based amplitude modulation implemented in rpitx.

  • Right now it is more useful to use these examples for e.g. demonstrations on SDR transmitters
    (as most of them use the PWM mode).
  • If you want to connect this to a real antenna, you should use a very good band-pass filter!
  • Please check your signal output on a proper spectrum analyzer before ever using this on the air!
  • In addition, only transmit if you have a proper license to do so.

Using a Raspberry Pi as remote software defined radio peripheral from GNU Radio

To do this, you will need:

  • a PC running GNU Radio on Linux,
  • a Raspberry Pi with rpitx installed,
  • both connected to the same network.

We will stream the I/Q signal from the PC to the Raspberry Pi via TCP.

On the Raspberry Pi, execute:

nc -l 8011 | sudo rpitx -i- -m IQFLOAT -f 28400
  • This will listen on TCP port 8011 for the I/Q signal.
  • The center frequency of the transmitter will be 28400 kHz.

If you want it to restart everytime the connection is lost, use this command:

while true; do (nc -l 8011; dd if=/dev/zero bs=4096 count=30); done | sudo rpitx -i- -m IQFLOAT -f 28400

NFM modulator example for GNU Radio

On the PC, open GNU Radio Companion, and load the flow graph in this repo at gnuradio/nfm-rpitx.

NFM in GNU Radio

If you execute it, the I/Q signal will be streamed to the Raspberry Pi through the TCP socket.

  • Note that the frequency translation is there on intention. On some unkown reason, the spectrum is quite distorted if our signal is centered at DC.

Here is the good result if received with an RTL-SDR and GQRX:

NFM in GQRX

SSB modulator example for GNU Radio

Use the flow graph in gnuradio/ssb-rpitx. This will transmit an USB signal.

SSB in GNU Radio

The spectrum of the transmitted I/Q signal looks like this:

SSB in GNU Radio

After receiving it with RTL-SDR and GQRX:

SSB in GQRX

If you want LSB, you should double-click the "Band Pass Filter" block, and change:

  • Low Cutoff Freq to -3000
  • High Cutoff Freq to -300

SSB in GQRX

AM modulator example for GNU Radio

Use the flow graph in gnuradio/am-rpitx. This will transmit an AM signal.

  • One thing that can be screwed up is gain. I had to play with the AGC to get it right.

AM in GQRX

The spectrum of the transmitted I/Q signal looks like this:

AM in GQRX

After receiving it with RTL-SDR and GQRX:

AM in GQRX

Using rpitx with csdr to modulate streaming input

csdr is a command line tool for simple DSP tasks. It can be used to build simple AM/FM/SSB receivers, and now transmitters as well, and is quite fast to setup.

You will need the dev branch of csdr for doing this.
Setup instructions:

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

Note that it should be already done if you installed qtcsdr previously.

Modulate from raw audio file

These examples will use the raw audio file music48000.raw and speech48000.raw, which is present in this repo. You can get this file by:

git clone https://github.com/ha7ilm/rpitx-app-note
cd rpitx-app-note; ls  #There are your files.

We will play these files in a loop, you can stop it with Ctrl+C.

Generate AM modulation:

(while true; do cat music48000.raw; done) | csdr convert_i16_f | csdr gain_ff 1.0 | csdr dsb_fc | csdr add_dcoffset_cc | sudo rpitx -i- -m IQFLOAT -f 28400
  • The part csdr gain_ff 1.0 can be changed to increase/decrease modulation.
  • The -f 28400 at the end gives the transmit frequency in kHz.

Generate USB modulation:

(while true; do cat speech48000.raw; done) | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc 0 0.1 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400

Generate LSB modulation:

(while true; do cat speech48000.raw; done) | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc -0.1 0 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400
  • It's the matter of the filter which sideband do we select:
    • csdr bandpass_fir_fft_cc -0.1 0 is the lower sideband
    • csdr bandpass_fir_fft_cc 0 0.1 is the upper sideband
  • I have experienced that if the SSB signal is in the center of the I/Q signal, then it is not transmitted correctly. The solution was to shift it. So the exact frequency should be around: rpitx frequency + 48000*0.2 = rpitx frequency + 9600 Hz
  • If you want to get some compression on the speech, you can try csdr fastagc_ff instead of csdr gain_ff 2.0.

Generate NFM modulation:

(while true; do cat music48000.raw; done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400

Generate WFM modulation:

(while true; do cat music48000.raw; done) | csdr convert_i16_f | csdr gain_ff 70000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400
  • Frequency deviation is set much higher with csdr gain_ff 70000, that's the only difference between this and NFM.

Modulate from microphone input source

Use this if you have a microphone connected to the Raspberry Pi via external USB audio device.
You will have to get the correct ALSA device ID via arecord -L, it will be something like plughw:CARD=Device,DEV=0. You should enter as the argument of the -D switch of arecord.

#AM:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr gain_ff 1.0 | csdr dsb_fc | csdr add_dcoffset_cc | sudo rpitx -i- -m IQFLOAT -f 28400
#USB:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc 0 0.1 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400
#LSB:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc -0.1 0 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400
#NFM:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400
#WFM:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr gain_ff 70000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400

Modulate from audio streamed from remote computer

First, start the transmitter:

#AM:
nc -l 8011 | csdr convert_i16_f | csdr gain_ff 1.0 | csdr dsb_fc | csdr add_dcoffset_cc | sudo rpitx -i- -m IQFLOAT -f 28400
#USB:
nc -l 8011 | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc 0 0.1 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400
#LSB:
nc -l 8011 | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc -0.1 0 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400
#NFM:
nc -l 8011 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400
#WFM:
nc -l 8011 | csdr convert_i16_f | csdr gain_ff 70000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400

The Raspberry Pi will listen on TCP port 8011, and wait for connection.

Then, on the remote computer, execute:

arecord -fS16_LE -r48000 -c1 - | nc raspberrypi.local 8011

You should replace raspberrypi.local with the IP address of the Raspberry Pi (unless avahi config is the default).

Using ADPCM codec to decrease network usage while streaming

Let's see an example for this on the NFM modulator. Execute on the Raspberry Pi:

nc -l 8011 | csdr decode_ima_adpcm_u8_i16 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 28400

On the PC, execute this:

arecord -fS16_LE -r48000 -c1 - | csdr encode_ima_adpcm_i16_u8 | nc raspberrypi.local 8011

Transmitting amateur radio digital modes from remote computer

On the Raspberry Pi, run this to transmit USB:

nc -l 8011 | csdr convert_i16_f | csdr dsb_fc | csdr bandpass_fir_fft_cc 0 0.1 0.01 | csdr gain_ff 2.0 | csdr shift_addition_cc 0.2 | sudo rpitx -i- -m IQFLOAT -f 28400

On your PC, run:

arecord -fS16_LE -r48000 -c1 - | nc raspberrypi.local 8011

If you have Ubuntu on your PC, you are likely to have PulseAudio.

Run pavucontrol and set the recording source of arecord to "Monitor of" your audio output.

pavucontrol

On the PC, run fldigi, and start to transmit:

fldigi

If you don't want to listen to the transmitted signal on your PC:

sudo modprobe snd-aloop

This will create an ALSA loopback interface. You also have to make the appropriate changes in pavucontrol:

pavucontrol

rpitx-app-note's People

Contributors

ha7ilm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpitx-app-note's Issues

Modulate from audio streamed from remote computer problem

Hi!
I'm facing a big problem...
I'm trying the "Modulate from audio streamed from remote computer" but when i do "arecord -fS16_LE....."
it quits immediately di the command prompt.
I've replaced of course the ip of my raspberry and tested that the ubuntu machine can reach the raspberry.
Any idea?

Buffer overrun #solved

Tried doing LSB with microphone input I'm getting buffer overrun with distorted voice signal. Anyone knows how I can transmit a clean voice SSB signal? File input voice quality is fine, however.

no TCP Sink block

Hi,
I was trying these samples. I am using Gnu Radio Companion 3.8.0. I do not find TCP Sink block.
Is there anyway to install it?

Interfacing GnuRadio with rpitx

Hello András,

I'm a bit confused regarding interfacing of GnuRadio with Evariste's RPITX, and I hope you can help.
I have used your test SSB flowgraph (but the effect is the same with several others and with CSDR tool also) for modulating in USB audio files and transmitting them over RPITX.
The situation is the following :

  1. I'm using RPITX "standard version" (not the new one) installed on a RaspberryPI2 with Stretch (Linux 4.14.49+ #11201 armv6l GNU/Linux)
  2. test trasmission over RPITX on USB of sampleaudio.wav test file, modulated using the Evariste's modulation program pissb is successful over 10 m band
  3. I made a test flowgraph on GnuRadio on Windows that reads the "modulated" (by pissb) wav file and send it to the RaspberryPI via UDP sink : this allows an RPITX correct transmission, but only if I use the following receaving statement :

nc -u -l 8011 | sudo rpitx -i - -m IQ -a 14 -f $FREQUENCY

Gnuradio reads in FLOAT format and send it to UDPsink in FLOAT format (not in COMPLEX)

  1. If I start modulating the sampleaudio.wav using your test USB TX flowgraph or other USB TX flowgraph or CSDR and I send the modulated output (correct, checking FFT scope...) to RPITX using again UDP sink, the result is a noise transmission (both setting RPITX in IQ or IQFLOAT format, both transmitting float or complex data flow over UDP sink.

Worst, the "correctly running" output of PISSB utility can be played using any kind of playing audio tool, while the modulated output of the different flowgraphs (being IQ) should not.
I'm consequently a bit confused : what is the real data format accepted as input from RPITX, and which the correct way for interfacing it with Gnuradio ? (I guess that UDP or TCP sink - now deprecated - is not the issue...)

Any help appreciated
Regards, 73
Ugo

Works with rpitx, but can it work with limesdr?

Greetings - The examples work but I want to use my limesdr-mini. I'm using limetools (limesdr_dump to capture an rf channel, then limesdr_send to play back the IQ file. It works.)

Instead of transmitting to the rpitx app I'd like to transmit with limesdr_send (takes an IQ file, transmits nbfm). What I've done so far:
arecord -c1 -r48000 -D plughw:CARD=Device,DEV=0 -fS16_LE - | csdr convert_i16_f | csdr fmmod_fc | limesdr_send -s 48000 -f 150e6

And other variations of this, but I don't have any modulation, just random noise.
Any hints you can give me?

  • Kurt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.