 Hello, welcome to this lecture on digital communication using GNU radio. My name is Kumar Appaya and I belong to the Department of Electrical Engineering at IIT Bombay. In this lecture, we are going to use GNU radio to explore some of the concepts that we have seen in previous lectures. In particular, we are going to look at the how we can practically evaluate the likelihood function for the presence of a signal and explore how impairment such as noise affect detection of the phase offset. By looking at these impairments and how phase offset and other such problems essentially affect your parameter estimation, we can build ingredients that go into practical communication systems as well. So, let us begin our exploration of this with GNU radio. Let us first consider the likelihood function of the presence of a signal S of t under AWGN. In this case, if you see the hypothesis HS and HN are to be compared based on the distribution of Z and much like our binary signaling example where we were figuring out the probability of making an error when you performed binary signaling. In this case as well, the likelihood function turns out to have a very similar form and the boundary, the decision region boundary is actually norm square upon 2. Since this is very similar to the binary signaling example, except that it is with norm square, you can try this on your own and we will not be repeating this particular example. The first example that we are going to implement in GNU radio is the phase offset and ML phase estimation. Remember in this case that the carrier at the receiver or rather the local oscillator at the receiver has a phase offset with respect to the carrier at the transmitter. So, in this case, we have to find out what that offset is and this can be done by using an overlap with the template function S of t and figuring out the phase of the resulting integral. Let us implement this on GNU radio. To implement our phase estimation approach, we will once again have to put together the complete basic digital communication example with baseband and passband and all those. So let us quickly do this because it is a repetition of something that we have covered earlier. We will first set our sampling rate to 192000, we will create a variable, so ctrl f for command f and type variable and our first variable will be, we will double click this, we will call it SPS that is the samples per symbol and since we want 8000 symbols per second, we will write this as sample rate divided by and the double divide is for integer 8000 and we will also do ctrl f and grab another variable and this variable will be our carrier frequency which we will call FS. Now we are ready to put together our system. Let us first get, we need to do phase estimation, yes, let us first get a random source to begin with but later I will remove the random source for reasons which will become clear later. So ctrl f for command f, I will say RAN DOM, I will get a random source, the random source we will change it to byte, we will choose QPSK and make it go from 0 to 4. The next thing I am going to get is a constellation encoder. So I am going to side type ENC and we will have this constellation encoder maybe below, I will just type ctrl f instead of this, ctrl f, c, o, n, s, t. So I have my constellation encoder over here and while I have the screen, I will also grab the constellation object that I will need to specify the constellation. Let me call this MyConst, my, c, o, n, s, t, it is a very standard QPSK constellation and this will also be MyConst. We will add a throttle next, ctrl f for command f, tr, let us grab a throttle. Now to ensure that our bandwidth constraints are met, let us add a pulse shaper. So I will get an rrc pulse, so ctrl f for command f, rrc and we will get these rrc filter tabs as a variable. This rrc filter tab, let us actually have the symbol rate here as 8000 and the rest of the parameters can be kept as they are. The gain has to be square root of 24 which is roughly 4.89, so we will just write that. Now I need an interpolating FIR filter, so I will say ctrl f for command f. I will say int er, so interpolating FIR filter over here, the interpolation factor is SPS, the tabs are rrc underscore tabs which I did not name that, okay, so I will just copy this and I will name these tabs as rrc tabs. So now my interpolating filter is ready, I just need to take this to passband and remember taking this to passband involves multiplying this by eprj 2 pi fct and taking the real part. I am going to do that by first adding a multiplier, ctrl f, command f, m, u, l, t and I will get a multiply block and by connecting this I then need to add a signal source. So ctrl f for command f, SIGN. Now remember the signal source which is complex has the form of eprj 2 pi fct, if you really want a cosine you must make this float but we will keep this the frequency will be fc and for scaling purposes the amplitude will be 1.414 that is we want it to be root 2. Finally we will just take the real part of the signal and that is our passband signal, so ctrl f for command f, complex to real and we have our complex signal and we can actually add noise right here, so let us actually just add a noise source, so I am going to say ctrl f for command f and noise source and we will make the noise source real by double clicking it and choosing float and amplitude I will call it NOISESTD, noise STD. We will add a QT range to control the noise, ctrl f for command f, I will say range and this QT GUI range we will set the name to noise STD and the values I think we will make it 0 by default, start at 0, stop at 3 and the step let it be 0.1 and I am going to just add these, so ctrl f for command f add and double click the add make it float, we will connect these and we will have to take this at the receiver, so it is very inconvenient to continue on the right because you cannot see the rest, so I am just going to add a virtual sync VIRT, so this virtual sync and I am going to call it RXSIG because that is the receiver signal RXSIG. Now this variable should be FC as opposed to FS or FC make it 40,000, so we have everything set now, now at the receiver we will create a virtual source which takes this RXSIG and gets back the constellation, so let's grab this virtual source right here, go a little below, now this virtual source should have the stream ID RXSIG so that we get the same signal back and we have already added noise, now if you remember what we should do at the receiver we will mix it with two sinusoids, a sine and a cosine and put low pass filters, so let us grab a signal source, so ctrl f for command f, I will type signal source and we will place the signal source here, we will make the frequency FC but amplitude should be 1.414 but let's also add a phase offset, let's say of P-H-A-S-E underscore O-F-F-S-E-T, we will create this variable in a minute and this should be float, now we will copy this ctrl C or paste it ctrl V and double click over here and this amplitude should be negative and this should be sine, now we are ready, we just need the phase offset as a variable, let's do that, ctrl F, V-A-R and we will call this P-H-A-S-E underscore offset, for now we will set this to zero, we will attend to it later, now we will multiply these signal sources with this signal, so I am just going to take this multiply block and ctrl C and ctrl V but I will double click it and convert it to float, I will connect it over here, connect this signal over here, I will duplicate this multiply block ctrl C ctrl V, I will connect this over here, connect my signal over here, now I need a pair of low pass filters, now before I add the low pass filters, I mean when I add the low pass filters remember that they will introduce some delay, so I have to account for that delay, so let me also add a delay range and a delay block, so ctrl F for command F, I will say range and this QT GUI range will get, we will call this delay and the delay let it be a number, you know default thing to zero and it goes from zero to it should go only up to SPS minus one, so we will just say SPS it doesn't matter and it should be of type INTER and we will also grab a delay block ctrl F D E L A Y and we will put the delay block over here, make sure that the delay is linked to that range by typing delay, finally we need a pair of low pass filters so ctrl F for command F, low pass filter, now this low pass filter should be real, it's decimation we can keep as one that is no problem, cutoff frequency should be FC and we will keep the transition with us a thousand hertz, now we need a pair for this similar low pass filter for the other arm, maybe I can just move things a bit above so that you get space yes, ctrl C, ctrl V and I have another low pass filter over here and I'm going to now add multipliers, so I'm going to just, I'm just going to rather connect this over here, connect this over here I'm done, I'm going to now convert this to a base band signal by just converting it to a complex data type, so ctrl F for command F, float to complex and I have my over sampled receiver waveform which I'm going to delay appropriately and finally I'm going to put a decimating FIR filter, so ctrl F for command F, deci, decimating FIR filter, remove this to the side and once you have the decimating FIR filter it should again have SPS as the decimation and the set apps are the same, RRC tabs, you can reverse them if you want but it's symmetric or it doesn't matter and finally we will place a QTGY constellation sync to make sure that the constellation is received well, so ctrl F for command F, QT or rather let's do const C O N S T, look at the bottom you have this QTGY constellation sync, you can use the arrow keys to rotate it if you want, so I've rotated it over here and connected it over here, now let us execute this flow graph and see what happens, so as you can see that there's lots of this effect and if you remember from previous experiment if you make this delay 9 you get back the constellation, oops correctly even when you have noise you can see that the constellation is pretty good, if you get the delay wrong you lose some quality, if you have the delay right you get the constellation pretty well, okay so we are set, now to check the effect of the phase offset let us double click the signal source we have this phase, this should not be offset apologies this should actually be initial phase and we'll do the same thing over here it should not be an offset it should be initial phase, now let us set the initial phase to something like pi by 8, we'll type 3.1415 divided by 8 and if you execute the flow graph you will see already that there is some hint that this is a skewed constellation, so if you set the delay to be 9 which is what we found out was right you can see that the constellation is skewed, now what explains this, the reason is because the i and q which would have been there had you done the phase or the receiver had you had the phase at the receiver correctly are not present and therefore you have this extra rotation, if you remember in the lecture we derived this fact by actually multiplying cos 2 pi fct with cos 2 pi fct plus 5 and sign with the corresponding plus 5 and we found that there is a rotation of the constellation, if you want to check for other offsets also you can just for example let's say pi by 4 which will essentially return the constellation because it corresponds to, so this kind of return meaning it will rotate it by pi by 4, so this point which is 1 plus 1j by root 2 went to 1j because of the pi by 2 rotation and if you rotate it by pi by 4, sorry pi by 2 rather then you will essentially get back the original constellation or of course you must remember that actually this point is actually this point in disguise because of a pi by 2 rotation, now these kinds of calibrations can always be done but if you don't know the phase offset then you will make errors when you detect, now how do you find out the phase offset, so one strategy is if you are looking for a known symbols approach you can actually connect you can actually send something that is known for some time, let us take a simple example, to understand how this phase can be detected let us temporarily remove this random source by clicking on it and pressing delete and it's actually add a constant source so I'll say control f, c, o, n, s, t and grab this constant source and double click this constant source make it output the byte 0 constantly, now the byte 0 corresponds to the first element of myconst, the first element of myconst is minus 1 minus 1j therefore if I make the phase offset 0, make it 0 temporarily then if I execute this flow graph in the absence of noise you will get minus 1 minus 1j by root 2 which is the expected constellation point even in the presence of noise, now if you have a phase offset this minus 1 minus 1j will be rotated by that amount, for example let's say that you have a rotation of pi by 4, 3.1415 divided by 4, if you execute this you will find that this constellation point has undergone clockwise rotation of pi by 4, reason why it is a clockwise rotation is because the phase offset is applied at the receiver, if you again now find that the phase offset is pi by 2, let's also make it in the presence of noise you will find that it's okay let's check this phase offset should not be pi by it should be pi by 2 not 42, yes now you will find that this minus 1 minus 1j point has actually gone to minus 1 actually minus 1 plus 1j, this basically means that if you send a known training sequence from the transmitter that can be used to identify and correct for the phase offset, so in the training mode in a PSK or similar constellation you can use this fact to identify and correct for the phase offsets, to complete let us go back to a random source let me remove this constant source, let me do control f for command f and say r a n d o m and we'll get a random source, we'll again double click make the random source go from 0 through 3 by pressing 4 here make it sub byte and if we connect it back we get back our original performance we get we have to set this delay to 9, let us also just do a couple of things let's set the default delay to 9 so that we don't have to keep doing it let's also add a bit of noise and let's say that the default noise is 0.02, now you can see that you know if you have noise then you really need to be careful because if you have noise like this where it can go into the neighboring bin as well so let's do one thing let's actually increase the q2ga constation points number of points so if I double click this and say 10240 and let's say I also have 10,000 random values here if you have more noise you can see that in these levels you are bound to make mistakes in such a situation what is typical is to actually have a more or a prolonged training period wherein you actually train so much so that you can average the noise out in other words you take many measurements and average out the noise so that you get a sufficiently high signal to noise ratio and use that to reduce the impact of noise otherwise you can't really calibrate if you have too much noise of course even blind strategies are not immune to noise they are in fact much more affected by noise and may require even a larger amount of training so to summarize whether it is in the presence of noise or you know um whether it is in the presence of noise with training or without any training and blind approach you have to estimate the phase using some method by using the property of the signal or something and only then can you reliably detect the symbols that are sent now the next thing that we will look at is the phase calculation one remark over here is that if you have a constellation like quam4 qpsk that is or something like quam16 as well once you figure out this kind of phase offset and it's a frequency offset by just looking at the distance of these symbols from the boundary you can find out the amplitude a if you remember finding the amplitude a was also one of our challenges and that can be found using this approach as well of course there is a blind strategy and a training based strategy but it boils down to finding the distance of these constellation points from the origin or fitting the constellation properly that is also a remark that is the maximum maximum likelihood estimate of the amplitude is also something that is implicitly captured over here in this lecture you got a taste of some of the receiver impairments that you can model using GNU radio in particular the presence of offsets in phase and how they can be visible on GNU radio in the presence of noise as well as some of the other aspects like parameter estimation of the amplitude are some aspects that you have seen so far in subsequent lectures you are going to look at other receiver impairments such as frequency offsets and methods to overcome these thank you