Wednesday, November 6, 2019

Build a BPSK modulator using simpleFE

simpleFE can be used a as a software defined radio baseband system. It is equipped with an I+Q ADC and I+Q DAC which runs at maximum 7.5MHz.  There are quite a lot of applications can be built based on simpleFE. Here let's start with the "hello world" application in communication -- BPSK modulation.

Suppose we have a binary random sequence which is our message bits 01011101...,  the first step to send the signal to air is to map the bits to symbols. BPSK modulation maps the bits to $\{a_n = 1, -1, 1, -1, -1, -1, 1, -1,...\}$ , then the waveform is generated using the root raised cosine pulse shaping filter
\[ s(t) = \sum a_n p(t-nT) \]

This aritcle explains the detail of a typical pulse shaping design criteria.  The smybol rate R is set to 100k Hz.

Now we would like to use simpleFE to make this waveform real!

First thing first, download and install simpleFE software at https://github.com/wnmusic/simpleFE and boot (load the firmware) simpleFE.

Using GRC

SimpleFE is ready to interface with GNURadio, install GNURadio, then build and install gr-simplefe which is also in the tree. After that when you run

#gnuradio-companion

you can see that simpleFE sink/source are in the tree.



Next create a flow graph like this:


Set the sample rate to be 1MHz, meaning that for each symbol period, there will be 10 samples, thus the sample per symbol should set to 10.  For BPSK, number of constellation points is set to 2 and there is no difference whether to use differential encoding or not. The raised cosine filter roll-off factor is set to 0.35. It means the bandwidth of the signal would be 50k*1.35.

And that's it, the BPSK modulator!

Write you own code

Using GNURadio is very easy and handy, it is especially useful for some research work, as you can drag, drop and connect the processing blocks in no time once you are familiar with the processing.

But if you would like to know exactly what's going on under the hood, or you wish to put all the math into code, or you would like your code to run faster and efficient, you can write your own (refer the code in examples/bpsk)

you need to compile libdsp

#cd libdsp
#mkdir build
#cd build
# cmake ..
# make

which provides a block convolution engine using overlap-and-add.

After that, goto examples/bpsk type
# make
# ./bpsk

you would see waveform generated from TX_I port.


It seems the waveform is not very smooth or dotty. It is mainly due to we only have 10 samples for each symbol. To make it smoother, we can either increase the sampling rate, or use a reconstruction filter. 

Reconstruction filter

A simple Sallen-Key 500kHz low pass filter is designed at hardware/accessories/filters
You can easily home-brew this circuit at home, or just use a breadboard, as it is rather low frequency, layout of the circuit is not that critical.




With this filter, the waveform now looks like:


and it looks pretty!
 


No comments:

Post a Comment