 If you can remember back before the midterm, we were on the topic of signal encoding techniques where we got through three or four ways to converting data into signals. When we have either analog or digital data and can transmit either analog or digital signals then we need to map the data to signals. We've got one that we didn't cover that we'll cover today but before we go through those signal encoding techniques, just a reminder or a refresher about some aspects of analog and digital data. Just a couple of slides I want to highlight in this set. So remember data is the information we want to get from one entity to another. That's what we want to communicate. It's about data communications. And we can classify data as either analog or digital. And examples of analog data, voice, video, some sensor data. Let's say we have some sensor that records the temperature in the room or the air, what the air conditioner is doing so it can get a continuous recording of data over time. Whereas digital data takes discrete values. And the best way to think about that is something we represent in binary. So a text file, some data that record into discrete values. But we transmit signals across our transmission system and those signals represent the data. And there are two types of signals that we can talk about. Analog or digital. In fact all of our signals in the fundamental form are analog but we can think of digital signals as pulses, for example a pulse of electricity, send plus five volts for some period of time and then send minus five volts for some period of time where that can be used as it represents a digital signal. So we have continuously varying analog signals and discrete values for digital signals. Sometimes we also talk about and the signals represent the data. And the four signal encoding techniques which we're covering are how do we map data to signals. Sometimes we talk about analog and digital transmission but we will not cover that today. There are a few slides on it but let's move along in this course and get into some other aspects. This is just an example of analog data. And if you remember maybe one of the last few questions in the exam in the mid-term there was something about AM and FM radio. And one of the questions was you've got some music and you want to send using AM or FM which one's better. Something related to this picture. This picture shows the spectrum of an example form of analog data, in this case audio. So a very common example. Remember the spectrum shows on the horizontal axis the frequency and on the vertical axis the signal strength. Here it's in decibels but it's a measure of signal strength. So it's a plot of data in the frequency domain. And the two ones to focus on the first one is the solar green line which is the range of human voice speech. So an example of audio data is speech when someone's talking. And what this figure shows is green line it says that when people talk the frequencies of the audio that they generate range from around here around 100 hertz up to about here which is have to be careful this is a logarithmic scale so several kilohertz, a bit less than 10 kilohertz. So it's saying that when you talk the frequencies that you generate are in the order of 100 hertz up to maybe five or four or five kilohertz. And in fact most of the frequencies the stronger signal strength when this line is at the highest around this area. When you talk you don't generate audio at 100 kilohertz that frequency is not generated by the human voice. So if we want to transmit this analog data the human voice through a as a signal then using an analog signal which is like using AM or FM where we take analog data and transmit using an analog signal we would need a signal which has a bandwidth which is large enough to carry the human voice. So what's the bandwidth of human voice? It ranges from about 100 hertz up to this point. Again logarithmic let's say it's uh what's here what two let's say it's four kilohertz be careful a logarithmic it's very it's two three four five six seven and so on. So let's say it's four kilohertz just for example because we actually we use that number later. So the bandwidth of voice is about four kilohertz if it ranges from 100 hertz up to four kilohertz what's the difference? It's about four kilohertz four thousand hertz minus 100 hertz is 3900 let's say about four kilohertz. So the bandwidth of voice is about four kilohertz. So if we want to transmit that we would need an analog signal which also has a bandwidth of four kilohertz. And that was related to the question in the exam what was saying which one's better AM or FM well I think in the question in the exam AM had a bandwidth of 10 kilohertz and FM had a bandwidth of 20 kilohertz. Actually the exam was about music all right let's see music then music has a higher bandwidth it contains a higher range of frequencies than voice so there are higher frequencies up to maybe about 20 kilohertz and some lower frequencies for the very low frequencies in music down to tens of hertz 10 or 20 hertz. So the bandwidth of music goes from say 20 hertz up to about 20 kilohertz which is approximately a bandwidth of 20 kilohertz 20,000 minus 20 is about 20,000. So the bandwidth of a human voice is about four kilohertz the bandwidth of music which has a higher range of frequencies because our ears can can make sense of the higher frequencies than what's produced by the human voice so frequencies from different instruments. The bandwidth of music is about 20 kilohertz and I think that was the exam question if you want to send music through AM or FM if the AM radio channel has a bandwidth of 10 kilohertz and FM has a bandwidth of 20 kilohertz which one's better well FM because FM can contain all the frequencies of our data our music whereas with AM if we want to transmit 20 kilohertz of data data with a bandwidth of 20 kilohertz then if we transmit that over using a signal which has a bandwidth of just 10 kilohertz we can't send and in particular we cannot receive some of those frequencies of the music. So you would not receive all frequencies of the music if you use the lower bandwidth AM so we need a signal that is large enough to carry the bandwidth of our data in that case. We'll see this when we look at the next encoding technique so the exam question was about AM and FM analog data using analog signals but the one that's remaining is if we have analog data the same music voice other types of analog data but we want to send them as digital signals as some discrete values well what we do is in fact we just convert that analog data into digital data so we'll use this we'll refer to this data this information again when we look at the next encoding technique. The diagram also shows for example your home telephone line so the green lines of the data the home telephone line allows for signals with a bandwidth of about this range which is around three kilohertz three close to four kilohertz which is designed to carry human voice so the home fixed landline telephones were designed for people talking so the signals that can be transmitted across those telephone lines are close to what's created by human when they speak that was the idea. If you try and send music across your home telephone you try and play some cd and and play it into your telephone and hope that the other person other end receives that music they will receive the music but some of the frequencies will not be delivered to the destination because the telephone line only sends this range of frequencies all of the music in the higher frequency range or the lower frequency range would not be delivered to the destination so we need to design a system that will support the data we want to send that's all I wanted to say about oh actually there's just to remind us the the four techniques everyone knows ASCII table this is just an example of digital data if we want say we have some text some English characters some message we can convert it to bits using say an ASCII encoding or other encoding techniques just these two slides remind us the the four combinations if we have analog data and we want to send analog signals one example of that is your telephone your home telephone not your mobile phone if you still got one at home not many people have nowadays but you talk produce analog data and the signal sent from the telephone across the telephone line would also be an analog signal but if you connect your computer and you want to use home internet access then you'd use a modem your computer generates digital data which goes into the modem and the modem transmits an analog signal across the telephone line so a modem performs modulation and demodulation to convert digital into analog what were the techniques the modem used and anyone remember from how do we convert digital into analog remember shift keying amplitude shift keying frequency shift keying and phase shift keying where we we change the amplitude frequency or phase of our analog signal to represent the digital data the zeros and ones so we've covered that technique analog data is analog signals AM FM and sometimes PM phase modulation the last one digital data using digital signals which techniques and remember the acronyms the first signaling toting technique we went through NRZ non-return to zero Manchester encoding bipolar AMI those techniques took bits zeros and ones our digital data and generated a digital signal okay so the techniques used by a digital transceiver a transmitter and receiver like we described in those signaling coding techniques the last one is what we want to cover today we've got analog data like audio but we want to send a digital signal well what we actually do is we take that analog data and convert it to binary we digitize the analog data convert it into bits and then once we have the bits we can send a digital signal using NRZ L bipolar AMI or some other technique so the way to convert analog into binary we encode the analog data and at the receiver we decode so we get a coder and decoder or a codec it's the name of the component we're going to cover just one type of codec a very common type of codec for converting analog into into digital and we'll go to that now which is on our other set of slides signaling coding techniques so jump forward to signaling coding techniques and the third approach analog data transmitted using digital signals and in fact what we do is we take the analog data convert to digital data and then transmit digital signals so in general we can take the analog data convert to digital and then transmit using NRZ as a digital signal another thing that we commonly do is convert analog data into digital data and then send that data as an analog signal like phase shift keying it's common today in communication systems to treat everything as digital data even if it starts off as analog like your voice it's much easier for a computer to process the digital data so convert your analog voice into digital voice and that's what your mobile phone does when you talk on your mobile phone you're creating analog data there's a codec inside your phone that the speaker records your voice sends it to the codec and the codec converts that into binary into zeros and ones and then those bits are sent from your mobile phone to the cell phone town so this part we focus on well how do we do the conversion from analog data to digital data and it's performed using a codec converts the encoding converts analog into digital and the decoding recovers that analog from the digital data converts digital back into analog in this topic in this course we'll cover just one technique a very basic one called pulse code modulation pcm delta modulation there is a few pitches off but we will not cover and it's quite simple and we'll go direct to an example to show the idea and then we'll go through a couple of examples to explain it in depth think of the solid line here this curve as the analog data it's some represent representation of the data that we want to send for example a recording of voice over some short period of time some period of time on the the horizontal axis and on the vertical axis we have the signal strength or the data strength so as you talk over time the strength of the data goes up and down and that's what this plot shows just a small portion we want to take this analog data and convert it into binary and the way we do it is that we take samples at regular intervals so we record the value of the analog data at a sample point and then take that value and convert it into a binary value and then at the next sample point some time later we record the value and convert that into a binary value and that's our digital data so that's the conversion we just keep doing that at regular sample intervals so in this picture the sample intervals start at the first point time zero and then at these vertical lines sample points at these locations now we record the the strength of the signal the height really and convert that into binary to do that we must have a discrete some discrete values to convert to binary we cannot have a continuous range of values so the common way to do it is to think okay what's the minimum possible level of the signal and in this example think of it as the bottom line here this bottom line on the graph is the lowest possible level of the signal and what's the highest well that's the top line and on the right hand side there's some scale we break it into all right the minimum we set at zero and in this example the maximum we set to 16 so we're saying that the our analog data ranges between zero and 16 we will see later we can change those it doesn't have to be zero to 16 we can be zero to another number but we assign some scale to the vertical axis and a linear scale in this case so looking at this right hand axis at the first sample point at this time we record the signal strengths and we look on the axis what's the value it's about 1.1 okay you look closely you'll see it's about 1.1 on this axis and that's recorded here the next sample we look at the signal strength and look across and it's about 9. something 9.2 and we keep doing that for each sample point 15.2 2.7 at that last sample point and we'd keep going if there's more data so all we do so far is map the signal strength into a linear scale we assign some numbers to it but we don't want to have decimals we just want to have discrete values and in this example we want to have values ranging from zero up until 15 and you'll see the y in a moment you may guess already 0 to 15 so what we do of those values that we originally get 1.1 9.2 we really map them to the nearest value between zero and 15 and that's tried to be shown on the the left hand axis here that any value that falls within this range will be mapped to the code number zero so any value that's between zero and one think of we we use the floor function if it's 0.1 0.2 0.467 we'll just map it to zero any number between one and two we'll map it to one any number between 15 and 16 15.7 or 15.2 for example we'll map to the discrete value 15 and that's what this row of values show here that the first sampled point was 1.1 which as a discrete we call it a code number is code number one the next one was 9.2 which becomes 9 15.2 15 2.7 here is within this third row maps to 2 now we have sampled values where the values range from between zero and 15 there are 16 possible values therefore we can represent those 16 values any of those values using a four bit binary value and that's what we get in this bottom row here one becomes 0 0 0 1 9 1 0 0 1 and 2 at the end 0 0 1 0 and now we've finished our pulse code modulation steps of taking analog data taking samples and each sample is mapped to a four bit digital value so the digital representation of this analog data is this sequence of what 28 bits four by seven samples or seven samples each of four bits in length any questions on PCM pulse code modulation you've probably used it in a number of cases maybe not so common now but probably if you've listened to a cd you've you've listened and and you've seen pulse heard at least pulse code modulated audio any questions yes not yet so i expect one later if not yet okay there are some some things in this example which may not be clear or why do we have 16 values and so on well that's just for this example the idea is that we want to map the signal strength into discrete values so we choose a range and really we choose between zero and 15 so each sample is going to be mapped to an integer between zero and 15 and once we have one of 16 values we can represent that in a four bit binary number there are two things two parameters in this case the sample interval the time between samples and the number of code numbers or the number of levels that we used here in this example we use 16 levels but we don't have to use 16 and we'll see that will have an impact upon what happens when we send the data let's go through some some other examples of the same technique and if you flick forward a few pages you'll see these other handouts on just a few other examples on pulse code modulation which will make this hopefully 100 clear once we get to the end we'll go through some simplified examples and then start to look at what the impact of those parameters of the sampling interval and the number of code levels have on our reproduced signal but first before I we look at those examples let's try and I'll just draw a picture just to show what happens with respect to the communications so the idea is that we start with some analog data and we want to transmit that analog data to the receiver who's of course going to receive eventually some analog data and the example that's maybe easiest to think about think of the source analog data is you speaking into a microphone and the the received analog data is what's played back on some speakers maybe at your friend's phone so with PCM we take that analog data and we use the algorithm PCM to convert it into digital data so the output of PCM is a sequence of bits so and then we send those bits so this all happens at the source at your computing device the conversion happens inside the source then we have a sequence of bits and we can use any of our existing techniques to send that across a link so we can send it as either a digital signal and the techniques we've got for example NRZ and the others or we could even send it as an analog signal it's not so important with respect to PCM e.g phase shift keying and those other approaches so we're focusing only on the conversion from analog data into digital data and the conversion back how we send it across the link doesn't matter in this case so the receiver receives that and converts back and of course I forgot to draw what it receives after it receives the signal it has digital data so we start with our for example voice analog data we convert it to bits we send those bits using some form of signal digital or analog we receive a signal which is converted back into bits the digital data and then PCM the decoder converts that digital data back into analog for example if it's your mobile phone the the decoder on your mobile phone has a sequence of bits as input and converts it back to analog and plays it on the speaker on your mobile phone so you hear some audio that's the analog data we went through or the process for converting to digital data is we take samples and convert those samples to bits and at the receiver the decoding is when you receive the bits so you receive zeros and ones you produce as an output some analog signal as an analog data at different levels and the idea is that the analog data at the receiver is an accurate reproduction of the original analog data ideally it would be the same what we have at the source and what's played back at the receiver would be identical but it turns out in many cases we don't need it to be identical and in fact it's hard it's impossible to have it identical with this approach for example with voice when someone talks here as long as what's played back on the speakers is understandable then that's sufficient so the quality of the reproduction how good is the audio the receiver may differ depending upon what we do in the encoding and decoding so given that we'll look at encoding and then we'll look at as we receive the digital data how we decode or reproduce the analog data and that's what these few examples try and show in a very simple scenario here's our original input analog data what we start with at the source and for this example so it varies over time it's continuously varying in this example I assigned some time scale so it's from zero up to about 18 milliseconds just to give us some numbers and this is the amplitude on the vertical axis so what the source does is take samples and maps those sample points to some discrete values and in the first example I'm going to assume that the sampling interval is four milliseconds just for this example so every four milliseconds we will record a sample and we'll also assume that we're using eight different levels or eight code numbers with eight code numbers we start at zero and go up to seven so I've trying to try to draw it so that think of these rows here between the dash lines any any value of the signal that falls between the bottom solid line and the first dash line would map to code number zero if it falls within this area it maps to code number one and anything above the top dash line maps to code number seven I haven't drawn the the actual values that was on the on the lecture notes just to keep it a bit simpler what's the first set of bits to be transmitted bits I want zeros and ones and we start at time zero so the first sample is at time zero first set of bits zero zero zero one no zero zero zero one no again zero zero one okay so be careful the first sample point is at time zero let's say we start here we record the sample what's the actual magnitude it's a it's here whatever the value is we don't really care in this simplified example we know that it will map to number one as the discrete code number it falls within this this range maybe it would the value was 1.3 I haven't given you the scale but it maps to code number one because we have eight different levels eight possible code numbers each code number will be represented by three bits so the code number one will become zero zero one unlike the previous example where we had 16 levels and four bits here we have just eight levels we only need three bits per code number so the first sample point produces the digital data zero zero one we could actually send that across the link now so if you can imagine now someone's talking on their phone as they talk the codec PCM is recording the input converting it to binary and then sending that binary across the link to the across the network to the destination we have a sampling interval of four milliseconds so four milliseconds later we record another sample at time four it's just above this dashed line so it's six one one zero and we could send that across the link we'll look at what the receiver does in a moment and we get the other sample points here how many bits sent 15 bits in this case what's the bit rate how fast are we sending bits every four milliseconds we take a sample every sample is three bits in length so we need to send three bits every four milliseconds how many bits per second three bits in four milliseconds there would be 250 samples in one second so there'll be 750 bits per second we'll see a calculation of that later but three bits per four milliseconds if we keep doing this we're generating 750 bits per second and we'd need to send them across the link here it is our input data our transmitter which includes the the PCM codec converts that into bits and sends them across the link and at what rate does it need to send them well one sample is generated every four milliseconds three bits per sample therefore three bits per four milliseconds which is the same as 750 bits per second now be careful i've said data rate here this doesn't mean it's the data rate of the link 750 bits per second is the speed that we must send our data to be able to represent this analog data it's think of it as the data rate required for this application for this data transfer we'll come back to that and when we compare some other approaches now what does a receiver do it receives the bits and must convert back to analog data i hope we've got that oh it's here this is what is reproduced as the analog data at the receiver how did it do it at time zero when the receiver receives the first three bits which was 001 it produces an analog output at level one 001 is level one and that it maintains in the simplest way it maintains that output for four milliseconds then at time four milliseconds it receives the next three bits 110 or six so the receiver produces an analog output at level six for four milliseconds and then at level three one and two so the green line here is the analog data at the receiver this analog data here so it's played back on the speaker for example if it's audio we want the analog data the receiver to be a good reproduction of what was at the source here's a comparison of the two the blue one is the original analog data the green one is the received analog data they're not the same but you can notice a little bit that the green one follows the pattern of the blue one it is some sort of rapid jump at the start to some height around six then it gradually goes down a bit and then it starts to go up a bit so this is only over a very small time scale so this green line is our reproduction of the input analog data it's not identical to the input but we need it such that it's close to the closer it is to the input the better the quality of the reproduction we say how do we get it closer how do we get the received analog data to be closer to that blue line to make it look like the blue one frequency be more specific frequency up frequency of what ignore noise noise will have an impact but in in this case it doesn't impact on how we sample the frequency at which we sample okay here we were sampling every four milliseconds and you see the output the simple way for the output is to hold the level for four milliseconds because we don't know what's between zero and four we only know what was at time zero and what was at time four we don't know if it was up or down the next sample until we receive it now there's some smarter ways to do it but this is that the basic way so one way to get closer to the blue line would be to sample more often instead of every four milliseconds let's say every two milliseconds and we'd get these sample values same number of levels eight levels but a sampling interval of two milliseconds you can go and check the values but we'd get these what 30 bits of data over the same time period at time zero it's one at time two it's three and so on we'd send those bits across our link the receiver receives those bits and produces an analog output and we get this and maybe you can see it's a little bit closer to the blue one we'll compare them later do I have it okay because we're sampling at a higher end higher rate a higher frequency we get a more accurate representation of the output analog data when we compare it to the input analog data any questions so far what we want to work through is how the different parameters impact upon quality and other factors the blue one is our original input let's check have I changed the scale one one thing that I haven't really explained is where do these these levels come from okay so sorry I'll go back to this one the the green output which we'll see in a moment if we have decimal one the first sample point then we'll produce an output in the middle of this band here in the middle of this area and that's seen here so it's not the same okay of course the input blue line is not the same as the output green line but we want to approximate it we want to get as close as possible okay and what we want to do is know what parameters will get it's more accurate get closer and closer so far we see that increasing the sampling interval sorry increasing the sampling rate increases the accuracy of the reproduced data the more samples the better will be what's the disadvantage of higher sampling rate we send more bits in all in these two examples so far it's the same analog data we want to get this blue line from a to b the analog data doesn't change one of the disadvantages of more samples is that we need to send more bits to transmit the same original information we send more bits across the link that is we use more resources to send the data and we'll see some calculations of that to compare in a moment one last example we can also change the number of levels two milliseconds sampling interval 16 levels instead of eight every sample produces a four bit binary value because with 16 levels we need to have a four bit number so now we have what 40 bits sent during our interval four bits every two milliseconds and the receiver receives and produces this and it's hard to compare across the slides which ones closer to the blue line this one tries to compare those three cases case one was four millisecond interval eight levels that's the red one when you don't see the red one it means it's underneath it's underneath the orange one here the case two the orange or the brownish one is two millisecond sampling interval eight levels and case three the green one is two millisecond and 16 levels so changing those two parameters case one is this green one four milliseconds eight levels case two is two milliseconds eight levels and case three is two milliseconds 16 levels changing the number of levels which one is closer to the blue line just visually case one all right maybe easier question which one's worse and which one's the furthest from the blue line now it's a not a great picture because the red one is actually underneath the other line say here but I think you may see that the red one especially at this point is furthest away from the the blue line and here it is the red one the case one is the worst when we compare it to the reproduced when we compare the reproduced output analog data to the original it's the furthest away case two and case three it's hard to actually see visually which one's closer to the the blue line you'd have to do some calculations but they're very similar you see maybe case two is it's a bit better here although not at this point case three is closer to the blue one here maybe the case two is here so they're very similar it's hard to visually compare case two and three but I hope you can see that at least case one is worse than two and three in this case especially at these points we want a reproduced signal which is as close as possible to the original signal how do we do it increase the sampling rate that is decrease the interval make it have more samples and increase the number of levels if you increase the number of levels and increase the number of samples then you'll get a better quality reproduction at the receiver that doesn't be closer to the original if you had instead of every two milliseconds you could try it every 0.1 milliseconds very often have samples and have a thousand different levels then if you reproduce it we very close to the blue one in that case so in general the reproduction at the at the receiver the analog data we produce at the receiver when we compare it to the original we can talk about the accuracy of that reproduced data how accurate is the reproduced data compared to the original well increasing the sampling well maybe I'm missing a word here increasing the the sampling rate and or levels increases the accuracy so increase the number of number of samples increase the number of levels will increase the accuracy of the reproduction and you see it in our picture that case three and maybe two are better than case one what's the trade off the trade off is that if we increase the sampling rate and or increase the number of levels we need to send more bits for the same amount of original data that is we increase the data rate required to transmit that data across the link that's a bad thing case one required 750 bits per second it was three bits per four milliseconds just record that case one was three bits per four milliseconds case two we had eight levels so it was still three bits but we changed the sampling interval to two milliseconds that is we have twice as many samples with twice as many samples will have twice as many bits per second 1500 bits per second with case three we had 16 levels therefore four bits per two milliseconds which is the same as 2000 bits per second in one second there will be 500 samples one sample sample every two milliseconds so in one second 500 samples four bits per sample is 2000 bits per second for these three cases with respect to the data required which one's worse one two or three hands up for one okay so the question is of these three cases which one is has is the worst with respect to the data rate required we saw before that case one was the worst with respect to the accuracy but now with respect to the data rate required which one is the worst ends up for case one ends up for case two case three okay good case three because even though it's a higher number this is what we require to send the data across our link or network the best way to think of it is that we have a link with some capacity maybe 10 000 bits per second that's our link data rate 10 000 bits per second if we're sending some analog data using case one we would use 750 out of that 10 000 for our analog data we only use a small fraction the rest is left over for other applications sending web pages sending other audio other data but if we use case three of that 10 000 we would use 2000 bits per second we'd use a much larger proportion of our capacity to transfer the same amount of data it's still the same original analog data so the smaller data rate required the better so case one is better with respect to the data rate required but case one is the worst with respect to accuracy and that's our trade-off really increasing the sampling rate and levels increases the accuracy that's good but increasing the sampling rate and you should write rate here and the levels increases the data rate required and that's bad so we need to choose a trade-off that that meets our requirements of accuracy and data rate required questions before we see some other examples go through one or two more examples of PCM this was a simple simple example that is we tried to keep the numbers and the signal simple let's go back to our slides so the question or the two parameters we have are the sampling rate how many samples per second and the number of levels or code numbers the other two parameters will impact upon accuracy and data rate required what are good values well with respect to the sampling rate Nyquist and others have done analysis and come up with what's called the sampling theorem and it says in ideal conditions really if you have an infinite number of levels which we don't but if you used an infinite number of levels it says if our data and here it's written as signal but our data is just another signal if it has that's maybe all right if it if a signal is sampled at intervals at a rate higher than twice the higher signal frequency let's explain that first that is our original data is made up like any signal of different frequency components remember voice voice range from about 100 hertz up to about 4 kilohertz so with voice the frequencies range from the frequency components are between 100 and 4 kilohertz the highest frequency component of voice is about 4 kilohertz yes so the highest frequency component in voice is about 4 kilohertz this theorem says if we sample at a rate which is twice the highest signal frequency so the highest for voice is 4 kilohertz 4,000 per second if we sample at two times that 8,000 times per second then the samples contain all the information in the original signal which means when we reproduce we get a perfect reproduction so this tells us something about what is the ideal sampling rate given some input data and maybe it's not written in the easiest way to understand if our data has the highest frequency component of 4,000 hertz then it says we should sample at 8,000 hertz 8,000 times per second because that's twice the highest frequency component if our data has a frequency can frequencies ranging from one kilohertz up to 10 kilohertz the highest frequency component is 10 kilohertz we should sample at 20 kilohertz twice the highest that's what it tells us so if we know what our original data is in particular the frequencies we know what the ideal sampling rate is here's the example for voice all right voice is approximately between 0 and 4,000 hertz remember hertz is just times per second per second that's what hertz means so therefore we should sample at twice that rate sample at 8,000 times per second or 8,000 samples per second and that would be sufficient if we had an infinite number of levels when we reproduce we'd get a perfect reproduction that's what it tells us so for voice if we sample at 8,000 times per second we get the best quality that we can achieve if we sample at 10,000 times per second higher we were not improved to accuracy that's what the sampling theorem tells us if we go any higher we can it's okay but we will not get better accuracy if we go less than 8,000 let's say 6,000 samples per second we will get lower accuracy lower quality so if we go at the this twice the highest frequency component that's usually sufficient now in practice we don't have an infinite number of levels there's no easy theorem to tell us how many levels to use it's usually done by experiments and tests for example for voice when people are talking across communication systems generally seven bit encoding is enough seven bits means there's 128 levels so a typical parameter with voice is that we sample at 8,000 times per second and we have each sample represented by a seven bit value and we can use that to encode the voice and that will produce a very accurate reproduction when we play it back so that the ear will not be able to distinguish between what's played back and the original version for other types of data you need different number of bits here I'll show you one more in a moment but just for that example of voice we have let's say that's the case what's the data rate required for voice then we're saying with voice the spectrum is about about zero hertz more than zero hertz up to 4,000 hertz so the the highest frequency component the highest frequency in in voice is 4,000 hertz so the sampling theorem tells us we should sample at twice that rate the ideal sampling rate right the ideal sampling rate we don't have to but it's recommended is twice times 4,000 it is 8,000 hertz or 8,000 samples per second just remember hertz means times per second times of doing something per second so we can use it to represent the sampling rate as well 8,000 hertz if we and the recommended number of levels from experiments is 128 levels therefore the bits per sample is seven every sample is represented by seven bits again we could use a different value but just for this example what's the data rate required well we have seven bits at 8,000 times per second 8,000 hertz it'd be 56,000 bits per second 56 kilobits per second so if we sample at that that ideal rate seven bits per sample seven times 8,056 kilobits per second what if we change the sampling rate in another case we didn't sample at 8,000 but use seven bits but did it at let's say 10,000 hertz then we get 70,000 bits per second and maybe a third example what if we stick with seven bits and used a lower sampling rate of say 6,000 hertz we'd get 42,000 bits per second just three different examples the ideal sampling rate plus one that's higher and one that's lower and for each of them the data rate required which one is best with respect to data rate required just make sure everyone's clear with respect to data rate required which one's best blue purple or green the lowest one green remember data rate required is let's say I have a link that supports one megabit per second I have a link from A to B and the data rate is one million bits per second then let's go through and see for those three cases how many so this is voice and think of these as as voice calls okay someone's talking on the phone and their their voice is converted to bits and they're sent across our link and let's say we have multiple people at location A and multiple people at location B and they all want to talk with someone else so the question is if we're using the first one the blue one how many parallel voice calls could be supported one voice call requires 56 kilobits per second if our data rate is one million bits per second how many voice calls could we support using the first case how would you calculate it we'll get the calculator out in a moment so the case of seven bits at 8000 hertz how many voice calls one voice call requires 56 kilobits our link supports 1000 kilobits so we get what 1000 divided by 56 gives us 17.8 we can't have a 0.8 of a person talking so we'll round it down to 17 we could have 17 people talking at the same time because everyone who talks generates 56 kilobits per second our link supports a thousand kilobits per second so 17 at the same time what about for the other two cases the purple case someone can calculate for me how many voice calls one is 70 kilobits we have a thousand we get 40 14 correct it should be smaller less voice calls that's worse in that I've got a link I want to allow as many people as possible to make a voice call using that link well with the blue one we can have 17 people talking with the purple one only 14 so that's worse in terms of using the link for our application of making voice calls in the green one 42 kilobits per second we get how many voice calls 23 voice calls that's best the best voice calls trying to make it clear that we want a low data rate required allows us to use our link for more things at the same time and this example the more things are more voice calls so the green one's the best with respect to the data rate required which one's the best with respect to accuracy which one's the worst with respect to accuracy the green one okay the green one we've got less samples and we will not try and draw it but the the few of the samples when we reproduce this the output analog data it will not be as close to the original as when we have more samples so the green one has fewer samples therefore be less accurate which one do you want to use of the three which one do you want well green one's good with respect to the number of voice calls that's good but worse in terms of accuracy there's no best answer but be careful compare the blue and the purple one in terms of accuracy which one's best in terms of accuracy they are the same okay the sampling rate of 8 000 hertz is sufficient to capture all the information so going more than 8 000 doesn't gain anything so going to 10 000 20 000 100 000 hertz doesn't help so 8 000 is sufficient in that case and because 8 000 produces a lower data rate required than the 10 000 that's better in that case so don't choose the purple one if you want high quality the blue one if you want more voice calls the green one and then that's up to you which one which trade-off you want to make any questions on PCM I'll leave you a homework task we'll get we will not finish it a cd the audio cds not a cd with mp3 on it but the original audio cds it uses PCM to encode the set the music and the specs are zoom in with a audio cd there are two channels of audio what does that mean two channels there's left and right it's stereo which really means there's two streams of audio okay think of two pieces of audio that's what two channels or stereo means using what's called l pcm which is pcm what we're dealing with linear pcm there's also a non-linear 16 bit values so with cd audio we use pcm and every sample is represented by 16 bits how many levels 16 bits per sample there's about 65 000 levels two to the power of 16 okay so it's not eight 16 we have 65 000 different levels when we take samples on a cd that is when someone creates the cd and at the sampling rate of 44 100 hertz meaning every one second there are 44 100 samples each sample is represented by a 16 bit value and from that you can calculate how many bits per second for audio and remember there are two channels so you do all that for the left channel and then you do it all again for the the right channel so you do it twice here it says the capacity of a cd it varies how big is a cd in terms of megabytes anyone remember 700 750 megabytes all right let's say it's 750 megabytes okay if the cd carry can contain 750 megabytes of data then the question is how many minutes of audio can it contain we will not write it down there are 44 100 samples per second every sample is 16 bits so that's the number of bits per second we have stereo so we need to do it twice so it's separate audio streams for left and right so that's the number of bits per second about 1.4 megabits per second okay that's how many bits per second we need to save on the cd how many bits do we have available on the cd 750 megabytes convert to bytes 750 megabytes times by eight convert to bits and divide that is the total size 750 megabytes divided by the number of bits per second that we need to write to it and that tells us the number of seconds divided by 60 gives us 70 minutes about okay that's why when you have a normal audio cd you can save about 70 minutes of audio on it it uses pcm stereo 16 bits per sample 44 100 samples per second if you had a bigger cd or a smaller disk in terms of bytes megabytes you'd have a different number there confirm that calculation yourself make sure you can do that calculation tomorrow we'll summarize what we know about pcm and move on to the next topic okay we'll stop there