Transcript for:
Understanding Quantization in ADCs

okay let's uh continue so in the uh last class we looked at sampling issues with sampling like aliasing related stuff so today we'll continue with quantization and the general flow we'll take in this course is this first we'll try to understand uh ADC at a block level before that we'll try to get a basic feel for the math behind the two operations that we do that is sampling quantization once that is done we'll look at this at a block level and we'll see how we can evaluate its performance characterize an ADC and so on those kind of things and then we look at circuit level implementation okay and of course in the last class we looked at the basic math behind the first operation we do which is sampling today we'll uh continue with the second operation which is quantization and as uh we discussed in the last class quantization is essentially discretizing the amplitude axis so let us say your incoming signal can take an amplitude anywhere within this range say some minus V reference voltage to a plus v reference voltage now instead of you having to store any possible amplitude that the signal can take here the the idea is you divide this into finite number of segments like this and you say any you know amplitude within this range will be assigned one particular amplitude level any amplitude in this range we'll assign another amplitude and so on and once you do that you have finite number of amplitudes that you have to store and this as you know can be encoded using binary bits that is the basic math behind this operation we'll see how we'll implement it later and anyways if you have eight levels how many bits do you think we need to represent this three bits I'm sure everyone knows so similarly if you have end bits you can basically have end bits means two par end levels right so hopefully that is clear so let's look at this uh charact input output characteristic in bit more detail so let me first draw the uh sky so again the input we'll assume that it spans this range minus V to plus VF and this typically is called the full scale R sometimes called FSR so let us say this is that uh from here minus VF to plus v let's say this is zero and let I say I want to quantize this amplitude axis into four levels so essentially I will uh segment it like this so what is this spacing I mean what is this value no no I mean don't go to J what is the value it's just simple question right minus P to plus P there are four segments no I asking about the spacing between these two I mean range is minus V to plus v what is the total span 2 V into four what is the step okay so this is 2 V by 4 and typically this is called the step size of Delta and in this case Delta as you saw is 2 V by the number of levels right and in general if I have n bit quantizer which means I have 2 power n levels what will this be of four levels if I have two power n levels what will that step size be by fine so so let's uh see how the characteristic of this operation is going to look like so let me can so let's say this is the input typically input is denoted with Y output is V and you know the simple nemonic to remember is quantizer is essentially rounding off so you take the input round off you chop off the tail and you get it's a typical thing so what I'll do is I'll basically uh normalize this axis with respect to step size so that it's easy for me so this is basically 1 Delta 2 Delta -1 -2 fine that's all so now uh any amplitude in this range I want to round it off to a some amplitude what do you think is a reasonable value to round off anything in this range 0 and 0.1 anything within that what can I round it off to5 I mean principle any value in this range is okay but5 seems to be a logical thing to do say I'll say anything within 0 Delta and 1 Delta I'll round it off to5 Delta and I'll normalize this also with respect to Delta so I don't have to worry about deltas everywhere so this is uh half and similarly anything between 1 and two I'll down it off to 1.5 that's basically 3x2 something like this similarly identical uh stuff happens in the right so this isus so in this particular example I've have chosen a case where in uh zero kind of is not an allowed level that is at zero we have this transition you can also have a quantier characteristic like this where in let me just draw it and show where zero is an allowed quantise level and then you can have let I say some levels here some this also equally possible quer characteristic you can have this is y by Delta if you have something like the one in the left that kind of quantizer is called mid rice quantizer and for obvious reason the at the middle you have this rice and this guy is called mid thread quantier there are just some minor differences between the two again one simple observation you can make is if you want to have a symmetric characteristic that is both on positive and the negative side if you want it to be symmetric you can have even number of levels here right whereas here since zero is an allowed quantize level you need to have odd number of levels so that you have a symmetric curve that is one and secondly if let us say if your input versus time is very small that is close it's very close to zero like this right basically input is spanning this range that's it if it's a midre quantizer what will be the output I mean input is lying in this r R so the output is always zero whereas if I have uh input spanning this range what will happen here it basically toggle between these two value right so if you want the output to be quiet when the input is not changing a lot maybe you can use this sir how do we know that like at Z the no I mean there is a discontinuity right if you have your quantier such that it I mean think of it like this don't worry about how it's implemented mathematically anything any amplitude in this range you map it to.5 any amplitude in this range you map it to minus5 so at zero it is not Define technically okay okay so yeah so let's now I'll take this mid rise as an example and huh mid r mid tread it's treading like it's going it's not changing so let me I mean there is nothing like the typically see uh like I these are the two things depending on what you feel is better for one particular case you can use here most common will be to use generally you'll use uh this midrise because even number of levels so number of bits is also easier right here you will have let I say five levels to encode five levels how many bits we need huh no four levels I need two bits if I have one extra level how many bit I need I need three bit you're kind of wasting a bit so if you think like that yeah I don't use this again it's there is nothing like you know this is the thing for this application and so F question like the correct yeah yeah both are unless let me take this so let's try to see if we can analyze it further so first of all do you think this operation is a linear operation or a nonlinear operation why not linear I mean how do you say if it's linear or nonlinear huh what is straight thing for 0 to one it would be it be monotonically increasing no here what monotonically increasing right monotonically increasing is if I keep increasing it is it changing it is also increasing of course in this range it is not changing but it's not falling right it is monotonically increasing yeah super potion so I mean simple cases see I take some input here the output is5 I scale the input by some Factor if it's a linear operation what should happen to the output output should also scale the same factor but do you see that happening here if I scale the input from here to here the output doesn't change so it is nonlinear so for analyzing linear system itself is great deal for us so if it's not linear you don't even have to ask and of course if you want to sit and do you can know with pages and pages of math you can regressively analyze it but that's not the point of uh this course we just want to understand this and make circuits that do this so what we'll do is we'll try to get a very simplified model for this operation okay so uh let's say this is the input y okay after quantization I get some output V I know my output is not same as the input what is the simplest linear way in which I can model this I mean this just look like a block diagram right at a block level what can I do to Simply model this operation they very you know like I mean my output is not same as the input so what can I do here so that I can model this I mean if you have to model this operation mathematically using so yeah so what you say you can just add something here see quantization is rounding off you add something here that is the appropriate error that you are incurring in the quantization process to get the okay I mean that's what I meant by mod so here Q is what we call as quantization error again it's a matter of fact naming so uh yeah so if I give you a quantier how can I find this quantization error I mean I Eva quantizer means I have I can apply an input I can see what the output is from these two how can I find the quantization error I take D minus y so it's basically quantied value of Yus y so uh we have decided that this how we are going to model this so at least let's try to understand more about this quantization error so what I'll do I'll try to plot quantization error also in the same uh thing like this again it's y by Delta so remember to get quantization error I have to subtract the quantized output or I mean quantized input with the input itself so I'll draw a straight line yal to X is not looking straight but something like this so this is basically V equal to y or V by Delta is y by Delta this is basically uh quantied value of the input so to get the quanti error I have to take the difference between this step green curve and yellow curve so at zero what happens let say this is also Q by Delta okay so at zero what is the difference why is it Z at zero the yellow line is zero the green one as a discontinuity so even the difference will show discontinuity right and what will be the levels of the discontinuities half and minus half fine so if I keep increasing the input uh the quantized value is constant but the yellow curve is increasing if I take the difference what happens it falls at this point what happens at that point both the curves are intersecting so it has to drop to zero and once again at this point it will show a jump so the same thing will keep repeating okay I'll just quickly draw it something like this okay fine course if I keep increasing the input uh beyond the full scale range let's say keep increasing the input like this this guy is constant but the input is increasing so essentially this will also keep going beond cool so from this uh can you make any observation about the quantization error yeah I mean at least you see if the input to the quantizer is within the full scale range what is the range of values the quantization error takes it's not plusus step size plusus Delta by 2 fine I mean this is normalized with respect to Delta it is plus Delta by2 andus Delta by2 right so this is one observation I can easily make this will Li in this range ofus Delta by 2 and plus Delta by 2 if my uh input is within the full scale range right but of course this alone is not a great piece of information for us to do any kind of no analysis or understanding so uh what we do in practice is the following we make some assumptions about the quantization noise and I'll caution that these assumptions might not make any sense it will sound atrocious but it turns out in practice under appropriate conditions these hold quite good that's all so the first assumption is this so firstly you tell me if the quantization error here is a function of the input or it's an independent signal does it depend on the input it it strongly depends on the input in fact that is one of the things that makes this analysis easy this is not some independent signal now of course you are in the process of making assumptions assumption should make your life simpler so what can you assume to be if you give you a free pass I want you to make any assumption on the quantization noise what can you assume it we'll assume that it's an independent signal okay so we'll assume that Q is independent of the input okay so which means I can treat it like a a random signal again that might not look any basis for this but as we'll see this kind of hold reasonably good so since we treat it like a random signal we also call this as quantization noise so that's the first assumption we make so uh now that we have declared this guy to be a random signal how do you uh analyze random signals what use some kind of statistical measures so we need to say something about its probability density function so again you're in the process of making assumptions what is the simplest PDF you can assume huh I mean Gan distribution equation cus X squ blah blah blah what is a simpler distribution uniform right so we'll assume that this has a uniform perod so basically its distribution or let say probability density function is this of constant and mind you what is the values the range of values for the quantization noise yeah as we saw it it's within this range so the uh distribution looks like this this is let's say PQ of Q thank you and of course we can now say what is this value yeah the area of this is one so this is basically 1 by so now uh let's see if this assumption is indeed reasonable or not for that I did a exercise so I basically generated a signal like this uh RAM signal going from minus PF to plus PF I sampled it I quantized it and then I saw what is the quantization error I did okay so this is the uh histogram you guys know what a histogram is right it's a proxy for the probability density function right so here if I normalize it by the number of sample size I get the density and as you see it's almost flat this is with the 6bit quantier right and if I do this with the 10 bit quantizer it once again looks pretty good but with this let's not make any conclusions because in practice we not dealing with ram signals so let's look at sinusoids because as you know any signal can be thought of as some of sinusoids so uh I did a second experiment wherein I took a sinusoidal signal with a frequency of 2011 Herz I sampled at th000 H Herz I the same thing I quantized it took thousand samples of this fellow and did the same experiment found the quantization noise and and plotted the histogram and this is what it looks like again this is not exactly uniform but okay again this is with the 6bit now if I go with the 10 bit quantizer it's reasonably fine at least if you zoom in from a long distance it will look like it's flat so this will make it tempting to again justify this assumption but hold on to that because I did another experiment uh not necessarily I we'll see that I'll make some statements after that you'll understand so we'll I'll uh do another experiment now wherein instead of doing this I just change uh the frequency to 200 HZ looks like a harmless change I do the same thing nothing else changed and if I do that vo the distribution looks like this just showing two fingers and then again this is the six bit the 10 bit at least I hope that it might be better like he thought it's not looking so what do you think is happening so let me put the two setups this is the first experiment okay the second experiment is where I just slightly change the frequency by 1z so what's the difference do you think so so mhm okay here is they saying that looks like at least the simple mathematical observation is this guy is a multiple of this or I mean I would say this guy is a divisor of this guy so let's see what happens so let's say if I do this sampling if I sample the signal with at th000 HZ what is the discrete time sequence I get S of 2 pi * 2011 T is replaced by NTS n by FS fine this is a discrete time sequence which is getting quantized so here what is the periodicity of this sequence or with how many samples do you think this signal is periodic th000 I mean after th000 this argument repeats as a multiple of 2 pi hopefully that is easy to see so the periodicity here is th000 samples right so let's do the same thing here if I do that here what do I get as a discreete Time sequence sin of 2 pi 200 into n by th000 this is basically n by 5 yeah what is the periodicity of this fellow it's periodic with just five samples right so in the first case when I actually took the signal quantied it and took thousand samples of the quantied data all the Thousand sign samples that were fed to the quantizer were unique because the signal repeats only after thousand samples if we take any set of thousand samples continuously it's going to be all unique right whereas here although I take thousand samples and quantize it how many of them are distinct only five are distinct right so essentially if this was the quantier characteristic in the first case I was exercising all possible levels of the quantizer in the second case I had only five unique amplitud udes that were getting quantied so I was probably exiting two or three of these levels so that's the difference so uh the bottom line is that as long as what we have what are called BC signals again this is are loose definitions by BC signals I just mean that the signal spans the entire range exites all possible quantizer levels and there is sufficient variation from sample to sample it is not repeating you know the small periodicity as long as we have these kind of things looks like the quantization error PDF is almost uniform okay I mean it's called DC signals technically I'm not going into a lot of rigor here it just assume that it is a case where signal spans the entire range exiting all quantizer levels and there is sufficient variation from sample to sample so so now at least we know for uh these cases the PDF is uniform so let's just convince ourself of that fact and try to understand more from that so let me sketch the PDF once again so this is the PDF right so now that we are convinced that this is the distribution let's make some observations what does the mean here this is a probability PDF what does the mean zero right because it takes both positive and negative values with equal probability what is the mean Square value how will you find and remember mean Square value is basically the power in the signal okay one how do you find the I mean it's expected value of how do you find it if I give you the so remember it's basically q^ s * PDF I integrate over all possible values of I integrate respective d right and if I I mean I'll let you work out because this is constant it's a simple integral you find this will be Delta squit so this what we typically say the quantization noise power is Delta squ by 12 where Delta is the step size as you know if it's uh nid quantizer with the range minus V to plus v Delta is this okay so as of now we have gotten at least some information on the quantization error quantization noise huh as no there's a difference variance of Q this basically expected value of where in you remove the DC offset and do it but Power includes DC right if a signal has a DC component that is power tool if it's a zero mean signal then variance is same as power okay otherwise power is basically mean squared value which is mean of the squared value right expected value is mean it's mean of the squared quantity that is basically the power cool so now we have gotten some information on quantization uh noise so now we can try to see how we can basically characterize an ADC right and this seems to be like a reasonable thing to do a good ADC as you know should have should be having the capacity to resolve with more and more bits which means I should have more and more end so which means uh this term should be smaller or larger should be smaller it's a quantization error power if lower that is you can say better is my quantizer or better is my ADC but uh this alone will not paint the full picture because in practice we are not only interested in the uh noise power we also interested how large my signal power can be right so here the again the range is minus VF to plus VF so I can have a sinusoid like this that is a maximum sin I can feed into my quantizer so what is the maximum power of the signal for a sinusoidal I mean this is the signal it goes from minus VF to plus v as sinusoid what is the power of the sinusoid amplitude is VF so hopefully this is clear so as you know we are interested in the signal to noise ratio so here we have something called signal to quantization noise Ratio or would say sqnr and here uh this is the maximum signal power mind you right so I'll say this is Peak signal to quantization noise ra so I can find this uh my signal power is essentially V squ by 2 noise power is Delta Square by 12 I mean a simple algebra I'll not do this you work out you get something okay and you typically signal to noise ratios are expressed in DB because you have to express a wide range of values so it's better done in log scale so if you do it in DB this will be 6n + 1.76 where n here is the number of bits you have for the quanti again I have to clarify this is peak sqnr for sinusal signals it is just for sinusal signals that we have made this calculation oh I mean this is fine H from here you know Delta you put it lead of goes off and then you have just you know n and constants and then you take log I don't want to spend time on doing basic math so now you tell me if I have a 10bit quantizer or a 10bit ADC what is the maximum sinusal signal to quantization noise ratio I can get 61. yeah about 60 to 62 DB right so now let me rewrite this so I know that sqnr is uh 6n + 1.76 DB from this we can calculate what is your resolution so we can say this is sqnr so this is typically called the effective resolution or enob which is the effective number of bits again this is an important metric uh for adcs because see let's say uh I mean let's say I mean for all that matters I can design a 2bit ADC okay and then randomly have eight other bits Connect randomly to ones and zeros put it in a black box and tell you that hey this is a 10p jdc go and use just because you have 10 digital bits coming out of your quantizer it doesn't mean that it has a capacity to resolve my signal with 10 bits of resolution right so that's why this is required of course what I told is a you know exagerated degenerate case in practice let's say you try to design a 10bit ADC ideally the peak sinusal signal to quantization noise ratio is about 62 DB or so but due to lot of circuit nonidealities you might find you might not be able to hit this it might be slightly smaller so in that case you quantify the effective resolution using this Eno okay and as you see for finding the enob we rely on sinus sqnr so if I were to measure my sqnr what should I feed to my ADC I should feed in a sinusal signal at maximum amplitude and then at the output again I'll have some Quant sinusoid like this I mean it will be discret time I'm drawing it smooth because I'm lazy so this you'll get something like this and from this you are supposed to find what is this ratio which means you supposed to distinguish signal from the noise right and from the time domain can you distinguish water signal what is noise exactly I mean okay can say oh this looks like a sinusoid but you think it's exactly possible for you to say my signal has this power this noise has this power from time domain with respect to timeon theise be random we can no if that's okay but if I give a sinusoid it is going to quantize like this right this is what I'll get of course if you subtract this and this exactly you will find some random quation noise but the point is you cannot exactly measure what is the noise from this alone what to signal from this alone is that clear so in time demain you're not able to do so what do you do go to frequency domain so I always say if your mom doesn't give pocket money you go and ask your dad something like that so you have to do it in frequency domain and that's why it is important that uh you should be comfortable with basic frequency spectrum plotting you know Spectrum analysis and stuff H from linear definition of the quation error so like we first def quation error then we proceeded toward quantization so like what were we actually doing like we were like eliminating the concept of quantization error as a like no no quantization error is there that is treated as a random signal or a random noise so but the definition definition we saying that a subraction of the correct it is subtraction of that but that's what I'm saying right ideally I mean it is subtraction of that that subtracted quantity we are treating as a random signal La I mean it might not make any logical sense but that is the easier way to analyze and this holds quite good as we saw okay