# The basics of digital signal processing for the smallest

Digital cameras, mp3, DVD, cellular, everywhere use various algorithms for digital signal processing. The figure has firmly entered our daily lives, it has greatly simplified the work with sound, graphics and video, made it possible to provide additional services in regular telephone communications and much more.
But what is all the same a “digital signal” and why it has such advantages, and most importantly how to get it. In this article I’ll try “on fingers” to explain the basics of analog-to-digital and digital-to-analog signal conversion and talk about the advantages of digital signals.

What is digital and analog signals and what is the difference? Figure 1 shows the simplest analog signal. Its main characteristics are the signal level and the time during which this level changes. The number of complete cycles of changing the signal level (that is, the number of times the signal level was the same) per unit of time is called the signal frequency. Frequency and level are not constant.

Figure 1. The simplest analog signal. The

digital representation of such a signal is essentially a conversion of the signal level value taken after certain points in time into a binary calculus. Figure 2 shows a digital signal.

Figure 2. Digital signal

As can be seen from the figure, a digital signal has only two level values, 0 and 1. Such a signal is very easy to process, because there are only two states. This property is used in logic, if input 0, then output 1, if input 1, then do not skip it, etc. Various coding and compression algorithms are easily applicable to such a signal. Such a signal is easily monitored for errors, for example, if the sum of zeros and ones in a block is 0, then this block came to the receiver without errors, and vice versa.
Another plus of such a signal is that it has a high degree of noise immunity. After all, the receiver is interested in only two states, two signal levels, everything else is cut off in FIG.

Now let's see how all the same, an analog signal is converted to digital.
The first thing that needs to be understood is that the human senses are not able to analyze information in digital form. For this reason, the digit is applied only at the stage of signal processing. Before a person, all information comes in analog form. Figure 3 shows the simplest signal conversion circuit. Here, the ADC is an analog-to-digital converter , and the DAC is a digital-to-analog converter .

Figure 3. Signal conversion scheme

As mentioned above: “The digital representation of a signal is essentially the conversion of the signal level value taken after certain points in time to a binary calculus.”
Let's try to convert our analog signal to digital. We take the signal level values ​​at certain time intervals, as shown in Figure 4. Such a process is called sampling, and the frequency at which signal level values ​​are taken is the sampling frequency (Fd).

Figure 4. Signal sampling.

The question is, what should be the sampling rate? After all, we need to take care of the reverse transformation, and most importantly, so that during this transformation we do not lose information. It is not possible to convert all values ​​to each unit of time, otherwise the sampling rate would be equal to infinity.
The answer to this question was given by an outstanding Soviet and Russian scientist in the field of radio engineering, radio communications and radio astronomy -Kotelnikov Vladimir Alexandrovich in his theorem of the same name ( Kotelnikov's theorem ).
The essence of the theorem is that an analog signal can be restored without loss if, during digitization, the sampling frequency was equal to twice the maximum frequency of the original analog signal.
For an example we will take a usual analog signal in a telephone line. Its frequency is not constant and depends on many properties of the human voice, but it always ranges from 0.3 to 3.4 kHz. That is, in this case, the maximum signal frequency is 3.4 kHz. Therefore, to digitize this signal with the possibility of its restoration without loss, you need to take a sampling frequency of 6.8 kHz.

After the sampling process, we get a discrete signal, that is, a signal that is a separate sample taken over time (Figure 5).

Figure 5. Discrete signal.

Now it remains to convert the obtained levels of the discrete signal into a binary system. For this, a concept such as quantization of a signal by level is used. In other words, the scale of signal levels is divided into intervals - quantization levels . At this stage, the bitness (bitness) of the future digital signal is determined, and most importantly, how accurately will the restored analog signal correspond to the original one. The more levels, the more accurately the digital signal will correspond to the analog one.
Next, the discrete signals are assigned the value of the nearest quantization level. Take a look at Figure 6. As you can see, in fact, the values ​​of the levels of the discrete signal are rounded to the nearest quantization level. Naturally, this introduces distortion into the received digital signal. Such distortions are called “ quantization noises .”

Figure 6. Quantization.

The quantization phase is completed. Now the values ​​of the levels of the discrete signal from the decimal system of calculation are converted to binary.

UPD:For example, one of the levels is 5, in the binary system it will be 101. As a result, we get a sequence (block) of three pulses with levels 1.0 and 1, respectively. You also need to remember about the bitness (the number of bits in the block) of the received digital signal, it should be the same in each block. To do this, the missing number of bits in the form of zeros is added to the beginning of each block.

That's it, the digitization of the signal is over. At the output, we get the signal shown in Figure 2.
It is not difficult to guess that the process of digital-to-analog conversion occurs exactly the opposite, therefore it makes no sense to describe it. And yet, the restored signal will never be equal to the original, another question is whether we will feel the difference, because the human senses are far from perfect.
I described only the basic process of digitizing a signal. Naturally, digital signal processing does not end there. Further, various coding algorithms come into play that allow eliminating redundancy (reduce volume, compress), add additional information to the signal for error control, and much more, but this is another story.