Encoder is not reading pulses

I am attempting to use Paul's basic encoder code.

I have set the pins to 2,3 because I am using an UNO R4.

I am attempting to use the following encoder:

I cannot get it to read any pulses in the example code. I'm not even sure where to start to test to see what is not working. The Red wire is +5, Black Gnd Yellow pin 2 and blue pin 3

It prints the basic encoder test and then a 0

Ideas?

So I tried the No interrupt code from the example and I get a pulse count. Wondering if I need to "active" interrupts on the unoR4

It says the encoder comes with a number of different output types. Which one disYou use?
How did You wire the encoder? Make a little drawing using pen and paper. Include the powering.
How did You declare the 2 UNO I/O pins?

I used the Line Driver Wiring Diagram.

Red ->> 5V
Black ->> GND
Yellow ->>Pin 3
Blue - >> Pin 2

Encoder myEnc(2, 3);

This is the whole thing. I simply was just testing to try to figure out the encoder portion.

Doesn't matter. Even for the simplest circuits a legible, annotated schematic can be invaluable. Consider too, that the forum is handicapped by not having as clear a picture as what you have right in front of you.

If necessary just make a hand-drawn schematic, take a photo and upload to the thread.

2 Likes

I would call this fairly self-explanatory based on his question.

Red ->> 5V
Black ->> GND
Yellow ->>Pin 3
Blue - >> Pin 2

Hi,
Which encoder do you have?
What is its exact part number?

That encoder comes with three different output configurations, each requiring a different circuit connection.

Do you have a DMM? (Digital MultiMeter)

Tom.... :smiley: :+1: :coffee: :australia:

1 Like

I do not believe that the released Stoffregen Encoder.h supports interrupts on the Uno R4.

See this posting for how to get to a version which does work with the R4
https://forum.arduino.cc/t/uno-r4-wifi-error-in-encoder-library/1215256/9

I installed the library you are referencing and was using that for my testing. Before I used that I got an interrupt error. To be clear I found the post you references prior and uninstalled and reinstalled per the instructions.

Now I may need to initiate the uno interrupts in the code somewhere. I don’t know much about interrupts.

I do have a multimeter.

As I read it there is two models. Both are identical except one has a molded cord the other a plug. Both can take 3 wiring modes I used the Line Driver Wiring Diagram. Railroader asked me to clarify the wiring in his first question and I made a simple diagram and stated the Line Driver. I could have been more clear on that I figured he understood since he was asking me what mode I wired it in.

My exact model is A80H-1024-HZC30-RL2



I think you need Yellow and Green wires, signal A and signal B.

Tom.... :smiley: :+1: :coffee: :australia:

1 Like

Ok. That makes a bit more sense. And then just take there corresponding wire to ground?

The encoder wiring diagram has 3 sets of wires and the code request 2 pins. Could you explain those pins a bit. I guess I assumed that it was measuring the low and high switch between the pins.

I think you are requesting be wired in the sourcing wiring model

No you don't, the /A and /B are A and B signals inverted, do not gnd, leave open.

Tom.... :smiley: :+1: :coffee: :australia:

1 Like

Thanks!!! Now it reads them in both directions instead of only 1. It still only reads using the no interrupt code. Some how I must need to initialize the interrupts since the Uno is not supported natively with the encoder code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.