Binary Phase Manipulation in Python

I am currently working on some code for transmitting messages / files / and other laser data using sound conversion. My current code uses the hexlify function from the binascii module in python to convert the data to a binary file, and then emits a tone for 1 and a different tone for 0. This theoretically works, although not the fastest encoding / decoding method, but when testing, there are several errors .

  • the generated tones are not accurate, that is: 150 Hz radiation may be equal to 145-155 Hz on the receiving side, this is not a huge problem, because I can simply set the borders on the receiving side lower or higher.

  • The real problem is that if I make a tone and play, the computer on the receiving side can read it several times or not read at all, based on the speed with which it counts the incoming sound. I tried to reproduce tones at the same speed as the samples, but this is very good.

In general, I had several successful runs using short messages, but this is very unreliable and inaccurate due to the above problems.

I went over this further, and solving it seems like it might include BPSK or Binary Phase Shift Keying, although I'm not sure how to implement this. Any suggestions or sample code would be appreciated!

My code for the project can be found here , but the main files I'm working on are for binary decoding and encoding, which is here and here . I am not an expert in python, so please forgive me if anything I said is wrong, my code is not the best, or If I missed something basic.

Thanks!: -)

+6
source share
2 answers

Take a look at GNU Radio!

http://gnuradio.org/redmine/projects/gnuradio/wiki

GNU Radio is a project that can be done in software as much as possible for transmitting or receiving a radio signal. Since radio already uses phase shift keying, the guys at GNU Radio have already solved the problem for you, and GNU Radio is already a Python project! And the complex DSP stuff is written in C ++ for speed, but is complete for use in Python.

Here is a page that discusses a project using differential binary phase shift keying (DBPSK) / differential quadrature phase shift keying (DQPSK) to transmit binary data (in the example, a JPEG image). Python source code is available for download.

http://www.wu.ece.ufl.edu/projects/softwareRadio/

I see that your project is under the MIT license. GNU Radio is under GPL3, which may be a problem for you. You need to find out if you can use GNU Radio without having to turn your project into a derivative work, thereby forcing you to change your license. It should be possible to make a standalone "sending daemon" and a standalone "receiving daemon", both of which will have GPL3 code, and then your MIT code will connect to them through a socket or something like that.

By the way, one of my searches found this very clear explanation of how BPSK works:

http://cnx.org/content/m10280/latest/

Good luck

+7
source

In response to the first frequency question:

Looking at your decoder, I see that your sample rate is 44100 and your chunk size is 2048. If you read it correctly, it means that your FFT size is 2048. This will set your FFT size to ~ 21hz. Have you tried resetting your FFT? Zero-padding FFT does not change the frequency, but will give you the best resolution. I see you are using quadratic interpolation to improve the frequency estimation. I have not used this technique, so I am not familiar with the improvement that you get from this. Perhaps the balance between zero padding and quadratic interpolation will give you better frequency accuracy.

In addition, depending on the hardware performing the transmission and reception, the frequency error may be the result of various clock pulses controlling A / D - one or both of these clocks are not exactly equal to 44100 Hz. Something like this can affect the frequency that you see on the FFT output.

+4
source

Source: https://habr.com/ru/post/897587/


All Articles