 In the previous lecture we have discussed in detail the aspects of orthogonal frequency division multiplexing. If you remember in orthogonal frequency division multiplexing the idea was to put your data in parallel narrow band frequency channels and in this way you are able to parallel parallelized transmission into several easy to equalize channels. In this lecture we are going to use GNU radio in order to come up with an FFT based implementation of the OFDM system. We will show that by parallelizing the channels in the frequency domain we are essentially getting rid of the effect of the inter-sample interference to a reasonable degree because you are splitting it into parallel channels but this inter-sample interference of course manifests in the frequency domain as different gains. We will do this with various PSK or QAM modulations and see how OFDM affects the receiver design. In our exploration of OFDM by first building a traditional system that does not use OFDM and then gradually add the OFDM related elements. So our first task will be as usual grab a random source and once we place the random source we will use QPSK therefore we will set the maximum to 4 and use the byte data type. Next we will grab a constellation object and encoder so controller for command f and type constellation and we will get the encoder also connect these up we will make the constellation my const and we will make this object use my const and we need a throttle controller for command f we'll say throttle we'll connect the throttle next let us also grab an RRC kind of pulse so that we can get the pulse shaping also so let's actually increase the sampling rate to let's say 192 0000 and let's limit our symbol rate to 8000 therefore we'll create another variable called SPS controller for command f we'll say variable we'll grab the SPS variable our SPS will be SAM rate double divide so that we get an integer 8000 next we will grab the RRC filter tabs controller for command f we'll say RRC so we have our RRC filter tabs here let's call these RRC underscore tabs and symbol rate is 8000 that gives us our RRC filter we'll then perform an interpolating FIR filter operation so we'll grab controller for command f say interpolating FIR filter and this interpolation is going to be SPS and the tabs are going to be RRC tabs this is what we have been doing so far a very traditional approach to generating the sampling signal we can view this on a QTGUI sync as well so controller for command f we'll say FREQ and we'll get the QTGUI frequency sync and we can connect it and if we view this you'll find that you're using the bandwidth between say minus 8 to minus 4 to 4 kilohertz rather if you want you can just perform an amount of averaging and if you perform the average you'll see that you're using somewhere between minus 4 to plus 4 of course there's a 1.3 factor because of the root trace cosine so it's going to be about minus 5 to 5 and this makes complete sense now our next task is going to be to view this in the context of the OFDM modulation to perform OFDM modulation what we will do is we will take this output of the encoder or from the throttle and we will then perform an inverse discrete Fourier transform as you've seen in the lecture the simplest way to implement OFDM is to take your symbols and to take an inverse DFT of those and then put them out in this exercise you will find use for some new elements of GNU radio let us first create a variable control f and say variable that defines the FFT size that we will use so I'll call it FFTSIZE this is because it'll be convenient to change later and we will set it to let's say 4 now we will then just disconnect this over here and we need to perform the DFT over here and then I find the in fact the inverse DFT and then pass it to this interpolating FIR filter to perform the DFT we have the FFT block controller for command F will say FFT you have this FFT block under the Fourier analysis heading now unfortunately this FFT block takes the takes vector input not stream input the reason for this is that FFT is essentially FFTs are essentially conducted on streams as opposed to just numbers so in other words you have to group these in blocks of FFT size pass it to the FFT block and then convert the output back to a stream and then view it in the frequency sync now this operation is going to require a bit of work because you cannot directly connect the throttle over here because a vector cannot be converted you know converted to a stream directly or a stream cannot be converted to a vector directly therefore let us first perform a stream to vector operation so I'll look for controller for command F I'll say S-T-R-E-M we'll say stream to vector if I say stream to vector and double click on the stream to vector and I say number of items as 4 and I connect this over here of course I must not just make the number of items for number of items should be 4 and the vector length to be 1 and then over here in the FFT block we need to make some changes the first thing is that the FFT size we will set to FFT S-I-Z-E then we want the inverse DFT so we will set this to reverse next by default the FFT block uses a black man Harris window that essentially alters the way you see the spectrum this is very useful when you perform spectral analysis but in this case we want to just view the spectrum directly so we will set this to just all once so we'll say square bracket 1 times FFT size that will give us an all ones of FFT size length shift essentially performs a rotation of the FFT so that it's easy to view we don't want any shift okay so now you can see that the connection is proper now after performing the inverse DFT we can connect this back over here using a vector to stream so you can have a vector to stream block and you connect the vector to stream block over here double click the vector to stream set the number of items as FFT size and your set now the stream to vector should not be for should be FFT size so that we can change it whole sale now if you execute the flow graph you get a similar spectrum which makes sense because you're essentially sending very similar data but it would be useful to see how our symbols appear or how the spectrum appears if we just switch on and switch off different parts of the frequency range to do this we have we can use multiple approaches I'm just going to use an approach wherein I'm going to demultiplex the stream and then multiplex it back to take only certain parts of the subcarriers let me explain what I'm going to do I'm first going to place for QT GUI ranges so controller for command F I'll say range and I'm going to switch on and switch off each of these FFT size each of these four streams so I'll double click this I'll call this S1 I'm going to set the default value to one start at zero stop at one step one so this is like an on-off switch I'm going to create four copies of this control C control V controls and control V again and control V again I'm going to call this S2 I'm going to call this S3 I'm going to call this S4 now I am going to first enable and disable these streams using these ranges so let's split this over here by deleting this and to control for command F will say stream demux a stream demux takes a stream and outputs them in parallel so that you can perform operations in parallel let's move this to make some space let's actually move this to the side we'll double click this stream demux we want FFT size number of outputs and the lengths are square bracket 1 times FFT size what this will do is this will take the stream and split it into four parallel elements now if I connect the output of my modulation here I now have the demuxed values I can then find a stream multiplexer by just searching for stream mux and just perform the inverse operation let's do a bit of neatness later let's make this neat later now this stream mux I will double click once again I'll call it square bracket 1 times FFT size number of inputs to be FFT size and connect this stream mux output here now in between these I'm going to switch these on and off using these ranges so what I will do is I will create four constant sources which act as multipliers so I'll do control F for command F I'll say multiply const okay and I'm going to just double click on this const and say this call this S1 connect this over here connect this over here and do control C control V this is the second one control C control V third one control C control V fourth one this should be S2 this would be S3 this would be S4 connect them out connect this and connect this over here now if I execute this flow graph you can now see the same spectrum but let's switch off everything first by making everything zero first you see that there is no spectrum let us now switch on only S1 now if you switch on S1 and let's make the averaging high you can see that the part of the spectrum that is being used is only near zero and it's actually occupying only about one fourth of the spectrum which makes sense now you can see the shape if I now just make the second one on you can now see a similar shape that appears however it appears at around two kilohertz which makes sense because we are splitting it we can split we're splitting essentially the spectrum into four parts the third one if it is on alone appears split it appears at the end about half of it appears near the four kilohertz mark the other half appears near the minus four kilohertz mark this is an artifact of the sampling theorem that is something which you've seen in DSP and makes sense now the next one will appear at around minus two kilohertz let's check so now if you see this center it's around minus two kilohertz therefore what this has essentially done is that you have split this particular signaling method into four parallel subcarriers now one thing to check is what happens if there are more subcarriers now an easy way to do this would be to just increase FFT size over here if you can make this let's say eight now unfortunately in case of eight you need more you know more ranges and more kind of constants to multiply let's actually go ahead and do it so I'm just going to take copies of this okay I'm just going to select all these hit control C and control V will give me the copies and just place them to the right I'm going to call this S5 S5 this SS6 this is a seven this SS8 and then I'm just going to add four more multiply constants so control C I'll do control V control V control V control V now let us connect the out four over here and make this S5 out five over here make this S6 out six over here make this S7 out seven over here and make this S8 everything checks out now we can execute our flow graph once more now executing our four flow graph let's keep only S1 on so I'm going to reduce this reduce this this this this this this increase the FFT averaging window we want none of course I think that's another thing so we can double click on the FFT yeah window is fine so with the averaging you can see that this spectrum is definitely narrower than earlier this around zero now if I look at the second one it comes up around 1 kilohertz so you're breaking 8 kilohertz into 8 parts so the second center is along 1 kilohertz the third one is at around 2 kilohertz let's check the center it's at 2 kilohertz the fourth one will be at 3 kilohertz roughly the fifth one will be split between 4 and minus 4 as you can clearly see this is again an artifact of the sampling theorem and if you remember your DSP the way you compute the DTFT it's between minus pi and pi and repeated that's why this happens and therefore you are able to see that you have effectively parallel parallelize the channels and this spectrum essentially confirms that we are able to put our data in parallel so now that we have done this we are now clear that using OFDM makes your data appear in the frequency it uses the same spectrum it doesn't have any other spectral characteristics that are altered but the data appears in the frequency domain and is split in such a way that the channel essentially is parallelized our next aim would be to confirm the equalization ease of OFDM wherein we will make sure that even in the presence of a channel we are able to use OFDM effectively to equalize using one tap equalization in this in this case to keep things simple let us perform a symbol equal to sample rate that is we'll assume there is one symbol per sample simulation we'll quickly do the same things we do by adding a random source and a constellation so what if for command F random source we'll make this 4-pite and we'll have a constellation constellation object constellation encoder connect the encoder we'll call it my const we haven't created it yet copy this call this my const and our constellation is ready we'll add a throttle now we need to perform convolution along with a channel but remember when you have a channel you need to also add a cyclic prefix that accounts for the channel let us assume that the channel will have at most three tabs so let's create a channel controller for command F we'll say variable and let's say that our channel is called H and its value is let's say 1.0 1 0.2 plus 0.3 J 0.1 minus 0.05 J this is our base band channel let us say and we are going to perform a convolution with this channel okay so now we first have to add OFDM and our cyclic prefix has to have length at least two so as you control F for command F let's bring in our stream T MUX and let's also have an FFT size variable control F for command F and sorry it's a variable we'll double click we'll call our variable FFT size let's keep it at 8 currently okay so now the lengths 1 times FFT size number of outputs FFT size we don't need stream T MUX we only stream vector I'm sorry I'll delete this so we just need controller for command F we'll say stream sorry we will see stream to vector sorry so we'll grab a stream to vector this should be number of items FFT size next we'll grab the FFT block controller for command F we'll say FFT of course we need to set the FFT size based on our variable only then the stream will be accepted we'll set this to reverse we'll set this to square bracket 1 times FFT size shift should be no FFT set now we will convert this back to a stream but demultiplex it so controller for command F we'll say vector to stream and then we'll have to set this to FFT size and then we should demultiplex this so that we can add a cyclic prefix so I'll do controller for command F we'll say stream D MUX now let's actually do one thing let's actually use the app let's actually use the arrow keys to rotate this so I'm just going to use the right arrow key to rotate this and I'm going to use the right arrow keys to rotate this this stream D MUX will have length square bracket 1 times FFT size and number of outputs will be FFT size okay so let's make this little more visible now let's actually rotate this once more okay now I need to add a cyclic prefix which means I am going to add a stream MUX that has extra places where I can add the cyclic prefix so I'm just going to grab a stream MUX I'm going to double click this and let's say my cyclic prefix length is 3 so I'm just going to say lenses square bracket 1 times FFT size plus 3 and this should be FFT size plus 3 so now I'm going to get this big stream MUX which has FFT size plus 3 length I'll use right arrow key to rotate left arrow key to rotate it now I'm going to connect the back parts directly because the cyclic prefix comes in the front once you connect the back parts you can then connect the out 7 back to in 2 out 6 back to in 1 out 5 back to in 0 this essentially has brought you the cyclic prefix why because you have the actual symbols prefixed with the last 3 this will ensure that performing the convolution does not affect you now we can bring in the channel controller for command F we'll grab the interpolating FIR filter and this of course the interpreting FIR filter also has to be rotated so left arrow left arrow twice and the tabs are H that performs the convolution and now we have the output and we will add noise controller for command F we'll say noise to grab a noise source we'll use the left arrow to rotate the noise source also the add controller for command F we'll say add rotate this also the noise source will have noise STD as its amplitude we need a range controller for command F we'll say range this range has noise STD as its standard deviation default value 0 start at 0 we'll start at 0.01 stop at say 3 and step 0.01 default value should be 0.01 and start at 0 I think this is fine now we have the noise source as well and then we have our output now we know that our output is going to definitely get affected by the channel now our next task is let's move the constellation object over here so that we get some space let's move this okay yeah now we have a better flow graph now at the receiver our first task is to remove the cyclic prefix and then perform equalization but we will show that the equalization is going to be very simple because just a single tap equalizer now again there are now two ways to remove the cyclic prefix one is to again do a stream demux and then take these take the multiple sources of FFT size plus three sources and then put three of them to the nut to another source and then get it back but we're actually just going to take a simpler approach so I'm just going to use us a key block called keep MNN controller for command F I'll say keep MNN this keep MNN I'll rotate it is an interesting block it allows you to keep only M out of N elements starting with an initial offset in our case the first three elements of every block are always going to be the cyclic prefix so what I can do is I can start with an initial offset of three and keep only FFT size out of FFT size plus three elements so if I connect this I have removed my cyclic prefix then my only remaining task is to take the FFT and then get see what I get back so I'm going to go a little bit down okay and I'm going to just do a controller for command F I'll say stream to vector I'm just going to take the stream to vector and use the right arrow to rotate it connect the stream to vector over here double click this will be FFT size then I'm going to grab an FFT block and just reverse it control C and control V now this FFT block I will double click and instead of reverse I'll say forward then again I will grab the vector to stream control C control V rotate it to the appropriate direction and then I'm now going to view these eight constellations separately on a QT GUI constellation sync so control F for command F as a QT GUI and there is a constellation sync over here and here is the thing I'm going to double click this and I'm going to say number of inputs is eight and now I'm going to demultiplex this stream and view them so I'll just copy this control C control V I'm just going to rotate this and I'm going to demultiplex and view these streams on a single constellation sync now after connecting these we are set we can run this flow graph okay we get some pattern okay of course one issue with the is that all these seem to have the same kind of color to do that you can double click on this and you can essentially just go to the configuration and change the color so first is blue second is red let's say third is green fourth is black fifth is cyan sixth is let's say magenta seventh is I think we'll say dark red and eighth will say dark blue I think we'll settle with this now if I execute the flow graph now there is a scaling issue because the FFT scales the output and we haven't really handled the scaling but let's look at only one of these by changing this interestingly you see a QPSK like constellation that is rotated now a rotation of a QPSK constellation as you're aware all you need to do is a single multiplication could to derotate let's look at the second stream aspect that also has a QPSK like constellation the third one again a rotated QPSK constellation the fourth one is also a rotated QPSK constellation so the impact of the inter-symbol interference introduced by the channel is not at all significant because you only need to do a scaling of this output in order to recover it of course as you can see the amplitude of some of these is higher or lower than the amplitude of others this is because the channel in the frequency domain exhibits frequency selectivity that causes some parts of the signal to be better than others so therefore different subcarriers have different weights but if you notice something carefully the amplitude of data zero and data one will be close the amplitude of the subcarrier two and three will be close amplitude of three and four will be close amplitude of four and five will be close but the amplitude of the first and the let's say fourth may be different first and let's say the sixth are quite different the reason is because the channel varies gracefully in the frequency domain also and this is what is manifesting if you change the channel let's say we change it to something more like 0.7 plus 0.7j and minus 0.1 let's say minus 0.4 now you have a different channel and with this different channel you will see again different characteristics let's look at the subcarriers one by one this is one second third fourth fifth sixth you can see that's very weak seventh is also weak eighth is here now if you don't believe me that this is some you know this is working very well just to make you believe it let's look at another constellation let's choose quam 16 and then just verify that things are correct we'll just set the constellation to quam 16 and the random source to go from 0 through 16 and there's lots of dots let's view only one of them as you can clearly see this is a quam 16 constellation just rotated this is another quam 16 just rotated even this is a weak quam 16 just rotated there's also a very weak quam 16 just rotated so the magic of OFDM is that the parallelization of the channels essentially results in only single tap equalization being required and this greatly simplifies the equalization almost like your transmission is pre-equalized without having to know anything about the channel so if you want to learn more about OFDM in GNU radio there are sophisticated OFDM implementations that perform allocation of your data to OFDM frames transmission reception and all those that is something you can explore yourself in this lecture we built from scratch a simulation of a an OFDM system in GNU radio of course a baseband OFDM system and we saw that even in the presence of a channel when you have a channel the channel's effect can be to an extent handled by making your bandwidth into several parallel narrow band channels using the DFT we saw that whenever you sent any constellation because of the use of OFDM and because of the conversion of the channel into several narrow band channels each sub channel or subcarrier underwent only a multiplication effectively by a complex number which is easier to equalize therefore OFDM can be used to effectively translate a wide band channel with frequency selectivity into several narrow band channels which have roughly frequency flat nature which makes it very very useful today a useful kind of standard and which is why it is used in several you know useful wireless and wired standards in fact Wi-Fi LTE and several other modern wireless standards also employ OFDM to good effect thank you