How to have fun in isolation, or transfer data using a sound card

Hi Habr.

After a recent publication on OFDM transmission , it became interesting to check how it would be most efficient to transmit data over the air. We will try different types of modulation, and see which ones are better for transferring data from one end of the apartment or office to the other. For tests, a laptop, smartphone and MultiPSK program will be enough.



For those who are interested in how this works, continued under the cut.

For tests, we will use the MultiPSK program, which is convenient in that it supports a huge number of different communication standards, both amateur (they are available for both reception and transmission) and professional (only reception is available). Of course, in order not to make the article gigantic, I will choose only the most popular types of modulation, and we will see what happens. MultiPSK was originally intended for radio communications.why the sound card should be connected to the receiver or transmitter, but nothing prohibits reproducing the signal directly from the speakers. The test will be quite simple - the plain text “1234567890” is encoded in different ways, the signal is played on a PC, and recorded by a smartphone at the other end of the apartment. Of course, anyone can repeat the experiments described below, no special equipment is required for this.

Let's get started.

Frequency Modulation (FSK, Frequency Shift Keying)


As the name suggests, the essence of modulation is to change the frequency of the signal. The simplest method available in MultiPSK is RTTY. In this case, we transmit data by switching between two frequencies at a certain speed. On the spectrum, this can be seen very clearly. Let's see what happens to the signal when it is transmitted through the air. At the top, the original signal, received from below:



In addition to the obvious attenuation, there is a more non-obvious change in the amplitude - the signal has become "torn", the output has turned out to be something like beats. It is interesting that they appear at moments of frequency change, at times when the frequency does not change, the amplitude changes are minimal. With what it is connected, it is difficult to say.

Speaking of the spectrum, it was distorted, although in principle, the waveform can be guessed:



Let's see if MultiPSK can decode the recorded sound. Alas, no, the output is just "garbage." Various attempts to normalize and filter did not lead to success either:



The next signal that is interesting to try is MFSK, frequency modulation, in which the number of frequencies is more than 2x. The picture “before” and “after” the transfer is approximately similar to the previous result.



We also see amplitude beats, probably arising in the process of sound re-reflection. But there is a noticeable plus - with more frequencies, the decoding of the signal is much more confident. With the exception of “garbage” in the pause between signals, the data itself is received without error.



Perhaps this is also due to the transmission rate or other decoding algorithm, but the result is quite interesting.

Phase Modulation (PSK, Phase Shift Keying)


The next type of modulation is phase, in which a sinusoidal signal is transmitted, and the information is encoded by changing the phase.



BPSK signal “before” and “after” the transmission:



Recognition result: 20-40% of characters were detected, from the line 1234567890, as you can see, 3, 4, 7 and 9 can be distinguished.



The spectrum is not shown, because for BPSK phase modulation, it is an almost straight line.

The general idea, I think, is understandable, and it makes no sense to consider more complex types of signals - it is clear that there will be no stable decoding. However, purely for "sports interest", consider an analog signal.

SSTV (Slow Scan Television)


This mode in its essence resembles a fax, and a change in frequency here encodes the brightness or color of the image over time. It is interesting to see how distorted the image is after transmission, and whether it will remain readable.

The “before” and “after” signal: A



picture with a cat, and an attempt to receive it:



With due imagination, the outline of the cat can probably be guessed. Although if you transmit something simpler, such as a "black square", it will probably be easier to recognize the image. By the way, this is one of the advantages of analog data transmission over digital - where the "digit" will no longer work, in the analogue, among the noises, the human eye or ear may well catch a useful signal.

Addition: frequency and time characteristics


Speaking of the analog signal, as suggested in the comments, it is possible to check the amplitude-frequency response of the “transmission channel” if white noise and a tone varying in height are reproduced. Such a signal is easy to generate in any audio editor. For the test, the file was played at one end of the apartment, and the record was made at the other. The result is quite interesting, as it is interesting that high frequencies are not audible at all (in my case the border is somewhere around 14KHz), and data transmission to them is still possible in principle:



And finally, a no less interesting result is obtained if a short sound pulse is generated :



When applying a pulse with a length of 0.01 s, the echo lasts almost 10 times longer. Of course, this should also be taken into account when choosing a data rate.

Conclusion


As you can see, the transmission of sound through the air (as probably through water), is not so simple, due to reflections, attenuation and other effects. Despite the apparent “frivolity” of the task, reliably transmitting data even 10 meters is not so simple due to signal distortion. The MFSK frequency modulation method has proven to be the most stable. And it seems that it was not only me who conducted similar experiments, an article on the Yandex.Station activation protocol says that it uses the same method of data transfer. But in general, the simpler the modulation and the lower the speed, the greater the chance that the data will be received without errors.

Those who wish can continue to experiment on their own, MultiPSK is easy to find on the Internet, the number of transmission standards supported by it is quite large.

All successful experiments.

All Articles