I have an EC11 encoder connected to the SCM20260D and using this to input numeric fields. It kind of works but I am seeing direction changes when I go in 1 direction depending on the speed. I’ve used this encoder before with an STM32 and it was super stable and would count up or down with no reverse pulses detected.
The datasheet says 2-3ms chatter so I set the debounce to 4ms.
Looking at the scope, the pulses look good. I have a 10K pullup and a 0.1uF cap on the input.
This is the count up direction at fast rotation speed. I have the interrupt set for falling edge on the yellow trace and check the blue trace to determine the direction. The scope shows that the pulses are all good with 8ms before the blue trace returns high.
Next is the scope from the other direction, again it all looks good with 6ms before the transition to the other state.
I’ve tried debounce 1ms, 2ms etc and I just don’t get a good response. It doesn’t look good from the operators point of view. Going slow works but that defeats the purpose of the endoder.
How do you disable debounce? Do we just leave this field unset or do we need to set this to ZERO?
Lastly, how does the debounce work? I could not see how the delay is handled in the Library files.
That doesn’t seem to work at all for me. I have falling edge triggering on encoderA
I can’t get any event with slow rotation. Fast rotation gives me a count up and then count down on the next event.
Not sure this code would work as it falls into the same issue that DAT mentions that reading encoderB input may not be active anymore if there is a delay before the falling edge and the event firing.
We kind of need a hardware level interrupt handler that is fast enough to capture the edge and the state of the second input. I have a hardware counter on another project that uses an Atmel ATTiny418 to handle encoder readings from a 2000 pulse encoder and I can record perfect steps up to 5 rpm with that.
Probably I was using different firmware which is not released yet, although I don’t see how it effect.
Also
Still not 100%. I am still seeing down counts when I turn cw and also up counts in the ccw direction.
I had that issue with one encoder that has no 10K and 0.1uF. We tried another one with10K and 0.1uF then signal pulses are clean and work fine. Just more information because I think you already have them installed.
If you look at the 2 scope traces I posted above for cw and ccw rotation, you will see that if you trigger on the falling edge of the encoderA signal and then read encoderB in the interrupt handler, you can determine direction as it will be either high or low for each direction. This it the exact same technique I’ve used for years with encoders and it works perfectly.
This is what I am doing now and the count seems to be perfect, even with fast rotation.