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.

No comments:

Post a Comment