EEVblog #471 - Overload Detector Circuit Design

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to fundamentals Friday well we take a look at a basic electronics building block circuit what we're going to take a look at today is a basic circuit that does overload and peak detection we're actually going to build up a circuit based on a requirement and then see what solution we can come up with yes there's more more than one way to skin this cat so we'll show you a couple of variations and then we'll build it up on the breadboard to see if there's any traps for young players as well so let's take a look at it what I've got is an amplifier here we're feeding the signal and we're feeding an output signal what we want to do here on this output is we want to check to see if this signal is going near the rails or it's going to peak we want an visual indicator iron LED to line up when the waveform this is our output waveform here the output waveform goes above a certain voltage threshold here both positive and negative because you want to get both peaks not just one side so we'll build up a circuit to do this step by step now when you're designing a circuit like this let's start out with the basic requirement of what we're actually trying to do in this case it's powered from a split 5 volt rail so plus 2.5 volts minus 2.5 volts the value doesn't matter at this stage but it may matter later when we build the thing up wait for it now what we've got here is we want to detect if a signal is above a certain threshold ie it's getting near the rails it's gonna clip because we want a visual indicator our product for example needs to have a LED on the front panel that lights up when the waveform gets near the maximum peak at positive or negative like this so basically it seems like a pretty simple requirement really we want to light up a lid when the voltage is above for example 2 volts here and below minus 2 volts down here so in this region down here we want the lead to switch on pretty simple how do you do it you've probably already thought of it a basic voltage comparator so let's take a look at our comparator here positive negative negative we'll have our reference voltage V now let's take the example of just the positive peak first let's treat both of these problems separately let's just solve this one up here first we've got two volts okay and we amplify as - 2.5 volts plus 2.5 volts like this here's our input signal and here's our output now we can actually drive an LED directly like this with this if we wanted to now when the it's working as a basic comparator because there's no feedback there you could use an op-amp or usually you would use a proper comparator designed for the purpose like an heirloom 311.00 efferent voltage on this pin here so when the input signal goes above 2.5 volts the non-inverting input is higher than the inverting input down here so our output goes high like that during this period here so it would go up high and then go back down low like that during when the sine wave is above that peak value up there and LED will light up for that brief period that it is high like that and that's all there is to it we've solved that problem but of course there's a couple of practical problems here the first one is that let's say this is an lm317 comparator out there it's actually got an open collector output so it can't actually drive a LED directly when it goes high like that because the output transistor inside the thing is only look like that inside the chip there's the output pin like this there's nothing inside it like that - there's no it's not like a totem pole output to actually drive that thing high so you know when if you used it in this configuration that lead would never light up because this output pin here can only pull low it can't pull high so how do you solve that easy you just change those around like that that's negative that's positive and you put your lid like that easy so all we've done there is just inverted the operation of this comparator so that we can use the open collector output on a typical comparator like the lm317 I'm so that's great we've got a solution for our positive point up there well kind of what about the negative point down here well we need an additional circuit to detect that too so here's the same circuit we had before I've just raised that redrawn it now using a dual comparator typical jellybeans part element 3 9 3 and that's the same as we had before our input signal our 2 volts reference and then our output go into our lead so that's exactly the same circuit we had before but now I've added another comparator in here to give us what's called a window comparator or more precisely an outside window comparator because what this circuit does is it will light up the LED when the voltage is above 2 volts or it is below minus 2 volts like that exactly what we want and that's why the these it's or because this output configuration here where you tie the two outputs to get to open collector outputs together on these comparators it's called a wired or configuration because this lab will turn on if this one is meets its condition or this one down here meets its condition it's a wired or configuration now let's take a look at some real scenarios on our input here let's say our input is 0 volts then this comparator down here the non-inverting input is 2 volts so it's higher than the inverting input therefore our output is going to be high or it's not going to below it be high if we actually had a pull-up resistor in there like that it had actually be high if this wasn't here okay so the same configuration here but our reference is minus 2 volts and you'll notice that the input goes to the non-inverting input this time and our reference goes to our inverting input so if input is zero volts that's actually higher than minus 2 volts reference remember because it's negative so this inputs actually higher bingo our comparator the output here is also going to be high high and high gives us high so our lead is also it was tied too high so our LED will not switch on so in the case of our zero volts input here or anywhere between that threshold of minus 2 volt plus 2 volts and minus 2 volts that's annoying there then our LED will be off and you can run through the scenario again where it's outside of these thresholds above these thresholds if our input is say 2.1 volts then the inverting input is going to be higher than the non-inverting input so our output will be low so our LED will switch on and it doesn't matter what this one's doing over here because that's just going to permanently switch on the LED and likewise if our input is minus 2 point one volts so it's lower than this it's beyond this threshold that we want to detect down here it's out in here this region then the same scenario this output here is going to go low and it doesn't matter if well they can't physically both turn on at the same time but even if they did it wouldn't matter it's a wired or configuration so that is a solution for a problem brilliant or is it now this window comparator is or window detector is that sometimes called is an absolute standard building block circuit you'll find it in any textbook but usually it's actually designed to detect within a window like that so it gives a useful output when you're within a window but in our case we're actually using it in sort of the opposite effect to detect when we're outside that window there so you can give it the name outside window comparator it's a bit more descriptive in what it actually does but really it's essentially exactly the same thing and you can actually swap the reference which is here this one could become the positive reference this could be the negative reference depending upon your output configuration that you actually wanted but we won't go into that now I said we weren't finished yet we haven't fully solved the problem why because what if this the frequency of our waveform is very quick or we have a very short pulse which just goes above you won't have time to see it yeah the little come on let's have very fast response times practically instant but your eye won't see it if it's all you know if it's a 100 microsecond pulse or something you won't catch it so what we want to do is add an extra circuit on the output here that even if we get a very short pulse which goes above or below our thresholds we want that to keep the lid on for a certain amount of time ie we want a pulse stretcher so how can we do a pulse stretcher well as always there's more than one way you can skin that cat and a couple of ways to do it you can do a triple five hour timer to do a one-shot pulse you could use a 7 4 HC 1 2 3 monastery trigger or mana stable to generate and stretch that pulse but we're going to do it a bit simpler because these solutions you know are triple five time you need a quite a few extra parts on there and stuff like that 7 4 HC 1 2 3 ah yeah it's okay but it's an extra chip you need some extra parts whereas let's say we had an LM 393 if we went for an lm339 quad comparator what a couple of comparators left over so let's take a look at that or more specifically let's take a look at an RC pulse stretcher so what I'm going to do here is take this output so pretend this lead doesn't exist anymore we're going to put it somewhere else we've got our wired all our output here and let's actually have a cap going to ground you'll see why in a minute and then we'll have a pull-up look that's not a very good resistor is it that's pretty crap there we go we're going to have a pull-up resistor and let's make that say 10 Meg quite a large resistor because we want quite a large pulse time and then see down here we'll be able to work out a value for Seibert basically what we want is this output signal here we already know that a wired or output is going to give us a pulse a low pulse it's going out with the open collector output it's going to pull that low or short out the capacitor there actually I made a mistake there that doesn't go to ground because it goes down to the negative rail so let's pull that down to the negative rail there got to be careful when you're working on these split supplies you can do little brain farts like that now let's do that minus 2.5 volts there but you can actually you know you can think of this as a single level system really instead of a split rail if you want to but anyway that's that's just argument's sake that's the negative terminal there now now why adore output goes low gives us a pulse when our signal goes outside of that range either positive or negative so it shorts out what it does is just shorts out that cap as soon as the it detects that over range or overload indicator so what happens when you short out that cap well there's no more charge on it so it's got to charge up how does it charge up because this is open collector output it charges up via the 10 Meg resistor so when we get our pulse this cap will slowly start charging up until well it gets to full charge now here's where we get into a little bit of math but stick with me now where the capacitor is obviously going to charge up you've seen the capacitor charge waveform like that charges initially from 0 because this open collector transistor short at the cap so it starts from 0 and it charges up like that and the formula for that V at any instant in time is 1 minus e to the power of minus T on our c-more nasty little formula thankfully unless we're really after a precise application we don't care about this formula cos what we want to do is light up a lid for a bit who cares if it's on for half a second or three-quarters of a second or a second right good enough near enough so you can just use the standard RC time constant formula tour the time constant is the value at a specific value of 62.3% of that charge voltage and it's equal to easy to remember the time constant r times c resistance times capacitance simple so what's a practical LED on time here about a second nice around value you can see that lights up for a second not a problem what very capacitor do we need with a 10 Meg resistor well you just rearrange that formula capacitance equals tor on our or one second on 10 Meg resistance a hundred nano farad's what I coincidence a hundred nano farad is a typical bypass capacitor value so you're probably already using that up here to bypass your chip like that not a problem so you've already got in your bill of materials beauty so there you have it this output here is going to have well we'll get to that point after one second so all we need is another circuit here which detects that threshold its threshold again and then lights up well led during what that time period there - there - easy how can we do that well a very simple way is with an inverter like that and our inverter can directly drive our LED like that so when this output here is low this output here is going to go high sorry inverter has a not on the output of course an inverter that once it gets to a certain threshold level it lights up the lid but of course you need a Schmidt inverter in there like a 7 4 HC 1 4 for example because a Schmidt has a very specific defined threshold level so it won't oscillate or do something weird above or below that it'll just cleanly switch the lid off and on and we mentioned before we've got a quad comparator lm339 so we actually have a comparator left over so we can actually use that as well so we don't worry about the Smitty inverter anymore we can actually use a third comparator up here too switch on the LED so when this is low if we have a inverting and non-inverting input up here to a voltage threshold which if you want the exact time period of one second you'd have to set it to null point 6 to 3 of V I've got of your voltage arts total voltage supply of course to get that exact one second threshold there and if you did that then that lead would turn on during that period they're very simple and of course that's the trick whether or not you choose to use a third comparator up here or you're willing to choose to use a Schmitt inverter here getting the exact threshold level for the exact time period you what if you want it really really precise you have to be careful but because we're just flashing an LED it doesn't really matter we can you know just use that RC it's going to be near enough who cares if it's one point two seconds or it's 0.6 seconds or something like that good enough so this is one of the examples of just back-of-the-envelope calculations that can get your circuit working like this you don't need to worry about this complex formal in the charging graph we got does the time constant is you know it going to be roughly R times C and you can pick some you know common e 12 values or something that is just going to do the job and of course the reason that we're using an extra device here instead of say connecting the LED directly on here is because these are high impedance input so they're drawing no current so our charge time is going to be accurate if we just tried to put LED directly on here another transistor for example like a a you know bipolar transistor on there it's going to take base current and or the LED is going to take current and it's just not all going to add up so you know really it's better to use a proper buffer here there are essentially acting as our buffers on this a high impedance buffer on this Ash RC time constant point so whether or not you choose to use that our third can like a quad comparator for example instead of the dual comparator because you can get these in a dual package or a quad package and have one left over but then you've got to generate the voltage so you're going to need a couple of extra resistors up here for example so you know it's all a bit of a trade-off of whether or not you might want to use the Schmitt in because you have five inverters in your package left over you might be able to use them somewhere else in your design it's one of those trade-off things it depends on your implementation and how you want to use it common values you've got you know you might choose a 10 Meg up here because well we want to make use of the additional capacitor down here generally the resistors are going to be more versatile so you choose the 10 Meg up here over say a very high value cap up here if you didn't have 5 suitable height value caps already in your bomb and it's going to be cheaper to buy a resistor than it is to get a high value cap so you're better off going 10 Megan and a hundred in there instead of you know 100k and you know tens of micro farad's down there for example so just an interesting trade-off scenario that you typically get in designs like this so as I said there's more than one way to skin this cat we've got a solution here it may or may not be suitable for your particular design people might go for a discrete transistor solution here they might use something else instead that window comparator etc etc if you wanted a clipping thing to see that you're actually waveform actually distorted and clipped that's a slightly different requirement again instead of just oh it's getting near the rail switch on the lid kind of seeing so you know just this sort of basic functionality could be done half a dozen different ways all right breadboard time will make it very quick exactly the same circuit configuration as we had before with the arch MIT inverter option instead of the comparator 7 4 HC 1 4 rated from 2 volts to 6 volts so perfect for this application dual comparator LM 3 9 3 jelly bean stuff once again rated for 2 volts upwards perfect for this application a positive and negative supply is going to be 5 volts total and here's this meter here is measuring the power supply total it's a split supply of course positive and negative so it's plus minus 2.5 volts relative to this ground point here and then we've got our lead on the output we have our pulse RC pal strecher 10 Meg 100 nano farad's you know time constant roughly a second or there abouts and then we've got a resistor divider here from the rail giving us a negative one point two five volts reference and a positive one point to 5 volts reference I just chose the split values it's just nice and even we're splitting the rail in half so if the input signal which is this pot here goes above or below 1.25 volts LED should turn on let's try it here we go off by the way this is the voltage on the pot here so this is the voltage on the input let's go on the positive side 1.25 volts it should here we go very close oh there we go well within half a be stick very close there you go as close as you can expect so not a problem let's go down negative - bit faster - 1.25 it'd be better if I had a like a 10 turn pot here but I only got a single parent turns bit crusty but there you go it just turns on about 1.2 - or there abouts close enough look at that perfect so there you go over that full range a switches and in the middle switches off of course above 1.25 or the voltage set on those reference pins it switches off works perfectly beautiful now let's just test the pulse stretcher there what I've just got this disconnected so I'll just temporarily just tap that there we go tiny little pulse going in and we're getting our lead for all my on for basically a second near enough so that works pretty much perfectly because the Schmitt inverter threshold you know is around about that time constant really give or take so we are gonna get a 1 second there fantastic now if we have a look at the data sheet for our LM 3 9 3 then look you know it's pretty much ideal for this application voltage range goes down to a tiny 2 volts and that can of course be a what a plus minus 1 volt rail the op amp doesn't really you know know the difference between a single supply rail and a plus mine and they you know a split supply like that goes right up to 36 volts yet not a problem in this application we couldn't go that high cuz we're limited by the volts of the seven for hc1 for inverter at low input bias current 25 nano amps so that means you know it's um it's basically taking you know nothing from the input we can have very high value resistors here I've got hundred k's in here oh by the way if you can't tell read that if you're not watching in HD these 100 keys and you know it's this effectively no input current there no input current from our input signal it's a you know it's really quite nice minimum maximum offset voltage plus minus three villain millivolts yeah it's not that great but for this sort of application ah doesn't matter a rat's really the offset voltage input common mode voltage range includes ground which means our input can go all the way down to the negative rail not a problem fantastic so let's try and test this down near two volts and see what we get alright we've got ourselves a 2 volt supply now so plus minus 1 volts of course our seven 4hc can work down to that our LEDs not going to be very bright of course got the same value drop a resistor and you know it's a red LED 1.8 volts or there abouts but we still have enough to light it up because 7/4 HC is across the jewel and what across the full supply so that's working down at 2 volts this comparator is supposed to be working work to down to 2 volts well let's try to our LED is off at the moment there's our 2 volt supply plus minus 1 there's no input voltage now because our threshold voltage is going to change now so we expect half of the split rail so nought point 5 volts well plus 0.5 volts minus 0.5 volts so let's go down to minus not point 5 volts and it should switch on at around about well hopefully let's try it will it will it is it still gonna be yeah it's still still operational round about the naught point to five volts yet there we go point 5 volts not a problem so that works a treat you can see it's a little bit dim there of course now what about on the positive side let's try it so your eyes should turn on at + OE should have turned on it's already switched on look it should have turned on nor point five volts but it doesn't it switches on at around about you saw at around about zero there yeah we hang on there we go so you know all Matt let's call that zero it's switch nine zero volts and not the half volts we expected why trap for young players now the trap here is that this is not a rail-to-rail comparator it is just your regular stock standard ancient bipolar comparator very simple and it has a limitation in its common mode input range which we have a look at our electrical characteristics here LM three nine three down here so this group over here where is it we've got our input common mode voltage range here we go minimum of zero of course you'd expect that because if you remember way back at the front here it said that it could sense to ground it could sense an account common mode range includes ground there it is and it these specs actually back up that top level claim it does go there it is it goes down to zero there but look at the maximum side of it is V plus minus 1.5 volts so it's your supply voltage V plus minus 1.5 what that means is effectively your input signal on your circuit here this one here can't go above one the supply voltage minus 1.5 volts and that's why with a supply voltage of only plus one volts there and minus one volts relative to that ground reference point when we're feeding in zero so that's only one volt below the positive rail so it's a wonder it even worked that well at all it should have been actually worse than that really according to the datasheet but we were lucky enough to get you know at least up to zero volts there so that's why it worked on the negative side this value up here it worked at - nought point 5 volts our reference will find at this point here our reference point +5 volts it just could not get the common mode input range didn't include right up to the supply so that's a trap for young players that's why it didn't work at all at those lower voltages something to watch out for and if you think about it it shouldn't have actually worked with our 5 volt supply either because then we had a supply voltage of effectively a two and a half volt and our reference voltage down here was 1.25 well that's only one point two five volts below that positive rail so it should have actually been one and a half volts so it shouldn't have actually worked at all but it did because the the practical comparator is you know a bit better in this particular application than the datasheet says with that nasty trap their common mode input range this applies to our op amps as well not just two comparators very key spec for an op amp and a comparator so what's the solution well we could just use an expensive rail-to-rail comparators at just does the business not a problem but you know it's not a jellybean part may not be in stock whatever yada yada more expensive um we don't need to do that we can just solve the problem with some extra resistor dividers so instead of our input voltage going straight in we actually divide it by a significant amount so I put in a 1 Meg series resistor and a 270 K to ground so that will act as a divider in there and also these values I'll change here a hundred K and 22 K so it's a very similar divider ratio this one's just slightly higher than the others so that means when we get near the peak voltage you know ninety percent or something it'll turn on our LED and likewise down here so let's change the values and see if it works now so instead of asking the op-amp to sense the input over the full range what we're doing is just dividing the range down over a much smaller area so we always have the Headroom in there above the positives supply and just a protip here when you're using bread boards like this and you're getting your resistors from these bandoliers they can actually have glue inside there that when you pull the resistor out it gets stuck on the ends there and when you plug that in they may not make good contact with the springs inside so just trim those off like that and it'll work a treat all right let's give it a try now back up to five volts again just to make sure it works at five volts and we're not sure the exact voltage but it should be down around one point well near to the full rail actually so there we go so not two point five so it's around about or negative there you go around about negative two point yeah two point one or something like that so our positive side should be plus two point one should be exactly the same and is it oh yeah you know near enough good enough okay not a problem now let's wind it down to two volts now unfortunately at 2 volts we're not actually gonna get a free lunch here because we're we're still working around that is that reference that ground reference points so we haven't really shifted that so we're still only going to get that plus 1 volts relative difference so unfortunately at 2 volts it's not going to make any difference let's try the negative side here it's around about it right it should be 1 volt it's going to around about well one one volt is the maximum supply there it is and it turns on it about yeah point seven five or something one point eight and we expect it to turn on at plus point eight as well but no it doesn't it's down near zero again because we've got exactly the same issue where this helps though this divider helps is that the higher voltages where you need to sense near the input you know how we had 100k 100k here before well if we had you know a 10k and 100k and we're sensing it right near the positive or here since he right near the positive rail it wouldn't have worked before with those aren't at even at five volts because L it would have tried to sense the input there near five volts so this technique doesn't actually help down at 2 volts we'd have to shift everything it gets real nasty but at slightly higher voltages it's always going to help you when you're trying to detect up near the peak range because instead of the input having to detect up here now it's only got to detect down here so it gives you that extra voltage margin in there and just to prove that what I've done is I've removed my divider there and I swapped these two resistors and these two around so that the 20k 22 K is on the top and 100 K is on the bottom so it should sense with a 5 volt rail at around about 2 2 volt mark instead of 2.5 volts peak does it well let's have a look might that's the full -2 let's see where it switches off yet switches on around about that minus 2 volt mark and we'd expect just like before it was symmetrical we'd expect on the positive side to also switch at 2 volts but you'll find that it won't will it make a liar out of me I don't think so there we go one point there it is 1.5 volts instead of 2 volts so even have a relatively high supply voltage of plus minus two and a half volts or 5 volts total then this thing isn't going to this basic circuit as we saw without this divider isn't going to work at near the rails there it worked when we had 100k 100k and we're only sensing half of the rail voltage or 1.25 volts but when we wanted to sense 2 volts not sorry we are sorry down here I keep getting these confused if we want to sense 2 volts here sorry our supply voltage is only two and a half that's not that some you know not within the common mode input range so it only worked as we saw that one volt our difference 2.5 minus one point minus 1 is 1.5 and that's where it's switched on because that is our common mode operational or a practical operational input range but if you want to go just by the datasheet of course where is it then you'd have to allow the 1.5 vaults full but in this case we're getting around about a volt in practice measured and I'd love to be able to show you the charged waveform on that cab there but I can't because my scope probe times 10 is 10 meek input impedance 10 mega 10 Meg as you can see look the lid just stays on permanently unless I well there you go stays off and then once it triggers on it just stays on because of the bloody scope probe but if I change those values to a hundred K and 470 nano ferrets then tada there we go but of course that won't be entirely accurate as the real circuit your timings going to be a bit off because of the 10 Meg still 10 Meg loading of your scope probe so just be careful there our practical effects when you probe things so there you go I hope you enjoyed that that's another fundamentals Friday if you want to discuss it jump on over to the eevblog forum that's the best place to do it and if you do like this segment please give it a big thumbs up yes it took longer than I expected yes I said I'd keep it to ten fifteen minutes last week I did for the theory part this one it turns out the theories about you know just under twenty minutes I'm not sure how much longer practical it could be thirty minutes ah what the hell catch you next time [Music] you
Info
Channel: EEVblog
Views: 74,480
Rating: undefined out of 5
Keywords: fundmanetals friday, circuit fundamentals, circuit design, tutorial, how to, breadboard, window detector, window comparator, schmitt, schmitt inverter, comparator, lm311, lm393, lm339, capacitor charging, pulse stretcher, voltage divider, prototype, schematic, rc timer, time constant, measurement, multimeter, oscilloscope
Id: b4Zh-RYRUq4
Channel Id: undefined
Length: 35min 0sec (2100 seconds)
Published: Fri May 17 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.