My First Software Defined Radio (SDR) Receiver - 2nd Section

Downconverter

full-spectrum-peq


1st Section - Capture Stage
2nd Section - Downconverter
3rd Section - Demodulation

Appendix - Spectrogram

 

Versión en Castellano

 

Bring back the main diagram:

non-realtime-sdr-stage-diagram

 

2.1 - What is baudline?

baudline: baudline (http://www.baudline.com/) is a great software application for signal analysis. It seems to be designed for analyze sound and music, but with the right parameters and with a radio signal into a file, it can become a downconverter. Its output will give us another .wav file with a portion from the original signal.

2.2 - Can I connect directly baudline to /dev/dsp without a .wav file?

I wasn't able to connect baudline to the /dev/audio with the Bt878 ADC. There are compatibility problems with the btaudio module. Although we could make this connection, then we will need a lot of computer power to be able to work in real-time.

An option to process the incoming signal from the Bt878A with baudline (under a power machine) is:

# sox -r 896000 -w -t ossdsp /dev/dsp2 -t sw - | ./baudline -stdin -samplerate 896000

(note: the parameter /dev/dsp2 is hardware dependent)

This way, the input stream that the SOX command gets, goes to baudline using a Unix pipe in real-time.


2.3 - What a downconverter is?

It's a mixer that mix two signals in frequency: (in our case) our input and a sinus signal at constant frequency. The result is,  simultaneously, our original signal added in frequency with the sinus signal and our original signal reduced in frequency with the sinus signal. If we discard the added component and just keep the reduced one, we get the original signal "down" in frequency. A downconverter. To learn more.

2.3 - What an antialiasing filter is?

"... It is simply a low pass filter (LPF) that removes signal above the soon-to-be-decimated new Nyquist frequency. Without this LPF you would get mirror images when you decimate. That would be bad. It would corrupt the data." [Erik Olson]

"... Aliasing is what makes the wagon wheels look like they're going backward in the old westerns: the sampling rate of the movie camera is not fast enough to represent the position of the spokes unambiguously."  [Eric Blossom] (article)

2.4 - What a decimator is?

A decimator is just a digital stage that divides the total number of samples by some value to obtain a smaller quantity of them. The result signal is still the same but with a lower amount of Sps and a reduced bandwidth. A decimator after a downconverter is used to discard the spectrum portion that we don't need and just keep the lower frequencies close to 0 Hz., that is, the base band.

 

Downconverter

2.5 - Using baudline

You can get a free copy of baudline for Linux here http://www.baudline.com/download.html. Is a executable file and no installation is needed.

The method is to launch the previously obtained .wav file (previous section) against baudline using a pipe, this way:

# sox -t .wav radio-capture-896000.wav -t sw - | ./baudline -stdin -samplerate 896000

In this case, the SOX command doesn't need the -r 896000 parameter because it gets the value from the .wav header. With -t sw we request the "signed word" format at the pipe output.

The main baudline windows opens. We can open the main menu pressing with the right mouse button inside the window. Select "Input  Devices":

sdr-baudline-selecting-input-devices-2

The "Sample Rate" pull-down is already setup to 896000 which is the speed we sent to baudline thru the command line. Initially the decimator deactivated. The option "Down Mixer" (downconverter) is present but deactivated and it shows us a 448000 Hz bandwidth (896000 / 2).

sdr-baudline-input-devices-start

baudline detects the sound devices but we keep them unselected. Our input device is stdin.

We open "Play Deck":

sdr-baudline-selecting-play-deck

 

 

         sdr-baudline-play-deck        sdr-baudline-record-button

 

Pressing the "Record" button, the signal process begins and we can see its spectrogram, from 0 to 447125 Hz.

sdr-baudline-record

sdr-baudline-stop-button

 

2.6 - Down Mixer

In the "Input Devices" window, we select 32 in the "Decimate by" pull-down to decimate by 32. This value is not arbitrary, when we divide 896000 Sps by 32 we obtain 28000 Sps. This speed is supported by almost every sound card and this will be helpful soon. The immediate inferior value (16) will give us a 56000 Sps stream which is too high for the 44100 Sps standard.

sdr-baudline-decimate-2

When we select the decimate value, the Down Mixer bar activates automatically. Now, the frequency range goes from 0 to 14000 Hz. (28000 / 2). This means that the spectrum analyzer will only show us a 14 KHz bandwidth.

sdr-baudline-record-button

If we press the Record button again and while the signal process is running we press on the Down Mixer bar, we can "move" thru the original 447 KHz signal, jumping 14 KHz every time. It's similar when you rotate a radio receiver tuner.

For instance: let's move the downconverter button up to 154492 Hz:

sdr-baudline-downconverter-154492

And we see the spectrogram:

sdr-baudline-record-154-khz

baudline ranges the spectrogram from 154492.19 Hz to 168464.84 Hz but this is just a display adjustment used for reference. In fact, once we mix and decimate the signal, those high frequencies disappears. At the left margin we really have 0 Hz and 14 KHz at the right margin. Next figure tries to explain this concept: 

homebrew-sdr-mixer-decimation-process

Then, when we see after decimation a carrier centered at 162 KHz, it really belongs to a carrier centered at 8 KHz in the output signal. But it still belongs to a 162 KHz carrier in the original digitalized signal.

sdr-baudline-stop-button

Press Stop in the Play Deck window and close baudline.

 

2.7 - Save the output signal

We've used baudline like a visualization tool but we can use the stdout to save the signal process results into a .wav file. That's the way:

# sox -t .wav radio-capture-896000.wav -t sw - | ./baudline -stdin -samplerate 896000 -stdout | sox -r 28000 -w -t sw - -t .wav radio-downconverter-28000.wav

The first and second commands have been already used but now we call baudline with -stdout parameter. This tell baudline to use the stdout as output audio device. The third command (SoX) takes the pipe output in format "signed word" at 28000 Sps (896000 / 32) and saves it in a .wav file.

baudline starts. In the Play Deck we press the little triangle to open the full window, then we select "Output Device -> stdout", as the following image shows:

sdr-baudline-selecting-play-deck-stdout

sdr-baudline-record-button

baudline remembers the last "Down Mixer" and "Decimate by" parameters. Press the Record button. The spectrogram runs again but now the processed signal is also stored in the radio-downconverter-28000.wav file.

 

2.8 - Signal Rendering

While baudline runs thru the original signal, the output file grows slowly. We should wait until the input file is over. One way to speed up the process is to turn-off the spectrum and the spectrogram window. We will know when the file is over because baudline stops using CPU or the output file stops growing.

sdr-baudline-stop-button     sdr-baudline-record-button

We can press Stop to run any other program in our Linux and pres Record again to continue the conversion just in the same byte we leave it, and no information is lost. baudline can take time to answer the Stop request due CPU load.

Now, something interesting is happening. The signal source and the output are files, and there is no hardware devices (the sound card or the Bt878a) between them, so, the conversion becomes asynchronous. I mean that although the baudline uses the 100% CPU, no buffer overruns happens. The software gets data from the stdin, process it and send it back to the stdout, as fast the CPU can. You can see in a power machine, that a 10 minutes long .wav can be processed in a couple of minutes or it can take 1 hour in a slow PC but the result file will be the same in both cases. That's what I call: Signal Rendering. All this can be obvious but for me has been a very interesting experience.

sdr-baudline-stop-button

Once the process is over, we press Stop and close baudline. In my case, a 596 MBytes radio-capture-896000.wav 5,48 minutes long, is converted into a 19MBytes radio-downconverter-28000.wav, in 20 minutes.

When we close baudline we break the pipe and this causes that the SoX command does not close the .wav file correctly. It can't write the signal length in the .wav header and this can cause some problems if we open the file using another program. To solve it, just make a repaired copy, with a new name, this way:

# sox -t .wav radio-downconverter-28000.wav -t .wav radio-downconverter-28000-sps-162-KHz.wav

In my experiment, the 162 KHz carrier is a broadcast radio station. In the next section we will try to demodulate it.

Thanks baudline!

->> 3rd Section - Demodulation->>


 


- Author:

Juan Domenech Fernandez

http://www.domenech.org
 

Versión en Castellano

v0.3 14-november-2004
v0 10-june-2004