Rotary Encoder (KY-040) Debounce Circuit Tutorial

  Рет қаралды 16,978

ForceTronics

ForceTronics

Күн бұрын

In this tutorial we look at how to combat switch bounce when using a rotary encoder with a debounce circuit made up of fairly basic components (see below). We use the KY-040 encoder as the test subject in the video. Below is the parts list from the video and a link to the ForceTronics blog where you can find the Arduino code used for the test application in the video.
Parts list: BAS16-HE3-18 (Diode), SN74LVC1G17QDCKRQ1 (Schmitt Trigger), standard 0805 resistors (300ohms and 15kohms), and 4.7uF 0805 ceramic capacitor
You can download the PCB design files and the gerber files for the KY-040 Debounce circuit from my Patreon page (just $3 US to join): / ky-040-encoder-93026341
Link to code: forcetronic.blogspot.com/2021...

Пікірлер: 44
@pjforde1978
@pjforde1978 10 ай бұрын
My man! This is almost certainly the most useful hardware debounce video currently on KZbin.
@madrigo
@madrigo 2 жыл бұрын
Man great content as always. What I love about this simple design is if you have switches with pull-downs, all you gotta do is to invert the diode. Super nice!
@avejst
@avejst 2 жыл бұрын
Great video Great and interesting solution for a not so often addressed problem Ralph S Bacon have shown a software solution to this problem, that I newer have seen before. It's his #226 video, great stuff Thanks for sharing your experience with all of us 👍😀
@beegee3817
@beegee3817 2 жыл бұрын
WOW, great example showing the bounce output on the scope. It would be nice to a comparison of the hardware and software denounce effectiveness.
@vrjb100
@vrjb100 3 ай бұрын
Analog electronics are realtime, and don't waste precious clock cicles on the microcontroller. So software debouce is the inferior solution by default.
@konturgestalter
@konturgestalter 2 жыл бұрын
fantastic
@donk73
@donk73 2 жыл бұрын
Thanks for a interesting and well-done video. A simple RC filter seems to work for me. I'm surprised nobody has produced a small, cheap eight-channel debounce board using the MAX6818 debounce IC. I've done some searching and haven't found anything.
@VeritasEtAequitas
@VeritasEtAequitas Жыл бұрын
Or just more cheap, high quality, pre-debounced rotary encoders so we're not reinventing the wheel for everything. Who really wants to use one without debouncing?
@jacquesmertens3369
@jacquesmertens3369 Жыл бұрын
Great tutorial. I wish these circuits were for sale, or even better: integrated in the KY-040. For just a dollar extra the factory can do it. What is stopping them?
@webslinger2011
@webslinger2011 2 жыл бұрын
Nice!
@diogocarvalho2934
@diogocarvalho2934 10 ай бұрын
Very cool. What would be needed to adapt it to a 5V circuit?
@t1d100
@t1d100 Жыл бұрын
Super-great
@LuisPa247
@LuisPa247 7 ай бұрын
Great video, i wish i had seen it earlier...lost a day dealing with the stupid bounce on a KY-040. Do you have a PCBWAY or JLCPCB board model? or you sell those boards? Thanks again for the good work, definetively won my sub and like.
@ForceTronics
@ForceTronics 7 ай бұрын
Glad you found the video useful, you can access the Eagle CAD PCB design files on my Patreon page. If you don't have Eagle, I also posted the gerber files for the design which you can send to any PCB manufacturer, such as JLCPCB or PCBway. Here is the link (it is $3 to join for a month): www.patreon.com/posts/ky-040-encoder-93026341
@jessehesch
@jessehesch Жыл бұрын
Thanks for the video and great info. Could you share your gerber files? Or, perhaps, are you selling the circuit boards you show in the video? Lastly, would it be problematic if the encoder being used did not have built in resistors like the KY-040? I am using a 100PPR encoder for a CNC jogging pendant, that has some pretty terrible bounce, and I want to use this type of hardware approach to improve the output signal, but my encoder does not have any built-in resistors. Can I simply ignore this fact, or would I need to add the resistors, so my encoder was setup like the KY-040 is before adding the circuit you designed? Thanks for your input.
@ForceTronics
@ForceTronics Жыл бұрын
Actually the resistors make the debounce tougher because they provide less flexibility when trying to get the ideal RC time constant. No resistors is better.
@stealthBae
@stealthBae 2 жыл бұрын
interesting. I never noticed it
@abhinmajix
@abhinmajix Жыл бұрын
Great content, keep it up, is this Schmitt triger ic and this circuit can be used for esp32.
@ForceTronics
@ForceTronics Жыл бұрын
Yeah it will work with any uController as long as you have the right voltage logic level
@kastor8274
@kastor8274 9 ай бұрын
I can see the BAS16-HE3-18 only as SMD part. What through hole can I use instead ?
@BenMitro
@BenMitro 2 жыл бұрын
Thanks for doing that for us! One thing I didn't understand is why the 300R across the diode?
@datawolk
@datawolk 2 жыл бұрын
The capacitor has to be discharged when there is no button press. And because this ic has a high impedance input, it has to take another route.
@BenMitro
@BenMitro 2 жыл бұрын
@@datawolk It puzzled me why it was across the diode and not across the capacitor as a discharge path as you point out Arnold. I can see it will discharge either way, but across the diode kind of negates the function of the diode to some extent.
@user-or1sb1zw9p
@user-or1sb1zw9p Жыл бұрын
Hei, thank you for the video. Would it be possible to realise that circuit with through hole components. I would like to try it on a breadboard.
@ForceTronics
@ForceTronics Жыл бұрын
Yes, I would assume so. You just need to do the parts research to find versions in through hole.
@RoterFruchtZwerg
@RoterFruchtZwerg 2 жыл бұрын
Hey, thx for pointing out this important topic 👍 But I'm wondering if this complexity is really needed. Isn't a simple RC filter in front of the schmitt trigger enough? With a time constant of few ms it should dampen all bounces enough and can also be pretty high impedance, so you don't have to worry much about the pull-up/down values.
@ForceTronics
@ForceTronics 2 жыл бұрын
Great question. Without the diode the capacitor would just be shorted to ground when the switch is closed so there would be no RC time constant. I guess you could put a resistor in series before the capacitor to prevent a short to ground. I think it would work but the value of the schmitt trigger is the clean high / low transition. If you are making a commercial product cap values have a 10 or 20% tolerance so you could get a situation where the timing of switches varies a bit across products, but the timing changes may be so small they are not noticeable.
@VeritasEtAequitas
@VeritasEtAequitas Жыл бұрын
Use a zener bypass diode too, lower forward voltage drop.
@t1d100
@t1d100 Жыл бұрын
Do you mean Schottky?
@kennywu4791
@kennywu4791 2 жыл бұрын
Are you selling the debounce board?
@ralmslb
@ralmslb Жыл бұрын
If you don't have a schmitt trigger, having the remaining of the circuit would help a bit no?
@ForceTronics
@ForceTronics Жыл бұрын
Yes! Schmitt just gives you a nice sharp pulse
@alexptvz1076
@alexptvz1076 6 ай бұрын
What happens if we'll just remove the triggers' ICs from the circuit? Is it a problem for MCU to read those smooth values using digital or analog IO?
@ForceTronics
@ForceTronics 6 ай бұрын
Yes it will work without the Schmitt trigger as long as the pulse has a large enough amplitude to register as a high logic level. The only downside is is you get a rising or falling edge that's unpredictable because of tolerances and capacitor values and aging of the capacitor. This is only an issue if you have tight timing in your application and you need interrupts to be in a certain order, etc.
@srinivaskosetty8785
@srinivaskosetty8785 7 ай бұрын
How can i make a debouncing ckt for 28V instead of 5 or 3.3V
@ForceTronics
@ForceTronics 6 ай бұрын
You would need to calculate a resistor divider network that divides the 28V down to an acceptable voltage level that can be measured by whatever device you are using to monitor the encoder.
@TheBauwssss
@TheBauwssss 2 жыл бұрын
6:30 dafuq, where did that so-called "sgmid trigger" suddenly come from? Not to mention another important question, what is a sgmid trigger?
@AJs-Projects
@AJs-Projects 2 жыл бұрын
Schmitt trigger is a pretty well known type of circuit. Googling it would probably make a lot more sense than if I tried to explain it.
@rwr5170
@rwr5170 8 ай бұрын
Will it work with 5 volts?🤔
@ForceTronics
@ForceTronics 8 ай бұрын
This will work for other voltage values. You just need to check / do the resistor voltage divider math to ensure you get enough voltage to be read as a logic high
@bertram-raven
@bertram-raven Жыл бұрын
I think I'll stick to using a MAX. It's a lot easier than making these pcb's if you don't have an engraving machine.
@makerspace533
@makerspace533 7 ай бұрын
I think you have over complicated it a bit. You have added 5 points of failure. In reality, placing a 0.1uF cap across the switch will reduce the bounce and not hinder the response of the encoder.
@ForceTronics
@ForceTronics 7 ай бұрын
Your not wrong and someone already made a similar comment. Just using a cap doesn't work well when working on applications with critical timing and complex interrupts. Using just a cap creates slow unpredictable rise and fall times that are not predictable from one unit to another. This is because caps have wide tolerances (typically 20%), they age, and vary with temperature. This approach creates fast rise and fall times that are predictable in manufacturing. The best approach is probably application dependent.
How to Configure a USB Type-C Connector for Your Arduino Project
25:14
How to use rotary encoders
14:12
FriendlyWire
Рет қаралды 28 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 58 МЛН
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 37 МЛН
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 39 МЛН
Tip Of The Day / Switch Contact Debounce Circuit
5:28
0033mer
Рет қаралды 2,8 М.
How to debounce a button (Hardware approach)
10:16
WellTronic
Рет қаралды 21 М.
HACKED!: Using an HDD Motor as a Rotary Encoder?!
8:21
GreatScott!
Рет қаралды 1,5 МЛН
How To Use A Rotary Encoder Without Software
29:41
Gadget Reboot
Рет қаралды 15 М.
Debounce a Switch
1:43
Texas Instruments
Рет қаралды 48 М.
How to use a Rotary Encoder with an Arduino - CODE EXPLAINED!
21:11
Debounced rotary encoder module
20:37
Curious Scientist
Рет қаралды 6 М.
Eliminating Switch Bounce with a Debounce Circuit
16:49
ForceTronics
Рет қаралды 29 М.
Хотела заскамить на Айфон!😱📱(@gertieinar)
0:21
Взрывная История
Рет қаралды 4,5 МЛН
Игровой Комп с Авито за 4500р
1:00
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,5 МЛН
Will the battery emit smoke if it rotates rapidly?
0:11
Meaningful Cartoons 183
Рет қаралды 36 МЛН
Gizli Apple Watch Özelliği😱
0:14
Safak Novruz
Рет қаралды 4,7 МЛН
Телефон в воде 🤯
0:28
FATA MORGANA
Рет қаралды 1,2 МЛН