YUMO E6B2-CWZ3E encoder has only one sense of rotation !?

Hi everyone,

Recently, I bought a rotary encoder : YUMO E6B2-CWZ3E in robotshop.com (https://www.robotshop.com/eu/fr/encodeur-rotatif-6mm-1024-p-r.html).

I use Arduino UNO’s pins 2 and 3 to connect the encoder’s outputs (Black cable -> pin 2 and White cable -> pin 3)
cable brown -> pin 5V of Arduino
cable blue -> pin ground

With this configuration, I have gotten a binary output.
So I increased the tension utilizing an external power supply 9V. Thus I have gotten a value which increases when I turn the encoder.
Yet, when I turn left or turn right the encoder, the value increases only and I don’t know why.

The code on Arduino is the basic one using Encoder.h.
Here the code :

#include <Encoder.h>

Encoder myEnc(2,3);

void setup() {
Serial.begin(9600);
Serial.println(“Basic Encoder Test”);
}

long oldPosition = -999;

void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}

Can you help me to fix this problem, please?

Thank you !

Hello @Antoinekei,

Try implementig Arduino logic from this page: https://dronebotworkshop.com/rotary-encoders-arduino/

There is a part of code which check the direction of rotation:

Hello @igor_X ,

Thank you for your help, I tried with the code that you showed me.
Yet, it doesn’t still work. Indeed, the value changed everytime (0 then 1 then 0 then 1 and so on, or -1 then 0 then -1 then 0 and so on) even if I didn’t turn the encoder.

I tried other codes but still the same problem : value which increases when I turn left or turn right. If not value changes everytime like I explained above.

The last hypothesis is that my encoder is defected …

I am opened to all solutions. Thank you for your help !

Maybe you already did, but if not, read this topic:
https://forum.arduino.cc/index.php?topic=488987.0

Seems like someone had same issues which were solved then.

Hello @Antoinekei !

Could you share a photo of your connections please?

Hello @RoboCS,

I think that it is not so clear.
So here the connections that I did :

Black = pin 2
White = pin 3
Brown = VCC linked to external power supply 9V
Blue = ground linked to external power supply 9V
Shield = Ground on Arduino (orange wire in the picture)

@Antoinekei , awesome. Could you check this tutorial , tutorial2 and let me know?

Hello @igor_X

I checked and I tried but it doesn’t still work. It increases only.

and @RoboCS, I looked at the two tutorials and I tried the parts that I have not tried yet but I have always the same problem. Indeed the value increases only.

I utilized the code that @igor_X sent it below with the image to know if the direction of rotation works correctly.
The direction changes even if I turn left only or if I turn right only, the value always changes.
I don’t know why …

If you have still ideas, thank you to share with me.
Thank you to help me :smiley:

Hey @Antoinekei !

I just can only thing in one thing:

  • Test your encoder alone. Took an oscilloscope, connect your encoder to VCC and GND and analyzed the output signal. If don’t, your encoder is the problem.
  • Try to channel the pin connection in your arduino. You can try 3 and 4 or something like that (different).
  • If not, then the code “should” be the problem.

Hope you find the problem!

1 Like