Criticize the project: 74HC14-based module to debounce incremental rotary encoder

Hello!

Please, take a look at my project: a module for debouncing the incremental encoder with a push button. My concerns are about the layout and tracing (connecting) the components: what is wrong or bad practices?

The layout is:

The schematic is: schematics.pdf (34.4 KB).
I found the concept here, and re-routed it according to my wishes. More details are in GitHub Repository

P.S. I’m not an Electrical Engineer, so mistakes could be very silly.

This module is intended to be used instead of existing modules like these (which I found very noisy):

Do you need to debounce an encoder…?

I’ve tested about 30 different encoders (mechanical, optical, magnetic… Absolute and Incremental) for use with telescopes (and for general utility). I boiled it down to some “simplified opinions’s”…

• Generally speaking, Debounce Electrically or Debounce via Software (depends on project’s need/design…)

• If the encoder is good, no electrical debounce needed (do it in software, if needed). In fact, I haven’t hooked them up with resistors (as typical info sheets call out) in years…

The “if needed” is the key, as follows:

• Optical Encoders do not need debounce
• Good Mechanical encoders do not need debounce
• Magnetic Encoders - throw them in the trash or use them for volume/selection control

I use many $2 encoders for projects other than Telescopes and like these (Panasonic EVEJB, Bourns PEC_11R and 12R) - they are low-cost and I never debounce (except for using the C-language “_ asm _("nop\n”)” which provides a delay in the code’s cycle of about 200ns (depending on your device (Arduino, PIC, Atmel…etc) - that’s the time it takes to run one line of empty code. They are great for Volume and Selection but, not for accurate position.

For Optical Encoders, I have several brands but prefer Signwise as they are the best value and reliability for the cost… Never had a problem with them and they’re deadly accurate and smooth. Not the same form-factor as what your schematic calls for - they’re more of a ‘Stand-Alone’ unit.
There are some other optical one’s and you can make your own (I did)

I haven’t updated this since posting 5yrs ago but, there are some links to encoders/code… the Signwise encoders are typical of others (probably made at same China factory) and prices vary (I usually pay around $16). I’ve seen the Vex for a low as $16 for Two…

Regarding your schematic - many encoders with the same Pin geometry but with different wiring needs - thus, will need to know the specific encoder and ensure it’s correct for usage…

I have no experience with incremental encoders.
Some contacts need to be loaded with some minimum current to automatic self-cleaning of contact take place. Such problem exists in relay contacts, and microswitch contacts. As I understand it is typical for contacts just touching each other. If contacts rub against each other problem not exists.
If you had only A and B outputs I would assume that are contacts that rub, but the extra switch output may be is something only touching.
I just want to say - ensure that VCC/10k is enough for your encoder long live.

If I were designing something like that I would certainly consider 74HC2G14. May be you will get simpler PCB. And the first HC14 in each channel is really not needed - after 10k to VCC you can use 100k + some C as CMOS inputs can be driven with high impedance source.

As BlackCoffee wrote before. There are many different types of rotary encoders. (I do not know why he does not like the “magnetic” type (although there are also several different “magnetic type” encoders)

Microcontrollers may have schmitt trigger inputs, and in such cases you do not need an extra IC on your encoder. Same for when you do the debouncing in software. I would add a few “Solder bridges” to the PCB to make it easy to bypass the IC if it’s not needed.

With the simple rotary encoders such as used in front panels / knobs, it is quite imporant that the capacitor can never discharge through the switch. Especially with the (most often) used ceramic capacitors, there can be very high peak currents (such as 10A) and this can lead to premature failure of the switch. You have done it correctly. This error is sometimes made when “cost optimizing” the BOM.

My experience with Magnetic Encoders comes mostly from a career divided between Rockets (big Missiles, really big - 3ft to 8ft diam, 30+ft long) on submarines, in silo’s and strapped to planes. And, the testing environments were noisy, loaded with Magnetic Flux…etc. And, being Nuclear Weapon Missiles, they needed to be Nuclear Hardened (to external bombardment), Flux Hardened and a host of other… Magnetic encoders were a ‘No No’

My medical engineering took me into X-Ray, MRI/CT, also in noisy, heavy flux environments…

Perhaps more of a habit than a particular project’s needs but, I tend to stick with what I know…

If you Google for info, you’ll see stuff like below…

1 Like

That “Must we abandon magnetic encoders?”
[Edit] Clickable link:
https://www.controldesign.com/articles/2005/249
And one of the responses mentioned that these usually can be used in motor applications without problems.

Without reading the whole article (Just your screenshots is enough).
Magnetic encoders are great, But just as any other kind of technology they have their limitations.

This is a nice example.
In this video from Big Clive he finds two magnetic encoders in a car steering wheel assembly. Hall effect IC’s on the PCB, and two magnets in small gear. The gears have a different tooth count to make it possible for the microcontroller to track the position over multiple turns.
These things are calibrated by first mounting the magnets (&gear) in a random position, and then turn the steering wheel fully to both extreme positions. With two encoders you also have redundancy and can detect when one of the encoders give false readings.

These things may have gotten a bad name because they may be “hyped up” when they were new on the market and abused by people who did not regard their limitations.

Also, These can have a resolution of 12 bit or more. I do not know of another solution with that resolution and similar price range.

I’ve seen a few different project (such as AnnanasStepper and BigTreeTech K42B, where a radially magnetized NibiDibiDibbibum magnet is placed on the stepper motor axle to form a closed loop system. Magnetic encoders have a very long life here and it’s extremely simple.
They all make the same mistake though:
All these projects put the magnet directly on the end of the axle, and the steel axle sucks up a part of the magnet field. There should be a non-magnetic spacer of a few mm thick between the magnet and the axle.

That “Susceptible to strong external magnetic fields” is true, but rarely important. Normally a strong magnet is placed at a distance of one to a few mm from the sensor. You would have to try very hard to overcome that, and it’s also easily overcome if the whole thing is placed in a steel housing. Maybe it’s just the people who make big money with optical encoders who spread such rumors.

This is offtopic, but I took time to find and read it. It was an actual question by a person who didn’t know, and what was said was an answer to that question. So it wasn’t an eyecatcher (if I understand the word correctly).

I cannot help but notice that 91 nF is a weird value. In >40 years of engineering experience, I do not think I have ever encountered a capacitor with “91” digits in the value, regardless of the decimal placement. It might make perfect sense if you happen to have the capacitors already. But be aware that the hysteresis in any 74HC logic input is not so precise so choosing such capacitor value seems like “measure with a micrometer, mark it with chalk and cut it with an axe.” 100 nF is very common and probably much cheaper. I am reluctant to believe that you need that value and if you do, it would make more sense to use 100 nF and change R2, R4, R6 to 9.09K ohms 1%. You would probably buy this capacitor in an 0603 or 0402 size (if someone else is soldering it) and X7R dielectric.

LATER EDIT: Capacitors are a complex issue by themselves, particularly if you want a relatively stable effective capacitance as you do with C2,C3,C4. If you have any uncertainty regarding the timing values, I recommend allowing these capacitors to be larger than may appear necessary, such as 0805 or 1206 size. This will make it easier to get significant capacitance with a value-stable dielectric type. The more stable types provide less capacitance in a given package size. The other thing…you could use R2,R4,R6 up to 100K and probably even 1 Meg in order to reduce the amount of capacitance needed.

Following is my design for debouncing an old Logitech trackball mouse where I guess that the switch springs are wearing out. The redeeming value of this circuit is that you can build this circuit on a small board and simply “add it in” to the mouse without cutting any wires. It is in the trackball which I am using right now.

Doing debounce in software assumes software expertise of which I (for example) have little or none.

I tried Windows debounce utilities for this mouse but nothing worked well as this debounce circuit does. This is only a 1-off so I hand wired it on perf board.

I think I needed to increase C1 to 680 nF metallized film for longer debounce time, but that result has endured now for a while. If I were to to make a product out of this, I would probably go with a 1 uF tantalum or X7R ceramic.

1 Like

Further to @BobZ comments:

Your debouncers will give you about .7MS with 100nF & 10K. You will get about .67MS with 91nF & 10k.

You will get about the same result with 10nF & 100K, and much easier to source parts.

Hah! and mistakes could be very silly even if you were an EE!

Cheers,

Yes! (These are added words to get up to minimum comment size.)

Thank you for teaching. I updated the starting post to explain, what exactly it is going to be used for.

Regarding the encoders themselves: I’ve never used Bourns, only those cheap-market modules and they are noisy(

Thank you! I think, I followed the values I found in original schematics on some forum and just wanted to remake the layout for a few issues more convenient for me.

I’ll switch to more standard values.

Could you tell me the formula you’ve used to calculate the debouncing time?

I think he calculated 70% of the RC constant which equals 50% of the final voltage, nice explanation here:

https://www.electronics-tutorials.ws/rc/rc_1.html

1 Like

I pulled the times from an ancient graph I still possess. It is pretty accurate for cmos Schmitt triggers.

There is a formula, but it is complicated.
I went for a surf and found this: https://my.eng.utah.edu/~cs5780/debouncing.pdf which just happens to use a 7414 as a working example for the math :slightly_smiling_face:

Things to remember:
R & C are multiplied in the equation, so you can just put a zero on both sides to help decide which components to select. eg. 10K & .1uF gives the same result as 100K & .01uF or 1M & .001uF.
There are some large tolerances involved, especially with the capacitor, so the only way to get a really accurate result (not that you need it with your above example) is with a CRO and a vacuo/visuo (suck it and see) approach.

I just wanted to add the Jack Ganssle Debounce article:
http://www.ganssle.com/debouncing.htm

And about 20 seconds later noticed that jmk linked to the same article…

Well, at least you have a link to the source (and apparently there is an update in 2014.

Debounce times (and other behavior) can vary wildly for different switches. The difference between a 91nF an 100nF capacitor is negligible compared to that.

I also just remembered:


There are some similarities between your project and that one.
They’re so similar that there likely is some kind of link from sources fourd on the 'web.

Personally I’m more of a fan of a “Front Panel” microcontroller.
Make a bit bigger PCB, (Probably piggy backing on a HDD44780 LCD) and then have that microcontroller keep track of a few of such encoders, a bunch of (multiplexed) buttons and some LED’s.

FYI - Not trying to sell you on the Bourns - just pointing out they are Low-Cost. Various configurations and price ranges from $0.9 to a couple of dollars (US), depending where you buy (Amazon, Digi-Key, Mouser…etc). (when checking price at Amazon, they often come in 6-packs). They are the choice of musical instrument/device makers because of their ‘Low-Noise’. Snippet of spec attached (shows bounce…)

They fit your geometry/footprint.

Poor-Quality video shows accuracy without noisy/random signals. No debounce or resistors used. Attached to Arduino

pec11r.mov

That’s actually kinda what AdaFruit is doing with their Seesaw platform. Many of thier daisy-chainable I2C boards have a chip with the Seesaw platform on it to translate miscellaneous things to I2C. Actually, they do have a rotary encoder I2C board that also includes a programmable LED on it here for about $6USD a pop. A bit pricy for a production project, but useful for hobby projects.

I once had a ‘big board’ with 16 encoders, gears, motors and a display. After some years went by, most of the encoders were no longer in production. By that time, I boiled down the number of encoders to 3 with the same footprint. The fourth is the Signwise on a stand-alone fixture.

I made a PCB with the 3 encoders and a selection switch. Didn’t bother to add electronics/display… too easy to just plug it in as needed…

But SeeSaw does not do rotary enoders (Yet).
[Edit] Oops, silly me, did not look beyond the first PCB of the project…

About front panels…
I do like the ht16k33. It can both multiplex a bunch of LED’s and scan a keyboard matrix.
It is also one of the Ali Express specials, so widely availabe (for hobby stuff) on ready made PCB’s and small prices. (Including different configurations of 7-segment or starburst displays and pushbuttons.

Also (very distantly) related:
PM2534 is an old bench top DMM from Philiips which uses I2C for almost everything inside. Service manual is available on the 'web.