so in the last video we used a 555 timer
here to build this little clock circuit
and so we have our pulsing clock output
on pin 3 of the triple 5 timer and we
can control the speed using this
potentiometer so that's great but there
might be times when we want to manually
control the clock we want to be able to
just push a button on each time we want
the clock to advance one wire or
computer to advance one clock tick and
so you might think well that's pretty
easy we just hook a button up and so we
have you know this output here of the
button is is pulled to ground through
this resistor normally but then when we
push the button it connects it to our
our 5 volt supply here and so push the
button it comes on and so we can
manually pulse the clock like that you
might think well that works pretty
pretty well and that's almost true and
in fact you might be able to use this
and you might be fine with it depending
on the button that you have what happens
is inside that button when you push it
there are two metal contacts that come
together to close the circuit and
sometimes what will happen when you push
the button is those contacts will bounce
and so it'll it'll close and then bounce
and then close again or maybe it'll
bounce a couple times and so what
happens is when you push that button you
actually get a couple quick pulses and
if that's hooked up to you know the
clock of our computer and we push that
button we could actually trigger a
couple clock pulses when we only meant
to trigger one and that could be really
frustrating if you've got you know some
issue that you're trying to debug in the
computer and you've you've spent a
couple minutes getting it all set up
just perfectly and you're right at that
point where the next clock pulse is
where you're going to figure out what's
wrong with it
and you push this button to get a clock
pulse and you get three clock pulses and
it goes right past the problem you're
trying to find there give you really
frustrating so what we want to do is
want to figure out a way to get rid of
that the or you know avoid that bouncing
and you guessed it we can do that with
our friend the triple five timer but
first I hooked up the oscilloscope just
to take a look at the the switch here
and so when we push the switch you can
see this is what we'd expect right it
transitions from off to on but if we try
this a few times we might see
some different stuff no there's
something yeah look at that so that that
definitely bounced right there and so
that's that's not good you know you
don't want that because that would you
know that would look like one two three
potentially clock pulses when you've
only push the button once so you
definitely want to get rid of that and
so this now is a triple five circuit
that is going to help us with this with
this switch bouncing problem and so well
only before we get into it let's just
try it out let's push the button see
what happens
push the button the light comes on and
then a little while later the light
turns off and importantly what happens
if we push the button multiple times the
light only comes on once and that's what
we want and this is called a debouncing
circuit and there's an you know there's
a lot other ways to build debouncing
circuits but you know I'm using the
triple five timer just because I think
it's a fun chip to play with and so the
timer here that's controlling how long
this stays on when you push the button
is controlled by the resistor and
capacitor over here and so you know you
remember before we had two resistors and
a capacitor that we're controlling the
the pulsing here we just have one
resistor in a capacitor and we'll go
into more about how it works but
basically the time that the LED stays on
is just you pretty much multiply the
value of the resistor times the value of
the capacitor and so this is a one mega
ohm resistor and this is a is a 2 micro
farad capacitor it says 1 MFD on it but
apparently these are 2 micro farad's
but anyway the nice thing about about
this is 1 mega ohm is a 10 to the sixth
and micro farad's are 10 to the minus 6
so the math works out really easily here
so that a 2 micro farad capacitor when
you multiply it together you just get 2
and so that gives us a two-second delay
I'm sure enough we push the button and
the LED stays on for two seconds which I
guess is further confirmation that this
one MFD capacitor is really 2 micro
farad's anyway so you know 2 seconds is
kind of long for what we want so what we
could do is we could put in a point 1
micro farad capacitor
instead of this 2 micro farad capacitor
and if we stick that point 1 micro farad
capacitor in there that's going to give
us point one seconds you guys we're
multiplying by oh this 1 mega ohm
resistor so now it stays on 4.1 seconds
matter how quickly I push it's kind of
hard to tell but that's what we want we
want it to pretty much follow what we're
doing when we push the button but we
critically are getting rid of those
balances and so as long as any bounces
that happen within the first you know
100 milliseconds or 0.1 seconds we've
gotten rid of and that's what we want to
understand how this works let's look
again at our circuit diagram and I've
got the triple 5 timer here the guts of
it exposed here but the the green bits
out here are our circuit and of course
we have an LED hooked here the output I
didn't draw but and of course we're just
looking at this this lower half here is
you know this is what we build in the
last video and so we've got our resistor
here which is our 1 1 mega ohm resistor
and we have our capacitor which is a 0.1
micro farad capacitor and then you know
over here I've got the the button hooked
up and if you look at how this is hooked
up the button is connected between
ground and pin 2 and then it's also from
pin 2 you can see we've got a a 1k
pull-up resistor basically what that
does is it ensures that pin 2 is
normally connected to 5 volts but then
when we push the button it connects it
to ground and then pin 2 goes to 0 volts
so just like before we've got this
voltage divider network going on inside
the the triple five timer and so we've
got 5 volts up here and then we've got
3.3 volts here at this first point and
then we've got one point six six seven
volts here at the second point then of
course ground is zero volts and so
that's just a voltage divider resistor
voltage divider we've got one third of
our voltage two-thirds of our voltage
and then
here's our voltage in second so we can
see right now you know our output is off
you know the LED is off so if our output
is off then you know that must mean you
know that the Q output of this SR latch
is off and so the inverted Q output must
be on and so if that's on then that's
going to be you know putting current
into the base of this transistor and so
this transistor will switch on and will
be discharging or will be you know will
be pulling current through this
transistor and so you know in this in
this state right now current is flowing
you know from our voltage source through
the transistor to ground and if this
capacitor had any charge on it that
would also be you know discharging to
ground and so this capacitor doesn't
have any charge on it and so our
threshold is at zero and of course zero
is not above three point three and so
this is going to be off and then this
down here is five volts right so it's
you know trigger pin 2 is 5 volts and 5
volts is not not below 1 point 6 volts
so this is also off so both of our s and
our our inputs into our SR latch are off
right now and so somehow this latch has
just latched into the state where it's
off but what happens when we push the
button we push the button we now pull
this trigger low we pull this to 0 volts
and so zero volts is you know is
definitely below 1 point 6 volts and so
this comparator here turns on and that
triggers the set of our SR latch and so
that turns the output on and so sure
enough you know we push the button the
output comes on it's a no surprise there
but the other thing that happens is when
that output comes on this turns off and
so we're no longer you know pulling
current through this transistor here and
we're no longer discharging this
capacitor so instead we're charging the
capacitor and we're charging the
capacitor through this resistor and so
this capacitor is going to charge it's
going to start to charge and eventually
you know it's going to get above 3.3
volts and so when the capacitor charges
to above 3.3 volts
the the reset is going to be triggered
this this comparator is going to turn on
it's going to trigger the reset and
that's going to turn off our output and
it's going to turn on our inverted
output here our inverse Q and that's
going to you know push us back into this
state where we're now discharging the
capacitor and then and now there's no
there's no resistor between this
capacitor remember the circuit before we
had another resistor in here there's no
resistor here so this capacitor is going
to discharge you know immediately and so
it's just going to you know drop right
back down to zero volts which of course
is going to immediately turn off this
this comparator right because zero volts
is is certainly not going to be above
three point three and so this comparator
is going to turn off and we're not going
to be triggering this reset anymore but
if we're not pushing the button you know
we're not triggering our set anymore
either
and so the latch is just going to stay
in its latch state and our output will
be off you know so if we're looking at
what our what our output did as soon as
we you know as soon as we as we hit this
trigger our output comes on right
because we set the the latch and then it
stays on while the capacitor charges up
but then once the capacitor gets to the
3.3 volts boom our output goes off and
it just stays off and it stays off until
we until we hit that trigger again we
until we push the button again and so
you might hear this referred to as a
monostable mode of the triple v timer
because it's called monostable because
there's one state where it's stable and
then if you push this button it goes
into this other state where it's not
stable where it's going to you know
eventually this capacitor and then it'll
drop out of that state where is the you
know what we did in the last video with
this this is called an a stable
multivibrator or a stable mode for the
triple v because it doesn't have a
stable state it's you know constantly
altering between two states on and off
so you might hear those terms mono
stable and a stable so to take a look at
that in action i've hooked it up to the
scope here and i've also gone ahead and
put the that 2 micro farad capacitor in
there again just so we get that nice
slow two-second
pulse there so if we fire up the
oscilloscope here push the button you
can see the output goes immediately high
and you can watch the capacitor charge
and then BOOM
as soon as it hits that 3.3 volts so
let's see one two three point three yeah
3.3 volts capacitor gets there and boom
it just that discharge pin flips and the
capacitor just instantly discharges and
of course our output turns off then and
so you can see any bouncing that the
switch is doing in here
doesn't matter our outputs already high
we've got that latch that's that lat
this latch did hi
and then you know as as long as this
capacitor will just charge away and then
BOOM turns off so I've got that point
one micro farad capacitor back in there
with our one Meg resistor I think that's
what I'm going to go with and you know
just like before we've got that that
control voltage pin which is a pin five
here that we're not using and that's
just kind of tied into here and again
the datasheet recommends putting a point
one point zero one micro farad capacitor
between that and ground so I'll go ahead
and add that in there and that's just
for that noise reduction that we you saw
in the last video so good practice put
it there and then the other good
practice is pin four also not using that
that's a reset pin that kind of ties
right into the reset of the SR latch and
it's an inverted reset so normally
should be at five volts and then
bringing it to zero volts forces this to
reset regardless of what's going on over
here just kind of override things so
we'll tie that to five volts there just
to prevent that from accidentally
tripping or anything like that and I
think that will that'll do it so now
we've got our our timer here so we've
got that and we can adjust the speed so
we saw that in the last video and go
really fast or really slow and if we
don't want to use that we've got a
manual clock pulse here so now we just
need to come up with some way to switch
between the two of those and we'll look
at that in the next video