#230

  Переглядів 29,717

Ralph S Bacon

Ralph S Bacon

День тому

It's time to try a final, alternative approach to the ubiquitous switch bounce problem.
► JLCPCB Only $2 for PCB Prototype any colour jlcpcb.com/cyt
00:00 Welcome Back!
01:34 Sponsor message, great PCBs jlcpcb.com/cyt
02:54 Demo of the Final Solution
08:48 Schematic (Circuit Diagram)
14:36 PCB Design (using EasyEDA)
15:32 3D image of the intended PCB
16:58 Breaking news! PCBs arrived so I built one
19:21 'Scope images of Switch Bounce
22:57 Conclusion
► To see whether there are any PCBs going spare have a look at the first pinned comment under this video!
► More details in my GitHub:
github.com/RalphBacon/230-Ult...
So we now have a simple, one-chip hardware solution that guarantees no switch bounce from any switch, not just a rotary encoder. Just feed the output from here into the microcontroller of your choice and never worry about switch bounce again!
► Useful or interesting video? You can support my channel:
Buy Me A Coffee! www.buymeacoffee.com/ralphbacon
► The Rotary Encoder I use in this demo
Bourns Rotary Encoder Datasheet PEC11R Series
docs.rs-online.com/1baa/09007...
► Calculating Maximum Encoder speed
www.linearmotiontips.com/how-...
► How to debounce KY-040 (a good read but not as good as this solution!)
www.best-microcontroller-proj...
► List of all my videos
(Special thanks to Michael Kurt Vogel for compiling this)
bit.ly/UKpostsVideoList-RalphB...
► If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite (and other μControllers) journey
My channel, GitHub and blog are here:
------------------------------------------------------------------
• / ralphbacon
• ralphbacon.blog
• github.com/RalphBacon/230-Ult...
• buymeacoffee.com/ralphbacon
------------------------------------------------------------------

КОМЕНТАРІ: 242
@RalphBacon
@RalphBacon 2 роки тому
==================================== PCB AVAILABILITY - SORRY ALL GONE NOW - No more requests please! ====================================
@stevehallam0850
@stevehallam0850 2 роки тому
Yes please!
@lambert0259
@lambert0259 2 роки тому
Yes Please Ralph, ive been trying through software to counter act the de-bounce problem on a stm32 MCU
@flemmingchristiansen2462
@flemmingchristiansen2462 2 роки тому
Yes please
@Joe-hu3cq
@Joe-hu3cq 2 роки тому
Thanks for the great video, Ralph! Please count me in for the PCB...
@allensmithphotography
@allensmithphotography 2 роки тому
Is certainly be interested in 1 or 2
@albertovillar5672
@albertovillar5672 2 роки тому
Ralph, thanks for sharing that knowledge with us. Very interesting explanations and also recommendations regarding JLCPCB
@RalphBacon
@RalphBacon 2 роки тому
Glad it was helpful!
@heyok
@heyok 2 роки тому
Thank you! Enjoyable explanations always are appreciated. Cheers, Al.
@RalphBacon
@RalphBacon 2 роки тому
Glad you enjoyed it!
@edgeeffect
@edgeeffect 2 роки тому
I never cease to be impressed by your video editing.
@RalphBacon
@RalphBacon 2 роки тому
Nice of you to say. I hope the content is equally impressive 😁
@billfischer7085
@billfischer7085 2 роки тому
Thanks, you are a fun and interesting teacher. Always love your stuff. My personal opinion is to use as many parts as needed plus some. When I started college in 1978 parts were orbital in price. Today I will build 3 or 4 extra boards just to test the extremes. The lectures are perfect. Thank You from Bill Fischer
@RalphBacon
@RalphBacon 2 роки тому
Thanks for sharing, Bill! I'm very happy you find my videos interesting (and even useful)! In 1978 we had no Internet, no Asian Market to get cheap components from, no Asian PCB makers (I made my own, Ferric Chloride etc, my fingers were permanently brown) but we did have MAPLIN (in the UK, at least) for components, sadly no longer here. And I was but knee-high to a grasshopper! Cough, cough.
@kentswanson2807
@kentswanson2807 2 роки тому
Thank you Ralph. In these days of reduced part counts and "just run a dupont wire" engineering, it is good to see some of the fundamentals being discussed. If I am not mistaken, that debounce circuit is a combination of an RC filter and a 1/2 wave rectifier. #savethebypasscapacitor
@RalphBacon
@RalphBacon 2 роки тому
I'm not sure that any rectification takes place here; it's all to do with that capacitor holding a charge sufficient long to miss the bounce pulses, then allowing the Schmitt trigger to do its magic.
@mickleuk
@mickleuk 2 роки тому
Thanks Ralph, got the PCB this morning. 👍
@RalphBacon
@RalphBacon 2 роки тому
Good news! As it's the UK post I was certainly expecting them all to be delivered soon-ish (albeit with a 2nd Class Stamp). Good luck with the construction, it's pretty straightforward.
@mickleuk
@mickleuk 2 роки тому
@@RalphBacon Put it together straight away. Didn’t take long and works a treat.
@egonsvensson2728
@egonsvensson2728 2 роки тому
Interesting content as always, keep up the good work.
@RalphBacon
@RalphBacon 2 роки тому
Thanks Egon, glad you found it interesting.
@TheDefpom
@TheDefpom 2 роки тому
I’ve always used two approaches, an RC filter from each output, and also reading the pins twice… works a treat. I actually read both pins to look for the alternating pulses, if it gets two pulses from one pin without a pulse from the other pin then it knows it was a bounce and ignores it.
@RalphBacon
@RalphBacon 2 роки тому
Sounds cool. I'm guessing there are quite a few ways to detect and/or eliminate switch bounce. What I like about this hardware solution is that we no longer have to concern ourselves in the code with such things!
@hopje01
@hopje01 2 роки тому
And if you use an esp32, you can use the hardware counters. In software you can set a debouncing value. It also helps debouncing. There are libraries available for rotary encoders.
@jfsaraceno9265
@jfsaraceno9265 2 роки тому
I use this circuit without the diode. I'll try with the diode and see if an additional component on the bom is warranted
@jfsaraceno9265
@jfsaraceno9265 2 роки тому
I like your approach of making a single board with both smt and tht components
@RalphBacon
@RalphBacon 2 роки тому
Well, this board unfortunately did not allow for SMT components just through-hole. I've done other boards that allowed both but it was hard work!
@martinmckee5333
@martinmckee5333 2 роки тому
Happy to second recommending the denouncing paper to just a out anyone interested in electronics to read. It's one of my favorites. Great video about an important topic. I've got an encoder board with a very similar bit of hardware on it, but that's SMD and the components fit on the back side of the encoder along with a microcontroller (NXP LPC845). It will act as an I2C device for use on random projects.
@RalphBacon
@RalphBacon 2 роки тому
Thanks for sharing!! Sounds nice and what I might have done had I used SMD components! Cool.
@PhG1961
@PhG1961 2 роки тому
In one word: great !
@RalphBacon
@RalphBacon 2 роки тому
Glad you enjoyed it, Philip.
@PhG1961
@PhG1961 2 роки тому
@@RalphBacon I always do. It's part of my Sunday entertainment... ;-)
@sunuk1915
@sunuk1915 2 роки тому
Awesome job 👏
@RalphBacon
@RalphBacon 2 роки тому
Thank you! Cheers!
@maxximumb
@maxximumb 2 роки тому
Nice approach to the problem.
@RalphBacon
@RalphBacon 2 роки тому
Thanks! It certainly is one way of sorting out those pesky bounces.
@andrewtoogood8774
@andrewtoogood8774 2 роки тому
Great Video Ralph :) When you present us with you fantastic research and findings not only do you educate us but you get our minds working, hence the many suggestions :) Sorry but I also have one: Is there any way of using your detection of interrupt < 20ms to give you a + 5 for that 20ms so it feels like there is no over spin limit and spinning it fast works fast? i.e. When "too fast" is detected set a variable and when you reach the acceptable 20ms threshold don't add 1 in that direction add 5 or more because the variable was set?
@RalphBacon
@RalphBacon 2 роки тому
The 20mS "Too fast" message was just there to show how my car deals with me spinning the volume control too quickly - it just ignores the "click" rotation entirely. You can reduce that if your rotary encoder still reliably works - but the manufacturer put the max rpm there for a reason! But you could easily set a flag (in the ISR) if the rotation is too fast and when you get the next < 20mS pulse detect the flag, add +5 and reset the flag. Simples!
@thomawhite
@thomawhite Рік тому
Thanks Ralf, I'm addicted to your content. Regarding this project - is there an optimal voltage for VCC?
@RalphBacon
@RalphBacon Рік тому
The datasheet for this exact Schmitt trigger chip (SN74AC14) says it works from 2v to 6v, so should be good for an ESP32 (or other 3v3 device) or an Arduino UNO (or other 5v device).
@DerMarkus1982
@DerMarkus1982 2 роки тому
Weirdly (as English is not my primary language), i understood the meaning of your "finger-in-the-air job" statement/idiom @10:04 immediately. Didn't understand it *phonetically* at first, so i had to go back and listen with CCs on. But as soon as i had read that line in the CCs, i had to chuckle a bit. " f i t a " as in, "let's lick the finger and put it straight up in the air to feel where the wind is coming from". 😁 Good analogy!
@RalphBacon
@RalphBacon 2 роки тому
I'm glad I've increased your (already excellent) command of the English language, Markus, but I have previously apologised for using British English similes, as the meaning is often unclear! On the other hand, perhaps non-English speaking viewers appreciate a richer language...
@arif3970
@arif3970 7 місяців тому
Great content
@RalphBacon
@RalphBacon 7 місяців тому
Thanks! Would you believe I'm having to switch debounce something right now. Sigh.
@arif3970
@arif3970 6 місяців тому
😀@@RalphBacon
@InssiAjaton
@InssiAjaton 2 роки тому
Once upon a time there was another switch debounce circuit in one of the "Designer's Notebook" or similar short idea article in one or other electronics Magazine that I apparently remember for ever. It used a Form C contact, two pull up resistors and an RS Flipflop IC. No capacitors or diodes. The switch common was tied to power common and both fixed contacts to a junction of the pull up resistor & S or R input, respectively. Supposedly the switch never chatters all the way to the opposite contact, only opens partially. So the pull up resistors raise both flipflop inputs high, but that does not matter as the IC toggles only at low level input at one of the two inputs and latches. I have used this sometimes and it works like a charm.
@RalphBacon
@RalphBacon 2 роки тому
The bit that does the business, so to speak, in this circuit is the (charged) capacitor and (relatively) slow discharge to allow for some chatter. This must be the basis of all circuits that deal with this problem. The Schmitt trigger ensures that the output only changes when the capacitor's charge drops to the threshold. Which sounds quite like the circuit you're describing, Pellervo; I tell you, there's nothing new under the sun! If you have a link to the article (you have to obfuscate it if you try and post it here or YT will zap it) I'd be interested. Or enough details so I can find it on the Internet!
@RalphBacon
@RalphBacon 2 роки тому
I searched given the information you gave me and found this article which is quite interesting; the first circuit uses no capacitor because the switch goes to ground, not VCC. www.embedded.com/solving-switch-bounce-problems/
@InssiAjaton
@InssiAjaton 2 роки тому
@@RalphBacon -- The Figure 1 circuit in your finding is what I recall and have occasionally used. The original article I saw probably in 1970's. In those days the authors got a token payment of $50 per accepted submission. (I got that amount for one submission, although they redacted the description beyond recognition...)
@saxhorn1508
@saxhorn1508 2 роки тому
In aircraft use, a fast twist kicks the interval from 1/click to 5 or 10/click for that twist. Useful for a big change and the lost counts don’t matter anymore.
@RalphBacon
@RalphBacon 2 роки тому
Or, in this case, you could push-click the encoder to make each detent worth, say, 5 normal detents, get to the position you more or less want, then push-click it again to get it into "normal" mode.
@Olavotemrazaodenovo
@Olavotemrazaodenovo 2 роки тому
Great job!
@RalphBacon
@RalphBacon 2 роки тому
Thanks, Glaucio!
@tonybell1597
@tonybell1597 2 роки тому
Nice one, thanks Ralph….
@RalphBacon
@RalphBacon 2 роки тому
My pleasure!
@grozaadrian4134
@grozaadrian4134 2 роки тому
just a few days ago did a de'bounce on a rotary encoder with schmitt trigger as you describe, i had to poll pin A stat for high / low and low/high to get 1 increment/decrement per tick and works like a charm. Suggestion since .. its a hex inverter, would of been cool somehow to be able to chose if you want the final signal high or low by using the other 3 schmitt trigger in series or not. Great video Ralph ! nvm: i just saw you said about it :D
@RalphBacon
@RalphBacon 2 роки тому
Thanks for sharing. Yes, using the other three gates is most do-able but by then the circuit was designed, the PCB on order... and I discovered it about an hour before I made the video. Oh well, high or low, it works!
@andymouse
@andymouse 2 роки тому
Hi Ralph, in a similar vein I have taken to using touch switches directly on the PCB and I use a chip to handle this that gives bounce free signals and it is the TTP223, they work great. Nice video......cheers.
@RalphBacon
@RalphBacon 2 роки тому
I'm hoping you got the idea from video #143 "Touch Switch 👆 with optional TTP223 module (ESP8266 or Arduino)". Bet you did. All in the subconscious.
@andymouse
@andymouse 2 роки тому
@@RalphBacon Oh Yeah ! you have used them I do believe that's where I heard about them ! ...It's been a long time!.....cheers!
@fredflintstone1
@fredflintstone1 2 роки тому
Cheese!!
@andymouse
@andymouse 2 роки тому
@@fredflintstone1 Squeak !
@jstro-hobbytech
@jstro-hobbytech Рік тому
I'll take any pcb you have to offer Ralph!!! I love building circuits and studying them while taking notes. I have thousands of pages written haha
@RalphBacon
@RalphBacon Рік тому
You should have a blog / website with all that information on it, Joey. Or do you have one already?
@jstro-hobbytech
@jstro-hobbytech Рік тому
@Ralph S Bacon naw. I'm not the type to put myself out like that. I've been working on doing something locally but I'm kind of a shut in brother.
@borayurt66
@borayurt66 2 роки тому
I used a crude RC filter together with a software debouncer routine in my never ending Nixie Clock project's rotary encoder. Although it is working perfectly as it is, I am intrigued to change the design once more to this and get rid of the software debounce part in the code. This is exactly why my projects seem to get forever to finalize :-) Thanks!
@RalphBacon
@RalphBacon 2 роки тому
Well you can build the debouncer circuit and try it out on a spare chip, I am sure, before committing to changing your project (again!).
@borayurt66
@borayurt66 2 роки тому
@@RalphBacon Always. I never integrate anything in my designs that I haven't made to work as a prototype. The whole Nixie project has been running on 5 protoboards at the moment and I keep adding, removing stuff (hardware/software) all the time. If I am happy with the result, it gets included in the final schematic.
@TonyLing
@TonyLing 2 роки тому
Did you not think of adding mounting holes to your PCB design? Excellent project, I watched with great interest.
@RalphBacon
@RalphBacon 2 роки тому
Well, Tony, TBH as this is more of a break-out or development board I didn't consider it (bad Ralph). I was trying to keep it small. But you can mount the rotary encoder on a front panel if the chip is soldered directly to the PCB. Even when using the socket I think it could work. You could mount it on another PCB (host/motherboard) by using the connectors intended for the header pins, of course. I've done that many times with dev boards without mounting holes. My next break-out board _does_ have mounting holes so I have already learned my lesson! Glad you liked the video!
@YoutubeBorkedMyOldHandle_why
@YoutubeBorkedMyOldHandle_why 2 роки тому
Good explanation. I used exactly this same debounce circuit in a little button board I made, for each of the 12 buttons on the board. It works great ... no more dicking around with software debouncing ;-) Mine is SMD.
@RalphBacon
@RalphBacon 2 роки тому
Yes, Richard (see, I worked it out!), I was going to use SMD but gave the reasons why I didn't in the video. An SMD version would be much more compact. I'm almost tempted!
@YoutubeBorkedMyOldHandle_why
@YoutubeBorkedMyOldHandle_why 2 роки тому
@@RalphBacon Thanks for the reply Ralph. You are the first person I'm aware of who has "worked it out." I would have just used my real name, but the ascii version was already taken. Nothing personal intended with the SMD reference, I just tend to use SMD as much as possible. This was particularly true for my little button board, because 'through hole' would have increased the size considerably. Also, I liked your observation that JLCPCB (and others) offer up to 100x100mm without penalty, so why not panellize small boards? I've done this a few times. But my real pride and joy is a little table saw I made with an old sump pump motor and metal scraps, to which I attached a shaft and one of those thin fibre cutting disks. Since then, I've filled up my PCBs with as many projects as I can stuff onto each board, and when the boards arrive I use my diy table saw to slice them all up. Works great ;-)
@RalphBacon
@RalphBacon 2 роки тому
Your SMD reference was spot on, Richard, I'm beginning to wish I'd made it that way now! When I panelise a board with JLCPCB, by the way, I choose V-Cut which enables me to just gently snap them off, no sawing necessary.
@YoutubeBorkedMyOldHandle_why
@YoutubeBorkedMyOldHandle_why 2 роки тому
@@RalphBacon Of course panelizing absolutely makes sense ... 'if' you need many identical boards. But consider this my predicament: I've been using 1.27mm pitch headers with different pin counts. I occasionally need to fabricate cables, or to convert from 1.27 to 2.54 pitch. So, I made these little tiny boards, Dip to Dip, SMD to Dip, 2x3, 2x5 pins etc. I have several useful configurations. There is a fabrication cost penalty for mixing different boards on panels. I could panelize each, but now I'd end up with hundreds of boards, and I just don't need that many. Similarly, I may have several projects for which I really only need one or two boards. Don't forget JLCPCB, is already providing 5 copies of each. Having the ability to cut my own means that I can (and have) put all sorts of different boards on a single panel making use of most of the available space. There are pros and cons to doing it either way, but I'm talking too much ... why don't I just show you? ... drive.google.com/file/d/13v_rhqNyMphHWalQLJxw260QPXI82dvX/view?usp=sharing Cheers.
@RalphBacon
@RalphBacon 2 роки тому
Right, I see what you have done! I'm not sure I could do that with EasyEDA as the PCB is an entity in its own right. And it's always created from the schematic. To combine the boards would required some other action - how do you do it, create the PCBs directly without a schematic?
@bluegizmo1983
@bluegizmo1983 2 роки тому
I just built a volume control knob out of one of these encoders. I installed an aftermarket Alpine stereo in my car and it doesn't have a volume knob, just onscreen capacitive buttons for the volume, which I didn't like. My car doesn't have steering wheel controls either, but the new stereo did have a 3.5mm jack for an optional box to interface with a vehicle's steering wheel controls. I found some code online where someone had decoded the protocol it uses to interface with steering wheel controls. I used some of that code, an Adafruit Qt Py ESP32-S2, and an Adafruit Stemma rotary encoded board to create an actual volume knob for my stereo. I found that this Adafruit encoder board doesn't seem to have the issue you mentioned of rotating too fast, as I could spin it as fast as I want and it never skips or loses track. However, this stereo can only accept inputs about once every 150 milliseconds due to the precise timings required for the protocol it uses. So, I had to program a buffer into the code so that if the encoder is spun faster than the stereo can accept a new signal, it buffers the commands and sends them as soon as its ready for another signal. I also used the encoder button/click function to mute and unmute the stereo. I chose the ESP32 because I wanted something with WiFi so that I can do OTA updates to the code without pulling the stereo out of the car every time I wanted to make changes to the code (as the ESP32 is behind the stereo). I coded it so that if I hold the encoder button in for 5 seconds, it enables the WiFi in AP mode and loads the OTA webpage, this way the WiFi is only active when I need to do a code update.
@RalphBacon
@RalphBacon 2 роки тому
Absolutely fantastic work, Daniel. You're obviously an experienced 'maker' and are putting to good use all the skills you have. Yes, OTA updates are a real blessing too, I too use that feature. Interesting that you are writing the data stream to a buffer which then sends the data in a controlled (timed) manner to the stereo. You could also have rejected signals coming too fast from the encoder, I suppose. Cool stuff, I'm impressed 👍🏻
@GnuReligion
@GnuReligion 2 роки тому
I've been building Marlin UI's with cheap rotary encoders recently, and am using a similar circuit, minus the R1 and the Schmitt Inverter. Most MCU's will already drive the digital read line high through a high valued resistor. So an easier, passive means is to just use a diode, resistor, and small capacitor for each switch.
@RalphBacon
@RalphBacon 2 роки тому
Sounds great! In fact, it sounds a bit like what @Bernd Felshe was saying the previous comment. Please don't tell me I have another switch bounce circuit to build?
@PolygonSwan
@PolygonSwan 2 роки тому
@@RalphBacon subscribed ....it's been 24 hrs ? 😜
@TheUnofficialMaker
@TheUnofficialMaker 2 роки тому
did you mean without R2?
@GnuReligion
@GnuReligion 2 роки тому
@@TheUnofficialMaker The idea is to eliminate the Vin+ and R1 because the read pin can be "INPUT_PULLUP", in place of the Schmitt device. You could go the other way (higher complexity), with 2 diodes for a symmetrical no-bounce circuit.
@TheUnofficialMaker
@TheUnofficialMaker 2 роки тому
@@GnuReligion got it. thanks
@lelandclayton5462
@lelandclayton5462 2 роки тому
I've seen that circuit all over the place for many years. Typically I see 100K and 10K resistors used and different variants of the Schmitt Trigger either as TTL or CMOS. I also seen a circuit that uses a 555 timer as a debounce, I never tried it but looked interesting.
@RalphBacon
@RalphBacon 2 роки тому
Interesting! I'm sure Jack Ganssle's circuit is being used everywhere! By varying R2 in the circuit (I use 18k2) we could adjust the bounce delay (eg 1mS - 10mS) because the cap will still hold its charge. As I say, interesting!
@edgeeffect
@edgeeffect Рік тому
Some (many?) microcontrollers have built in Schmitt triggers on their inputs.
@lelandclayton5462
@lelandclayton5462 Рік тому
@@edgeeffect Yea but controlled in software.
@NormanNodDunbar
@NormanNodDunbar 2 роки тому
Hi Ralph. Happy Christmas. I'll see your "ultimate" switch debouncer, and raise you the MC14490P hex debouncer. I use these when debouncing switches, surprisingly enough, and one chip takes up to 6 separate switches and requires only a single capacitor to set the frequency of the debouncing circuitry. You can pull each attached switch up to VCC or down to GND depending on your needs -- but they do all have to be the same. Other than that, it's surprisingly good! Happy New Year when it comes. Cheers, Norm.
@RalphBacon
@RalphBacon 2 роки тому
Hmm. I see that sales of your (excellent) Arduino hardware book must be doing well to suggest a chip that retails for £5.69 (RS Components) in single quantities! Yikes. I've read the spec sheet and I'm sure it's wonderful but "my" simple hex-input SN74AC14N chip costs just 45p when bought in packs of 10 - still less than a single MC14490P. Along with a resistor or two and a capacitor it still makes it very pocket-money friendly. Seriously, I wouldn't mind spending a few pounds extra on a personal project (just look at the cost of some of my project cases!) but on a commercial basis, cheaper is better (mostly). Just ask our Chinese suppliers!
@NormanNodDunbar
@NormanNodDunbar 2 роки тому
@@RalphBacon £5.69? Each? Goodness gracious! I got a pack of 10 for much less some time back from eBay. I'll have to check prices. Insert suitable delay here.... eBay has lots from China. Ranging from a pack of 10 for the price of one from RS, to a pack of 50 for £37. I expect some might not be kosher, but mine work fine. Cheers, Norm.
@RalphBacon
@RalphBacon 2 роки тому
"I expect some might not be kosher..." Oh, really? 🤣😆😊
@NormanNodDunbar
@NormanNodDunbar 2 роки тому
@@RalphBacon Yes, really!😉😉😉
@IanSlothieRolfe
@IanSlothieRolfe 2 роки тому
Where the bounce doesn't seem to go all the way up to supply voltage is probably just where the pulse is so brief that the input capacitance of the oscilloscope is still charging when the voltage is sampled.
@RalphBacon
@RalphBacon 2 роки тому
Sounds very plausible, Ian. Some of the bounces were very brief indeed. Such a source of irritation to us developers!
@romancharak3675
@romancharak3675 2 роки тому
I played with Jack's circuit some time ago, but I think my Oscilloscope probe setup added some extra ringing on the screen, causing me some confusion. Thank you for this interesting topic, Ralph.
@RalphBacon
@RalphBacon 2 роки тому
I detected no ringing in my experiments so maybe it was your probe setup, Roman. Glad you found this interesting and thanks for posting.
@asagk
@asagk 2 роки тому
There is a little trick that can be used, which is to connect one of the two pins (A/B) as a trigger for an external interrupt, and tell the direction fomr the state of the other pin as direction whenever the interrupt takes place, which can grant a safe higher turning speed, than with the shown schematic. That is especially true when a flip-flop stores the direction information of the pin that is not used as the trigger, but as a downside requires an additional IC like a 7474. But besides that a very good choice to use an external low pass filter to get rid of the bouncing. ------ Btw. shottky diodes are not used for rectification for some reason, which makes them not the best choice for blocking reverse current. They work to a certain limit the same way as silicium diodes, but do not block currents as fast, caused by their satturation characteritics. So do not expect that a shottky-diode does exactly what you expect when the switch connects the low pass to ground at all times. A 1n4148 (small signal si-diode) might be the better choice for this application, since it sppeds the charging at least up to Vcc-0.7V, while the rest up to Vcc then comes through R2. But when the switch connects the low pass to ground, the satturation charge is removed much fatser, so the time of reverse conducting is reduced until the diode blocks, while a shottky can under circumstances still be in a reverse conducting state. This behaviour is very depended on charge, amount of current, etc. ... but can play a role depending on the application.
@RalphBacon
@RalphBacon 2 роки тому
Hmm. My sketch uses a single interrupt on Pin A and then interrogates the state of Pin B to see which way the rotary encoder was being turned. Not the most elegant bit of code (too many if statements in an ISR) but works well enough to show that no bounces were corrupting the direction information. Isn't that pretty much what you are saying? Regarding the diode, guess what? I wasn't using a Schottky after all, but a 1N4148 (just like you say), much to my surprise when I built the PCB. I was getting confused with my remote temperature sensor from my Smart Heater Controller which definitely uses a Schottky to block reverse voltage flow - works OK in that circuit (a future video will tell all). In this bounce circuit the diodes are optional - might not be needed at all.
@asagk
@asagk 2 роки тому
@@RalphBacon Well, since I did remember something you had mentioned a shottky, I felt to point out that shottky diodes might not fit the purpose, since all the load in the capacitor wants to get discharged at once in reverse mode, so a huge current within a nanosecond, and the saturation characteristics might allow that to some degree, instead a fast small silicium signal diode with little saturation charge might be the better choice then. But perhaps I got your comment wrong then? My bad... :)
@byronwatkins2565
@byronwatkins2565 Рік тому
If you work it out, the inversion doesn't matter; A still changes before B (and vice versa) and the counts will be the same. Similarly, whether A,B are pulled down or up (as long as the common is the other) does not matter. tau1=(100 n)(82 k) = 8.2 ms and tau2 = (100 n)(18 k) = 1.8 ms. This gives a cutoff frequency f = 1 / (2 pi 10 m) = 16 Hz. If more than 16 cycles / revolution, then you have reduced the maximum rotation rate below Bournes' specifications in exchange for filtering the bounce noise. You could also save the cost of the diode by placing the 18 k in series with the switch and connecting C and the inverter 'in' between the resistors. Most port inputs also have hysteresis -- although Schmidt triggers usually have more.
@RalphBacon
@RalphBacon Рік тому
I'm not going to check your calculations, Byron, so let's assume they are correct. Your changes may work but until you actually try them out... you know what mean. 😉
@fredflintstone1
@fredflintstone1 2 роки тому
Nice video Ralph, I stopped throwing switches on the floor that stopped them bouncing :-)
@RalphBacon
@RalphBacon 2 роки тому
Yes, that would most definitely work too. Unfortunately you couldn't really have that floor-bouncing switch in a decent enclosure or you'd have enclosure-bounce too. For which I have no solution. Other than a visit from the men with those cute white jackets, very long sleeves and very long belts...
@fredflintstone1
@fredflintstone1 2 роки тому
@@RalphBacon those men in white coats expelled me from my last place there:-)
@therealemmpunkt
@therealemmpunkt 2 роки тому
if you put the components on the backside, there would be more space in the front to mount it in a panel...
@RalphBacon
@RalphBacon 2 роки тому
Yes, indeed. Just looking at mine here, if the 74XXX14 chip were soldered directly to the PCB (no socket) then the rotary encoder would fit onto a front panel and nothing gets even close to that. Or redesign it with SMD components, as I originally was going to do.
@lezbriddon
@lezbriddon Рік тому
just a thought i had while thinking of this today, although i watched it months ago, the schmitt trigger inverters, if the microcontroller has hysteresis of its own on its input pins, would they really still be needed....
@RalphBacon
@RalphBacon Рік тому
The microcontroller is more than quick enough to detect all the switch bounces going, I'm afraid. The difference with and without Schmitt triggers has to be seen (on an oscilloscope) to be believed!
@lezbriddon
@lezbriddon Рік тому
@@RalphBacon I'll swap 2 resistors and a little cap for lines of my code anyday...... The simple mistakes I've made in code I'll take hw over it anytime lol
@--JYM-Rescuing-SS-Minnow
@--JYM-Rescuing-SS-Minnow 2 роки тому
I would like to see you make an optical encoder ! I know you can !Outstanding work as usual! Harry Potter's proof of concept!
@RalphBacon
@RalphBacon 2 роки тому
Well, an LED, an opto-sensor and a circular disk with bits cut out of it placed between the two. Hmm. Now you got me thinking.
@Roy_Tellason
@Roy_Tellason 2 роки тому
@@RalphBacon You might find some useful bits to do this in an otherwise defunct computer mouse...
@romancharak3675
@romancharak3675 2 роки тому
They already make Optical Rotary encoders, they are much more expensive. Are you thinking of a DIY version, @Fantasy Engineered?
@BerndFelsche
@BerndFelsche 2 роки тому
You can do without the Schmitt trigger chip as digital inputs on microcontrollers have threshold levels for each logic level and known input impedance. There is typically hysteresis as well. With some rearranging, the resistors can be reduced by employing pull-up (or pull-down) on the microcontroller inputs. You have to do the maths! 😎😁
@RalphBacon
@RalphBacon 2 роки тому
Sounds feasible... but only proven in practice. Let me know when you've tried it, Bernd!
@LimbaZero
@LimbaZero 2 роки тому
Yep. You can check MCU IO block diagram if it have schmitt-trigger input. It seem at least AVR has these.
@markday3145
@markday3145 2 роки тому
As do STM32. On the RP2040, the Schmitt trigger is enabled by default, but can be disabled in software.
@jstro-hobbytech
@jstro-hobbytech 2 роки тому
I'm in nova scotia Mr. R.S Bacon or I'd take one off ya. You made an incredibly dull topic highly interesting. Great video
@RalphBacon
@RalphBacon 2 роки тому
Nova Scotia still has a postal service though, right? Send me an email and I'll add you to the list, Joey.
@leec2106
@leec2106 6 місяців тому
How much did the 30 PCBs cost? Did you ever make a surface mount PCB? I think I may build my own SM version for my project! I am using 1 single button and a toggle left to right to control a stepper motor. The single will bypass the pot setting and go full speed, otherwise it will do a percentage of speed set by the potentiometer. Lee
@RalphBacon
@RalphBacon 6 місяців тому
I've made a new (tiny) one recently, using a single SMD Schmitt trigger chip. Works well. Email me for more details (if you want them, of course!)
@daedelus1982
@daedelus1982 2 роки тому
Great video, really well explained as ever. Stupid question probably... In your code you have your ISR triggered on change, so you are watching on falling and rising edges. Why can't you have the ISR trigger on pin A falling edge only? From the ISR you can then just read pin B to check if pin B is high or low and whether the turn is CW or anti-CW? A lot less code that way. Ive probably missed something obvious, so apologies.
@RalphBacon
@RalphBacon 2 роки тому
No, it's not obvious at all. This particular rotary encoder has a detent part way through the cycle. If I only watched for falling (or rising) edges I would have to rotate it TWO clicks to get the full cycle detection. By watching for both edges I detect all clicks (detents). I've found that the cheap(er) rotary encoders from the Far East don't have the mid-cycle click so your 'rising' watch will work fine. I've done a video (#19, getting on a bit now but still works well) on those too: ukposts.info/have/v-deo/gmmUeHucnWZ6w4U.html BTW If you need a PCB from this video I still have some, just send me an email with your address.
@daedelus1982
@daedelus1982 2 роки тому
@@RalphBacon Aha, makes sense now. Thanks. Im actually having a go at making an SMD version of your's/Jack's circuit using JLCPCB. Using their SMD soldering service means I don't need to solder so much and I can make it much smaller as you said. Havn't done any board fabrication before or used any circuit design software so its a bit of a learning curve for me. Fun though. I'm sure I'll make a few mistakes, JLCPCB is very cheap though even with the shipping. Thanks again.
@ronalddhs3726
@ronalddhs3726 2 роки тому
Hi Ralph, Thanks for the vid. How do I contact you to get a PCB off your hands (I'm in the UK). Thanks again.
@RalphBacon
@RalphBacon 2 роки тому
Here: ukposts.infoabout scroll down to find my email address.
@Alltechfab406
@Alltechfab406 Рік тому
Can I get a bit more info on the sn74ac14n on digi-key there is so many options on different switching voltages, what are you using?
@RalphBacon
@RalphBacon Рік тому
For the demo in this video I was using 3v3. This was undoubtedly because I was using an ESP32 and I didn't want 5v appearing on any of the input pins from the Rotary Encoder (A/B/PB pins). The SN74AC14N is tolerant to 7v, however, so if you have an Arduino Uno (or other 5v microcontroller) it's safe to use 5v.
@Alltechfab406
@Alltechfab406 Рік тому
@@RalphBacon sorry for the silly questions I'm pretty new to this, am I correct in thinking that eats that of pins across from each other is a different trigger? Is the multiple pins able to be used for multiple inputs and outputs I'm not sure I'm saying that correctly. Maybe a better way to say it is Can I with one of the sn 74ac14n chips denounce say 4 buttons, or do I need one chip for each circuit? Thank you for your time!
@Enigma758
@Enigma758 2 роки тому
I noticed that your code does not use the state machine technique. I suppose that's because Gannsle's approach is good enough thereby rendering any further software techniques redundant.
@RalphBacon
@RalphBacon 2 роки тому
You are correct. The previous Rotary Encoder video used the state machine technique, but even then it was possible to miss a pulse if the loop() was particularly busy (or awaiting a response on, say, SPI). It also depends on how much work you put into the ISR, of course.
@sleepib
@sleepib 2 роки тому
R2 and the diode aren't needed here. When the switch contacts are closed, you know what state the switch is really in, so you should discharge the cap without delay. When the switch contacts are open it could be actually open, or it could be in the middle of a bounce, so that's when you need the delay. Given the scope shots, your delay is longer than it needs to be, as you only need to smooth the longest single bounce, rather than the whole settle time(and manufacturers generally specify the whole settle time). That said, you want to be characterizing heavily worn switches, so you can pick the lowest value that won't impact long term reliability. Basically, don't sacrifice performance to solve problems you don't have. If your debouncing circuit gets you reliable operation at high rates of rotation, by all means use it. For an encoder this RC + hysteresis method is good. If you have a double throw switch you can do better though, use a non-inverting buffer with positive feedback, read the common pin, and tie the NC and NO pins to opposite rails. The switch will latch in the state of the last closed contact, even if it closes for a fraction of a second before getting stuck on some dust that breaks continuity. No delays needed.
@RalphBacon
@RalphBacon 2 роки тому
Hmm. Whilst, in principle, what you say sounds very plausible, given that each switch is different, Jack Gansle has done some _serious_ work on this subject of switch bounce so what he has discovered must have merit. Of course, as you (and I) say that each switch is different we are free to modify the code/hardware to suit - but in a commercial environment we would defer to the lowest common denominator - the worst example of switch we found (or specified by the manufacturer). So if the datasheet says 60rpm *max* that's what we should allow. In a hobby environment if we discover, empirically, that _our switch_ can manage 200rpm, so be it!
@sleepib
@sleepib 2 роки тому
​@@RalphBacon I suspect that 60RPM max is just what the manufacturer believes will work with simplistic software debouncing(only a few samples, rather than the continuous sampling you get with hardware debouncing) and a switch at the end of its rated cycle life. When I've compared new and heavily worn switches on a scope, the worn ones bounce a lot more, but the individual bounces don't get THAT much longer, because the single bounce time should be mostly determined by the mass and springiness of the contact. Here's an example of a new mechanical mousewheel encoder and one that's been used for several years(same model, purchased at same time), even though the worn switch looks horrific in comparison, the longest single bounce there is still only ~40us, so you shouldn't need several milliseconds to filter it out: imgur dot com/a/0W7sO6Y I read the section of the paper that second resistor and diode were discussed, and I don't think they apply here, maybe if the switch was a long distance from the debounce circuit. Even then, you can get rid of the diode and lower R1 by the value of R2. At 5v, R1 can go as low as 2.5k and still stay inside your encoder's ratings. At least for the push switch I'd probably use 10k for R1, omit the diode, either 0 or 1k for R2, and 100n for the cap. Very high value pull up resistors can cause problems depending on what material the switch contacts are made of, and we don't know the pushbutton contacts are self wiping like encoder wipers would be.
@Clark-Mills
@Clark-Mills 2 роки тому
The inverter MUST be a Schmitt triggered input gate; the 7414 is, so great. In the schematic the gate should show the Schmitt symbol. If you don't use a Schmitt input gate you get noise as the input gate voltage passes through the grey zone where the input might be read as a logic one or logic zero.
@RalphBacon
@RalphBacon 2 роки тому
Indeed. I did emphasis that there was no "linear" (or grey) zone with a Schmitt trigger, hence why it was being used. The schematic symbol was one from the manufacturer, I think, without the Schmitt symbol, how remiss!
@WagonLoads
@WagonLoads 2 роки тому
I bought 2 rotary encoders from ebay and had a problem that wonder if this circuit can fix. If I turn both encoders clockwise, one counts up and the other counts down. I am guessing that the encoder wheel on one of them was flipped over. Can you tell us about optical rotary encoders? I know some are rated to be attached to motor shafts and spin at very fast rates.. Do they still have a maximum spin rate?
@RalphBacon
@RalphBacon 2 роки тому
Rotary encoders use light to determine the HIGH and LOW values; no switches or physical contacts. However, when I was investigating these, some had a maximum rpm of just 1,000, others 3,000. As these were already in the region of £30 - £40 each I decided I would not proceed with my experiments. I'm guessing that if you were to spend more you could get one with an increased rpm. I'd also recommend buying from a reputable supplier (RS Components, Digikey, Mouser) and the like.
@WagonLoads
@WagonLoads 2 роки тому
@@RalphBacon On Optical encoders, isn't there a transition point when the beam is being partially broken, where there is noise? Or does the optical detector have a built-in Schmitt trigger? Example of what I am thinking: Feed a triangle wave into one side of a comparator and a analog voltage from a pot into the other side. At the point where the triangle wave goes above or below the voltage set by the pot, is there a bunch of noise?
@RalphBacon
@RalphBacon 2 роки тому
I don't know is the quick answer; but I have found one of my optical rotary encoders (a Grayhill) so I might wire it up and try it out...
@WagonLoads
@WagonLoads 2 роки тому
@@RalphBacon Hey (just a side thought) In my example above. using a triangle wave on one side of a comparator, could you make a timer count how long the output is high and use that to make an infinite resolution ADC?
@staticpower4105
@staticpower4105 Рік тому
What about optical encoders? Are they limited for speed of rotation?
@RalphBacon
@RalphBacon Рік тому
Optical encoders are usually not limited but the datasheet will specify a maximum.
@jensschroder8214
@jensschroder8214 2 роки тому
the solution is not only for rotary encoders, but also for buttons, switches, reed switches and others. i ordered circuit boards from china, it's cheaper than from england.
@RalphBacon
@RalphBacon 2 роки тому
Yes, this is a general purpose switch debouncer, that is true!
@buzzwerd8093
@buzzwerd8093 2 роки тому
Your circuit has an RC delay built in between switch change and debounced signal change. Software debounce does too but I wonder which is quicker.
@RalphBacon
@RalphBacon 2 роки тому
Most switches are done with bouncing around after 2mS but I use 5mS in my software and don't have issues. The hardware version could be tweaked by adjusting the cap or better the R2 resistor to suit the switch being de-bounced.
@MrEdwardhartmann
@MrEdwardhartmann 2 роки тому
It seems to me that you could do SMD components mounted on the back with the rotary encoder mounted on the front and end up with a unit just slightly larger then the original rotary encoder.
@RalphBacon
@RalphBacon 2 роки тому
Indeed you (or I) could do that, Edward. Even the chip is available in SMD format. But as I explained in the video that would preclude lots of my viewers from taking one of my PCBs and constructing it for themselves. I suppose I should have made two versions but there are only so many hours in a day... I might talk to my MP about a 30-hour day soon.
@MrEdwardhartmann
@MrEdwardhartmann 2 роки тому
@@RalphBacon I don't think I would build it myself - JLCPCB's board manufacturing service is so cheap that it's easier to let them do it. And the last time I used them, they had a discount coupon for the cost of assembly, so the 5 boards I was having made cost less the a dollar to have assembled. I don't think I could have bought the parts for that price. The full price for making the boards and doing the pick and place was less then the shipping cost to get it to me.
@MrEdwardhartmann
@MrEdwardhartmann 2 роки тому
@@RalphBacon As for the chip, they do carry a SMD hex schmitt trigger chip - SN74LV14ADRG4 in a SOIC-14 case, but I also found a smaller 3 channel chip - 74hc3g14, but they are currently out of stock.
@RalphBacon
@RalphBacon 2 роки тому
I do keep intending to use their SMD Assembly service but keep designing though hole boards! Maybe next time.
@MrEdwardhartmann
@MrEdwardhartmann 2 роки тому
@@RalphBacon Just for fun, I did an SMD panel 20x23mm - so a 4x4 panelized board would give you 80 small boards. But, this first layout did not have any mounting holes. As long as you used rotary encoders that bolt through a panel, that should not be a problem. But I could make the board a little wider and add some mounting holes and maybe get a 3x4 panel. (who needs 80 rotary encoders anyway!) Not counting the rotary encoders and the 5 pin headers, the part that JLCPCB would mount would cost about $21 including the $3 charge for the one extended part.
@RalphBacon
@RalphBacon 2 роки тому
PLEASE READ THIS EVERYONE!
@chrismolloy131
@chrismolloy131 2 роки тому
I would like one to try
@RalphBacon
@RalphBacon 2 роки тому
Email me Chris! The address is buried in here: ukposts.infoabout
@jacquesmertens3369
@jacquesmertens3369 Рік тому
Why haven't the manufacturers come up with this? What's stopping them from improving the KY-040?
@RalphBacon
@RalphBacon Рік тому
In a word: Cost. Whilst you (and me) think that 50 cents or even $2 is a worthwhile investment in ensuring we have a bounce-free Rotary Encoder or switch, the bean counters at Acme Inc do not. They see no return on their investment, so don't do this. If they want the functionality, they leave it to the coders to implement. So as hobbyists we can "afford" to over-engineer our solutions. You could not (afford to) do this in a commercial environment. Not unless your company name is Apple. 😲😁
@edgeeffect
@edgeeffect Рік тому
Now I know how I've managed to b----r up the rotary encoders in my synths.... turning them at 10,000 RPM isn't such a good idea? ... I wrote that comment before you brought up 10,000 RPM... I like the fact that we both have the same idea of what constitutes "stupid speed" :)
@RalphBacon
@RalphBacon Рік тому
You _can_ turn _optical_ encoders at that speed (well, check the data sheet). But several thousand rpm is not uncommon.
@rpasco9352
@rpasco9352 Рік тому
Why are there no switch(es) debouncer(s)/switch(es)+debouncer(s) modules available ANYWHERE ???
@RalphBacon
@RalphBacon Рік тому
You mean, why can't you buy them? Because most developers either cater for the debounce in software or create their own hardware solution. Probably not worth a dedicated solution (although I did find some out there, silly money).
@gregtoman7678
@gregtoman7678 2 роки тому
I have never required more than an RC circuit to interface to a rotary encoder, EXCEPT for the bourns. I stopped using Bourns encoders because of the horrible performance, and the deceptive information they provided me when I talked with them. Great advice in the video, and I will implement this in my next design just to give myself more tolerance for a bad encoder, but I do not recommend using any Bourns encoders...you are asking for problems. They should be ashamed.
@RalphBacon
@RalphBacon 2 роки тому
Thanks for the info! I was _hoping_ that Bourns was a reliable make; your experience says otherwise. Hmm. More investigation needed!
@paulpkae
@paulpkae 2 роки тому
Think I suggested Schmitt triggers on your last video Ralph. Schmitt triggers, Op-amps, Comparators, Decade counters, Multiplexers, Shift Registers....... all excellent IC companions to micro controllers. The decision to solve a problem through software or hardware is a common dilemma. Personally I get more satisfaction going the hardware approach and not rely on code so much. I really like the idea of creating custom PCBs and I must get round to giving that a try. Your boards look great!
@RalphBacon
@RalphBacon 2 роки тому
You could well have done, Paul, although I have covered a hardware solution before (using a different chip) a few years back. But this was with a PCB and everything (well, except mounting holes, apparently). I do like the hardware solution too! It's what we intuitively expect from any switch, a simple on/off action!
@arminth
@arminth 2 роки тому
Did I miss the link to the debouncing paper?
@RalphBacon
@RalphBacon 2 роки тому
I guess you did - it's in my GitHub (link in the video description) but here too: github.com/RalphBacon/230-Ultimate-Switch-Bounce-Eliminator - good reading even if I didn't fully understand all the maths.
@arminth
@arminth 2 роки тому
@@RalphBacon as usual, the error was sitting in front of the computer! Thanks for pointing me to the right direction!
@jyvben1520
@jyvben1520 2 роки тому
Got a jlcpcb ad just before, how did they know ? ;-)
@RalphBacon
@RalphBacon 2 роки тому
Big Brother is always watching you, Jyv. And he knows _everything_ about you 😲
@joerideman
@joerideman 2 роки тому
Now that I have happily implemented the Pinteric algorithm I can turn as fast as I want. Out of the 20 cycles per whole rotation I miss 6 of them for being to quick. The algorithm prevents any bounce effects as if I was turning the other way. Why would you want to solve this with components?
@RalphBacon
@RalphBacon 2 роки тому
One reason to do this with components, not software, is to relieve the microcontroller from having to service the interrupts. It greatly depends on what your software is doing _apart_ from waiting for an interrupt, of course! But you could find that the main loop is significantly affected by all the ISRs (and associated function calls). It's the same with NeoPixels. Sure, you can run many hundred NeoPixels from a relatively fast processor - but you won't have any clock cycles left for anything else. That's why they invented NeoPixel Drivers, so the microcontroller can do lots of other work and just chuck stuff over the wall for the NeoPixel Driver to take care of. Horses for courses, as they probably don't say anymore 😁
@gregclare
@gregclare 2 роки тому
Given that you are effectively implementing a 20ms denounce delay in software (ie. not allowing another pulse for 20ms), I don’t really see the practical need for adding hardware denounce? Although I agree that the 2 resistor, 1 capacitor, plus Schmitt trigger is the standard switch denounce approach. :)
@RalphBacon
@RalphBacon 2 роки тому
In its current form, that is true, Greg. But the 20mS "Too Fast!" message was there merely to demonstrate the point. There is no need for it in real life. If someone does spin the rotary encoder that fast that it cannot cope, well, on their heads be it!
@banalestorchid5814
@banalestorchid5814 2 роки тому
You should have made the board through hole AND SMD, that would be really cool.
@RalphBacon
@RalphBacon 2 роки тому
Well, as I said in the video, I was _going_ to make it SMD (to make it smaller); then I would have had space for some mounting holes too. As it happens, through-hole is probably best for most people (the needs of the many outweigh the needs of the few) but there was really no space left for mounting holes. Sorry! My next board does have mounting holes though, keep tuned.
@johnstephenson2891
@johnstephenson2891 2 роки тому
Hi Ralph. Do you have any left? I don't see a pinned comment.
@RalphBacon
@RalphBacon 2 роки тому
It's there John. Just email me so I can add you to the list!
@johnstephenson2891
@johnstephenson2891 2 роки тому
@@RalphBacon Sorry I must be going blind, I don't see it.
@RalphBacon
@RalphBacon 2 роки тому
You know my email address surely, John?
@johnstephenson2891
@johnstephenson2891 2 роки тому
@@RalphBacon Haha, the reply is which one!!
@jumadhaheri
@jumadhaheri 2 роки тому
Maybe we can get the ultimate ultimate denounce eliminator
@RalphBacon
@RalphBacon 2 роки тому
Well, where there's a problem, there are a thousand engineers thinking about a solution...
@hansdegroot652
@hansdegroot652 11 місяців тому
But great video thx
@RalphBacon
@RalphBacon 11 місяців тому
You're welcome!
@hoggif
@hoggif 2 роки тому
Why not just debouce in software? I've never debounced with hardwaree. Software is "free" and uses no physical space. Unless you're running out of memory hardware is no better and compact debouncing code uses very little memory space. Having a clean input can enable different kind of software though, like just using pin change interrupts or what not.
@RalphBacon
@RalphBacon 2 роки тому
Why not indeed! Well, you've jumped into the debounce series at Season 4, so you've missed all my software debounce videos: #226 ukposts.info/have/v-deo/q4F_hHeqkYGfpas.html #98 ukposts.info/have/v-deo/q3RjZK6ijY2Zk6c.html #96 ukposts.info/have/v-deo/sZZhjmaYq55_roE.html #19 ukposts.info/have/v-deo/gmmUeHucnWZ6w4U.html Happy viewing!
@Charlietuna49
@Charlietuna49 2 роки тому
I don't understand how to order the pcb.
@RalphBacon
@RalphBacon 2 роки тому
Just "let me know" were the words I used! No details. It was a test. Ok, the best way to tell me you are interested in the PCB is to email me. My email address (carefully hidden so I don't get even more spam than I already do) is on this page: ukposts.infoabout
@Charlietuna49
@Charlietuna49 2 роки тому
@@RalphBacon Thanks
@laurentiujinga5558
@laurentiujinga5558 2 роки тому
do you still have the pcb? I can't see any pined comment
@RalphBacon
@RalphBacon 2 роки тому
Send me an email Laurentiu (you'll find my email address on this page: ukposts.infoabout) and I'll add you to the list.
@KaiseruSoze
@KaiseruSoze Рік тому
Optical rotary encoder.
@RalphBacon
@RalphBacon Рік тому
Pricey.
@YTbxg
@YTbxg 2 роки тому
Do you think this circuit work with the likes of windspeed and robot wheel quadrature encoders which I would suppose turn at higher rpm than a rotary encoder switch? A very interesting video and do pop my name into you circuit board giveaway lucky dip :-)
@RalphBacon
@RalphBacon 2 роки тому
Yes, absolutely. The 60rpm restriction is just for that Bourns encoder. A windspeed device usually has a magnet and a reed switch (mine does, anyway) and can whizz round quite fast. This circuit should have no trouble with that. I'll put your name into the draw if I know how to contact you (and what your name is)! You can email me. Address is on this page ukposts.infoabout
@yogeshitaliya473
@yogeshitaliya473 2 роки тому
😍😍😍😍😍
@RalphBacon
@RalphBacon 2 роки тому
I can always rely on you, Yogesh, nice to see you here!
@philchadwick9470
@philchadwick9470 2 роки тому
You must take a MINUMUM of one second Ralph, not a maximum.
@RalphBacon
@RalphBacon 2 роки тому
Doh! Of course I meant minimum! I should have said "one second or more" to make it clearer. I'm sure (most) viewers will have understood that it was not a race... I hope! (Smacks forehead with palm of hand - hang on, got an emoji for that) 🤦‍♂️🤦‍♂️🤦‍♂️
@harveyellis6758
@harveyellis6758 2 роки тому
"not unsurprisingly"?
@RalphBacon
@RalphBacon 2 роки тому
I suppose that's the same as "surprisingly", I guess. But with more confusion to add a certain je ne sais quoi!
@srduke
@srduke 2 роки тому
7:37 *minimum of 1 second.
@RalphBacon
@RalphBacon 2 роки тому
Yup. I'm hoping that as you picked up on this so will everyone else. "1 second or more" is what I should have said to avoid all confusion. Doh!
@zaprodk
@zaprodk 2 роки тому
*Ganssle, not Gansler :)
@RalphBacon
@RalphBacon 2 роки тому
I couldn't decide on the pronunciation: I thought it might be a Dutch or other European name in which case it would be pronounced Gans-ler. The English (or USA) pronunciation would be Gann-sell. How do you know which one? OK, I Googled him and he's American. Gans-ell it is. 😀
@rollyavecilla
@rollyavecilla 2 роки тому
Can I have your PCB re-fabricated at JLCPCB?
@RalphBacon
@RalphBacon 2 роки тому
Indeed you can, Rolando. If you open up the GitHub for this project, you will see I have uploaded both Gerber files and EasyEDA project. If you just want the PCBs exactly as I have made them, just upload the Gerber (zip) file to JCLPCB and they will provide them! If you know EasyEDA then you can import and then modify the project to suit yourself. github.com/RalphBacon/230-Ultimate-Switch-Bounce-Eliminator
@flyboy3633
@flyboy3633 Рік тому
Teach me your accent !
@RalphBacon
@RalphBacon Рік тому
It's not _me_ that has the accent, Ed, it's everyone else not in the UK! 😁
@pekkagronfors7304
@pekkagronfors7304 2 роки тому
He, he, This one is funny to watch
@RalphBacon
@RalphBacon 2 роки тому
It wasn't supposed to be funny, so do share what you find amusing, Pekka!
@laurentiujinga5558
@laurentiujinga5558 2 роки тому
I have to comment. I had a rotary encoder, test it and all went wrong... I ordered another 10 pcs on Amazon and I've quit trying after I test half of them. Just junk. I will never add a rotary encoder to my projects, not with this available junks
@martinmckee5333
@martinmckee5333 2 роки тому
In what way did they not work? I have used high quality encoders as well as cheap bulk encoders and they have all worked to some extent. The code can be tricky to get working the first time, but they are really lovely to use once they are working.
@RalphBacon
@RalphBacon 2 роки тому
If you watch my first video from a few years ago on the Rotary Encoder I can almost guarantee you success! The video: ukposts.info/have/v-deo/gmmUeHucnWZ6w4U.html Just do exactly what it says!
@hansdegroot652
@hansdegroot652 11 місяців тому
The best part is no part.
@RalphBacon
@RalphBacon 11 місяців тому
The best part is the part that "just works" and is a true fit-and-forget.
@hansdegroot652
@hansdegroot652 11 місяців тому
I think I better stick with software
@RalphBacon
@RalphBacon 11 місяців тому
Hardware is easier if you can already do the software, Hans.
@siliconjunkie7297
@siliconjunkie7297 2 роки тому
This sort of thing is simpler to do in software, no components required.
@RalphBacon
@RalphBacon 2 роки тому
Well, "simpler" is a relative term. This was an _alternative_ way of doing this (I did a software version a few weeks ago) and it enables developers to focus on their code rather than workarounds for shortcomings in the hardware!
@markcummings150
@markcummings150 2 роки тому
I think you missed the whole point of Ralph’s design. Maybe watch it again. I’m a hardware fan, and I’ve used an almost identical circuit on an Apple II plus hardware lowercase mod where there is simply no space left in the ROM to try and deal with all the issues that have to be dealt with to overcome key bounce. It barely takes any extra room on the pcb for one gate and a few passives.
@t1d100
@t1d100 Рік тому
Do not exceed RPM code = clever.
@RalphBacon
@RalphBacon Рік тому
Well, certainly informative!
@ReneKnuvers74rk
@ReneKnuvers74rk 2 роки тому
In my opinion this is nowhere near the ideal solution. The state machine was better is everal aspects, not the least the external component count and reusability in other encoder situations. But that is just an opinion.
@RalphBacon
@RalphBacon 2 роки тому
And I totally respect your opinion, Rene. I think either solution is good. It depends on how much "software" vs "hardware" you want the solution to be, I suppose. I just loved building this and then not having to worry about switch bounce in the software; it felt weird!
#227 ✨printf for Arduino✨(and ESP32, ESP8266) easy, formatted output
23:02
#226 ROTARY ENCODER with no switch bounce 🤓 - you MUST use this
25:49
Ralph S Bacon
Переглядів 27 тис.
Мама и дневник Зомби (часть 1)🧟 #shorts
00:47
Это было легко! Оживили и Отдаем BMW владельцу!
1:40:26
ИЛЬДАР АВТО-ПОДБОР
Переглядів 3,5 млн
How to use rotary encoders
14:12
FriendlyWire
Переглядів 23 тис.
How to De-Bounce Switches on the Arduino - Ultimate Guide to the Arduino #21
17:52
#BB9 Organising your code🧹for easier debugging and maintenance✅
18:45
#238 The Wrong Connectors😲forget DuPont, use JST or IDC for final use
22:12
Rotary Encoder (KY-040) Debounce Circuit Tutorial
15:03
ForceTronics
Переглядів 15 тис.
#19 How to use a Rotary Encoder with an Interrupt routine on your Arduino
16:44
#BB4 MOSFETs - From an Arduino Perspective
15:10
Ralph S Bacon
Переглядів 20 тис.
HACKED!: Using an HDD Motor as a Rotary Encoder?!
8:21
GreatScott!
Переглядів 1,5 млн
I7 2600K тест в играх и сравнение с AMD Ryzen
17:53
All New Atlas | Boston Dynamics
0:40
Boston Dynamics
Переглядів 5 млн
Сомнительно... Ну Окэй... Распаковал Nothing Phone (2a)
16:19
РасПаковка ДваПаковка
Переглядів 56 тис.
Секретная функция ютуба 😱🐍 #shorts
0:14
Владислав Шудейко
Переглядів 1,8 млн
I7 2600K тест в играх и сравнение с AMD Ryzen
17:53