 In the previous lecture, we have seen how you can alter the amplitude of a signal in order to convey a discrete set of messages. In this lecture, we will be using an approach wherein the information that you want to convey is embedded in the phase of the waveform. That is, we take a set of messages and generate different waveforms for each message and these waveforms differ in the phase. This approach is called phase shift keying as you have seen in the lecture. This approach is very distinct from the amplitude variation that you have seen in the previous lecture. Again, we will generate a PSK modulated digital signal. Look at how it can be transmitted to pass band, recover it again at the base band and recover the original transmitted symbols when using a rectangular pulse. The next digital modulation approach that we will consider is phase shift keying. Here the symbols phase conveys information and the different values of phases correspond to different symbols. For example, if we define BK as being one of e power j 2 pi k upon n where k takes values 0, 1, 2 or a value up to n minus 1, then there are n possible phase values and each of these corresponds to a different symbol. This particular approach can convey one of n different symbols. Let us now take the example of 8 PSK. Let us now take the example of 8 PSK. Here one of 8 possible phase values equally spaced give you the symbol. For example, e power j 2 pi times 0 upon 8 is this particular symbol, e power j 2 pi times 1 upon 8 is this particular symbol, e power j 2 pi times 2 upon 8 is this symbol and so on. As you can see if you ascribe bits to each of these 0 0 0 0 0 1 0 1 1 and so on, then one of three possible bits are conveyed by these symbols. In this case, as we mentioned only the phase and not the amplitude conveys the information therefore just by checking the phase of the received symbol you should be able to recover your bits. In terms of our signals perspective, SK of t can be treated as BK times psi 1 of t where psi 1 is the waveform that you use for signaling, for example it can be a rectangular pulse or a sink or so on and it is a one dimensional signal because the same signal is being scaled by just a unit magnitude and phase varying complex number. Let us now explore how we can put together a PSK simulation on GNU radio. We will be keeping with the same parameters that we have been using that is a carrier frequency of 8 kHz and a symbol rate of 1000 symbols per second. Let us begin. Let us first set our sampling rate to 64000 as we have been using so far. Next we will first find a way to generate our random PSK symbols. Before that let us also fix the PSK size, we will use PSK 4 at the beginning but in order to have flexibility over the PSK size let us create a variable. Control F for command F and we will say VaR and we will grab the variable. We will call this variable N as we chose in our slides as well and keep it as 4. Now let us first grab a random source so that we can generate random PSK symbols. Control F or command F, random we have our random source that we will bring here. Minimum is 0, maximum we will set as N which is what we chose over here is the variable and let us make it a 1024 samples with repeats so that we can get a constant stream of random symbols. We will say ok, next we need a chunks to symbol that can map the numbers 0, 1, 2, 3 to one of the PSK symbols. So let us grab a chunks to symbols, control F for command F, CHUN and we will grab this chunks to symbols, double click the chunks to symbols, the dimension will be 1. Now for symbol table it is inconvenient for us to have to write the symbol table every time we change N. In fact, the very reason why we use these variables is for convenience in GNU radio so that the symbol tables and such other dependents can be automatically recalculated. So before we complete our chunks to symbols, let us first use the power of python. We will import numpy for our assistance. So control F for command F, we will say import, grab the import block, we will then say double click on this and type import numpy. This allows us to use the numpy functions to create our symbols very very easily. Now let us double click on our chunks to symbols. Our symbols are just E par J 2 pi K upon N where K varies from 0 through N minus 1. To get the numbers from 0 through N minus 1, we can say numpy dot A range N. This gives us the values which K can take. Now we must do J 2 pi K by N so let me just do 1 J into 2 into numpy dot pi times this upon N and this belongs within a numpy dot exp. So I will put this in brackets and I will say dot exp. So if you see what we have done, we have done numpy dot exp of J 2 pi K upon N. Let us say okay and now let us connect our random source and this chunks to symbols should be connected to a throttle. So control F for command F, we will grab our throttle. Let us then have a time sink and see what the symbols look like. So control F for command F and we will grab a QT GUI time sink and if we execute this we will see some things essentially looking like this. The values which the blue which is the real part and the red which is the imaginary part take are either plus 1 or minus 1 or 0. That is what we see over here but what is more useful is if we grab a QT GUI constellation sink, control F for command F and constellation sink. If we look at the constellation sink this will tell us the real part and imaginary part simultaneously and as you can see you have 4 possible values which correspond to e power J 2 pi 0 upon 4 e power J 2 pi 1 upon 4 which is exactly J e power J 2 pi 2 upon 4 which is minus 1 and e power J 2 pi 3 upon 4 which is minus J. So these are the 4 possible symbols that are being produced by the chunks to symbols module. This makes complete sense if because we chose NS4 we get these 4 symbols if you choose NS8 you will get one of 8 symbols. Next our goal will be to send these symbols at 1000 symbols per second. To do so let us first remove this QT GUI time sink and place an interpolating FIR filter. So let's make some space control F for command F, enter and grab this interpolating FIR filter. We will connect the throttle to this interpolating FIR filter double click this set the interpolation to we need a 1000 symbols per second therefore we must interpolate it by SAMP rate divided by 1000. So we will say SAMP rate double divide because we want integer division by 1000 and the tabs we want exactly all ones because we want to use rectangular pulse shape therefore I will just say numpy dot ones. Now if we grab a time sink control F for command F and time sink and place the time sink over here and execute this flow graph let us stop this you will see that each of these symbols begins at 9 milliseconds ends at 10 and then this begins at 13 milliseconds ends at 14. So each of these symbols essentially takes two values and these values are separated by exactly 1 millisecond to get a better idea of why these are the exact values it's very easy to check our symbols are essentially 1 j minus 1 minus j. So when you have a 1 or minus 1 then the imaginary part essentially is 0 which is why whenever the red is high you can see that the blue is 0 or red is low blue is 0 when you have j or minus j the real part is 0 which means whenever the blue is high or low the red is 0 which makes complete sense. In other words you can easily verify that the complex signal being shown here its values are exactly one of these constellation values. For example over here the blue value is 1 the red value is 0 that means this is 1 plus j is 0 which corresponds to this symbol over here the blue value is minus 1 while the red value is 0 which means it corresponds to this symbol finally over here the red value is 1 while the blue value is 0 this corresponds to j which is this symbol. So this makes complete sense our next task will be for us to take this to the carrier frequency and then get back the baseband signal. For that let us create a variable called fc so you would say control f for command f variable grab this variable double click it call it fc and value is 1000 sorry 8000 ok. Now our task is for us to modulate this particular waveform if you remember to modulate this we can multiply this by e power j 2 pi fct and take the real part we are going to take that approach but as the flow graph becomes messy we don't want to take wires across so let's use virtual syncs and sources. So I am going to use control f for command f type virtual I will grab a virtual sync and I will also place a virtual source in anticipation and double click this virtual sync call it psk baseband connected over here and double click this and call it psk baseband as you can see the color gets automatically chosen based on what you connected the next task for us is to modulate this or multiply this by e power j 2 pi fct and as we have seen in the past a simple way to get e power j 2 pi fct on Guru radio is to grab signal source control f for command f grab the signal source drag it over here and we keep it as a complex signal source ok we'll keep the frequency as fc ok amplitude can be 1 that's ok now what we will do is we will multiply these two so control f for command f we will grab the multiply we will multiply these two this is essentially x of t times e power j 2 pi fct then we need the real part so control f for command f type real and we get complex to real connect this and then we will grab a time sync control f for command f qt gi time sync and let us set the time sync to float let's add a grid let's add auto scale and connect our signal over here and execute this flow graph now you will see that we get this kind of passband signal now this passband signal looks innocuously like a cosine but there is something special let's actually stop it and zoom in a little so exactly at 10 milliseconds there is a phase change and then we have a nice sinusoid and again exactly at let's say e 12 milliseconds there is a phase change of course even at 11 there could have been there wasn't that's that could be because the phase was retained as is ok let us continue running this and we'll you know so you have these potential phase changes happening for example over here at 14 milliseconds there is a phase change and 15 milliseconds there is a phase change so the information is essentially conveyed within the phase of the waveform this phase variation essentially captures the phase variation of the baseband waveform in fact if you write out the equations you will find that the actual passband waveform you get looks like cos of 2 pi fct plus some phi of t but this phi of t essentially has this particular phase within each symbol duration so as you can see at around 3 milliseconds 4 milliseconds 5 milliseconds so every 1 millisecond there is a phase change that conveys the symbol and by observing the phase within each of these intervals you will be able to find out which waveform or which symbol is being sent during that interval now however our task is for us to get back some waveform that looks like this because this is our baseband waveform the question is how do we recover this kind of waveform from this passband signal for that we must take this passband waveform multiplied by cos 2 pi fct times root 2 multiplied by minus root 2 sin 2 pi fct and filter out the 2 fc components and then combine them to get back our symbol signal let's do that let's make some space in our flow graph by just making things a little more compact so now what we need to do is we need to take this particular symbol and we need to this signal rather and multiply it by cos 2 pi fct and minus sin 2 pi fct multiplied by root 2 so let's grab a signal source so control f for command f signal source grab a signal source place it here double click it we will have a real signal source frequency will be fc amplitude will be root 2 and then we will create a copy control c or command c control v or command v place it just below double click this we want a sign and we want a negative sign so that we can get root 2 times minus sin 2 pi fct now we will grab a pair of multipliers so control f for command f multiply will double click this we call it float now we are going to multiply the signal source with the received signal will copy this controls here command c control v or command v connect this over here connect this over here and now we will create a complex signal out of these two after taking out the two fc component remember your passband signal has an fc component these cosines and sines have an fc component so we need to take out the two fc component so let us grab the interpolating FIR filter so control f for command f in type entropy interpolating FIR filter we will double click this oh let's not use an interpolating FIR filter I am sorry let's use a low pass filter so control f for command f type low we will grab the low pass filter because we just need to specify some few components over here we will set the cutoff frequency as fc because we need to remove the two fc component and we will set a transition width of about a kilohertz we will call it float to float interpolating will copy this control c control v for paste command c command v for mac users connect these over here because we need these two parallel filters and we will then combine these two waveforms into a single complex waveform so control f for command f so we will grab the float to complex over here connect these and to visualize our symbol on the same time sink we can double click this we will set grid s autoscale s and we will set two inputs and we will connect this over here and we can run this flow graph now if you run this flow graph you can see that there is a some very minor scaling issues these scaling issues are because we did not take care of the root 2 when we constructed the modulation waveform so let us first address that so over here we will choose this as 1.414 to make sure that we have the correct energy now we have amplitudes correct but there is a certain non overlapping between 3 signal 3 and 4 and signal 1 and 2 as well as some distortion the distortion is very simple because we are using rectangular signaling this rectangular signal when passed through the low pass filter at the receiver side when coming back to baseband causes those high frequency components to get removed and therefore you have this Gibbs phenomenon like effect that is something that we will ignore but more importantly they are not aligned why the reason is because this low pass filter causes some delay it is a causal implementation and it causes some delay so one way to address this would be to just delay the output of the interpolating FR filter over here and then just see how we can align them so let's see let's add a QT range to adjust the delay so control F or command F type range QT GUI range and we will double click it and call it delay and we will type make the type as integer default value 0 stop 100 step 1 this is fine now we are going to add a delay so control F or command F type delay we'll grab the delay over here and we will set the delay to actually the delay very variable that corresponds to the range connect the output of this interpolating FR filter to the input here connect this over here now it we execute the flow graph you get this range and because the FIR filter has a group delay of roughly 75 if you make this delay 75 you will now see that there's a reasonable overlap let's actually stop this signal 1 and signal 2 correspond to the original input baseband waveform signal 3 and signal 4 are what you get when you go to passband come back to baseband after those two filtering operations let's compare signal 1 and signal 3 so if you look at signal 1 and signal 3 they have a beautiful overlap barring that little oscillatory behavior because of your filter similarly if you look at signal 1 signal 2 and signal 4 rather they also exhibit very close relationship so therefore what have you done you have gone from a passband signal back to baseband and if you overlap the signals it is very evident that the received signal and the transmit signal are almost the same the reason for the slight difference is because of the fact that the high frequency components are getting eliminated by the low pass filter if you really want to honor the frequency constraints and make these waveforms match then you must design your transmit waveform using a pulse other than a rectangular pulse so that you have a band closer to band limited signal one exercise that you can do is to observe the frequency components of these signals you will find that they are very close except that the low pass filtering causes the rectangle in your signal 3 and signal 4 to be slightly distorted as a final step let us just modify this n to 8 by double clicking and setting it to 8 and run our simulation now you can see that there are more way phase variations that are being observed and if you see our constellation it takes one of eight possible values and our waveform also seems to indicate that there are more values in the baseband why is this the case the reason is because the values which you now take are for let us say the imaginary value is plus 1 over here it is 1 upon root 2 here it is 0 minus 1 upon root 2 and minus 1 so there are five possible values so if you stop and let us look at the original waveform you can see that it takes 1 then it takes 0.707 which is 1 upon root 2 0 and then it takes you know over here it takes minus 1 minus 0.707 so as you can see more values are there and you can see different kinds of phase variations as well so if you write if you make your flow graph rather in a very generic manner you can easily simulate various other psks let us also check out psks 16 and you will see that there are 16 possible phases and you can see different kinds of phase variations in this lecture we have put together a phase shift keying or psk based system in this system we have essentially embedded the messages that you wish to transmit in the phase of the waveform and you have seen that both in the baseband waveform and in the passband waveform variations in the phase can be used to infer information in the next lecture we will be exploring different modulation formats particularly what happens when you combine phase shift keying and amplitude shift keying in which case you end up with quadrature amplitude modulation we will also explore an orthogonal modulation scheme called frequency shift keying wherein the frequency of the signal varies and is used to convey information.