Thursday 23 June 2016

Paint a LimeSDR with Radio waves.

The below is silly, a total waste of RF spectrum, but it is fun to do at least one.

Because I installed gnuradio with pybombs I was able to install the gr-paint block with pybombs
$ pybombs -v install gr-paint

I also downloaded a random image (of a LimeSDR board) from the Internet. Looking back at what I actually did below there probably was no need for me to convert the image into a png file. My subconscious worked out, with no actual verification, that a png would require slightly less CPU than a jpeg file to decompress is the only justification I can give for why I converted the file. You could probably skip those steps and everything should work fine. In hindsight I do not think the CPU overhead saving would be all that much.

$ wget https://www.crowdsupply.com/img/f331/limesdr-frontcrop-1_jpg_open-graph.jpg
$ sudo apt-get install imagemagick
$ convert limesdr-frontcrop-1_jpg_open-graph.jpg limesdr-frontcrop-1_jpg_open-graph.png
$ file limesdr-frontcrop-1_jpg_open-graph.png
limesdr-frontcrop-1_jpg_open-graph.png: PNG image data, 1500 x 1000, 8-bit/color RGB, non-interlaced

I used the above command because I needed to find out the exact "Image Width" parameter for the "Spectrum Painter"  block. I also tweaked the "Line Repeats" parameter by trial and error to get a waterfall that was not too squashed or stretched. It is still not perfect, but it is good enough.

 (click on the above flowgraph to see it full screen, there is not much to it)

The above multicoloured waterfall (click on for full size) is just a local screen output from GRC, no RF was actually transmitted (I don't have any LimeSDR hardware). With an actual LimeSDR I could TX, at extremely low power, from a TX antenna to a RX antenna (Or cable TX to RX though a 40dB attenuator, to avoid any actual RF emissions and damage). And then use a LimeSDR Source block tuned to the same frequency band  as a TX block and connect that block directly to a Waterfall sink in the same flow graph.

Wednesday 22 June 2016

Bit bang morse code

I'm sure that something better could be made by anyone who knows their way around gnuradio, Morse code and is willing to spend more time than I have creating a flowgraph.

The below flowgraph  bitbangs some predefined Morse code on an ISM band using Gnuradio companion.

After a speed reading about ITU Morse code at https://en.wikipedia.org/wiki/Morse_code and http://morsecode.scphillips.com/morse2.html I randomly decided that one unit was going to be exactly 50 milliseconds. I also randomly chose the following as the message I would transmit - "HELLO WORLD 73 ".

With the rules for International Morse code and the dah dit encoding for letters I made the below bit-banging table. 
  1. short mark, dot or "dit" (·) : "dot duration" is one time unit long
  2. longer mark, dash or "dah" (–) : three time units long
  3. inter-element gap between the dots and dashes within a character : one dot duration or one unit long
  4. short gap (between letters) : three time units long
  5. medium gap (between words) : seven time units long

H .... dit dit dit dit 1010101
Letter Gap 000
E . dit 1
Letter Gap 000
L .-.. dit dah dit dit 101110101
Letter Gap 000
L .-.. dit dah dit dit 101110101
Letter Gap 000
O --- dah dah dah 11101110111
Word Gap 0000000
W .-- dit dah dah 101110111
Letter Gap 000
O --- dah dah dah 11101110111
Word Gap 0000000
R .-. dit dah dit 1011101
Word Gap 0000000
L .-.. dit dah dit dit 101110101
Letter Gap 000
D -.. dah dit dit 1110101
Word Gap 0000000
7 --... dah dah dit dit dit 1110111010101
Letter Gap 000
3 ...-- dit dit dit dah dah 1010101110111
Word Gap 0000000

So I created a vector source with the above information and use On Off Keying, of which Morse code is a subset.
(Thanks : https://zeta-two.com/radio/2015/06/23/ook-ask-sdr.html )

Vector:(1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,1,1,0,1,0,1,0,0,0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0,1,1,1,0,1,1,1,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,01,0,1,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0)


154 units x 50 ms = 7700 milliseconds, or 7.7 seconds to transmit "HELLO WORLD 73 "

50ms (0.05 seconds) at 2MSPS would be 100000 samples per dit (and 300000 samples per dah).


So I used a "repeat interpolation" block that repeats each unit for 100,000 samples. And then I multiply my cosine carrier at 500kHz with this to implement my On Off Keying. If it is 100,000 "zeros" then cosine is turned off and if it 100,000 "ones" then the cosine is turned on.

 (click on the above image to see it full screen) I don't have a LimeSDR yet (will be almost half a year until the crowd funded rewards arrive) so I'm just using a disabled generic sink block.



100,000 zeroes

 
100,000 ones. I'm using a float to complex bandpass filter (with complex taps) to attenuate the  negative frequency component by around 80dB which should be below the noise floor of the transmitter.

Unfortunately a nasty spike will be transmitted because of the DC imbalance between I and Q at 433.42MHz. Normally you would have a bandpass filter on the TX output and have this spike buried well inside the filters rejection band. So that you are not broadcasting the spike, and polluting the RF spectrum. Depending on the frequency you could be breaking the law, and risking hefty fines. But since the spike will be inside the ISM band and I only plan to run this flow graph for at most 60 seconds, I am ignoring this problem for now.