 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 will tie together all of the ingredients that we have seen over the past several lectures by putting together a complete system simulation involving generation of data, conversion to symbols, up converting to passband, getting it back at the passband, I mean getting it back at the receiver along with noise, bringing it down to baseband and then visualizing and confirming that we are able to recover our symbols correctly with and without noise. This is the culmination of the ingredients that we have seen in the previous lectures and putting everything together will give us an idea of a reasonably realistic communications system. Let us begin as usual by first introducing a random source. So control F for command F and we'll say random, we'll grab a random source and preemptively I'm going to make it use bytes and since we're going to use QPSK, I'm going to set this to four. Next we will get a constellation encoder. So control F for command F, we'll say E N C O D E R. So we get a constellation encoder and we'll connect these two things. We'll then get a throttle. So control F for command F, we'll get a throttle, connect the throttle over here. Now before we continue, we have to define the constellation. So let's grab a constellation object. So control F for command F, we'll grab a constellation object, double click this, we will call it my const, which is fine. And this variable constellation we can leave as is this is actually a gray coded QPSK. Now we need to make sure that we use this constellation that we have created. Our next course of action is to get the get a pulse shape in place. So we'll use a standard root trace cosine, so the control F for command F, R R C. And we will grab the R R C filter tabs, double click this, one change that I made, I did tell you is that I changed the sampling rate to 1 9 2 0 0 0 for convenience. And let's actually use a samples per symbol variable. So I'll say control F for command F, I'll say variable. And we will first keep this over here, call this SPS and I want my symbol rate to be 8000. So I'm going to call this SAMP rate upon 8000, this double division is for integer division and that gives automatically computes the samples per symbol S4. So now the symbol rate is essentially SAMP rate divided by SPS. So that automatically is going to give me 8000 and this computes our R R C filter tabs automatically. Our next course of action is to just pulse shape our constellation encoded symbols. So we'll just call an interpolating FIR filter, so control F for command F, interpolating FIR filter, connect this over here, the interpolating factor will be SPS because we want the result of this interpolating FIR filter to give me 24 samples for every input symbol. And the filter that will do the job for us is R R C underscore tabs. Now that should be the name of this filter over here, which I did not give R R C underscore tabs. Now to verify that this filter, you know, if it's coupled with a decimating FIR filter gives the correct result, let's place a decimating FIR filter as well over here. So control F for command F, D E C I M, we get a decimating FIR filter, connect it over here, we'll set the decimation to SPS and use the same R R C tabs. And now to check that outputs are correct, let's add a constellation sync and a time sync. So control F for command F, we'll say time sync and this time sync, we'll add a constellation sync as well. So we'll create a constellation sync over here and just check that the constellation looks nice. We run this, it seems to be small and it seems to be really really tiny. The reason is because the filter essentially has a scaling related issue, so you can just double click this and you can set the gain to about five and that should essentially do the job for you. So now you get close to 0.707. It's actually not 0.0707 because this number has to be square root of 24. So if you really want to get that right, you can actually just compute square root of 24 or you can just add your numpy module. So we'll just control F for command F, we'll say import, we'll actually import numpy SNP and we'll just say np.sqrt of SPS because that's essentially what we want. This will take care of the scaling and now you will get a very nice constellation close to 0.0707. We have a very nice stream of data that is being shown over here. You have the baseband complex data, real and imaginary parts and this is after decimation. So you can actually just use this as a template to see whether you're receiving the same data. Now temporarily let's get rid of this constellation sync. We don't need it now. Our next task is to now convert this to passband. So let us actually add an FC variable. So control F for command F, we'll say variable and we will take an FC. We will take our FC to be, I think 32,000 should be a safe number because our baseband signal is around 8,000 and should not be too much of an issue. We can just change it if needed. Our next task is to modulate the output of this interpolating FIR filter using the epar j 2 pi fct. Now you need root 2 cos 2 pi fct, root 2 sin 2 pi fct, but you know that we can just cheat a little bit and then just do a single complex signal source over here. So I'll say control F for command F, I'll say signal source. We'll just grab the signal source and this is cosine is fine. We can change the amplitude later, we may need some scaling, that's okay. We are going to multiply these two, so control F for command F, we'll say multiply and multiply these two and take the real part. Remember it's real part of x of t e par j 2 pi fct. So we'll now do a complex to real control F for command F and we'll say complex to float. No, let's not do that, let's do complex to real, that makes it more convenient. And with this complex to real, we now have our pass band signal. I'm going to call, put it to a virtual sync so that I can do the work below control F for command F, I'll say virtual sync. So this virtual sync is my pass band underscore signal. So I now have my pass band signal and at the receiver, I must first add noise and then I am going to essentially get back the original signal. So let's actually again do a standard thing, we'll add a range and our range will have noise std and I don't, I'm not worried too much about the precise scaling. So that is something which you can check subsequently, but we're going to add some amount of Gaussian noise. So now this pass band signal, when it comes to the receiver, let's actually place a virtual source control F for command F, we'll say virtual source, this virtual source, I am going to make some space by moving this down. This virtual source is going to have the stream ID pass band underscore signal. Say okay, let me make these come into your view so that you have enough view. Now this signal, first you have to add noise to it. So let's first do control F for command F and type noise and this time we're changing it around to add real noise because in the real world, noise is real with noise std, this is fine. We're just going to grab an add control for command F and say add make this a float add connect this like this. Now we have our virtual source which has the pass band signal, noise added, now we're ready to do our receiver work, which is multiplying by root 2 cos 2 by fct, multiplying by minus root 2 sin 2 by fct and then of course those outputs have to be filtered with a low pass filter and then we will get back our base band signal. Let's try it out. So I'll grab a signal source control F for command F type signal, I'm going to place one here, we need this to be at fc, we need this to be a cosine, we need this to be square root of 2, I'll approximate it as 1.414, I also need this to be float. Now we will, let's see how I can make some space, we'll copy paste this, yeah we'll copy paste this below control C, control V and we will now put this over here and this becomes minus 1.414 sin. Now what I'm going to do is I'm going to multiply the signal by these two and then low pass filter them. So I'm going to do control F for command F, multiply, we need a real multiplier. So let's multiply this with here, multiply this with here, we'll just do control C control V, we'll multiply this with here, this over here and now I need a pair of low pass filters to get rid of the 2 fc component. So control F for command F, we'll say low pass filter, we need a float low pass filter, we're just going to say decimation is 1 that's fine, sample it, cutoff frequency, we will set it to something like I think in our case the fc, fc itself can be a cutoff and we'll say 1000 hertz and we'll just copy this filter and paste it control C control V and now we are just going to multiply these out and we've got rid of our 2 fc component. Now all we need to do is we need to combine these and get to the baseband but before we do that we need to do the decimation. So let's first combine these and then do the decimation. So we'll do float, control F for command F, we'll do float to complex. So now we are essentially going to do the matched filtering because we now have the baseband signal, we can do the matched filtering, let's just grab this decimating filter control C and control V because it's just the same job effectively but over here let's add a delay element and a delay element is needed because we want to make sure that the sampling location is correct. So let's add a delay element so control F, we'll first say range and this QT GUI range we will place here, we will call it delay, it can go from let's you know it can go from 1 to SPS which should be fine. So now we'll add control F for command F, we'll say DELAY. So now this delay is connected and now the decimating affair filter goes through a delay. Now the reason we need this delay is because we are introducing this causal element in the form of this low pass filter and we need to adjust for its length and its group delay so as to get back our signal and let's get our time sync so, no, constellation sync so control F for command F we'll say constellation sync and let's see whether we are able to get our signal back. So now if I execute this, there is obviously some issue, yeah we have to set this to delay so that our delay essentially takes effect so set to zero, we'll set it to delay, now if you execute the flow graph now by starting to change our delay we see that our constellation starts to come back and it's 0.5, 0.5 that means there's a scaling issue, the scaling issue is because over here we needed this original cost or other e-project by FCT to be 1.414 and now with this change if we set this to essentially 9 it turns out we get it. So let's make the default for our delay range as 9 for convenience so that we don't have to keep tuning it and now if we start increasing the noise you will see that the constellation essentially behaves in the same way that it was behaving in the earlier scenario. Now as a final step, actually we need to be able to recover the data as well but here I'm not going to go through the hassle of adding a, you know, adding a bit error rate counter or a symbol error rate counter, the reason is because these delays, practical delays will need to be aligned before you do the data computation and in practical systems because there's always going to be some or the other delays even more than this 9 because of various system related issues you will eventually have to look at recovery of the signal and the start of transmission and all those those are things that we will see eventually but let's see if we can at least get a hint of seeing that the two sequences are the same. So one thing we can do is we can essentially take this time sink and then just add the other input to it and see whether it makes some amount of sense. So I'm connecting the output from the decimating filter also to the same time sink. So now we have many of these signals. Let's actually try to stop and zoom in a little. Now if you zoom in, signal 1 and signal 3 correspond to the real part and signal 2 and 4 to the imaginary part. Let's hide signal 2 and 4 temporarily. So now let's look over here. So there let's see if there is any pattern that we can notice. So if you look carefully, of course, it's not very easy to see the blue one is the original one that should be early and the green one should essentially trail. So whatever pattern you see should appear first in the blue signal and only subsequently in the green signal. So if you observe any pattern in the blue signal that should come in the green signal later. So let's actually look at some particular location and see if we can observe some pattern. So over here, let's say that we have, let's look for a pattern like these. Let me see. Let's hide the green one. So there are four of these sharp kind of peaks surrounded by two of these non-sharp peaks. So we're looking for four sharp peaks and two non-sharp peaks. So then that must be delayed. There are four sharp peaks, two non-sharp peaks. So as you can clearly see, so this four sharp peaks, two non-sharp peaks appear over here. So there is evidently a bit of delay. So you can see that there is an amount of delay. So if you want me to quantify it, the four sharp peaks, the first peak is at 1.63 microseconds. Over here, it's at 1.68 microseconds. So there is a practical bit of delay. Similarly, let's look at the imaginary signals also. Let's hide this. So for the red, we're going to have, remember the red is early. So the black is going to have it delayed. So let's look for this big valley between these two flat peaks. The big valley should appear somewhere here, about half a millisecond later. As expected, the big valley appears here. So this big valley and this big valley are very much the same. So by actually aligning your transmissions, you can definitely recover the data without any significant issue. Now there are some very minor changes that we can make to simplify things. So because this act of using a constellation encoder and interpolating FIR filter is very common, you can actually play a trick and you can actually just combine these as well. So for example, what you could do is you could just remove this interpolating FIR filter altogether and remove the encoder. And if you do control f or command f, there is a constellation modulator. The constellation modulator actually has some nice features. It has an inbuilt RRC generator. And if you just specify the constellation MYCONST and differential encoding should be no, samples per symbol should be SPS. So now you can actually use this to do the modulation automatically. But if you now execute, yeah, you now have to connect this over here as well. If you now execute the flow graph, however, notice that let's ignore the delayed ones. Notice that these signals also have some issues in the constellation because there is some amount of, you know, delay related issues. They're not the sharp peaks that you saw earlier. So essentially the filter which it is using inside is maybe causing some delay here. So let's add another delay. So I'm just going to do control C, control V, and I'm going to call this delay, let's say delay underscore zero, set it to zero. And let us now just add that delay in between over here, control f or command f, type DELAY. We'll connect this here, connect this here, and this will call DELAY underscore zero. Now if we execute this, you can see that you can see that the, sorry, you can see that these are not really, you know, nice looking, they should always, if you have the right sampling point and you're using a root trace cosine, you should essentially have these really nice peaks. So let's keep adding some amount of delays and check whether things improve. It seems that at this point, it is improving at this point. It's actually looking quite good and beyond it's spoiled. So now with this, then let's tune this, let's tune the delay of at the, at the other end. The other end we have, okay, zero, one, two, three, four, five, six, seven, nine, okay. And we have it at around 21, which makes sense because 12 plus nine is 21. So if you had the original signal, then you had to send at nine. Now there is a slight bit of artifact, of course, there's a very slight bit of artifact because actually it's probably 12, between 12 and 13. So that's why there's a slight bit of artifact over here, but this is good enough. But this is a small issue you will face whenever you're using the constellation modulator because you have to then depend on the filter that it uses. It may not be using the same RRC filter that you are using. Nevertheless, if you use constellation demodulator, yeah, if you are using a, you know, demodulator for the constellation, you could get away with it. But for now we are going to just stick to this kind of approach. Now this is a bit of a complicated flow graph, but it does tell you a lot about how these systems can be built because very practically speaking, you have the modulation, you have the data generation covered, you have the modulation covered, you're doing the up conversion to passband, you're doing the down conversion to baseband by removing these spurious frequencies and you have the matched filtering as well as the recovery of the constellation as well and you encountered some issues like the issue of noise. Let's first set this to 12 and 21, 12 and 21. So now if you have noise, then noise does cause some amount of irritation. For example, let's say the noise is really high, then it causes some amount of issues. So all these kinds of problems start occurring and because of these problems, you know, these are some of the problems you have to address and in addition, there are also other issues which we have not really looked at. For example, what happens if this FC is not correct at the receiver? What happens if there is an offset phase at one of the sources at the receiver and many such practical issues occur? And these cause various other problems when you try to recover the data and some of these are the challenges that we will see in the coming lectures as well. In this lecture, we have seen how we can put together various components that are involved in practical modulation and demodulation in particular, how you can take your random data to symbols, how you can then convert it into a waveform using pulse shaping, how you can upconvert it using a carrier frequency, noise addition, down converting, match filtering and recovery of the symbols and bits. This complete our basic picture of a communication system and subsequent lectures, this will serve as a template which we will keep using, we will keep building a system that resembles something like this and then start looking at more practical aspects such as frequency offsets, phase offsets, channels and several such other impairments. So, in this next lecture onwards, we will start relaxing our assumptions about the receiver and see how receiver impairments are going to affect the performance of our communication system. Thank you.