Placeholder Image

Subtitles section Play video

  • There are a lot of ways to build a clock circuit for a computer.

  • But you know, we want something that's relatively flexible.

  • We can adjust the speed.

  • You know, we don't want to run too fast.

  • We wanna be able to see what's going on.

  • And so I'm gonna use the 555 timer.

  • This is a classic integrated circuit here, the Triple Five timer.

  • And that's that's what this chip is here.

  • And so you can tell Pin one here is by the defense And 12345678 And right now I'm powering this with just five volts coming in from a cell phone charger that I've cut into the USB cable pulled the five bolts out and the power of the chip power comes in five volts here on pin eight and ground to pin one.

  • You can actually go up to 17 volts or 16 bolts or something.

  • With this chip, five volts works and to control the timing, you've got to resistors and a capacitor.

  • And so the first resistor here is going from five volts to pin seven.

  • This is a one K home resistor and then from pin seven to pin six.

  • I've got ah, 100 k own resistor and then pin sex is connected around a pin, too.

  • And then from pin to ground, I've got this capacitor and this is Ah, this is one micro fared capacitor and you could see the positive side is connected here to pin too.

  • So the negative side of connected to ground make sure that's in the right way.

  • And so those resistors, in the capacity of control the timing, we'll see how that works in a minute.

  • But the output of this chip is on pin three, and so that's just connected to this led.

  • And you know, the output can drive a fair amount of current.

  • So we want to make sure we have a current limiting resister.

  • This is just a 220 ohm resistor here limiting the current through the led so we don't burn up our led.

  • So how does it work?

  • Well, good place to start, of course, is the data sheet is a data sheet for the 555 timer and you can see they actually give you a whole schematic of what's going on inside that chip, which way won't go through all that.

  • But they also give you Ah, bunch other stuff in here.

  • One is this sort of block diagram that gives a little higher level view of what's going on.

  • And so you can see there's, Ah, a couple Comparator Tze there's you know these three resistors.

  • There's a flip flop that these comparator is connect into.

  • And then there's this output stage.

  • So this is this is pretty interesting.

  • I don't personally like the way that this is drawn.

  • It's kind of drawn to line up with pins here.

  • They give you a different version of it a little bit later on in here.

  • This is a sort of a different view of the same thing.

  • But I don't really like this one either.

  • It doesn't share.

  • That actually should be a connection from here to this comparator and you don't really know what these inputs are is like Okay, there's three things going into the flip flop.

  • But what what are they?

  • I don't know.

  • I don't particularly care for these diagrams.

  • Eso I drew up my own That I think explains a little bit better and you can see just like those other diagrams.

  • There's the two Comparator Tze there's ah, flip flopped actually an s r latch.

  • I think it's probably a better way to describe what this thing is.

  • Um and you just kind of walk through what's going on here.

  • So everything inside this blue box here is is kind of what's going on inside the inside the timer itself, and then the green stuff that I've drawn out here is is the rest of the circuit.

  • So we kind of go through and look at what we've got.

  • So this one K is the one k resistor going from five volts to pin seven and then between Penn seven and six.

  • That's this 100 k resistor here.

  • And then you see pin six and two are connected.

  • That's his little green wire gone around here and then between pin too and ground, we have this one micro Farid capacitor and then over here we have our led and this is our thing.

  • It was a 220 ohm resistor over here.

  • So this is this is our circuit and understand how it works.

  • We can kind of look at what's going on inside the Triple five timer.

  • So I just start by looking at this this path through here, you can see we've got our plus five volts up here.

  • And then, of course, I ground down here.

  • Zero volts.

  • Um And then there's these three resistors, and I think each of these resistors inside here is five K's, five K five K five k.

  • I think it's a complete coincidence.

  • That's a 555 timer, but anyway, but what they do is they set up a voltage divider.

  • And so, at this point here, you're you've got 1/3 of the voltage between zero and five volts.

  • So that's, you know, one in 2/3 volts.

  • 1.67 volts will call it.

  • And then at this point here, we've got 2/3 of our five old supply.

  • So this is 2/3 is 3.33 volts.

  • And so you got this.

  • Vultures dividers.

  • Five volts.

  • To go through this resistor, you're down to 3.3 years.

  • Other resister you down to 1.6667 whatever.

  • You go through those other resistor and you're down here at ground zero and what that does that sets up these inputs for these Comparator Tze And the way the Comparator is work is there's a positive input in a negative input.

  • And if the positive input is above the negative input than the Comparator switches on and the output is ah is five volts And if the positive put is below the negative input, then the current switches off and the output here is zero votes.

  • So let's think about what happens when we when we turn this thing on, get this out of the way here for a second.

  • So what happens his Let's assume that these inputs over here, this is all zero volt.

  • So we've just turned this on.

  • This stuff is zero volts.

  • Um, so we've got zero votes coming in here that is below 1.6 volts.

  • And so this comparator turns on and so that triggers the set pin of the RSR latch.

  • And if you don't know what s R latches, I've got a video on that, but basically it's gotta set in a reset.

  • And when the set goes high than the output comes on and when the reset goes high, then the output turns off.

  • And then, of course, if they go lower than it remembers its last state.

  • And there's both the output here.

  • And then there's the inverted output here, which is which is always the opposite of our output.

  • So we have zero volt here.

  • We got zero votes here.

  • This Comparator will be on because zero is below 1.6 and this Comparator will be off because zero is not above 3.3.

  • So this one's off.

  • This one's on and said the latch is gonna be set, which means our output will be will be on.

  • So the led you'll be on, we're gonna start on So we'll do a little, uh, graph here.

  • And if our output is on than that are are not output are inverted que here is gonna be off.

  • And so this transistor will be off, So nothing, nothing's gonna happen here.

  • We can kind of ignore this this whole discharge thing here for now.

  • So what's gonna happen is we're gonna have a current flowing through this one k resistor through the 100 k resistor and into this capacitor down here, this one microphone capacitor and a capacitor is going to start to charge.

  • And so, if you look at the charge on the capacitor, which is also the voltage here going into pin, too.

  • It's gonna start move.

  • This gets here.

  • Uh, it's gonna start here at zero votes, and it's going to start to climb, and it's gonna keep climbing and climbing and climbing as this capacitor charges.

  • And so what's happening is the voltage here is increasing, and at some point it's gonna increase above 1.6 volts.

  • And if it's above 1.6 holds, this comparator will turn off because 1 26 is no longer above, uh, whatever this voltages compared to turns off, that's fine, right?

  • Because the latch is gonna latch its output.

  • So we're not We're not asserting the set pin anymore this set signal, Um, but, you know, if we haven't reset it yet, it's still gonna be We're still gonna have a high output here, but eventually this voltage is going to reach 3.3 volts.

  • It's gonna it's gonna maybe go a little bit above 3.3 volts.

  • And at that point, uh, you know, that voltage is gonna be above 3.3 volts and this comparator will turn on because the positive input here is above the 3.3 old negative input.

  • Um, and this will turn on and this will reset the latch.

  • I guess I didn't give myself enough room here, so Nor that s so this is our output output is gonna get reset when this hits 3.3 volts.

  • Yeah.

  • So this is this is, like, 3.3 volts on our capacitor here.

  • Maybe this down here is 1.6 volts, and we'll say this is zero.

  • So we started at zero.

  • We went through 1.6 volts.

  • You know, nothing happened.

  • We turn off the set pin with state latched on, and then we get up to 3.3 volts, and at that point, our output turns off.

  • But the other thing that happens is are not output.

  • Are are inverted output.

  • This turned on, and that's gonna cause current to flow from here through into the base of this transistor.

  • And that'll turn on this discharge transistor.

  • And so then what happens is you know, current can now flow through the one k resistor through this discharge to ground.

  • Okay, that's that's not very exciting.

  • But what's more interesting is that current can also flow from the capacitor through the 100 k resistor.

  • So before we were charging the capacitor in this direction Now we're discharging the capacitor current is flowing from the capacitor through the 100 k resistor and through this discharge into the capacitor is going to start to discharge and it will discharge for for a while.

  • And of course, little you know, Soon as it started charging, it'll drop below the 3.3 volts and so the reset will turn off.

  • But again, this is latched, so nothing happens.

  • But eventually the capacitors of voltage will drop below 1.67 volts.

  • And now with this below 1.67 the set Comparator turns on and it sets the latch again.

  • And so when we set the latch, when this gets down to 1.6 volts, we set the latch, we turn the output on.

  • We also turn the discharge transistor off.

  • So we turn this off so we're no longer pushing current through the base of the transistor into this transistor is off and so no longer is a capacitor discharging.

  • We're back into the state where the capacitor is charging again.

  • Pastoral charge.

  • Our output is on and eventually pass will get back up to 3.3 volts.

  • This will switch.

  • We'll start discharging again and this will turn off pastoral discharge.

  • It's off capacity charged discharge.

  • And so we get the capacitor is charging and discharging kind of like this, but our output here is this nice, clean square wave.

  • And that's what we see when we look at circuit here we see our led flashing.

  • And of course, we can control the rate that the lady is flashing based on the values of these resistors and capacitors.

  • Right, because, you know, the rate is is is, uh, set by how quickly this capacitor charges and how quickly it discharges.

  • And so how quickly a charges is going to be dependent on you know, these two resistors and capacitors.

  • So the bigger these resistors are, the slower it's gonna charge.

  • And of course, the bigger the capacitor is, the longer it's gonna take charge.

  • Um, and if these resistors are smaller than it'll charge faster, pastor smaller, it will charge faster on, and then for discharging to the time when this is low.

  • It's just discharging through the one resister here on.

  • So you know again, if if this is a bigger resistor, it'll take longer to discharge and so this will be low for longer.

  • If it's a smaller resistor, it'll be faster.

  • And so, by adjusting these components, we can kind of control the rate here.

  • And so one thing I notice is that, you know, I chose 100 k resistor here and then a relatively smaller one k resistor here.

  • I mean, this is only 1% of this and that's because because we're charging, we're charging through.

  • Both and we're discharging were only discharging through this one.

  • But I wanted this square wave to be fairly symmetrical on dso by this only being like a 1% difference in the charging from discharging.

  • You end up with essentially essentially the same time that it's off.

  • That it is, that is, on its sort of what's called the duty cycle.

  • And if you look at the data sheet, they actually give you, um, some formulas here for figuring out the time that it takes to charge or discharge.

  • So charged time discharge time on, and they actually show a nice little graph looks very similar to the one that I just drew.

  • Um, but you can see, you know, they give you They gave you the charge.

  • Time is based on our A plus R B, and we're calling this our A and this is our b times, the capacitance, which is the sea here.

  • Where's the discharge?

  • Time is just based on our be right, because we're only discharging through that one resister so you don't see our A in there and then the total period is our A plus two r B.

  • Because it's our A plus, you're going through our be twice for the for the total period times are capacitance and so we can figure out our total period.

  • Just using this formula, you pull out a calculator here, and so just sort of order of operations.

  • Here.

  • Resistor be is 100,000 homes of times, too.

  • And then we can add in Resister is 1000 homes are one k resistor, and we'll multiply that by our capacitor, which is it's a one micro Farid capacitor.

  • So I think that's that's one micro fared and then we multiply that by this 0.693 and you know, the reason you're multiplying by that is you know, you know, the Resistance times the capacitance gives you the time constant, and that's used in the to sort of give you this exponential.

  • See what I'm doing here.

  • They curve for this exponential function.

  • Um, but, you know, we're not We're not going the whole way.

  • And, you know, we're just going from 1.6 bowls to 3.3 volts.

  • And so they've They've done some of the math for you to figure out what, what coefficient and to use to get from the time constant to the actual period.

  • And so what?

  • We come up with 139 milliseconds 1390.139 seconds, and so that's the period that are that are led is flashing.

  • Now, if we want, we can double check all of this for ourselves by hooking up to a telescope here.

  • So I'll just hook up ground for my probes here, and then I'll connect one probe to the output, which is the pin three here.

  • And then I'll hook the other probe up to the capacitor so we can watch the charge on the capacitor and Here we go.

  • We can see our output, which is which is this nice square wave.

  • And then we can also see the charge and discharge the capacitor.

  • And so, if you look, zero volts is down here.

  • So this is 12345 volts.

  • You can see the charge and discharge the capacitor is going from.

  • You know, this is about one and 2/3 of a volt up too, you know.

  • 123 and a little bit.

  • Three and 1/3 volts.

  • It's exactly what we'd expect from that.

  • You know that voltage divider?

  • Now the output you see is going from zero votes here, Thio.

  • 123 and a little bit here.

  • Three and 1/2 colds.

  • Maybe you might expect it to go all the way to five volts.

  • But but actually the data, she does talk about this.

  • It does say, Look at the, uh, output voltage here for our five volt says typical is 3.3 volts, and we're getting, you know, a little bit more than that.

  • But it says the minimum is 2.7 viable, So we should be getting at least a minimum of that which is fine.

  • That's enough for a logic high level.

  • So if we're per feeding this indoor or any kind of digital logic will be okay with that.

  • And then we should see, uh, 139 milliseconds here.

  • So this is 50 milliseconds per division.

  • So this is 102 100.

  • And huh?

  • So that's not quite not sure why I double check this.

  • Well, I figured out the mystery, so we calculated 100 and 39 milliseconds, and we're seeing about double that.

  • And the problem turned out to be these capacitors.

  • So, you know, looking, it's capacitor.

  • It says one m f d 50 v.

  • So I would assume that that means it's a one Micro fared capacitor 50 volts.

  • It's got this 10 to 2.

  • I assume that that's ah date code of some sort.

  • Maybe it's manufactured in 2010 the 22nd week of that, and that's all it says on it.

  • So I would assume is the one Micro fared capacitor, uh, turns out when I hook it up to my meter.

  • He had measures had to micro Farage's, so I don't know what's going on with that I got a whole bucket of these things and they all say one M f D on him, and they all released all the ones I measured measure to Micro Fareed's.

  • So instead of one micro ferrets to my preferreds And so you know, if we if we plug that into our formula, we had one micro fair there.

  • Instead, we plug to were basically multiplying by two.

  • So multiply that by 2 278 milliseconds, and you know, we're measuring 263 milliseconds period here, and that's Ah, that's much more in line.

  • That's that's certainly within.

  • You know, we've got 5% tolerance is on this resistors and stuff.

  • So 263 278 close enough.

  • So very interesting.

  • I always assumed these were one micro fair, but apparently apparently not.

  • If anyone knows why they're marked that way, maybe maybe I'm missing something obvious, but I would assume that one m f d means one Micra fired, but apparently one m f d means to micro parents go figure.

  • Yes, the 263 milliseconds that that's much more what we do expect.

  • And so if we take one over 263 milliseconds.

  • We get about 3.8 s O that tells us that should be flashing about 3.8 times per second.

  • And that little visually seems about right.

  • So I think we're almost done with this circuit.

  • It looks like it's working.

  • I did want to talk just briefly there some power supply recommendations in the data sheets.

  • And I want to talk a little bit about power supply we've got This is just a cell phone charger.

  • This is from Apple, which is actually very good power supply if you get a genuine Apple one.

  • But in any event, it looks like everything's working fine.

  • You know, our led is flashing.

  • We've got our nice clock output here, so you could probably use this and it would work.

  • Okay, probably.

  • But there are a few things that the data she recommends doing, uh, to reduce noise.

  • And so one thing it recommends doing is putting a capacitor on pin five.

  • We're not using pin five.

  • It's controlled voltage.

  • It's for some other features of the the triple Five time or that we're not using any recommends putting a 50.1 micro fared capacitor from pin five to ground to reduce noise.

  • So what is it talking about?

  • Well, we see on the scope here we see this nice transition from zero votes to five volts.

  • But if we if we zoom in on that or zoom in Oh, what you see is that that nice transition from zero votes to five volts is maybe not so nice.

  • There's some lot of junk in there.

  • So if we add this capacity that they're recommending from ground to pin five, boom clears it right up.

  • So definitely recommend that 0.1 microphone capacity.

  • We're going from pin five to ground.

  • There's still some other noise.

  • If we d'oh in even further, go in tow, I'm going the wrong way.

  • Go all the way into Ah Nana, second range.

  • You see, there's some over shooting here, and what's happening is when the when the output wants to turn on.

  • Yeah, there's a bunch of transistors in here switching and doing whatever they dio and you know, when they switch, there's a different current requirement, so they're pulling more current or they want to pull more current from the power supply, and they're not able to pull that current a CZ as quickly as they would like to.

  • And then at this point there, they end up getting more current than they they wanted.

  • And it kind of overshoots and probably don't seem or sort of back and forth isolations here.

  • That's fairly typical, but it looks like it levels out pretty quickly here.

  • But we're overshooting above, you know, right here, this is five volts were going up over six volts, which may not be good.

  • You know, if we are, output is supposed to go between zero and five volts were feeding into something that's expecting five volts, and we give it six votes.

  • That could be a problem.

  • And the reason that this is happening is you know, our power supply is over here, and we've got all this wire that's connecting it to the board.

  • And you say, Well, the wire is just gonna It's a conductor, you know, just electrons flow right through.

  • No problem.

  • Well, almost.

  • You know, in a perfect world, sure, that's how wire would work.

  • But, uh, we're we're not in a perfect world.

  • And so, uh, this this wire has some impedance.

  • It's actually acting as an inductive.

  • So when you've won current through the wire, you get a magnetic field that builds up around it, and that magnetic field is gonna resist changes to the current that flows through that wire.

  • And so when we try to pull more current, we get a little bit of, ah, oven impedance.

  • That's resisting that.

  • And so I demonstrate this by getting all of this wire out of here and hooking up this short, short USB cable that I've that I've hooked up, and, uh, plug that in.

  • And there, you see, this comes up a lot faster eyes.

  • One thing you'll see, and he also say it doesn't go above five volts.

  • Still doesn't take a little bit of time to settle in.

  • But this is much better.

  • We're staying.

  • Inspect.

  • We're not going above five volts.

  • It's turning on pretty quickly on, and that's just because I don't have all the competing in this wire.

  • We do still have impedance, you know, from here through the traces inside this bread board, you know it into the chip and everything, so there's still not still not perfect, which is why it doesn't look perfect.

  • here, but a lot better.

  • But of course, we don't want to have a short little power cable like this.

  • We wantto be ableto not have our extension cord around all the way up to it.

  • Eso let's plug this back in and see what else we can do.

  • So we're back to that crazy overshoot.

  • Another thing Weaken Dio is if we put a capacitor just across our power connection here, that capacitor can sort of, uh, you know, get charged.

  • And then when this chip wants to pull more current, it can pull it from the capacitor.

  • So we just take a za 0.1 micro fared capacitor and just stick it right across those power pins Boom we get, we get basically the same thing.

  • And that's because, you know, the power supply has capacitors, and it's doing essentially the same thing that we're doing with his capacitor here now, ideally, which he wanted to is.

  • You want to get this capacity as close as possible to the chip and put it right across the power pins on the chip.

  • And if you look in any any electronics, every chip is gonna have a capacitor or maybe multiple capacitors sitting right next to it to smooth out these current transitions.

  • You know, I'm not gonna get too crazy with it.

  • I think you know, with this computer we're building, we're not running at a super high speed.

  • So if it takes a little while to come up and stabilize, it's, you know, not too big a deal.

  • So what I'm gonna do is just put one of these little 10.1 micro fared capacitors on each bread board and hopefully that will be good enough.

  • Okay, so we've added are zero point 01 micro fared capacitor here to pin five, and we've also got a 0.1 micro fared capacity was just sitting across our power pins and I'm gonna move that over here just so it's a little bit more out of the way.

  • But it's still connected to the board across the power pins, which which I think is good enough.

  • There's one other thing that the data she recommends, which is pin for which we don't have anything connected to, and I didn't draw it on the diagram here, but what pin for is is it kind of gives you this other connection here to to the reset of the latch.

  • So it gives you kind of a direct connection in here to just reset this latch if you wanted to.

  • And actually I should draw it.

  • It's inverted input.

  • It's not.

  • It doesn't hooked up exactly like this, But this is basically how it functions is if you bring pin for low, it'll just force this latch to reset.

  • It overrides anything that's going on over here.

  • Eso Normally we wouldn't want to bring that low unless we wanted to reset this.

  • And so what?

  • The data she recommends doing is to prevent it from accidentally, you know, going low.

  • If there's some stray voltage or something, it recommends.

  • If you're not using it to just Hyatt 25 volts so we just connect that to five votes, then this will always be high, Which means we're not gonna be, you know, inadvertently resetting this if there's some noise, so that's just something else will do.

  • And then the last thing I wanted to dio is I want to be able to control the speed of this thing.

  • So we haven't blinking at this, you know, 3.8 times per second or whatever it is, which is which is great.

  • But it would be nice to be able to control.

  • And of course, you can change out the capacity to change out these resistors.

  • And, you know, hopefully you know, you can You can kind of see how to do that.

  • And but what would be really nice is to add, you know, change this 100 k resistor to ah, variable resistor.

  • And so I have this one mega home variable resistor, and you just turn this and get a different resistance And it goes from zero homes.

  • So just a short all the way through 11 mega home, which is 10 times more than this s so we can do is we can add this to the circuit here.

  • And, uh, what we can do is we could hook that up in place of this this 100 k, this 100 k resistor.

  • So if I take the 100 k, resist her out and what we'll do is just hook up some jumper wires from pence six and seven, right?

  • Wanna connect between pin six and seven on?

  • I'm just sticking it over here with the jumper wires because this too big to just jam right in there like the little resistor was, um But the other thing I'll do is I'll put it instead of just hooking this variable resistor between pins and six and seven by itself.

  • You know, because when you turn it down, it goes down to zero volts.

  • That would be a direct short between six and seven, Which would mean that when our our clock turns off the capacitor instead of discharging like this, the pastor will discharge almost instantly through here if there's no resistor there at all.

  • And so then you basically this would never go low, because as soon as this goes low, it would instantly, almost instantly go high again.

  • So we don't really want that.

  • So what we can do is we can put another resister in Siri's with their variable resistor, and that'll it essentially act as ah is a minimum value.

  • So I'm gonna put in this one k resistor, um, between the the other pin of their variable resistor and pin seven there.

  • So, you know, if this has turned all the way down, it's one.

  • It's one K.

  • And if it's turned all the way up.

  • It's one meg or 1.1 maker, whatever, whatever it is, Um, let's, uh, hook that up again.

  • That's who we get.

  • And it looks like it's all another goes.

  • Yeah, it's just going really slowly.

  • And of course, we can turn this knob and get it to go faster.

  • There's going little bit faster, and we can turn it even more.

  • It goes even faster, and if we turn it all the way, it's I don't know if you can see that I can see it's basically flickering because it's just going so fast, because right now, with this turned all the way down, we just have a one K resistor.

  • And so when it's charging, it's charging through to K of resistors, and that is discharging through one K, and so you could probably do the math and figure out how fast it's flashing.

  • But, uh, I like that you can get it kind of dialed into whatever speed we want.

  • If we want to go really slow again, we're using a clock for a computer so we may way may want to go really slow to see exactly what's going on.

  • We could do that.

  • But we might also want to just manually control the clock by pushing a button s so we can go as slow as we want.

  • And so we'll look at that in the next video.

There are a lot of ways to build a clock circuit for a computer.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it