 Let's quickly look at the one that we started on Monday. So we covered digital data as digital signals, so things like non-return to zero, Manchester encoding, bipolar AMI, so if you want to transmit a digital signal, they are techniques for taking the data and creating that signal. And we finished with a quick but short example on some techniques if we have digital data, zeros and ones, but want to send an analog signal. And we use this concept called shift key. With an analog signal, if you think of some combination of sine waves, remember our basic equation for the sine waves, we have the signal as a function of time is the amplitude times sine 2 pi f, the frequency t plus the phase. The three parameters that we can vary are the amplitude, the frequency and the phase. By changing those parameters, we change the shape of our signal. With the shift keying techniques with digital data analog signals, we change those values to represent different sequences of bits. The quick examples we saw, okay, we can change the amplitude. In this example, amplitude of zero, amplitude of say plus one, representing bits zero and one respectively, or change the frequency. So we get a different frequency or slightly different frequency of our resulting signal depending upon the bits we're trying to send or change the phase. And we can combine them. Whereas we can create a signal that is from changing, say, two of those components. Changing the amplitude and the frequency, or changing the amplitude and phase is a common one. Here's an example. What's the data? If this shows the signal, let's say you receive, so that you receive a signal, an analog signal. The vertical dash lines show the duration of each signal element, which represents one set of bits. And down the bottom here, I show the encoding for this example, that this sine wave, a simple sine wave with a low amplitude, bit zero, high amplitude, bit one. And let's put some numbers to this. Let's say the duration between the vertical lines is two milliseconds, just to put some numbers to this example. So between here and here is two milliseconds. First, what is the sequence of bits that you received? Zero, zero, one, zero. Okay, easy one. You just see that when the amplitude is low, bit zero, when it's high, bit one. So this is amplitude shift keying. We shift the amplitude of our signal to represent the different bits. We call genuinely this, the signal over this period a signal element. It's one element to represent our bits, so this is one signal element, this is another signal element. The signalling rate is the number of signal elements we send per second. What's the signalling rate in this example? It's the signalling rate, where the time period between the dashed vertical lines is two milliseconds. This diagram is on the website, if you don't want to draw it, it's not a complex one. It's just another example from what you see in the lecture notes. Signalling rate, anyone? Five hundred, yeah right, what is the units? Let's call it, let's start simple and say, okay, if this is one signal element, let's say there's five hundred signal elements per second. We'll talk about bits in a moment. Because there's one signal element every two milliseconds, so five hundred in one second. Not a good unit, but signal elements per second. What's our data rate in this case? How many bits per second? It's the same number, five hundred bits per second. Because one signal element, which takes two milliseconds to transmit, corresponds to one bit. So they're identical in that case. What's the frequency of this signal? Of the sine wave. You have to, from looking at the signal, can you determine the frequency? What is it? Two kilohertz. No. No. What's frequency? Frequency is the number of cycles per second. So think of our sine wave, well this is from zero, this is one cycle. How many per second? Five hundred, five hundred cycles per second. Because remember this period is two milliseconds, one cycle in two milliseconds, in one second there'll be five hundred cycles. That's five hundred hertz in this case. This two milliseconds is just an example. The signals don't have to be this value, there can be any value. Okay, this one's easy, amplitude shift keying, where we create an analog signal to represent our digital data, and that was the data that corresponds to it. This scheme was defined, so needed to be known in advance by the receiver to be able to decode and get the data back. Here's another scheme, and I'm defining it as, when we want to transmit the bit zero zero, we send this sine wave, let's say, let's give it a number, zero zero, we'll send a sine wave with an amplitude of, if we compare it to the lower two, we'll see that it's lower, these two will be higher, so let's give it a number, say an amplitude of one, and a frequency if we compare it to the right two, the frequency of this will be higher than these two. We see this is slower, it's a longer period here, this is faster, so let's say double the frequency. Let's give it a number of, say, one thousand hertz. When I want to transmit the bit zero zero, I'll generate a sine wave with an amplitude of one and a frequency of one thousand hertz, and zero one, same amplitude, but lower frequency, one zero, higher amplitude, let's say double, two, and a frequency of one thousand hertz, and one one, amplitude of two, frequency of five hundred hertz. So that's my definition of this encoding scheme. We're combining both amplitude shift keying and frequency shift keying. What's the data? If you receive this top signal, what data have you received? Quickly work it out. Where the dashed lines, again the vertical dashed lines, the space between them represents two milliseconds, the same as in the previous example, so two milliseconds, two milliseconds, and so on. What's the first bit? Zero. And in fact, now we look at pairs of bits. That is, a signal element over two milliseconds, so think of this as one signal element represents two bits. In this case, the signal element in the first instance is a low amplitude. We can measure it, say an amplitude of one, and a frequency if we measured, if this is two milliseconds of, we'll find it's one thousand hertz, because there are two repetitions of our sine wave within two milliseconds, meaning one repetition in one millisecond, one thousand hertz frequency, which corresponds to, where do we get to, amplitude of one, frequency of one thousand. This signal element represents the bits zero zero. And then we do the same for the rest. The second one, we have a high frequency, high amplitude, corresponds to one zero. Third signal element, same as the first, in fact, zero zero. Then we have a low frequency, high amplitude, one one, and so on. It turns out it's the same data as the previous example. So an alternative approach of combining different shift keying techniques. What's our signalling rate in this case? How many signal elements per second? It hasn't changed, because I've defined, this is two milliseconds for this example. This corresponds to one signal element. So the signalling rate is the same as the previous one, it's still five hundred. What's the data rate? We see that each signal element now represents two bits. So five hundred signal elements per second corresponds to one thousand bits per second. We've doubled the data rate in this case. By using a different encoding scheme, we've increased our data rate. And you've seen this before. When we did the Nyquist capacity, if you remember the equation, it was two times B log base two of M. M was the number of levels, we said. Well, in this case, M is four, we have four different levels. Not levels in terms of amplitude, but four different types of signal elements. So by increasing the number of levels, M in the Nyquist capacity equation, we can potentially increase the data rate. So we've done that in this case, going from two levels to four, doubling the data rate. And we can go more levels, eight, sixteen, usually a power of two, because we map it to bits, to zero, one, binary. What's the problem of increasing the number of levels? So we get a higher data rate, which is a good thing. What's the problem? It's more complex. That is, the transmitter, the circuitry that generates the signal must generate a more complex signal, so more variations. So there's a higher cost involved there. And at the receiver, there's more chance of errors, because as you increase the number of levels, there's a smaller difference between each level. It may not be so easy to see in this example, but if we had four different amplitudes, as opposed to just two amplitudes, the difference between each level would be much smaller, and the chance of the receiver making a mistake and interpreting that level to be the wrong one is higher, especially in the presence of noise. So increasing the number of levels in theory increases our data rate, but in practice there are limitations, as we have noise, that the more levels it becomes harder to receive error free. Any questions on how to get the data out of this signal? We just look at the mapping from bits to signal element. Database systems won't help, SQL won't solve this problem. Focus on that after this lecture. Go sit in the cafeteria and do your database homework. If you feel like it, that's okay. Let's go back to our lecture notes. So these were examples of the simple schemes where we just have two levels, either two amplitudes or two frequencies or two phases. And when we have two, the common name is binary frequency shift keying, B meaning binary because of two different values, binary phase shift keying. So these are shift keying techniques. Amplitude phase frequency shift keying, where we take some analog signal and vary either amplitude phase or frequency depending upon the bits. And we can combine the techniques together as we saw in our example. Where are they used? In practice, it turns out amplitude shift keying is the least efficient of them in terms of utilizing the bandwidth. So used when we need a small data rate, old voice systems, or we have a lot of bandwidth, optical fiber, because it's quite simple. Frequency shift keying commonly used in wireless, some radio systems, high frequency radio systems, some coaxial cable, cable TV systems. And instead of just using two frequencies, it's generalized to allow M frequencies. So 2, 4, 8, 16, and so on. The larger the M, the larger the number of frequencies, the better the data rate, but the worse the error rate, more errors. So there's a trade-off there. Phase shift keying used in wireless systems as well. On the next slide there's some more examples. A common one is to combine phase shift keying with amplitude shift keying. And it's called quadrature amplitude modulation, QAM, QAM. Used in many wireless systems and in ADSL, for example, so your home internet. So not just for wireless systems, where you have, for example, 256 QAM, where you have 256 different levels, as opposed to the simple cases of ours of two or four levels. The more levels, the higher the potential data rate, but the more complex and the higher the error rate. DPSK will not cover. Just quit again some more examples. Mobile phones, Wi-Fi, cable modems use PSK, phase shift keying and quadrature amplitude modulation. There's some wireless systems, radio systems, frequency shift keying, optical fiber, RFID, talking between very small sensors. It may use amplitude shift keying. Just some examples. So each are used in practice. When we want to send our digital data, but as an analog signal, we use a shift keying technique. So we've covered sending digital data as either digital signals or analog signals. Now what if we have analog data, some continuously varying data, audio or video, for example. So some sensor data, not in binary. Let's skip through to the last one, because it's the quickest, and then we'll go through the third one. Let's go to the case of if we have analog data and are going to send it as analog signals, what techniques do we have available? Analog signal techniques that you know about. In the same case as before, we can vary three parameters of our analog signal. Amplitude, frequency or phase. So what we do is we take our analog data in this diagram. The middle line is an example of analog data, a very simple sine wave. Of course, if it was, say, me talking, it would be some variations over time. But this is our analog data in the middle. Then we take another signal called a carrier signal of some defined frequency. And the output signal that we produce, we take the carrier signal and modify it based upon the input data. In this case, we modify the carrier signal by changing its amplitude. And you can see the pattern here. When our input data is high or a positive level, we have a high amplitude of our carrier. And when it's negative, we have a low amplitude of our carrier. And you can see the shape here following the data. This is called amplitude modulation. We modulate our carrier or our data onto our carrier signal by changing the amplitude of the carrier. AM radio. So in AM radio, the input data is someone talking or some music. The carrier signal is some signal at frequency according to the radio channel. So let's say around 900 kilohertz depending on the channel. So that's the frequency of this carrier signal. What's the frequency of voice or the frequency range of voice? Anyone remember from earlier topics? When you talk, what range of frequencies do you generate? You'll see in some of the earlier slides we covered, we said typically voice ranges from around 300 hertz to 3 kilohertz. Of course we have a bandwidth of around 3 kilohertz for voice, 3 or 4 kilohertz. Music slightly more. So if we want to transmit voice across our AM radio, the carrier frequency is around 900 kilohertz according to the radio channel. The input data is ranging from 300 to 3 kilohertz. That's this one. And we simply change the amplitude of the carrier determined by the amplitude of the input data. And we transmit this signal. And the receiver, say your car, you receive the AM radio signal, detects the amplitude of the signal. And from the amplitude generates the output, analog audio that's played on your speakers. In this case we have both an analog input and an analog output, analog data in, analog signal out. The advantage of transmitting using a carrier signal in this case as opposed to just transmitting this analog data as it is across our communication system is that we can shift the frequency from transmitting analog data in the range of 3 kilohertz to send it in the range of 900 kilohertz. And remember at different frequencies our signals have different characteristics. They propagate through obstacles differently. They travel further or over a different distance. And there may be interference from other sources at different frequencies. So with AM radio we take our analog input and shift to some AM radio channel, say 900 kilohertz, using amplitude modulation. And as you can guess we can also change the frequency or the phase to get phase modulation, FM or, sorry, frequency modulation, FM or phase modulation, PM, which is not so common and you'll see in a moment why. An example of phase modulation, take some input carrier signal, take the input data and modify the phase of the carrier depending upon the input data. And for example it's hard to notice here but we see it going down here and we see that in fact the frequency of this signal changing. You'll see that phase modulation produces a similar result to frequency modulation. Again, take our carrier signal, input data and vary the frequency of our output signal. We see the pattern. When our input data has a high amplitude we have a low frequency output signal and in this case a negative amplitude we have a high frequency output signal. So frequency modulation and amplitude modulation are the main ones in use, AM and FM radio for example. And that's all we want to say about those techniques. They're quite simple. We have no more examples. We of course know plenty of places where they're used. Any questions before we move back to the third technique, the hardest one? So going backwards, we've now talked about analog data using analog signals. What if we want analog data to be transmitted as a digital signal? We have some audio for example but we want to send some digital signal, some pulses. So what can we do? We can take the analog data and convert it to digital data. And once we have digital data, zeros and ones, we can use one of our previous schemes like non-return to zero to transmit that digital data as a digital signal. So that's common. So we take our analog data but convert it to digital and once we have that we send some voltage pulses using a different encoding scheme. That's one approach. In fact in some cases what we do is we take our analog data and instead of sending directly as an analog signal like we saw with AM and FM radio, we take the analog data and convert it to digital data, zeros and ones and then use one of the shift keying techniques to send that digital data as an analog signal. So that's also common. For example digital radio. The original input and I don't think it's common in Thailand but in some countries you can receive digital radio. So how that works is that the original data is analog, the music, the voice. It's converted into digital data, zeros and ones. And then those zeros and ones, the digital data is transmitted using one of these techniques. So normally as a wireless signal using an analog signal like phase shift keying or amplitude shift keying or frequency shift keying. The important thing from our perspective is that we need to convert that analog data into digital data and that's what we'll cover in this part. How do we take that analog data and create digital data? How do we digitize that data? And of course it's not just used in communication systems. Think of all the music files you listen to, or the music that you listen to, mp3 files. What is an mp3 file? Well it's some digital representation of analog data. The analog data is the audio but it's saved on your computer as a sequence of bits. So one thing that the mp3 codec does is converts the analog data into digital data. And we've mentioned the terminology on Monday. A codec is something that encodes and decodes into digital. So it converts the analog to digital data and then a decoder recovers the digital data from the analog data. Sorry, that's wrong. That was the analog data from the digital data. We're going to look at one technique. The slides have two techniques but we'll go through the first one only. Pulse code modulation. A very common technique, a standard technique for taking analog data and producing a sequence of bits. PCM. There's a few slides here that explain it but there's also I hope in your lecture notes a few slides later another example. If you go forward a bit, if you go to the end of the amplitude and frequency modulation you'll see a pulse code modulation example. We'll go through that first. You've got this in your handouts, pulse code modulation example. So our goal is to take some analog data and I've drawn this sort of random looking line to represent our analog data to take this and produce some binary representation of it, a sequence of bits. So what we're going to do is take measurements of the magnitude of this data at regular periods and convert those measured values into a binary value. So what we'll do is let's consider the minimum amplitude and the maximum amplitude of our input analog data. And so let's say it goes from here and the maximum is this value because this is just a small portion of our input that may go longer and look at it as over time. So I've given some time scale here. So this is 0 to 18 milliseconds so we can do some calculations. And we divide the range of the amplitude into different levels. In this example I'm going to divide it into eight different levels. So I take from the minimum 0 up to the maximum here and divide it into eight even levels. So the first level in between in this range, the second, the third, the fourth and the eighth at the top, eight levels in. And you'll see the labelling I've used here doesn't correspond to the level but will correspond to the value that we get when we take a sample in a moment. So we divide our space evenly into in this case eight levels. It doesn't have to be eight. We can see we can use a different number. And then what we do is we take measurements of our input analog data at a regular period. We take samples of the data. So we'll record a sample at some point in time. And then some time later record another sample. And the time in this example between each samples, the sampling interval is four milliseconds. So for this example. So let's say we start at time zero. We record the value here. And if you looked at the absolute value, if this was zero, then the value fits in this range. The sample value fits in this range. It's here, which is the second level, which we map to the value one because we start at zero. In fact, so we can say level zero, level one. And then we map that decimal value one into a binary value. And the length of the binary value should be long enough to be able to represent any of the eight levels in this case. Since we have eight levels with the values from zero up to seven, to map any of those decimal values into a binary value, we need three bits. Because with three bits, we can represent the values zero to seven. So the value one in decimal corresponds to the three bits, zero, zero, one. So for the first sample, at time zero, this level, the level one, sorry, binary value, zero, zero, one. So this just corresponds to the level in binary. And in fact, this is our digital data. This is the output of this scheme. Our scheme take the analog data and produce digital data as output. And then with a sampling interval of four milliseconds, at time four, we take another sample. We record the magnitude of the input. It falls within this range, which corresponds to level six in decimal, which corresponds to one, one, zero in binary. And that's our next output bits. And we just do that every four milliseconds. What's the next three bits? We take a sample at time eight, falls in the range for level three, we get zero, one, one as an output. Another sample at time 12, zero, zero, one. And at time 16, zero, one, zero, level two. So this is pulse code modulation. We'll come back and define the terms later, but we simply see that we take the input analog data, take regular samples, where each sampled value mapped to a binary value. So the two things we needed to define is how many levels, how do we divide the minimum to the maximum amplitude, in this case, into eight levels? And how often do we sample? So we take our input analog data, we've produced a sequence of bits. We can now transmit those bits across our communications link. For example, using non-return to zero or any other encoding technique. The receiver should receive those bits, and then the receiver has the job of reconstructing the analog data. It takes those bits and tries to produce the original analog data. It's captured here where we have an input data, the transmitter that includes a codec or a coder that converts that into binary. So here's our sequence of binary that we generated. That binary information is sent across our link using whatever technique we choose, a non-return to zero, Manchester encoding, or even a shift keying technique. When the receiver receives that, those sequence of bits, it then takes that and tries to reproduce the original analog. And I've drawn it as this step diagram here. Let's see how that comes about in a moment. First, before we look at the output, how much data was sent, and at what rate does it have to be sent? In our example, we said we take one sample every four milliseconds. And there were three bits for every sample. So three bits were generated every four milliseconds, which corresponds to 750 bits per second. So with this technique, we're producing 750 bits per second to represent that analog data. If we want the receiver to receive, and let's say it's audio, to play back the analog data at the same speed at which it was recorded at the transmitter, we need to deliver 750 bits per second from transmitter to receiver. If we deliver slower, then the playback at the receiver will be slower. It will not be able to play back fast enough. So using this scheme, we need to be able to send at least at 750 bits per second across our link. So we say that that is the data rate required to send this data. This confuses people in that when we talk about data rate, we've always said that higher data rate is better. But this is in fact the data rate required to send the analog data. We'd like a small data rate required to send this analog data to make better use of our link. So our link may have a particular data rate that it supports. What is required to send this analog data? We want to use as little as possible of that link to send the analog data. We'll see when we compare some other cases shortly. So in this case one, we require 750 bits per second to send the analog data. This is what the receiver generates as an output. The receiver receives the bits. Every four milliseconds, it receives three bits. So what it does is produces an output that corresponds to the level indicated by those bits. So a simplest approach is to, okay, at time zero, we have the bits 001 received, produce an output at level one. And because we don't yet know what the next three bits are, let's maintain that level. We don't know if the next bits will be up or down. So just produce a constant output there. Until at time four milliseconds, we receive the next three bits, 110, level six. So let's produce an output, an analog output at level six. Then 011, level three, one, and two. So this is the analog data reconstructed at the receiver. Is it the same? Is it the same as the original analog data? Is it the same? Is it the same? Simple question first. No, of course not. The original analog data shown here is this blue line. This is at the transmitter. Let's say it represents audio, someone talking or some music. So the blue line represents some audio at the transmitter. It was converted to bits, those bits were sent. The receiver receives those bits and reconstructs an analog audio output. In this case, the green line. Of course, in this case, they're not the same. It's not identical. But we can see the shape starting to match the blue line. You can see some correspondence in that, okay, we're low, we go high for a while, then it's medium level, then down, and it's stepping up a bit at the end. So the green line is the reconstruction of the blue line. But of course, it's not identical. Because we've introduced these discrete samples and the discrete set of levels here, we would like that reconstructed signal to be identical to the original. Because, for example, when you play it back on your speaker, or speakers, if it's a large difference from the original signal, it would sound different from what the person was saying at the transmitter. So it should be the same or very similar. So how do we get it closer? So we've got two parameters here. We can increase the sample rate. In this case, we sampled every four milliseconds. Well, let's try and sample every two milliseconds and see what happens. So this is case two. Same analog data, same number of levels, zero through the seven. But now the interval between each sample is two milliseconds instead of four milliseconds. So we take a value at zero, two, four, six, and so on. And these are the values you can check and see. At zero, four, eight, and 12, they're the same as before, but at two, OK, three, six, at 10, we get two, and so on. So now we have more bits to send. What's the required data rate in case two? What's the required data rate when we use this case? How many bits per second are we sending? So every two milliseconds here, how many bits per second? 1,500 bits per second. You can do the calculation because there's three bits every two milliseconds. So two milliseconds, there are 500 sample intervals in one second. Three bits per sample is 1,500 bits per second. So using this scheme, we generate 1,500 bits every second. In the previous one, we had 750 bits every second. Which one's better from that perspective, the bits generated? The lower one is better, because we're talking about data rate required. The data rate required to send this information from A to B. We want to use as little as possible. It's like if we talk about bandwidth as well. What's the bandwidth required to send this information? We want to use as little as possible. In the previous case, we required 750 bits per second to send the analog data. Using this approach, we require 1,500 bits per second, which is worse, because we need to send faster to get the same information from A to B. The blue line hasn't changed. The analog data hasn't changed. It's the same information. We construct that 1,500 bits per second, and they're sent. And the receiver receives the bits, and then reconstructs the analog data. Using the same approach, we take at time 0, level 1, then at time 2, level 3, 6, 6, 4, 2, and so on. And this is the reconstructed analog data at the receiver. Is it the same as the original analog data? Well, no, it's not. Is it better than the previous one? Well, we'll see. It's slightly better. Better in terms it's closer. I've got a picture later. We'll see. So in case 2, we reduce the sampling interval from 4 milliseconds to 2 milliseconds. Or we can say we increase the sampling rate. In the first case, the rate was 1 every 4 milliseconds, or 250 per second. In this case, it's 500 samples per second. The other thing we can do is change the number of levels we have available. This case 3, we use the 2 millisecond sampling interval but move from 8 levels to 16 levels. So I divide the space from the minimum 0 up to the maximum instead of into 8 different levels, into 16 different levels. So the first sample at time 0 corresponds to this level, which is 2. But note now with 16 different levels from 0 to 15, when we map that decimal value into a binary value, we'll need 4 bits. So the value 2 here corresponds to 0, 0, 1, 0. And later we see the value, I think the highest we get to, 12 here, 1, 1, 0, 0. We cannot represent 12 in 3 bits. So for 16 possible values, we need 4 bits. And we're sampling every 2 milliseconds. What's our data rate required? It'll be 2,000 bits per second. We're sending, we're taking a sample every 2 milliseconds, which is 500 samples per second. Each sample contains 4 bits. So 500 times 4 is 2,000 bits per second, worse than the others with respect to the data rate required. We need to send more bits in the same period of time to represent that same analog data. We generate the bits, we send the bits to B, and then B, the receiver, reconstructs the signal and we get this one if we look at the levels. Again, we've got 16 levels here instead of just the 8. Not the same. This compares those three cases. Case 1, case 2, and case 3. So case 1 and case 2, so the red one, it's actually under the orange one here, the red one, where it's not red, it's the orange line. Case 1 to case 2, the difference was the sampling interval. Case 1 was every 4 milliseconds. Case 2 was every 2 milliseconds. If we try and compare them, well, hopefully you can see that which one's closer to the blue line, well, the orange one, ignoring the green one, the orange one is closer to the blue line because we see the red one is under the orange one here. It's hard to see, so they're the same here, but then the orange one is close to the blue line, whereas the red one is further away. That is, we could say that the case 2 produces a closer reproduction of the original analog input than case 1 does. That's better from the user's perspective because when we say play back the audio, it will sound closer to the original audio. What about case 3? Compare case 3 and case 2. The difference was the number of levels from 8 to 16. Well, it's hard to see much difference here. They are very similar. There's a little bit difference here. Maybe at this point you see case 3 is maybe a little bit closer to the blue line than the orange one, but it's not clear in that case. Yeah, in this case, in this specific example, with these values that we used, case 3 and case 2 are not much difference in terms of the reproduction. That is, they're not much difference from the blue one. Therefore, well, what was the advantage of case 2? With case 2, we sent 1,500 bits per second, case 3, 2,000 bits per second. So case 2 is better in that perspective because to send the same analog data, we send less bits. We require less data rate. So there's a trade-off there in terms of what data rates require to send the data and how accurate is the reproduction of the receiver. Those data rates are listed here. So the two main issues we have, when we take samples of our analog data, we want to reconstruct that original analog data at the receiver. Ideally, it should be the same, but because we're taking samples, we cannot get exactly the same, but we want to get as close as possible. So one measure of this scheme of how good it is is how accurate is the reproduction of the data at the receiver. In this case, we're just visually comparing and we saw that case 3 and 2 are about the same. They were better than case 1. Case 1 had a larger difference from the original signal. So case 2 and 3 were more accurate than case 1. But another issue is how many bits per second do we need to send to get that data from A to B? Case 1 needed 750 bits per second, cases 2 and 3 more, more than double. The smaller data rate required is better because it's the same data, that is the same analog data, we'd like to send as few bits as possible. So case 1 is better in that perspective, but so better in terms of the data rate required, but worse in terms of the accuracy. So you need to make a trade-off when you choose the scheme as to give a sufficient accuracy but small as data rate required as possible. So you now know PCM, let's go to the lectures and recap. What we're doing is taking analog data and converting it to digital data and then we can send the digital data across our link. The formal steps with pulse code modulation is that we take some continuous time signal, our analog signal, our analog data. We take samples, so at a regular interval, record samples, and then convert those samples into a discrete level and those values are then converted into binary values into a sequence of bits. This is another example, we take a sample. In this case, we measure the value and say it's 1.1, convert that value into one of our, in this case, 16 levels, level one, and then convert that decimal value into binary value. So that's the full steps involved. The two parameters that we have is how many levels? Generally two to the power of n different levels where n is the number of bits per sample and the sampling interval, the time between samples, to yes to no to here. The more levels, generally, the more levels and the more samples, the more accurate the reproduction at the receiver, the more accurate representation of our original analog data. So increasing the number of levels, increasing the sampling rate, decreasing the interval between samples is better for accuracy, but worse for data rate required. So that's the trade-off there. How many samples do we, should we use? Should we use the sampling interval of two milliseconds, four milliseconds, or what? What's a good sampling interval? Yeah, well, in this case, Nyquist again and others have done some analysis and determined that if our original input, analog input, it is sampled at intervals at a rate higher than twice the signal frequency, then that's sufficient to contain all the data. So this is a theorem that was developed and it tells us that if our input analog data, remember it's made up of sinusoid components. Sine waves. And we can determine the bandwidth, the spectrum, and the maximum frequency component of that input. If we sample at twice that maximum frequency component, then in a perfect environment, when we reconstruct, we'll get all the original data back. An example of that is that, okay, our voice, before I said from 300 hertz to three kilohertz, the frequency range of voice, well, for simplicity, let's say voice ranges from zero hertz to 4,000 hertz. When you talk, the maximum frequency is 4,000 hertz. So if we want to sample that voice and convert it into digital, the maximum frequency component is 4,000 hertz. This theorem tells us then we need to sample, well, if we sample at 8,000 samples per second, 8,000 hertz, then that is sufficient to reproduce the original data. If we sample at 9,000 samples per second, or 10 or 20,000 samples per second, there's no benefit gained in the accuracy of the reproduction. If we sample at less than 8,000, the reproduction will not be as good as if we sample at 8,000. So it tells us the ideal value for the sampling rate. And that's a common sampling rate for voice systems, 8,000 samples per second. This assumes that we have an infinite number of levels, but in practice we don't. We divide the levels into a finite value. What is a good number of levels? So this theorem tells us the good value of the sampling rate. What is a good number of levels? It depends upon what accuracy you want. In terms of voice, because most work has been done on voice for telephone systems, then it turns out that using 128 levels is good for a very accurate reproduction. So if you have some voice in analog and you want to transmit that in digital, if you sample at 8,000 samples per second, and each of those samples corresponds to one of the 128 different levels, then when you reproduce that voice at the receiver, assuming there's no errors, then the playback will be almost identical to the original voice. Very hard to distinguish for a human. If you use less levels instead of 128, 64 levels, then the playback will not be quite as good. If you use a higher sampling rate, you'll not get any more quality, because it's sufficient to use double the maximum frequency component. We may return to this theorem, the sampling theorem later, with some different examples. Let's finish this lecture today with one different example. So PCM is one encoding technique to mapping our analog data to digital data. There are others. We'll see in here there's delta modulation and many others. We're covering the very basic one. PCM is still common. It's used in CDs. So not MP3 CDs, but the original audio CDs that you buy and the encoding there, of course we have music, but it's stored in binary on the CD. And the mapping from the analog data, the music to binary, uses PCM, also called modulation. How big is a CD? Yeah, 700, 750 megabytes. If you buy a CD, then the amount of data that they can store, let's say 700 megabytes. Let's do a quick calculation. If a CD is 700 megabytes, how much music can we store on there? Anyone? 700 megabytes worth of music. How many minutes? Can anyone have not an MP3 CD, but the normal CDs? About how many minutes of music? How many songs can you fit on a CD? But when you buy an audio CD, not an MP3 CD, but an audio CD, about how many minutes are on there? 10 minutes, one hour, 10 hours? About one hour? Let's work it out and find out exactly if we have 700 megabytes. Because audio CDs use PCM, they use pulse code modulation. And if you check the details, the two parameters of pulse code modulation and the sampling rate and the number of levels. And audio CDs use PCM and I've checked the details. They use a sampling rate of 44,100 hertz. So you can look that up for the details of an audio CD. Why this frequency? Well, music, although voice ranges from, say, 0 to 4,000 hertz, music has a larger range of frequencies. Usually 10,000, maybe 15,000 hertz for music is the maximum component. So let's say it's about 20,000. The maximum frequency component of music is 20,000 hertz. Then the sampling rate should be double the maximum frequency component. And that's how they come up with this 44,100 hertz. Assuming the maximum's around 20,000. There's some details about the 44,000. But if the maximum's around 20,000, then with a sampling rate should be double that at 40,000 hertz. The specification says 44,100 hertz to be precise. So that's the rate at which the music is sampled. 44,100 times per second. And each sample with CDs mapped to a 16-bit value. In our examples, we saw we produced three-bit values, four-bit values, with audio CDs, 16 bits. How many levels? Two to the power of 16 levels, 65,000 levels. So in our example, we used eight levels and 16 levels. In CDs, there's about 65,000 levels. So we divide the space into many different levels and map each sample to one of those levels. Okay, so if we take 44,100 samples per second, each sample is 16 bits, and I'll do it, I need it in my calculator, how many bits per second? If we need to store this music in binary, how many bits per second do we need to store? Well, let's get a calculator and calculate. We have 16 bits every sample, and in every second, we have 44,100 samples. So in every second, we produce around 705,000 bits in one second. Let's convert that to bytes. About 88,000 bytes are produced every one second of audio. Yeah, let's go back and see, okay, our CD stores 700 megabytes, 700 million bytes. We're saying that in one second, using PCM, using PCM, we produce 88,000 bytes. So how many seconds worth of audio can we store? Well, if we have 700 million, 700 million bytes in total, one second takes up 88,000 bytes. How many seconds? There's the value of about 8,000 seconds of music. How many minutes is that? I'll divide by 60 to convert seconds to minutes. 132 minutes of music. More than two hours. Someone told me one hour of music. What's gone wrong with my calculation? I think CDs don't hold two hours of music. One thing we've missed. CDs, the music is recorded in stereo. There's a left channel and a right channel. So all of this PCM encoding is performed on the left audio channel, and then again on the right audio channel, which means we need to store, we need to perform this for two channels, two times, which means we divide this by two. If we had mono audio, we could store 132 minutes, but with stereo audio, which is what CDs use, we can store 66 minutes of audio on that CD. And that's closer to the one hour that we typically are aware of with audio CDs. So audio CDs use pulse code modulation to store that data. And it's stored in stereo. Let's, I'll just write down what we did. So we got, we have our 44,100 samples per second. Each sample 16 bits. So that gives us the number of bits per second. We have, we can convert that to bytes. So divide by two, and we get our bytes per second. And that was about 88,000 bytes per second. So we need 88,000 bytes for every one second of music, but we have 700 megabytes, so 700 million bytes divided by 88,000 and gave us the value of whatever it was around 8,000 seconds, 7,000 something, divide that by 60 and we get minutes. And we got 132 minutes. So we had the number of seconds, we just convert that to minutes divided by 60. But then we said, well, we need stereo. We need to record not 88,000 bytes per second, but 88,000 for the left channel, 88,000 for the right channel. So double that. So if you double that, you in fact halve this to our 66 minutes. So the conversion there was we just, we determined the bits per second and then therefore the bytes per second needed, 88,000. And since we know the number of bytes we have, we can find out how many seconds we can record. Bites divided by bytes per second gives us the number of seconds, around 8,000 seconds. That a question back there, is it a yawn, hands up? Check the calculations, you can do them yourself, okay? You should be able to solve that. Given this information, given the sampling rate and the number of bits per sample and the amount of data we have available, you can work out how many minutes of music we can store. And one other quick example, similar parameters. Here's some audio recorded from one of our lectures, one minute of audio. And it's saved in a WAV file. You know, the format WAV, well WAV format typically stores PCM encoded audio. There's no compression. In this case, one minute. There's one minute of audio there. How big is the file when we store on my hard disk with 60 seconds of audio and the sampling rate is the same as before. Same as the CD. And we had 16 bit samples. So 42,000, 42 million bits per second with 60 seconds. So 60 seconds times by the number of bits per sample and the sampling rate. And in this case, it's stored in mono. There's not two channels. Convert to bytes, 5 megabytes, 5.29 megabytes to store this WAV file. If we perform the calculation, how big is the file on my hard disk? 5.29 megabytes, okay? Because WAV format doesn't include any compression. It's just a pure PCM mono audio. And there's 82 bytes of header in this case. The rest is the data. MP3, other codecs do the same things, but they also involve compression to reduce the size of the binary's information. So we're not gonna talk about compression, but there are many other codecs that take our analog input, convert it to digital, so either we can send it across the network or we can save it on a hard disk in a digital format. So there are different codecs. Some include compression, WAV and PCM are very basic and there's no compression involved. Let's stop there.