 Hello, welcome to this lecture on digital communication using GNU radio. We have been looking at aspects connected to digital modulation, in particular how discrete symbols can be mapped to waveforms. In this lecture, we will be performing a simulation of digital communication or digital messages and mapping them to waveforms using GNU radio wherein we will generate a random set of symbols that correspond to different amplitudes. Convert it to waveforms, a baseband waveform, also take it to the carrier frequency and get a passband waveform and finally, we will also get the passband waveform to, we will use the passband waveform to return to the baseband and recover our symbols. In this particular lecture, we are going to begin with amplitude shift keying or pulse amplitude modulation wherein the amplitude of the signal is used to convey information. Modulation in digital communication involves mapping messages such as bits to waveforms. The key idea is for us to select a waveform based on the input message and transmit it and the receiver will match these waveforms across its available list and figure out the most likely waveform that was sent and map it back to the transmit message. That is what we call demodulation. Right now, our focus will be on mapping these bits or symbols to waveforms. The constraints involved in the design of these modulation waveforms are bandwidth, power, hardware and various other aspects that the design may offer. The question is how can we most efficiently design reliable high-speed modulation schemes within the constraints that are given to us by the system? In this lecture, we will be looking at some of the most common modulation schemes and discuss how we can put them together by looking at them in GNU radio as well. Some of the most common modulation waveforms are ASC which is amplitude shift keying, PSK which is phase shift keying and FSK which is frequency shift keying. In each of these, some aspects of the waveform is modified in order to convey some message. At the simplest level, if your aim is to transmit bits which are zeros or ones, one way to achieve this would be to send a signal which is zero for the duration of the symbol, to send the bit zero and raise it to a 1 volt level to send the one message. In this case, if we assume that the duration of a bit is let us say 1 second, then this is held at zero for 1 second, 1 at 1 second, 1 at 1 second, 0 at 1 second and so on in order to send an amplitude shift keying waveform. The next waveform is a frequency shift keying waveform wherein to send zero for the duration of the zero symbol, a partial sinusoid is sent. Subsequently, to send one, a sinusoid of a different frequency is sent. Again, the sinusoid of a different frequency is sent to indicate one and it falls back to the slower frequency sinusoid to send zero. In this way, by modifying the frequency of the sinusoid within the duration of a symbol, we are able to send bits by modifying the frequency. Finally, this is a phase shift keying waveform. In this case, you can see that there is a sinusoid which has two cycles which is used to send zero. There is another sinusoid which has two cycles to send the one except that it starts with a pie phase shift. In other words, the first waveform can be considered as a sign. The second waveform looks like a minus sign. The minus sign continues to give you another one and then you again have to send a zero so you send the positive sinusoid. In this way, by appropriately adjusting the phase of the sinusoid during the duration of a symbol, you can use phase shift keying to convey information. One simplifying assumption that we will make is that we will look at linear modulation if we consider messages as bk and our baseband pulse as gtx of t and the symbol rate as one symbol for every t seconds. We have the transmit waveform s of t is summation over k bk times gtx of t minus kt. Some things to note are that waveforms generally are translated to passband before transmission. This is something that we have seen in the context of the complex baseband equivalent. The challenge for us is to design gtx of t in order to honor the bandwidth and power constraint. An important note is that in this simplifying assumption, we are fixing gtx but a more general modulation scheme may involve gtx also depending on k. We should now keep in mind what are constellations and their connection to waveforms. It is convenient to map messages, it could be bits like 0 and 1 or it could be a set of 10 messages but these have to be mapped to something more convenient wherein we choose complex symbols also known as constellation due to their appearance on a two dimensional space. These constellations consist of complex symbols that are sent and have to be detected at the receiver. k is a value that is chosen appropriately from this set in order to obtain or design a transmit waveform. We will see some specific modulation formats and their waveform versions to get an idea of how these messages are effectively translated into waveforms. For all our simulations on GNU radio we will be using 1 kilo symbol per second which means that we will be sending 1000 symbols of the form bk per second and for the passband we will be taking 8 kilohertz as our carrier frequency. The first modulation scheme that we will be looking at is amplitude shift keying. Here bk is a number that is 0 among 0 1 2 up to m minus 1 or it can be an offset variant like say it can be this can be minus 3 this can be minus 1 this can be 1 this can be 3. If you want a bit picture this can correspond to 0 0 this can connect point to 0 1 this can correspond to 1 1 this can correspond to 1 0 meaning that you are able to send 2 bits per symbol. In this case your sk of t corresponding to a single symbol is just bk times psi 1 of t which corresponds to one dimensional signal. Let us now look at how this appears on GNU radio. We will begin by first introducing a couple of new blocks that will come in handy for signal generation especially random signal generation. The first block that we will consider is the random source we will use our control f or command f and type random to obtain a random source and put it on our flow graph. Since we want to generate an amplitude shift keyed signal consisting of 4 possible values we will modify the random source by double clicking it and choosing the maximum to be 4 and let us also make it 1024 symbols and set repeat to yes. Next we will introduce the next block called chunks to symbols so control f or command f chunks to symbols chunks to symbols can be thought of like a lookup table if this random source generates messages then this chunks to symbols generates symbols which also correspond to constellation points. Let us double click the chunks to symbols set the dimension to 1 and define our 4 symbols in this case I am going to use 0 1 2 3 which I have written as a python list by putting a square bracket and putting the number 0 2 3 separated by commas. The next thing I am going to do is to introduce a throttle control f or command f throttle get our throttle here and finally I am going to introduce a time sink the time sink will allow us to visualize what this random source gives us control f or command f press time qtgi time sink let us now connect our blocks and execute this flow graph upon executing this flow graph you will see that you get these numbers or values let us middle click and choose the control panel and say auto scale let us also middle click and choose stem plot and then zoom into a particular region you can see that the values are either 0 1 2 or 3 we get two signals the reason for this is our choice of complex symbols let us address that first we will set the chunks to symbols to have type float our throttle to have type float our time sink to have type float now we middle click control panel auto scale or we can even set the auto scale here if we say stem plot and zoom into a particular region you will see that the values are 0 1 2 or 3 and they appear in somewhat of a random fashion this is expected because we are connecting the output of a random source to the time sink the next task for us is to ensure that we generate one kilo symbol per second or in other words the symbols must be separated by a thousand micro there must be separated by one millisecond each which is how you can get a thousand symbols per second to do that we will use the simplest pulse which is the rectangular pulse to approximate a rectangular pulse we will just repeat each of these symbols for one millisecond durations time let us first increase the sampling rate for convenience we are going to make the sampling rate 64000 so I double click the sampling rate change it to 64000 then before I go to the time sink I will click this arrow hit the delete button to remove this connection I am now going to introduce an interpolating filter so controller for command f we'll type interpolate and we will get the interpolating FIR filter which I drag and place here we double click this filter we want float to float real tabs now we want this to be interpolated so that we get exactly a thousand symbols per second so before we fill this in let us do some computations when we have 64k as the sampling rate to to have this symbol repeated for one millisecond implies that we need this 64k to be divided by multiplied by one millisecond rather that corresponds to exactly 64 samples in other words let us create a variable so control f for command f and type variable drags variable we will double click this variable and we will call it interpolation factor as the id and we will set this to sample rate upon 1000 note that there are two slashes this will ensure that we have our symbols last for exactly one millisecond why because if 64000 samples correspond to one second 64000 divided by 1000 will correspond to one millisecond by doing it this way our flow chart will still continue working correctly even if we change the sample rate later therefore it is always a good idea to keep variables wherever needed we will say okay we will double click this and say interpolation factor as our interpolation and tabs currently we need to provide a list of filter coefficients that are used to fill in the gap that is introduced when you interpolate i am going to simply say square bracket one indicating that i want only a one and then nothing else during the interpolation we will say okay connect these inputs and run now you can see that you have a picture like this let us first stop and let us make it stem plot as you can see you get a few symbols this value is two this value is three this value is one let us see by how much they are separated this is at around two millisecond this is at around three millisecond this is at around four milliseconds in other words because the interpolating filter essentially says give me a one and then nothing else you have all these symbols separated exactly by one millisecond but after a single impulse there is no other signal present to address this we will ask our interpolating filter to fill in a rectangle for the full duration of one millisecond to do this easily we can either sit and write that many ones or use some python in this case i am going to use numpy function to do this we need to first import numpy so i'm going to hit control f or command f and type import gab the import module double click it and type numpy rather import numpy now over here we are going to get just use the function numpy dot ones interpolation factor this will essentially populate 64 ones that will essentially fill the duration for one millisecond let us now execute this flow graph as you can see we now have these rectangles let me first enable the auto scale by double clicking this and enable the grid enable auto scale now by executing this flow graph you are able to see the values being zero one two or three let us stop this and let us look at the duration it is very evident that this starts at six milliseconds this starts at seven milliseconds this starts at eight milliseconds and thus what we have now is our baseband waveform for amplitude shift keying with four messages zero one two and three corresponding to those symbols and this is the baseband waveform that we wanted as an exercise you can try to change the interpolating filter steps and see what happens for example rather than use in p dot ones you can use a different set of tabs to see that those steps are reproduced in this particular time sync our next task is to see how this waveform would appear once we go to pass band but before we do that we will now introduce another pair of blocks which make it convenient to visualize our flow graphs when we have multiple elements when we have to take multiple signals across the flow chart sometimes it becomes messy if you can start connecting arrows across the flow chart therefore we will introduce a couple of convenient blocks which are called virtual sources and virtual sinks let me just press ctrl f or command f and type virtual and we will first choose a virtual sink a virtual sinks input appears white it has no output this is because the virtual sink takes in a particular signal and consumes it and it can take in a signal of any type which is what the white color indicates let us double click the virtual sink and give it a stream name i'm going to call it pass band one and i'm going to connect the output of our interpolating filter to this virtual sink now if i want to get this signal somewhere else in the flow chart i need a virtual source so let's grab our virtual source put it over here as you can see the virtual source is the counterpart to the sink we just need to double click it and give it the same name which is pass band one and we now have the float detected because it is the same name as the virtual sink by connecting this further we have essentially avoided having to pull this arrow across the flow chart and thus making the layout of our flow chart much more convenient our next task will be to modulate this baseband signal to carrier frequency before that let us first introduce a variable called fc so ctrl f or command f variable drag the variable block double click it we will call it fc and we will choose it as 8000 hertz again the advantage of having these is because if you want to change one of these parameters across the flow graph it is much easier for you to change it in one place rather than having to change every block which is very cumbersome and error prone now if you recall from our complex baseband to passband conversion we have to multiply this signal by a cos and the other baseband signal by a sign but in this case we have just a single signal only the real or the i part and therefore we are just going to multiply this with a cos and that will give us our passband signal so i am going to press ctrl f for command f type signal grab a signal source i am going to double click the signal source make it float the frequency will be fc and now we are just going to multiply these so ctrl f or command f multiply grab the multiply block we double click this multiply change it to float and we connect these signals and thus this will be our passband signal and let us visualize how the passband signal looks like let us actually create a separate time sync just to visualize this so ctrl f for command f we can grab a time sync or let us just double click this time sync hit copy ctrl c or command c and ctrl v or command v and connect this time sync and if you now execute the flow graph you now see that the signal above looks very much like the signal below except that it has been modulated in fact let us actually look at this in this look at these in the same time sync as well so if you double click this time sync and set the number of inputs to two and drag it across if you now see the modulation essentially just multiplies the signal by a cause the peak value of the cosine has the same value as the rectangular portions of your amplitude shift keyed waveform therefore it is very easy to understand how the passband waveform looks like for amplitude shift keying it is just a cosine or sine which has peak amplitudes resembling that of the baseband waveform our next challenge will be to recover the baseband waveform from this passband signal temporarily let me remove this and let me now work on how we can get back the baseband signal so if you remember the way we got back our baseband signal from the passband signal we essentially have to multiply it by a cause and a sign and get it back so let's actually make the amplitudes correct first so remember that if you now want to have the correct values you must choose root 2 over here so we'll make this 1.414 and we will copy this cosine source paste it we'll copy this cosine source paste it again now the second one we will make a sine source now if you remember how we can recover our baseband signal we will multiply the modulated waveform with each of these signal sources and then place a low pass filter that cuts off frequencies around 2 fc so let us first get multipliers i will just click this multiplier and hit control c or command c and command v control v command v and again repeat command v or control v take this signal connect it over here take the source take the signal connect it over here take the sine source i now need a pair of low pass filters so i'm going to hit control f for command f and say low pass filter drag drop the low pass filter double click it change it to float to float decimating and we will set the cutoff frequency to be it should cutoff frequencies about to or near to fc but we will just make the cutoff frequency fc and we will make the transition width about a thousand hertz we'll copy this filter control c command c control v or command v paste it and send these signals through the respective filters and this will be our baseband signal if you now convert this to a complex waveform what we will do is we will actually directly just view this on our original time sync let me double click this time sync make it have three inputs connect this over here connect this over here and visualize now you can see that there is some resemblance over here to the original signal signal let me first stop this you can see that there is a blue oops let me first enable this auto scale again you can see that there is a blue followed by a red a blue followed by a red and this red looks like the blue but there are a couple of things that you must observe the first is that the red has this ringing the reason for this is that we chose a rectangular waveform as our gtx and as you know rectangular waveform is not band limited and therefore by passing it through the low pass filter you end up getting these ringing effects this will not happen if you choose a more band limited pulse such as the race cosine or sync or any other waveform that we will see in subsequent lectures next there is a green signal that green signal corresponds to the q part and as you recall we are modulating only a single signal in the baseband as opposed to a single rather a single real signal in the baseband as opposed to two real signals or a complex signal therefore we can safely ignore the other signal now to verify whether these two are indeed the same we will now try to match these the cause of this delay is because we are using the filters over here these filters because they are practical filters will inevitably possess some delay let us try to match the waveforms by adding a delay block to the original signal and then seeing how we can match the delay to see whether the signals are indeed the same so i am going to do do control f or command f and get a range we will get a qtui range widget we will double click it set the type to integer set the id to delay set the default value to zero it started zero stop at let's say 1000 we will next grab a delay block so control f or command f the delay block we will double click this delay block make it float because we are going to deal with float signals and the delay will be the variable delay it's from the qtui range now rather than connect this output directly we will connect it through this delay and now let us run our example as you can see we have a range now let's actually set it to something over here as we move it you can see that the blue one gets closer so if we move it over here roughly at around 75 samples we see that we are almost matching the output of the output after converting the passband signal down and it's a reasonable match and obviously this ringing effect is the Gibbs phenomenon because we have essentially filtered what is fundamentally a band unlimited signal in the form of the rect therefore as you can see we have converted an amplitude shift keyed waveform to passband and recovered it at the baseband as well as a final step in order to view more of the waveform let us just adjust our GUI time sinks to show more points let's say 16384 double click this one over here say 16384 and now let us visualize and let's again set this delay to 75 and you can clearly see a very nice match and over here you can clearly see that the waveforms look in this way if you really want you can also overlay this waveform in the same you will actually get the modulated signal as well I leave that as an exercise but with this we have essentially built a simple approach to making a flow graph wherein an amplitude shift keyed waveform can be obtained from random source converted to passband then obtained back in the baseband in this particular case remember that we did not have an imaginary signal in the passband therefore this will yield zero the other part yields the original signal and because you chose GTX as a rectangular signal you got these ringing effects in this lecture we have carefully designed a digital communication system wherein discrete set of values are mapped to waveforms we have seen how the waveforms look in the baseband when using a rectangular pulse and how they go to passband as well and from the passband when we recover we see that using the rectangular waveform allows us to recover the data but there are some minor issues like those ringing effects thanks to the band unlimited nature of the rectangular waveform in the next few lectures we will be continuing this exploration and we will be seeing how not only amplitude but the phase variations in the baseband signal can be used to convey information