Comparators: The Building Blocks of Analog to Digital Converters (ADC)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is a comparator well it'll take about 30 seconds to answer that question it'll take a little longer to explain some of the applications [Music] so what we're going to talk about today is this thing called a comparator and if you look at that name that pretty much defines exactly what the circuit is what the purpose of the circuit is it compares things right well at the heart of a comparator is something called an open collector circuit now an open collector circuit is nothing more than a switch and this switch when put in series with the resistor between some sort of a positive voltage and 0 volts we can use this as a binary output or a binary signal and the way it works is this if you're familiar with this idea of a voltage divider all we've got is a voltage divider when the circuit is open when the open collector circuit is open then what we've got is basically infinite resistance here and a finite resistance here which means that for all intents and purposes this binary output is connected to our positive voltage giving us a logic one so when the switch is open that's a logic one when the switch is closed it's connected to zero volts a logic zero and what we've got is a binary output of zero of doesn't really make sense for those of you who are thinking about a binary switch close would be true and open would be false actually the way it works is when you have it closed it's false when you have it open it's true so let's talk a little bit about how these open collector circuits are used in a comparator really a comparator's output is nothing more than an open collector it's what controls the switch so i'm going to draw the circuit diagram for a comparator all right now this output here is the output of that open collector switch one of these inputs the one that's identified with the negative sign that one is called our reference voltage i'm going to just simply call this vref and then i've got my input voltage vm now the way it works is that the comparator the circuitry inside of there and by the way these are analog voltages the circuitry inside of there says okay if v ref is higher than vn i'm closing the circuit if v ref is lower than vn i'm opening the circuit so v in greater than v ref what we've got is our output is going to equal 1. so our output is going to be 1. if v in is less than v ref sorry about the squeaky pin then our output is going to be 0. now some of the applications when it comes to these comparators well there's a lot of them in fact let's just just talk about a really simple type of application there is a device called a thermistor okay maybe there's an o there all right now the way a thermistor works is well it's really a variable resistor a resistor that changes except instead of us being able to control that resistor with some sort of the position of a knob temperature changes its resistance and so what we do is we put some sort of a positive voltage i'm going to go ahead and put vcc here and in line we'll put this thing called a thermistor a resistance a variable resistance t r sub t and then we'll have some sort of a reference resistance we'll just call this r sub s and this point right here that voltage as the temperature changes this resistance across this thermistor is going to change and the voltage is going to change now if we run that through some sort of an amplifier and then run that in as the positive connection or the input connection for our for our comparator and then come set to our reference voltage i'm going to connect that also have vcc and then what i'm going to do is connect this to some sort of a variable resistor that you can change with a knob okay so we've got two voltages here this reference voltage is a voltage that's controlled by some sort of a variable resistor a knobs or a slider of some sort so you as the user can change the voltage here the thermistor is what's changing the temperature is what's changing the voltage level for this circuit here and when you compare them if the voltage coming in from the thermistor is higher than the voltage that you've set on this resistor we will get a logic one if the voltage coming in from the thermistor circuit is lower than the voltage that you've set with the resistor we get a logic zero sounds like a way we can turn on and off an air conditioner a thermostat all right now what i really wanted to talk about in terms of examples today was this thing called an analog to digital converter a way that we can take analog voltages and convert them to digital voltages for use with our processing systems now before we start talking about analog to digital converters these types of systems that convert an analog voltage to a digital number right we need to talk about something called a sample and hold circuit now a sample and hold circuit plain and simple what it does is you get an analog signal and if you remember analog signals well those are changing all the time right you've got this analog signal whether it's temperature or audio waves you know the compression and rarefaction levels for audio or color whenever you're looking at video we've got some sort of a continuous signal well if that thing is changing we can't really do a good measurement so we need to run it through this sample and hold circuit so we get this kind of a latched analog value now that latched analog value is what's going to be read by the analog to digital converter now the vast majority of these analog to digital converters guess what they're made up of comparators let's talk about a couple of them right now now the first type of analog to digital converter or adc that we're going to talk about is something called a flash adc that idea of flash kind of implying it's fast it turns out that this is in fact the fastest way to convert an analog value to a digital value problem is it's also the most expensive but let's take a look at how it works what we've got and if you remember from our um discussions on analog to digital conversion we've got some sort of and i don't know why i put a positive there because it doesn't necessarily need to be positive but what we've got is a maximum voltage an upper level a top level that we can read that this analog to digital converter is capable of reading and we also have v min the lowest value that this analog to digital converter can read now connected between these is a series of resistors a bunch of resistors now the key is is that all of these resistors are exactly the same value doesn't really matter what the value is but they're all the same value and what we do is we have comparators that are connected to each position as the reference the v ref remember this minus input and so we've got each one of these levels connected to our v ref for these comparators all right we keep coming down here let's see v ref and vref and so on all right now if you remember our discussion about analog to digital conversion if our input voltage if the value that is sampled and held so coming from our s and h our sample and hold circuit if that value is equal to v min or less than our digital value is going to be all zeros if the value that we held is equal to our v max our value is going to be all ones all right now what we do is we go to the input of each of our comparators and i'm not sure how well i'm going to be able to draw this what we'll do is we'll come in over this way drop that down connecting the input the held voltage to each one of the input levels on our comparators let's say that there are 255 resistors between this point and this point we have 255 resistors between v min and v max then what has happened is that our voltage level is going to be divided equally into 255 different levels so at this point right here we're going to have 1 over 255 of our range at this point we're going to have 2 over 255 of our range and so on so what happens is is that at some point this sample and hold we're going to go from comparators where the sample and hold value was greater than two comparators above that where the sample and whole value was less than and so we run this into a device we run all of these inputs into a device called a priority encoder and what that priority encoder does is it tells you which number was the which number was the highest one with a one in it okay so if all of these are zeros that means that the sample on hold value was less than or equal to v min and then so all of those all of those values being zero will output a zero if all of them are one then that means that the v max was greater than all of these values and the comparators all of these different resistance all of these different values on this volt long voltage divider then the output's going to be all ones all right so there's one idea and so you're going to get your digital value coming out of that priority encoder so there's one way that we can do an analog to digital conversion using comparators let's take a look at a second way now this next way is something called a successive approximation uh adc let's see just put in there all right now once again we've got a sample and hold circuit and so it's taking our analog voltage and it's going to hold it it's going to grab a hold of a value to hold on to it and we're going to run this into a comparator directly a single comparator all right now so that is our input voltage but what's going to be our reference voltage well it turns out what we're going to do is we're going to have well it's the opposite of an analog to digital converter it's called a digital to analog converter and that is going to be driving our reference voltage now what we need to do with this successive approximation ad adc is we've got this sample and hold circuit and what we're going to do is we're going to test values we're going to create values to put into this digital to analog converter so i've got some sort of a set of digital inputs here and what this is going to be driven by is just some sort of a logic and we'll talk a little bit about what that logic is equal to now the input one of the inputs to this logic is the result of the comparator now the way this works is that whenever we get this sample and hold the logic is going to put a value that is in the middle of our range remember we've got our full range going from v min up to v max we're going to pick a number in the middle of that range and we're going to compare it if it's less than half what we're going to do is we're going to get a in other words if the sample and hold value is less than half then what we're going to do is get a 0 here and we're going to say oh okay so it was less than half so we're going to pick a value that's halfway in between that and then we're going to pick a value that's halfway in between the ranges let me show you with a little bit of a demonstration so i have and this is going to be done over time so this is not as fast as the flash but it's a lot cheaper so i've got something i've got v max right that's the top level that's the level that the analog to digital converter is going to output and all ones for and then i've got a v min that's the value that the analog to digital converter is going to output all zeros for right so what's going to happen is that the logic is going to output the value 1 0 0 all zeros so that's pretty much the halfway point and let's say that the analog value that we're reading is right here this is actually v in right now we are going to in the logic output one zero zero zero zero zero zero and so forth and that's going to be a point exactly halfway so our d to a converter is going to output this value here and the comparator is going to say ah you know nope the value that we have sampled and held is above this so we know that the first bit of our a to d value is going to be a one so the next thing we do is we make the next bit a 1 and by making making the next bit a 1 that comes halfway in between this range so we're going to change the value coming out of the d to a converter to that point now that point right there is 1 1 then a bunch of zeros right the comparator is going to say nope the sample in hell voltage that's less than so the next bit's not a one the next bit is a zero and so we go to test the next bit and since the next bit is a zero what we're going to do is we're going to divide this in half and that's going to bring us down here and so this value right here is 1 0 one zero zero right and that value when compared to our input voltage the input voltage is higher so we know that that next bit it's higher than this value so we know that that value has to be a one and so we get to the next position and we take this range right here we cut it in half and this value right here is one zero one one zero and so forth and we notice that our red value or our compared value is less than so we know the next bit is a zero now we keep doing this moving down each bit of our d to a value trying to get closer and closer in other words successfully successively approximating it and eventually we'll get as close as our bits allow us to get all right that successive approximation also uses a comparator let's take a look at the third one now our third one is referred to as the integration adc and yes when i say integration i'm talking about the calculus type of integration but don't worry you don't need to know calculus in order to know how the integration adc works it's pretty simple what we've got once again is our sample and hold so we've got our you know our latched value right now what we do is we have well we've got this ability to switch back and forth between the sample and hold value and then some sort of a known reference voltage now this known reference voltage is a fixed voltage we know exactly what it's supposed to be doing exactly what level it's at we the the sample and held value we don't know exactly what that is well this is run through what we refer to as an amplifier an op amp all right and i'm going to draw the circuit up here i don't expect you to really know much about what that value is or what that that how that circuit works i'm going to explain how it works in just a second and then it runs into a comparator that we've got connected to ground or zero volts so we've got zero volts at this end and then we this runs through some logic that does timing all right now how does this system work well the key is is that this op amp right here does what we refer to as integration and if you know about integration and by the way this known reference voltage is a negative voltage and if you know about integration you know that when you integrate something what you're going to do is if i've got a constant level like if i have a one when i integrate it what i'm going to do is change that function to a slope to a to a function that has a slope of one if i have a negative five and i integrate negative five i'm going to get a slope of negative five and so all this integrator circuit right here does is it creates an output with a slope equal to its input all right so let's erase this because i didn't leave myself a whole lot of room and show you how that works in terms of being able to determine what the analog input is so if we're going to look at the output and once again we've got a little graph here with respect to time if i'm going to look at the output what i'm gonna gonna do is this is the output from from the amp from the op amp all right now what i've got is i'm going to start out with my op amp having an output of zero now if i connect it to a very low analog input so if you remember from the earlier diagram which i've erased what i'm going to do is i'm going to switch that switch so that the op amps input is connected to the value from the sample and hold circuit all right and so if i have a very low voltage coming into that sample and hold circuit i'm going to have a circuit with a very low or output voltage with a very low increase a very low slope if that voltage is a little higher i'm going to get a value that has a higher slope if it's even higher i'm going to have a value with an even higher slope so in the end what i've got if i hold on for a fixed period of time so this is a fixed period of time then the output from the amp is going to be proportional to the value that's coming from the sample and hold circuit now i switch that after this fixed period of time i switch it so that my my op amp is now connected to that reference voltage that that that that input to my op amp is now connected to my negative reference voltage so i'm now going to get a slope down i'm going to get decreasing voltages but it's a fixed negative voltage so the slope is always going to be the same the rate of slope is always going to be exactly the same and so you'll notice that depending on how high we got with the sample and held voltage it's going to take different amounts of time for that to decay all the way to zero and so depending on how much time it took all you got to do is just simply measure how much time it took and so the amount of time amount of time to get to zero well that tells you what your analog value is okay and that's really all there is to it so although it's been kind of a whirlwind of going through a bunch of analog to digital converters hopefully you got an opportunity to see a little bit about how we use comparators in our everyday circuits
Info
Channel: Intermation
Views: 22,694
Rating: undefined out of 5
Keywords: comparator, adc, analog, digital, converter, reference, voltage, flash, embedded, system, design, divider, open, collector
Id: CQapmDx5oV0
Channel Id: undefined
Length: 23min 4sec (1384 seconds)
Published: Thu Feb 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.