Encoder Module with button (CE09436)

Hi All

The ongoing quest for the perfect encoder.

Now I don’t know what sort of input signal the interrupt pins prefer, a fast transition or a sloping one, nor do I know at what point this triggers. Suppose I could look and find out but I thought a fast one would be nicer and a chance for some final filtering.

Enter the Schmidt Trigger. There are a couple of ways to go about this.

  1. Use a dedicated IC. Some cons, most of the commonly available devices are inverting (probably not a big deal), they usually come in a package of 6 with 14 pins, the data sheets indicate a fair bit of variation in the hysteresis values, the reference point is not controllable….Pros, no external components required.

  2. Use an OP Amp (in this case dual for switch a & b). Cons, external resistors are required….Pros, hysteresis is controllable, reference point is controllable, inverting or non-inverting take your pick.

The circuit I have used……

Schmidt_Trigger_schematic

I have chosen the LM6482AIN, Dual low power, operating voltage 3V to 15V, performs quite happily at 3.3V. I have used 5V as it is connected to UNO R3, and is “rail to rail”.

The hysteresis is controlled by the ratio R5(R6) / R3(R4). Formula and handy calculator here…

https://daycounter.com/Calculators/Comparator-Hysteresis-Calculator.phtml

With the values shown this is 1.5V (1.75V – 3.25V)

The reference point is set by R1 & R2. In this case 2.5V

R7 and R8 are not necessary but are there for a bit of “insurance” in the case of accidents.

The outputs of the OP Amp are driven HIGH (source) and LOW (sink) so pull ups on the Arduino, Rpi or whatever are not required.

This Pic shows the basic operation with a sine wave input, the hysteresis can be clearly seen.

Next 2 pics showing the encoder filter output (yellow) and Schmidt trigger output (blue) for switch a, CW and CCW rotation. Did not investigate the little glitch on the charging curve but once again the hysteresis can be clearly seen and allowing for some measurement error is very close to the calculated value (little block top left of oscilloscope screen).

Next demonstrates what I mentioned previously. Rotating the encoder much faster than “normal” could result in missed counts, in this case 4, which I think would have been avoided with a diode across R1 & R4 in the filter network and thus a shorter capacitor charging time.

Next 2 pics show the schmidt trigger output for both switch a (yellow) and b (blue) for “normal” rotation speed for both CW and CCW rotation. Note nice clean pulses.

Using the schmidt trigger and rotating the encoder 1 rev CW and 1 rev CCW for several minutes produced 0 errors in the CW direction and an occasional 1 count error in the CCW direction.

Conclusion. If you can tolerate some errors particularly in the CCW direction this unit is fine as is. For volume control and similar where rotation would be relatively slow I don’t think this is a big deal as you would not be monitoring actual positioning and only rotating the encoder until you get it where you want it.
If you want or need minimal errors the use of a schmidt trigger as well as an RC filter is recommended.

If you need to rotate at some speed an optical or magnetic device would be needed anyway as the mechanical types have speed limitations (see data sheets).
I note with interest that of the few optical encoders I looked at on Element 14 quite a few had schmidt triggers built in and those that didn’t recommended using one.

That’s all folks. I hope this helps those contemplating using these devices in the future.
Cheers Bob

2 Likes