"Manifesto for beginner programmers from related specialties" or how I got to this life

My article today is thoughts out loud from a person who embarked on the path of programming almost by accident (although naturally).

Yes, I understand that my experience is only my experience, but it seems to me that it fits well into the general trend. Moreover, the experience described below is more related to the field of scientific activity, but what the hell is not joking - it can be useful outside.

"Manifesto for beginner programmers from related specialties" or how I got to this life
Source: https://xkcd.com/664/

In general, dedicated to all real students from a former student!

Expectations

When I was finishing my undergraduate degree in Infocommunication Technologies and Communication Systems in 2014, I knew almost nothing about the world of programming. Yes, I, like many others, had the subject β€œComputer Science” in my first year - but, Lord, it was in my first year! It's been an eternity!

In general, I did not expect anything particularly different from the bachelor's degree, and when entering the master's program "Communication and Signal Processing" German-Russian Institute of New Technologies.

And in vain ...

We were only the second enrollment, and the guys from the first were just packing their bags to distant Germany (the internship takes six months in the second year of the master's program). In other words, no one from the inner circle had yet seriously encountered the methods of European education, and there was no one to ask about the details.

In our first year, of course, we had various kinds of practices, in which we were usually democratically offered a choice between writing scripts (mainly in the MATLAB language) and using various highly specialized GUIs (in the sense that without writing scripts - simulation environments).

"Manifesto for beginner programmers from related specialties" or how I got to this life

Needless to say, we, the future Masters of Science, in our youthful stupidity, avoided writing code like fire. Here, for example, is Simulink from MathWorks: here they are blocks, here they are connections, here they are all kinds of settings and switches.

Native and understandable for a person who was previously involved in circuitry and system engineering, view!

"Manifesto for beginner programmers from related specialties" or how I got to this life
Source: https://ch.mathworks.com/help/comm/examples/parallel-concatenated-convolutional-coding-turbo-codes.html

So it seemed to us...

Reality

One of the practical works of the first semester was the development of an OFDM signal transceiver within the framework of the subject β€œMethods for Modeling and Optimization”. The idea is very successful: the technology is still relevant and quite popular due to its use, for example, in Wi-Fi and LTE / LTE-A networks (in the form of OFDMA). The best thing for masters is to practice the skills of modeling telecom systems.

"Manifesto for beginner programmers from related specialties" or how I got to this life

And now we are given several options for technical specifications with obviously impractical frame parameters (so as not to look for a solution on the Internet), and we pounce on the already mentioned Simulink ... And we get a kettle of reality on the head:

  • Each block is fraught with a lot of unknown parameters, which are scary to change from the kondachka.
  • Manipulations with numbers need to be done, it seems, simple, but you still have to fence, God forbid.
  • Cathedral machines noticeably slow down from the hectic use of the GUI, even when surfing through the libraries of available blocks.
  • To finish something at home, you need to have the same Simulink. And no, in fact, alternatives.

Yes, in the end, of course, we completed the project, but we completed it with a loud exhalation of relief.

Some time passed, and we came to the end of the first year of the master's program. The number of homework using GUIs began to decrease proportionally with the increase in the proportion of German subjects, although it had not yet reached the point of a paradigm shift. Many of us, including me, overcoming our considerable amplitude for buildup, more and more used Matlab (albeit in the form of Toolboxes) in our scientific projects, and not the familiar, it would seem, Simulink.

The point in our doubts was the phrase of one of the second-year students (they had just returned to Russia by that time):

  • Forget, at least for the duration of the internship, about Similink, MathCad and other LabView - over the hill, everything is written in the MATLAB language, using MatLab itself or its free "version" Octave.

The statement turned out to be true in part: in Ilmenau, the dispute over the choice of tools was also not fully resolved. True, the choice was for the most part between MATLAB, Python, and C.

On the same day, a natural excitement took me: should I transfer my part of the OFDM transmitter model to a script form? Just for fun.

And I got to work.

Step by step

Instead of theoretical calculations, I will simply give a link to this great article 2011 years from tgx and on slides LTE physical layer professors Michel-Thiel (TU Ilmenau). I think this will be enough.

β€œSo,” I thought, β€œlet’s repeat, what are we going to model?”
We will model OFDM frame generator (OFDM frame generator).

What will it include:

  • information symbols
  • pilot signals
  • zeros (DC)

From what (for the sake of simplicity) we abstract:

  • from modeling a cyclic prefix (if you know the basics, adding it is no longer difficult)

"Manifesto for beginner programmers from related specialties" or how I got to this life

Block diagram of the considered model. We will stop before the inverse FFT (IFFT) block. For the sake of completeness, everyone can continue the rest for themselves - I promised the teachers from the department to leave something for the students.

Let's define those. exercise:

  • fixed number of sub-carriers (sub-carriers);
  • fixed frame length;
  • we must add one zero to the middle and a pair of zeros to the beginning and end of the frame (total 5 pieces);
  • information symbols are modulated using M-PSK or M-QAM, where M is the modulation order.

Let's get to the code.

The entire script can be downloaded from link.

Let's define the input parameters:

clear all; close all; clc

M = 4; % e.g. QPSK 
N_inf = 16; % number of subcarriers (information symbols, actually) in the frame
fr_len = 32; % the length of our OFDM frame
N_pil = fr_len - N_inf - 5; % number of pilots in the frame
pilots = [1; j; -1; -j]; % pilots (QPSK, in fact)

nulls_idx = [1, 2, fr_len/2, fr_len-1, fr_len]; % indexes of nulls

Now let's determine the indexes of information symbols, assuming that the pilot signals must necessarily go before and/or after zeros:

idx_1_start = 4;
idx_1_end = fr_len/2 - 2;

idx_2_start = fr_len/2 + 2;
idx_2_end =  fr_len - 3;

Then the positions can be determined using the function linspace, reducing the values ​​to the smallest of the nearest integers:

inf_idx_1 = (floor(linspace(idx_1_start, idx_1_end, N_inf/2))).'; 
inf_idx_2 = (floor(linspace(idx_2_start, idx_2_end, N_inf/2))).';

inf_ind = [inf_idx_1; inf_idx_2]; % simple concatenation

Let's add zero indices to this and sort:

%concatenation and ascending sorting
inf_and_nulls_idx = union(inf_ind, nulls_idx); 

Accordingly, the pilot signal indices are everything else:

%numbers in range from 1 to frame length 
% that don't overlape with inf_and_nulls_idx vector
pilot_idx = setdiff(1:fr_len, inf_and_nulls_idx); 

Now let's deal with pilot signals.

We have a template (variable drivers), and let's say we want pilots from this template to be inserted into our frame sequentially. Of course, this can be done in a loop. And you can be a little smarter with matrices - the benefit of MATLAB allows you to do this with sufficient comfort.

First, let's determine how many of these templates fit into the frame completely:

pilots_len_psudo = floor(N_pil/length(pilots));

Next, we form a vector that consists of our templates:

% linear algebra tricks:
mat_1 = pilots*ones(1, pilots_len_psudo); % rank-one matrix
resh = reshape(mat_1, pilots_len_psudo*length(pilots),1); % vectorization

And we define a small vector that contains only a piece of the template - the β€œtail”, which does not fit completely into the frame:

tail_len = fr_len  - N_inf - length(nulls_idx) ...
                - length(pilots)*pilots_len_psudo; 
tail = pilots(1:tail_len); % "tail" of pilots vector

We get pilot characters:

vec_pilots = [resh; tail]; % completed pilots vector that frame consists

Let's move on to information symbols, namely, we will form a message and modulate it:

message = randi([0 M-1], N_inf, 1); % decimal information symbols

if M >= 16
    info_symbols = qammod(message, M, pi/4);
else
    info_symbols = pskmod(message, M, pi/4);
end 

All is ready! Assembling the frame:

%% Frame construction
frame = zeros(fr_len,1);
frame(pilot_idx) = vec_pilots;
frame(inf_ind) = info_symbols

You should get something like this:

frame =

   0.00000 + 0.00000i
   0.00000 + 0.00000i
   1.00000 + 0.00000i
  -0.70711 - 0.70711i
  -0.70711 - 0.70711i
   0.70711 + 0.70711i
   0.00000 + 1.00000i
  -0.70711 + 0.70711i
  -0.70711 + 0.70711i
  -1.00000 + 0.00000i
  -0.70711 + 0.70711i
  -0.70711 - 0.70711i
   0.00000 - 1.00000i
   0.70711 + 0.70711i
   1.00000 + 0.00000i
   0.00000 + 0.00000i
   0.00000 + 1.00000i
   0.70711 - 0.70711i
  -0.70711 + 0.70711i
  -1.00000 + 0.00000i
  -0.70711 + 0.70711i
   0.70711 + 0.70711i
   0.00000 - 1.00000i
  -0.70711 - 0.70711i
   0.70711 + 0.70711i
   1.00000 + 0.00000i
   0.70711 - 0.70711i
   0.00000 + 1.00000i
   0.70711 - 0.70711i
  -1.00000 + 0.00000i
   0.00000 + 0.00000i
   0.00000 + 0.00000i

"Bliss!" I thought contentedly and closed my laptop. It took me a couple of hours to do everything about everything: including writing code, learning some Matlab functions and thinking through mathematical tricks.

What conclusions did I draw then

Subjective:

  • Writing code is nice and akin to poetry!
  • Scripting is the most convenient research method for the field of Communication and Signal Processing.

Objective:

  • There is no need to shoot sparrows from a cannon (if such a training goal, of course, is not worth it): using Simulink, we set about solving a simple problem with a fancy tool.
  • The GUI is good, but understanding what's under the hood is better.

And now, being far from being a student, I want to say the following to the student brethren:

  • Be of good cheer!

Try writing code, even if it's bad at first. With programming, as with any other activity, the worst of trouble is the beginning. And it’s better to start earlier: if you are a scientist or even just a techie, sooner or later you will need this skill.

  • Demand!

Demand progressive approaches and tools from teachers and supervisors. If that's at all possible, of course...

  • Be creative!

Where else is the best place to get sick with all the sores of a beginner, if not within the framework of an educational program? Create and hone your skills - again, the sooner you start, the better.

Novice programmers of all countries, unite!

PS

In order to record my direct relationship to the students, I am attaching a memorable photo of 2017 with two rectors: Peter Scharff (on the right) and Albert Kharisovich Gilmutdinov (on the left).

"Manifesto for beginner programmers from related specialties" or how I got to this life

It was worth finishing the program at least for the sake of such costumes! (kidding)

Source: habr.com

Add a comment