 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, this is the third in our series of relaxing the assumption that all the parameters of the receiver are known. That is we are going to look at synchronization, parameter estimation, how you can estimate the delay, amplitude, phase, frequency at the receiver. Where we left off in the previous lecture was a brief discussion on the phase lock loop. Just to refresh your memory, in the case of a phase lock loop, we have this feedback based structure where if the phases of the phase differences rather of two frequencies are tracked, like two sources are tracked, this phase difference can essentially be used to nudge or adjust the voltage control oscillator to match the carrier that is present in the received signal. One thing I was mentioning was that this works excellently for a pure carrier that is an unmodulated carrier when you you know even in the presence of Gaussian noise. But in case you have some signal modulated on the carrier, then you have to be careful and find alternate ways to get back the carrier local oscillator which matches the carrier that was used at the transmitter. We will now discuss the maximum likelihood interpretation of the phase lock loop. If we consider an observation interval of length t0, that is we will take enough number of cycles to have the variations of the carrier present. Now, your y of t is e power j theta n of t. Now, implicitly I am ignoring the variation of theta, but assume that this is e power j theta of t that is the phase is essentially varying and variation of phase as you are aware is actually because of frequency that is if you differentiate the phase you get omega. Therefore, here implicitly assume that it is e power j theta of t. So, y of t is e power j theta plus noise and this theta is unknown and it is not a number it is varying with time you have to essentially find out the frequency offset. So, this L of y given theta is exponential 1 by sigma square real part of y e power j theta minus t0 by 2. How? If you perform the integration over an interval of t, this is what you will end up getting because if you take n of t and n of t right, if you integrate n of t from 0 to t0, then that becomes a random variable and that random variable will have various proportionate to t0. So, if you now look at this and this t0 is essentially number we do not really care much about. We just need to we just need to look at this particular quantity and we want to maximize this particular quantity that is integral 0 to t0 minus y c. So, if we write your y of t as y c of t plus j y s of t, you are going to get minus y c of t cos theta t plus y s of t sin theta t dt that is you are going to essentially multiply this and take the real part. So, if you multiply this by cos theta plus j sin theta of t, you are going to get this. Now notice that in this integral, we have y c cos and everything like that and we want to essentially maximize this in a way. So, as to match the phase correctly over time, the only difference between the phase tracking problem and this is that we are averaging over time and the theta is varying during that interval. Your theta is essentially varying during this interval. So, you want to maximize j of theta to match the varying phase. To do this, I have written the same expression once again. If you differentiate for steepest ascent, now why steepest ascent? So, whenever you have any function, then if you want to basically maximize it, then you take the derivative and move along the derivative to go to the peak. That is if you have a function like this, what to do is you find the derivative and move along that direction and you always keep moving to the peak and at the peak, the derivative becomes 0. So, that is why we call this steepest ascent. So, what we are essentially saying is differentiate your j and now there is a trick which is being played over here. If you differentiate your j, you get the derivative of y c, you get the derivative of y s. Now, the derivative of y c and y s, we are actually not considering over here because we are assuming that y c and y s are slowly varying. That is your phase lock loop essentially has the your phase lock loops frequency it is the frequency it is tracking is much much more significant. So, we only perform the differentiation in these. Now, if you perform this differentiation, you get minus y c sin theta hat plus y s sorry this should be cos theta hat sorry and this is proportional to pi delta f. Now, one question is how did I get this to be d theta by d t? Well, if you differentiate j right, you do d j by d d j by d theta times d theta by d t. Now, d j by d theta times d theta by d t, you look at the d theta by d t and take the d j part away, this is essentially what you end up getting. You can work this out in more detail, but I am not going to cover spend too much time on this. So, if you now just look at this, this is very similar to the exercise which we did, where we mix that cos with a negative sign. So, that is it is very similar and that essentially is going to give you 2 pi delta f. Now, an integral is like a low pass filter that is if you remember we performed integration with respect to t naught. So, over here this integral with respect to t naught is like a low pass filter and with feedback to correct for this 2 pi delta f by means of using a voltage control oscillator, you end up getting a phase locked loop. So, that loop filter and you know all those things that we did is in a sense performing an averaging or integration and adjusting the voltage control oscillator to give you the correct output frequency and this jointly performs both frequency and phase tracking. Intuitively, a PLL tries to track the phase, but because it keeps tracking the phase with time, it changes the phase with time and this change of phase with time essentially translates to the frequency offset. So, this is the intuition with which you can understand how a phase locked loop works even from an maximum likelihood perspective because we set up the g of theta that is an optimization metric and that essentially translates to you know maximizing that essentially translates to tracking the frequency optimally. This is something that you can look at in more detail at the references. In fact, designing of phase locked loops is a very well studied problem and you can get several circuit related literature where efficient implementations of phase locked loops under various constraints, various modulation formats essentially covered. So, this is something which you can look at in more detail in the references. Of course, in GNU radio we will cover some aspects of PLLs you know using a simulation as well to find out how well it performs under noise. A small aside, there is something called Costa's loop for phase shift keying, only phase shift keying, ok. In this case what you have is you essentially perform the symbol you know you perform the symbol sampling, but then you find a way by which you can essentially track the frequency offset by tracking the phase offset. In this case right, because of the phase offset which is varying you are going to have your PSK symbols going all over. Let me give you a practical scenario. So, let us say that you send PSK symbols. Let us say that you have QPSK ideally you send this. Unfortunately, you remember the frequency offset manifests as a phase. So, what you will end up getting is if you keep sending this symbol also at the receiver you are going to get this kind of rotation. Why is there a rotation? Because if you remember we discussed that if there is a phase offset you are going to get an e power j phi and if there is a phase offset which changes with time you are going to get e power j phi of t. This is very harmful and this is not going to help our cause at all. So, what do we do? We are going to use a trick. Let us say that we have QPSK. For QPSK let us take e power j pi by 4 that is this symbol and what do you get when you take e power j pi by 4 to the power 4 you get e power j pi which is minus 1. If you take e power j 3 pi by 4 that is this symbol that also gives you minus 1. e power j 5 pi by 4 e power j 7 pi by 4 all of these map to minus 1. So, what trick can you play? Well let us now look at what we can do. Let us say that you have y 0 is equal to and this is y 0 is equal to let us say we will for temporarily ignore noise b 0 y 1 is equal to b 1, but it is e power j 2 pi delta f times t where delta f is the frequency offset and t is the duration of a symbol y 2 is equal to b 2 e power j 2 pi 2 delta f t and so on. Now, there are a couple of things that we can do unfortunately we do not know b 0 b 1 b 2 we know they are QPSK symbols we do not know what they are, but you know this b 0 b 1 b 2 are one of these. Let us now play this trick y 0 power 4 is minus 1 why because we know that y 0 is one of these four symbols y 1 power 4 is actually b 1 power 4 gives you minus 1 and this gives you minus e power j 8 pi delta f t y 2 power 4 is minus e power j that is 2 times 2 times 4 16 pi delta f t capital T. So, what do you see over here if you find and if you know let us just go down a little if you now perform y 1 power 4 let us do multiplied by y 0 power 4 conjugate what do you get you get e power j 8 pi delta f times t. Similarly, if you do y 2 power 4 times y 1 power 4 conjugate actually y 1 yeah y 1 power 4 conjugate it is let us just change the order over here does not matter, but let us just do it properly you end up getting e power j 8 pi delta f t at the receiver you know the duration of one symbol let us say that you have figured it out if you know the duration of one symbol then just by taking the argument of this the argument of this is 8 pi delta f t divide by 8 pi t you are done now this will give you the same answer. So, in the presence of noise what do you do you take a large number of these you then find the argument of all of those and just average out the noise and you are able to get the frequency offset very very easily. Now, this will work for PSK BPSK QPSK 8PSK 16PSK and all those things it will work for and in fact work for any constellation that has equi-spaced and lies on a circle because you just have to find the right power of you know right power to take the symbols 2 to map them this will also work for other versions of QPSK for example, if you choose this version this is also this QPSK constellation rotated by pi by 4 this case it is 1 minus 1 j minus j in this case if you take power 4 you get 1 instead of minus 1. So, it will just work for this as well. So, the costars loop allows you to effectively track the frequency offset very very easily for PSK constellations. So, let us go back. So, x power 4 is minus 1 for all of these symbols. So, raise these symbols to the power of 4 and track the movement and that essentially allows you to get the frequency offset. Now, one remark that I will make is that while costars loop is very easy to understand and implement and we will actually see that it works very well for certain scenarios it fails when you have some other impairments like a channel like let us say that you essentially have your symbols, but unfortunately they get convolved with some other channel or something in that case you have to make some adjustments for the costars loop to work. So, for example, if the problem that we face is that we have to jointly estimate the delay the amplitude the frequency offset the phase and eventually we will look at the channel also. So, in that situation the costars loop may or may not be the most effective and a more traditional phase lock loop based approach is much easier to realize there because you can extract those frequency components much more easily. This costars loop is something which you will be looking at in the simulations using GNU radio as well, but it is a very powerful and conceptual tool to understand how the PSK constellation looks like in the presence of frequency offsets. Now, we will just go to a continuation of this called differential modulation. I will quickly motivate it. So far we have seen that system parameters vary with time. In other words, you have differences between the transmitter and receiver. The transmitter receiver have some differences that phase difference and frequency difference and all those and you are able to calibrate it. They vary with time, but you can use phase lock loops or some other calibration mechanism periodically to track it. Now, you need to frequently recalibrate the system that leads to more overheads, but what if we exploit the fact that the system parameters change only slowly and can we encode information in the difference between these symbols. That is where differential phase shift keying comes in. This is a method of non-coherent communication that is we do not want to do carrier recovery, but still utilize or exploit the fact that the carrier to the receiver is nominally close and get away with this. How do we do it? So, in the case of differential PSK as we just discussed, let us say that you have QPSK, but there is an offset, offset in the frequency. The offset in the frequency manifests as a rotation of the constellation that if you send 1 plus 1j, it is going to become 1 plus 1j slightly moved away. That is, it is going to move away on the circle, but move away. And therefore, if you have noise, you are less robust to noise because you are going to have all these bad impacts of the movement of the constellation. Now, one approach is of course, the traditional route where you use a PLL or use some approach to get the carrier, but let us say that we want to completely avoid the carrier estimation and use the fact that it does not move by much. Well, let us actually play the same game as we discussed in the case of the costars loop. Let us actually do one thing. Let us not encode information in the constellation points, but let us encode information in the difference. I will tell you what I mean by difference. I mean in the phase difference. That is, let us say B0 is my reference and I am always going to have it as e power j pi by 4. Now, if you remember we had this mapping 0 0 0 1 1 0 1 1 and we did gray coding. So, this is let us say e power j pi by 4 and this is e power j 3 pi by 4 e power j 7 pi by 4 e power j 5 pi by 4. You can verify that this is one of the more effective ways to allot the bits so that you do not you have minimum bit errors in the presence of symbol errors this is gray coding. Now, for B1 write you write this as note carefully whatever symbol you want to send let us call the let us call my symbols let us say actual symbol let us say m 1 m 2 and so on. So, m 1 m 2 all belong to this set. Let it be m 1 times B0. Let B2 be m 2 times B1 that is I am always encoding the information in the phase difference. Now, B3 is m 3 times B2. So, now let us come up with this scenario as we discussed above ok. The scenario we discussed above let us say that our Y1 is B0 our Y2 is actually sorry let us say Y0 sorry Y1 is B1 e power j 2 pi delta f times t. Now, this is a problem, but the way we have encoded the information the information that is encoded is in B1 B0 you know we have to just take the conjugate of B0. So, let us actually do this let us just look at Y0 conjugate Y1. That is going to be equal to B0 conjugate and what is B1 m 1 B0 e power j 2 pi delta f t this is equal to m 1 times e power j 2 pi delta f t. Now, if delta f times t is small then e power j 2 pi f this is approximately equal to 1 that is this does not add too much of phase. If your delta f times t is really small this does not really add too much phase and you get your m 1 directly. Let us do one more exercise Y2 is equal to B2 e power j 2 pi delta f t I am assuming that the delta f is the same Y1 star Y2 is equal to and this is going to be 4 times 2 times 2 delta f t. Now, Y1 star Y2 is B1 star e power j 2 pi delta f t negative times P2 e power j 2 pi 2 delta f t that is equal to now B1 star B2 what is B1 star B2 from this particular equation B1 star B2 is m 2 why because all of these are PSK constellations I get m 2 e power j and this is negative delta f this is 2 delta f 2 pi delta f t. So, what is the concept here the concept is that we are essentially encoding information in the jumps that is there is a jump here the jump here jump here these three jumps or that it can be at the same point where essentially encoding information in these you know if the if you have pi by 2 jumps and so on sorry I mean they will just change this a little bit this having pi by 4 jumps is not going to work let us just call this plus pi by 4 in all of these plus pi by 4 plus pi by 4 plus pi by 4. So, you can essentially just check that you know this is pi pi 4 plus pi 4 you can essentially if you now jump by pi by 2 right. So, you are now going to have a pi by 2 jump here a pi jump here a minus pi by 2 jump here and 2 pi jump or 0 jump over here if you start encoding information in these jumps then you will end up not having to worry too much about the frequency offset. So, in other words if your modulation is actually let me just fix this for you. So, let us just get rid of all this ok. So, now if your modulation is essentially going to be differential and you end up doing something like this let us say 0 0 corresponds to let us say as 1 it no no no jump at all 0 1 corresponds to e power j pi by 2 0 1 0 corresponds to e power j pi and 1 0 corresponds to minus pi by 2. So, based on whether your m 1 is 1 or m 1 is e power j pi by 2 and so on you can essentially extract the bit sequence this extra bit of e power j 2 pi delta f t is something that you ignore and you assume that does not affect you so much if delta f t is small. Now, there are some obvious pitfalls with this approach as well one key issue being that if the frequency offset is actually quite large you know if it is close to you know let us let us give you a let us take an example. Let us say that your constellation point is this and you are always encoding information the difference ok that is and let us say that you are you are essentially getting this much of difference this is fine, but what if your frequency offset causes you to go somewhere here then you have a bit of trouble you have to essentially start undoing it and the problem is you will have lots of noise as well. So, your frequency offsets very high and you have noise then this differential approach really does not work that well. More importantly because you are not really estimating the carrier and phase properly you are actually just trying to track it you are less robust to noise and in fact the if you look if you do the computation carefully you will find that in the case of phase shift keying you have poorer differential phase shift keying has poorer SNR properties you have a higher biter rate or symbol rate for the same signal to noise ratio. So, frequency errors so this is just you know kind of formal statement of what we did encode information the difference in the case of differential qpsk we arbitrarily choose b0 as e power j pi by 4 and bn is e power j phi n bn minus 1 where phi n is 0 pi by 2 pi or 3 pi by 2 that is exactly what we did and we just do angle of our argument of b prime b you know b prime and star times bn minus 1 this prime essentially refers to what was you know received even if it is deviated and that essentially gives you your phase. Now, you are robust against slight frequency offsets, but like I mentioned you have a higher penalty in the presence of noise. So, to summarize we have seen in this particular sequence of lectures at the receiver getting your parameters right is important you have to get the amplitude right for example, if you use qpsk quam 16 let us say you have to get the amplitude right so as to get the decision regions correctly. So, estimating the amplitude is one thing getting the sampling location right requires you to estimate the delay for start of symbol as well getting the phase and frequency offset is also important. There are various approaches for example, phase lock loop or cost loss loop various approaches that work under different scenarios that have been tried and tested over the years. One approach where you can say I do not want to estimate the frequency offset correct in our phase offset I want to just send my signals with some amount of you know basically differentially across the phase works pretty well in the presence of a small amount of frequency offsets, but you have large frequency offsets and when you have issues like you know noise being very significant then differential modulation does not really work that well. So, in general coherent or frequency carrier at the local oscillator based receivers have slightly better SNR to BR performance SNR to simulated performance than differential modulation. We have now seen the impairments at the receiver that can affect your performance in the next sequence of lectures we will be looking at some of these using GNU radio and then we will look at the next major impairment that is the channel model. Thank you.