Encoder Help

Hello,
I am using a BOURNS - ENC1J-D28-L00128L encoder that is 128 CPR; When I use it with the example TwoKnobs and in one revolution (more or less) the position is more than 500... I do not know what I am doing wrong. Is this normal? If so, what is the position that I am supposed to get after exactly a 360 degrees turn.

Thanks.

maxwee2001:
Hello,
I am using a BOURNS - ENC1J-D28-L00128L encoder that is 128 CPR; When I use it with the example TwoKnobs and in one revolution (more or less) the position is more than 500... I do not know what I am doing wrong. Is this normal? If so, what is the position that I am supposed to get after exactly a 360 degrees turn.

Thanks.

Keep in mind that the way encoders 'steps' are defined in industry is that four complete transitions of the A and B channels is equal to one 'step'. So depending on how you are defining 'steps' in your decoding of the two channels you can end up with 128 steps, 256 steps, or 512 steps per shaft revolution on an encoder rated as a 128 CPR encoder. If sounds like your decoding method is using a change on either channel A or B to increment the step count. I'm not familiar with the 'Two Knob' code or library so I can't verify what your code is doing unless you post it.

Lefty

Here is the code I am using:

#include <Encoder.h>
long position  = -999;

void loop()
{
  
    //Reading Encoder Position
      long newPos = myEnc.read();
      if (newPos != position) {
          position = newPos;
      }

I do not know how to share the library with you; but I found it here: Encoder Library, for Measuring Quadarature Encoded Position or Rotation Signals

That is a very high performance encoder library with some setup options, using two or one or none interrupt pins. The default setup in the TwoKnobs example does look like it enables interrupts on change for both encoder channels so your seeing 512 counts for a 128 CPR encoder is as expected. It looks like you can change the setup option to use only one interrupt pin and one non interrupt pin and that should change to generating 256 'steps' per revolution for a 128 CPR encoder.

Is it important to you how many 'steps' per revolution you get? The fact that you get more (better) resolution steps then you expect shouldn't prevent you from using it.

Lefty

I just needed to know how many steps I will get in one revolution to integrate it in my system.

Thanks for your help!