 Welcome to this lecture on digital communication using GNU radio. My name is Kumar Appaya and in this lecture we are going to look at some particular approaches to communicating without having to worry about frequency or phase offsets. We are going to look at the Costa's loop. The Costa's loop as you recall from class is an effective way for you to track the frequency offsets for PSK symbols. Remember in the case of PSK symbols, you can essentially take a power of the PSK symbols like QPSK, you can take the power of 4 and that allows you to estimate the frequency offset and then just successively ignore it or correct it. The other approach that we are going to look at is to use differential phase shift keying. In the case of differential phase shift keying, you encode information not in the PSK symbols themselves but in the transition between successive PSK symbols so that when you are, when you have frequency offsets then a conjugate of the one symbol with the previous essentially tries to minimize its impact. So these are some things that we will explore in GNU radio. Let us begin by just adding a random source. So control F for command F, say random source and let us also just increase our sampling rate to 1 9 2 0 0 0 and we will make the random source have bytes going from 0 through 4. Let us then get our constellation encoder, control F for command F we say C O N S T E and we will get the constellation object as well as a constellation encoder. Now connect these and the constellation encoder uses the object my C O N S T E and we will call this my const which is a standard QPSK constellation. Now we are going to model the impact of noise by just adding or by just adding an extra modulation over here. Let's just do one thing. Let's just do the up conversion control F for command F say interpolating FIR filter connect this will grab an RRC control F for command F and say RRC, RRC filter tabs will use the same approach that we did we will call this RRC underscore tabs will set the gain to 4.9, sampling rate is SAMP rate 8000 is the symbol rate and we need SPS so let's create a variable control for command F type variable and the variable called SPS remember we always want 8000 symbols per second so we will say SAMP underscore rate double divide to make integer addition 8000 that gives us SPS and sets this. Now the tabs as RRC underscore tabs and we can make the interpolation SPS now we have our up converted function now we are going to add the carrier so we will just refine F C first control F for command F will say VARI variable will call this F C will make it 40000 and we are then going to get a signal source control F for command F will say signal get the signal source will call the signal source F C frequency amplitude of 1.414 because we want something close to root 2 where then go to multiply control F command F MULT will connect these finally we just need to take the real part over here so control F for command F will say COMPLEX complex to real and that gives us the real part and we have made our transmit signal the up converted signal now let's add a virtual sync over here so that we can continue at the bottom so control F for command F and VIRT will grab a virtual sync to connect this virtual sync over here call it up up converted we will grab a virtual source over here and call it down up converted so that we get the same sequence let's also add Gaussian noise over here so that we can analyze the impact of noise as well so control F for command F we will first create a range to control the variance of the noise we double click this and call the ID NOISE STD and let the default value be 0.01 let it go from 0 through 3 step 0.01 that sets up our noise standard deviation we will grab a noise source control F command F will say noise source and the noise source should be a real noise source double click it will make it float and then amplitude will be noise STD we will add the noise so control F and will say add grab the add operator make it float and finally we have our up converted noisy signal now we will repeat the same things that we were doing except that we will also add a frequency offset so we need to mix this with a cos mix this with a sign and then low pass filter except that we will add an extra frequency offset to those so let me just create a range first for that control F for command F will say range we will call the range delta underscore F and let it go from let's say minus let's say minus 20 Hertz to 20 Hertz should do I think that should do minus 20 Hertz to 20 Hertz now we need two signal sources to multiply and mix these so control F for command F S I G N we'll grab the signal source this will be our cosine source double click it make it float the frequency will be FC plus delta F that is the difference and we don't want offset or initial phase make them to 1.414 will control C and control V this to have a copy and we will call this one the sign and we will add a negative sign to account for the fact that we have to have a negative here so that the mixing occurs correctly we'll add multiply blocks we'll just copy this control C control V make this into a float connect this over here connect the signal over here copy this control C control V connect this over here connect this over here we need a pair of low pass filters controller for command F will say low W low pass filter to cut the two FC components so double click on this cutoff frequency will set to FC with a transition width of a thousand and this should be float to float copy paste control C control V and then we'll just connect it over here connect this to a complex block control F float to complex and then we need an appropriate delay and a decimating filter so let's actually do that so I'm going to add a delay controller for command F let's say range first so the QT GUI range I'm going to call this delay and as always we'll make an integer delay going from zero through SPS since from previous memory the delay was nine let's just set the default value to be nine because that's the delay of these filters so controller for command F we said delay grab this delay block set this delay to delay and finally we have a QT GUI constellation sync controller for command F CONST and the constellation sync is just going to come over here and we are now ready to execute this flow graph let's run this oh sorry I need to decimate as well I'm sorry before the constellation sync we need a decimating FIR filter so controller for command F decimating FIR filter let's just rotate this so that we get it nicely and this decimating FIR filter is going to have a decimation of SPS and the tabs are RRC tabs now this decimating FIR filter output can go to constellation sync controller for command F the constellation sync appears here we connect the filter output here and execute the flow graph and now you can see that the constellation appears very well now here is the problem if you add any sort of frequency offset delta F you see that there is a rotation and this rotation is actually harmful because it doesn't allow us to get back our symbols correctly in fact by changing this you sometimes don't even get it back when you go to zero because there's an extra phase and that is causing some issues so what are we going to do we are going to add a costa's loop in order to address this issue a costa's loop as you remember takes these symbols to the power of four and adjusts the frequency offset from there to compensate let's just do controller for command F and type C O S T A costa's loop now this costa's loop requires three parameters let's connect this connect this over here now we need the loop bandwidth we'll choose that as 2 pi by hundred so 6.28 divided by 100 and order in this case we are using QPSK so we'll set the order to be four now if you execute this flow graph even if you increase this you will sort of see that the costa's loop still is able to figure things out that is let's say that if you make it this is 0.3 0.5 and let's actually remove the effect of noise and let's make the zero the costa's loop is able to figure out the constellation points let's actually increase the number of samples to 10,000 random thousand so now let's also increase the number of constellation points now if you observe by adding this okay the reason for the lack of performance was because the step size was set to 1 over here so we'll change the delta of step size to 0.1 so that the frequency offset is reasonable so now if you execute this flow graph you have this constellation even if you start adding some amount of frequency offset you can see that the costa's loop is tracking it that is it's not rotating to verify that this is indeed the case let's actually view the rotated and derotated constellations both simultaneously we'll double click on the constellation sync we'll increase it to two inputs we'll connect the original constellation over the first and the rotated constellation at the second so now let's check our flow graph's performance you see that both are overlapping which is fine we now start adding the frequency offset the blue one rotates because of the fact that there is a frequency offset and the red one still is right there because the costa's loop is tracking your frequency and phase offsets effectively of course like we discussed in class there's a limitation on how far you can go that is if you keep increasing the frequency beyond if you keep increasing the frequency beyond the acceptable limits then like if you keep going like this you can see that the performance of the costa's loop starts diminishing because of the e power j 2 pi delta f times t and that adds an extra phase if you go further and further you will see that the point starts spreading around and your SNR essentially SNR limitation is come going to come to four you're gonna have a poorer performance than the original carrier recovery algorithm if you go very far then it loses the lock if you go like and if you add more noise you start to have performance degradation so overall the costa's loop does simplify the implementation significantly but it comes at a price and with some limitations and if you make the frequency offset too much for example let's go let's make it gradual it locks if you make it go too far then it really doesn't work it actually tries its best but fails as a final example let us inspect how differential phase shift keying can perform we will create a simplistic example by just constructing the basic elements needed to understand this let's first make our sampling rate 192 000 okay let's save this no radio and you call this DPSK 4 yes let us first get a random source ctrl f for command f we'll say random source now this random source is a byte that goes from 0 to 4 and let's get a constellation object in the constellation encoder constellation object will place below constellation encoder will place here so now we'll double click this constellation object we'll call it my const and we'll call this my console that it uses that constellation now we will assume that this is differentially encoded even though it probably isn't but let's just assume that the output is differentially encoded temporarily ctrl f we'll get throttle now let's add a bit of noise so I'll say ctrl f I'll say range and we're going to just call this noise sdd going from 0 to 3 step 0.1 let us also get a delta f to just add a frequency offset so ctrl f we'll say range again and we'll make a delta f to model the frequency offset and this frequency offset let's say goes from minus 10 to let's say default value 0 goes from minus 10 to 10 step 0.1 and then we're going to add noise and we're going to add a rotation so ctrl f for command f we'll say add first and we'll say connect this we will grab noise source ctrl f command f we'll say noise we'll grab the noise source and then we will add a multiplier so that we can introduce the frequency offset rotation and the frequency offset we can produce by using a signal source ctrl f for command f we'll say signal source and this signal source we will make sure that the frequency is delta underscore f now we have this constellation and we will also do a differential decoding of this and view both so as to control f for command f and say differential so differential phaser this will take successive samples and just perform the neck you know one conjugate the other which is the differential decoder basically and then we will grab a constellation sync say nst and view both of these so the first one is this one let's double click this constellation sync and make it two inputs the first one is the original constellation with the rotation the second one is a differential phaser let us make sure that this is noise std now let us execute the flow graph now you will see even with a bit of noise let's say yeah that you have these one two three four five six seven eight of the constellation points these are the differential decoded because remember the phase difference is pi by two pi by you know pi by two times two pi by two times three and pi by two times four so these are differentially encoded and that is where that is the key to understanding that you know you are you are these should be robust to a little bit of frequency offsets let's check so now let's increase the frequency offset it's just verify what is happening so the frequency over here is delta f and we're multiplying this this should be connected over here of course we're multiplying we're now doing a frequency offset let's add some noise and if you perform frequency offset you can see that the constellation is rotating but the red one is not rotating the reason is because the red one is differentially decoded let us actually just increase the number of points by a factor of 10 and if you execute it with noise you will see that this constellation rotates while the other one doesn't and for slow rotations the differential decoding will work pretty well as the rotation speed increases you are going to become somewhat susceptible to noise and that becomes a problem so in this manner you can see that because you're doing differential detection the red one is more robust and not does not have the propensity to rotate for especially for small frequency offsets in this lecture we have seen some techniques to not have to use a PLL or to a great degree that is let's not track the frequency but let's just use a costar's loop to essentially track the frequency but one limitation with the costar's loop as I mentioned earlier is that it works only under some scenarios and for PSK constellations and not otherwise similarly differential phase shift keying makes use of of the fact that you can embed information in transition between the successive symbols phases and that to an extent diminishes the effect of frequency and phase offsets however in the presence of noise it is less robust than a coherent detection strategy where you use a phase lock loop to lock and track the frequency the reason is because if the frequency offsets essentially affect your decision regions that is in the case of differential phase shift keying with four symbols if it takes you slightly away then you are less robust to noise because of the fact that you are not really estimating the carrier just hoping that it doesn't take you away these are some aspects that you have seen in the series of lectures and in the next sequence of lectures we're going to now look at the next impairment that is how the medium or the channel affects your performance how distortions introduced by the medium can be tracked and corrected thank you