I bought an Sparkfun RGB illuminated rotary encoder.
The encoder is connected as mentioned in the manual (fig.4) - means 4 x 10kOhm resistors and two capacitors.
Unfortunatly I only had 0,1yF capacitors instead of the 0,01yF in the manual. but I would assume that this is not a big deal.
The task for the encoder is that I can select an value between 0 and 180, so so every time you rotate the encoder clockwise, the value should be incremented and vice versa.
Sometimes the value will be changed by one if you rotate the encoder for one “click”, sometimes the value jumps multiple values (up to 100).
As I have no experience with encoders (and i don´t have an alternative product here), I attached the encoder to an oscilloscope.
The record was made rotating always one single step, short break, next rotation - I only rotated into one direction.
I attached three screenshots.
First one is what I expected an encoder should work - and this one does this sometimes
Second one shows that one output isn´t switching back, third one the same but in this one sometimes the encoder shows two peaks, even if just rotated one step.
Can anyone confirm that the behaviour recorded by oscilloscope is correct?
Then the problem is software related - otherwise I should buy some new the encoders.
The ground from oscilloscope was connected to Terminal C of the encoder, the probe tip of channel A to Terminal A of encoder and probe tip of channel B to Terminal B
You need to debounce your inputs. The Sparkfun sample sketch for that device demonstrates one way to accomplish that. See https://github.com/sparkfun/Rotary_Enco … ncoder.ino. There are also many other examples and explanation on the web if you search on the word debounce or debounce rotary encoder.
thank you for sending the link, in the meantime I implented the code to my project.
And, yes it´s defiently a differnet behaviour now.
But still not really satisfying at all.
Rotating the encoder now will increase or decrease the value, but only sometimes.
So now it could be that the encoder has to be rotated by 10~25 “clicks” before the value changes - and then not even guaranteed that in the correct direction (up- or downcounting).
Also tried the “alternative” compare values (0x06 / 0x0C) as descriped in the code.
To doublecheck I ordered some other rotary encoders - anyhow, as it is christmas time, I would expect that it will take some days before the arrive…
This brought me back to the idea to compare the rotary encoder with another rotary encoder.
So I received some EC11 encoders the last day, gonna put them in a simple circuit (each Terminal (A and B) connected with an 10k resistor to +, Terminal C connected to ground).
I made the same exercice with both encoders - rotaing CCW and capturing this with an oscilloscope.
The screenshots are attached, but for me it looks like the RGB illuminated encoder is broken or has very poor quality.
For sure the debouncing by software will make it a bit better - but it´s GI-GO (garbage in - garbage out) for me.
Look e.g. at second 8 in the screenshot from Sparkfun encoder, the red line doesn´t goes back to 5V, it stays at 0V - so inside the encoder the contact is still closed) and just after another rotation it goes back to 5V - similiar behaviour several times (e.g. at 0,8second and 1,5 second).