How do you debounce a clapping monkey?
Probes The Monkey makes his return.
All about contact debouncing, setting up a universal counter as an event counter, and other issues that can arise on a seemingly simple test setup.
Forum: http://www.eevblog.com/forum/blog/eevblog-961-monkey-debouncing/'>http://www.eevblog.com/forum/blog/eevblog-961-monkey-debouncing/
EEVblog Main Web Site: http://www.eevblog.com
The 2nd EEVblog Channel: http://www.youtube.com/EEVblog2
Support the EEVblog through Patreon!
http://www.patreon.com/eevblog
EEVblog Amazon Store (Dave gets a cut):
http://astore.amazon.com/eevblogstore-20
T-Shirts: http://teespring.com/stores/eevblog
๐ Likecoin โ Coins for Likes: https://likecoin.pro/ @eevblog/dil9/hcq3
Probes The Monkey makes his return.
All about contact debouncing, setting up a universal counter as an event counter, and other issues that can arise on a seemingly simple test setup.
Forum: http://www.eevblog.com/forum/blog/eevblog-961-monkey-debouncing/'>http://www.eevblog.com/forum/blog/eevblog-961-monkey-debouncing/
EEVblog Main Web Site: http://www.eevblog.com
The 2nd EEVblog Channel: http://www.youtube.com/EEVblog2
Support the EEVblog through Patreon!
http://www.patreon.com/eevblog
EEVblog Amazon Store (Dave gets a cut):
http://astore.amazon.com/eevblogstore-20
T-Shirts: http://teespring.com/stores/eevblog
๐ Likecoin โ Coins for Likes: https://likecoin.pro/ @eevblog/dil9/hcq3
Hi Do you remember Probes The Monkey from the batteries of videos? Well, let's say that you wanted to use Probes The Monkey for a test where you actually wanted to count the number of times that he clapped like this. And he usually uses symbols. but you know these are actually pretty loud and well, you don't want that. Yep, and on for hours and hours.
So I've removed these little La symbols here. I've screwed in some crimped wires into here so that when they make contact. bingo, We close a circuit and we can count the number of times that probes. The Monkey actually claps.
Here we go. GoPros Yeah, so you might think this is a pretty easy thing to do. just have a circuit that counts the number of times that these contacts close like this. So you might think if you've got a frequency or a universal counter in your lab.
a universal counter is not just a frequency counter. it's universal. It counts stuff. So you could actually hook up to your frequency counter like this and put it into what's called totalized mode like this.
which actually just counts up the number of times that the input goes through the threshold. In this case, I've got a power from a couple of double-a batteries. Just got a pull-up resistor here, so every time that this shorts out, it shorts out to ground and it should count the number of pulses. But let's actually try it, shall we? Hmm, let's just manually do it.
For starters, Oh whoops, 225. Oops. You no doubt familiar with this problem. It's contact bounce when these contacts close like this, you don't just get one edge, you get multiple edges and we can actually have a look at that.
If we actually hook our scope up here to our input, let's have a squeeze, shall we? and put in single shot capture mode. You'll notice it was high there. and let's just capture Boom. One little pulse like that.
Look at that. We've actually got not just one, not just the one nice. Do have actually one nice pulse there. but after that, look at all the crap that we've got there.
There's lots of stuff happening with the contacts here. For the screws, the surface, you know, corrosion on the screws, and all sorts of weird and wonderful stuff. Look at that. I mean that's why we're getting hundreds of pulses counted at any one time on our frequency counter here.
So we have to do bounce those contacts. So if we've got our switch like this with our typical pull-up resistor, we're gonna get contact bounce or switch bounce on those contacts. Pretty much doesn't matter what switch it is. Any mechanical switch A be it a you know, a proper mechanical one that you actually buy a push button or toggle or whatever or air probes.
the monkey here or how do we actually debounce this? Well, one of the obvious and common ways to do it is to add a capacitor across the switch and that's exactly what I've done here. I've added a 330 micro farad capacitor on there I think I've got a 5 K 6 pull up on there. Let's give it a try now. All right here you go. Probes: Let's count. Oops, We're already screwed. We've got to hear it. Counted two instead of one.
And but look at our waveform now. we now have a beautiful classic exponential capacitor rise like this: Classic RC Time constant you're familiar with. and check out that edge that we've got there. It is beautiful.
Look at that. There's no contact bounce in there whatsoever. Because now that we've got the capacitor across the switch, when you activate the switch, the very first instant that that's which goes low, then it shorts out the capacitor and then then the capacitor will remain a short circuit and only charge up based on the resistor value and the capacitor value. That classic RC Time constant.
Like we get like that. So that is why we only get the one switch transition in there, which is absolutely beautiful. But why on earth did we get a count of two on here? We've got to count a two on here because our universal counter here is not a Schmitt trigger input. I've done a whole video on Schmitt trigger, so click here if you want to see that Schmitt trigger video that explains everything in detail.
this counter is not designed to debounce inputs. But as I pointed out in my Schmitt trigger video. and demonstrated, when you've got a slow rise in input signal like that into any sort of, our digital logic input which is counter effectively is really Ultimately Then it can cause multiple are transitions due to noise on that signal. But I think what we might have here is a pencak.
A problem exists between keyboard and chair ie. me I haven't set up this Universal counter properly and I don't think I've are showing setting up a universal counter before. Let's take a look at it now. you might be able to just see under there that there's a 100 Kilohertz filter I've got that switched on.
so it's a low-pass filter. filters out any noise above 100 kilohertz. but you know we could have some higher frequency noise on here for the threshold and stuff like that, so that could still be an issue. But let's take a look at the shutter.
the set up, shall we? You'll notice that there's an Ac/dc mode here DC the lead is not on. so we're actually in AC mode. So we're a C coupling our input. so our input here is being AC couple.
We don't know what the value is and all that sort of stuff so we don't want that. What we want is DC mode like this. Okay, and then let's go and have a look at our trigger. Okay, our auto triggers off.
That'll just reset the thing on my demo that later. But look our threshold is set at zero volts. So now we're in DC mode. We definitely don't want our threshold at zero volts because that'll be right down the bottom here and you might see that there's actually a tiny, you know, there's some noise down there.
So if I threshold a zero, that's not going to work. Actually, let's let's try that and see what we get, shall we? So let's go back into our run mode and now it's actually not even working at all. So yeah, we get absolutely nothing there. So let's go back in and set our threshold. What we want is DC mode our level. Let's say we want it to trigger. It's a 1 volt. This is 500 millivolts per division.
So like right in the middle of that on the positive going edge you could said on the going edge. Yeah, it doesn't matter. In fact, in this case, you probably would want the negative going edge because you want the important account to occur exactly when the switch contacts are come together. So let's go in and we'll set that up to 1 volt.
There we go and positive it's currently set, the positive edge will change. That will have negative edge. Thank you very much. What else we've got: Sensitivity: High Low Medium I Can't remember off the top of my head what that actually does and could be some sort of window.
I'll have to read the manual on that So RTFM Anyway, let's leave it too high, shall we? So we're all hunky-dory ready to go. Let's try that again. Come on. Probes, Here we go.
Let's try it up. Ah, cheated. Hang on. there we go.
We're running and it should instantly count. This split second that we touch these together. Boom. One and it's counted up.
One. Beautiful. So now we're working. let's do it again.
Two. Three. What? Nope. See.
See, There's our second problem if we try and do this too quickly. it's not charging up to that one volt. So obviously you know we have to choose our capacitor value correctly. So if you had something, it depends on your object that you're having.
So if you've got an RC debounce circuit, you really need to know the how fast your inputs occurring. All that sort of stuff. So if you've got a fairly controlled device like probes the monkey, you know how often he's going to clap and stuff like then you can then tweak your capacitor value to do that. But obviously he's not gonna count things that are so quick that that capacitor can't reach ours.
Okay, so let's try and capture this on the scope. Let's just do. Look. we can see that Whoa like that.
all these multiple pulses here didn't count because we didn't get to our 1 volt threshold that we set up on here. So yeah, it's possible to use our universal counter tweak the capacitor value, tweak our trigger sensitivity. All that sort of stuff for our Mu T, our monkey under test here. or good old Probes The Monkey and you get sort of the output that we actually want from this thing.
So let's turn him on and see what we get There we go. So we only get into count once. Her? yeah, like cycle so to speak. So he doesn't count those individual pulses there.
so that's actually pretty good. You could say that you know it depends on what you're counting. Do you want to actually count individual contacts? Or did you want to count cycles of probes to make these cycles? Not too bad. No. There we go. What happened there? Whoa. You see that jump up. I Think we've got problem number three.
You'll notice that when probes is chirping like this, the count can actually go up. This is caused by. look. look at.
The contacts aren't even close in. We've got our big antenna wires here picking up coupling from what probes. The monkey is causing some counts to go up. So I'm kicking up just crap even though he's not doing anything.
So we have a noise kick up issue in our system. Can I Just test in something like Probes The Monkey. There's a lot of tweaking and messing around involved in getting something like this book, so we certainly have a problem there with our probes. Just the movement of his our head action in his chirping causes noise pick up in the wires and we can solve that.
That's not something that I want to solve today, but just be aware that that's a problem that we encountered in this particular our test setup and that might need its own solution. Shielded cables? whatever. But there's another potential problem that I want to discuss. We're probably not going to see it here today.
It might be hard to demo, but have a look. This is your traditional RC debounce circuit to switch directly across the capacitor. Now, when you short out the switch, of course you short out there. When you press the switch, is short out the capacitor, and then when you release a switch, the capacitor slowly starts to charge up until it reaches your supply voltage up here, and we've got a three hundred and thirty micro farad cap on there.
It's a fairly sizable cap. It's going to store it. You know, a reasonable amount of energy in there. So if we let it charge all the way back up to say, our three volts from our two double-a batteries here, and then we shorted out again.
We're generating a large short-circuit current through that switch there. and that could also cause interference problems similar to what we're seeing here because a very fast high current discharge like this generates lots of EMI alot. So lots of electro magnetic interference. Lots a big loop current in here with the switch and everything else through these wire through these very long wires that we've got here.
massive loop area and that could upset your measurements as well. And you know, I'd have to go to some effort to design something to actually show you that working. So to it, you know this RC circuit your traditional one you know works reasonably well, but it does have that problem of generating potentially a large current, especially if you're using a large value cap in here. So you're better off of course, using a much larger value pull-up resistor and a smaller value capacitor to avoid that problem. But just be aware of that. So to solve that problem, you can put an additional series resistor in here between the switch and the cap so that when you press the switch, you don't directly short out the capacitor. Instead, you're discharging it through R2 and R2 is you know, generally going to be a smaller value than R1, so you want it to discharge fairly quickly. Once again, depends on your monkey under test and what you're actually and what the timings are of you.
You know to choose that capacitor value correctly specifically for your particular setup. You'd also have to choose R2 to get exactly the right conditions as well. and I won't go through all the particular calculations of RC time constants and things like that because this is not a really an in-depth switch debounce tutorial. But suffice it to say that can solve any potential issue was shorting out a large value of capacitance here, but of course you might have noticed that now - is in series with I1 for your charging circuit and when you're driving a Schmidt trigger depending on the threshold levels, the upper and lower threshold levels for the Schmitt trigger, it might cause issues with the values you choose and everything else.
So another common technique to avoid that is to put a diode in parallel with the R2 here. it's got to be in that orientation, so it effectively bypasses R2 when you charging up, but it reverse Rises and does nothing when you're discharging like this. so it can just charge up faster and basically almost takes R2 out of the equation there in terms of charging. so you might have to do something like that.
But as you can see, there's a lot of you know little things that I can go wrong with. Just a simple RC debounce. A lot of things to consider depending on your test, set up, your monkey under test your mu T and it really does require you know a little bit of thought. I Mean you don't have to go through the charge equations for the capacitor and everything else.
you can just sort of, you know, do basic back-of-the-envelope calculation rules, a thumb or just even trial and error. Ah, the 330 micro farad doesn't work it I think it's a bit high. It's not Some detecting multiple things are lower it to 220 or a hundred my core. You know you might increase your pull-up resistor value or something like that.
Just you know. experimentation can get the job done, but so can calculation as long as you know the variables and the threshold level is just setting up and all that sort of stuff. So there you go. that's just setting up a universal counter like this to measure something like Probes The Monkey.
But we still have that issue with that noise. Hmm. and if you actually have a look at the waveform, you can see it's quite noisy. While probes the monkey is actually operating, there's a fair bit of superimpose noise from the motor.
whereas if I stop if I stopped probes and do that manually, you can see it's much much cleaner. So yeah, Probes is generating a fair bit of noise there. you could really come a guts are on that if you are hadn't filtered your import or something else. So there you go. That's certainly worth watching out for when you're testing monkeys like there's the pesky little things. Let me tell you so through a combination of settings now I Seem to have got a system that counts reasonably well. It counts. You'll notice that it counts up on the because: I've got 1.5 volt threshold voltage set and I've got medium sensitivity on this and positive rising edge of but 400 kilohertz to run.
so it's only counting cycles when he actually goes through that one cycle like that. That's if that's what you wanted. If you wanted to count the actual clicks here, they're just the RC time constant. So do whatever.
Yeah, it's a tricky business. Now of course there's another way to do this. Obviously, if this input was going into a Schmidt trigger, of course, you've got to have it going in the Schmitt trigger and then going into a microcontroller. The microcontroller, as I pointed out my previous video, might have a Schmitt trigger input.
In fact, a lot of them do, but just double check the datasheet that it does, and you can do software debouncing. You can, you know, adjust effectively, do a similar thing to what you'd use in the capacitor, the RC time constant for, and you can add little software delays in there. It tweak the values in your software delay loop to do software debouncing and you could do that on a micro and another way to do it might be a resettable one-shot timer. For example, you can get seven for series or 4000 series CMOS logic to do that, and so for multiple inputs like this, it would just generate a single nice one pulse out.
Then it would reset the timer so you could do it that way you could build up a little hardware circuit if you didn't want to do while software debouncing. But you know, and if IC didn't didn't do the job you wanted I didn't You know it entirely depends upon what you're actually using to count your number of monkeys. but of course we will get in a pretty noisy waveform on this due to the motor in probes here. So I can just hook up filter in there to clean up that signal.
I've got my our Stanford Research Si 650 here which you see me repair in a previous video and I've just got a low-pass filter in here 20 Hertz You don't need something fancy like this, you can just roll your own RC filter to do something like this if you want. And of course people are going to want to see probes with the cymbals back on. So here we go. Let's reset this puppy and here we go There we go.
It's counting individual claps now, no problems. If you have a look at the scope waveform there you can see we've got our noisy input blue waveform down the bottom. I've just start moves them. they're the same volts per division and then the nice cleaned up output of the filter there so that we can trigger off. in this case the negative going pulses just down in there, the negative edge inside there so that works a treat. So I hope you enjoyed that little look at just setting up a test system to count probes the monkey here. how many times he collapsing? Lots of subtle little things actually go on in this. In such a setup you got contact bounce issues, noise issues are conducted, moder conducted, and radiated motor emission shielding.
all sorts of you know, problems you might think. hey, that's easy just to count the number of our claps. But yeah, you can come and guts it in many different ways. And yes, there are other ways to do this.
Of course you can do it with a set up, a micron, count, pulses, and all that sort of stuff. But stick around for the next video where I'll show you how you can replace or well, kind of sort if there's not too much noise. Replace all this wonderful setup by hacking a calculator. Check it out.
The video will be here somewhere right at the very end of this video. And don't forget to give it a big thumbs up and all that sort of jazz cuz that really helps these days with the YouTube metrics and/or ranking and all that sort of jazz. Catch you next time you.
Probes the stigmata monkey XD
๐ต๐๐๐๐๐๐.
๐คจ๐๐๐ โ
I learned DUT from an aussie when i worked for cochlear, now I learned MUT from an aussie ๐น๐น๐๐
"This is a traditional arse" …. uhmm….. oh shit….. RC !!!
you have an extremely annoying voice, you are stalking the tympanics
Give him a motion sensor and glowing red eyes, and you'll turn him into Jangles the Moon Monkey.
Hi, Dave! The sensitivity / hysteresis is in fact specified in the operating manual on page 3-2. But to be fair, not everyone has time to search through the manual to find it. First you set the trigger level to the midpoint (or slightly under in your application using a capacitor). Then you look at the section "Voltage range and sensitivity (single shot pulse)". We find the sensitivity is 50mVpp for this application. Then we see LO sensitivity is roughly 2x HI sensitivity, so our LO sensitivity is around 100mVpp in this application. Easy. ๐ Anyway, I like your channel. You're doing some great work!
I was expecting the end to be: Put in some new batteries and autocount claps. Put on Batterizer and autocount additional claps. Compute percentage, additional/new x 100. Compare to 800% claimed. Compute lie factor = claimed / measured.
I just realized Dave has never done an episode on frequency counters practical uses and common use of the tool, eg. maths available and what you would use them for, period measurement, difference etc. In fact there does not seem to be anything like that on the tubes.
damn dave this is a fantastic and relevant video. im about to make a mixing desk. 65 buttons! gotta get this debouncing sorted before i make the same mistakes 65 times over ๐
thanks once again dave!
What's your opinion on using a 555 for debouncing?
I would have used my trusty $3 Arduino with no added circuitry whatsoever.
Sweet little tutorial based on a simple project. Love it. People must watch the calculator counter hacking video. Shows how you can get the same result with nothing but a dirt cheap calculator!
You could have picked up faster triggers by setting the threshold nearer to zero volts instead of 1 volt like you did. So even if the cap was only slightly charged, you catch those falling edges at the bottom of the graph.
Fuck Yes finally the EEV blog is back into doing electronics
Much simpler way to do it, use a Micro. read the input check in the loop versus last state count up delay bout 50ms and write it to some serial interface.
Great!
thought for a moment you had the monkey on a Lie Detector
A lot of talk about R2, but what about C3PO?
I would use a 555 timer, to debounce
You should call it DAD… Dave Assisted Design! My 12yo son came up with that…He's a big fan, and loves his tech……….. little smart arse!
Why not just put R2 in series with the switch and save the diode?
All joking aside, another great tutorial by Dave . . . thumbs up!
Why not just use a piezo + arduino?
neato video Dave!