3 phase encoder (Z-phase output)

Hi, I'm currently using an Orange 2500 ppr 3-phase encoder.

I would like use the z-phase to count the cycles, both clockwise and anti-clockwise.

The reason I'm doing this is, because I've used 2 phase encoders, which is not accurate for multiple cycles. So currently I've switched to 3-phase orange encoder.

I would like to use the z-phase for an up-down counter kind of value.

can someone help me, with a solution. Thanks a lot.

why wrong with the code posted on the datasheet?

why isn't it accurate for multiple cycles? isn't a cycle every 1000 transitions as indicated on the datasheet?

1 Like

That's a problem! if the Z phase overlaps the A/B phases you can count multiple cycles instead of only one.

I used, different encoder earlier. On which, the optical disk is a separate module. Installing it manually produces errors. Approximately 200 points error for 20 rotations.

Then I switched to orange encoder, Since I do not have the ground truth, I cannot trust these too. That is the reason for using 3rd channel.

I came up with this code, which temporarily solves my issue, but I cannot add a delay in my main loop, is there any better way to do this?


#include <Encoder.h>
Encoder myEnc(11, 12);

int zpin = 17;

void setup() {
  Serial.begin(115200);
//  Serial.println("Basic Encoder Test:");

  pinMode(zpin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(zpin), zchange, RISING);
}

long oldPosition  = -999;
long newPosition = 0;
int diff = 0;
long zcycle = 0;

void loop() {
  newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    diff = newPosition - oldPosition;
    oldPosition = newPosition;

    Serial.print(newPosition);
    Serial.print(" ");
    Serial.print(zcycle);
    Serial.print(" ");
    Serial.println(diff);
  }

}

void zchange() {

  if (diff < 0) {
    zcycle -= 1;
  }
  else if (diff > 0) {
    zcycle += 1;
  }
}

what is a "ground truth"?

you should be able to count complete rotations looking at any one phase. multiple phases provide greater resolution.

i found that i needed to use interrupts even when using my fingers to rotate an encoder

So, I use motion capture system (marker tracking system), to verify the angle: which is my ground truth.

I understand, that I can count complete rotation using 1 phase. But It was not accurate, for the other brand encoders.

If I do 10 or 20 rotations, my wheel which is attached to my encoder are 20 degree off.

That is why, I was thinking to use 3 channel encoder, so even if there is an error: let's say 3 degree error for each rotation, It will not accumulate overtime, I could write an algorithm to solve it.

still don't understand what you mean by "ground truth"? is it a technical term (provide link)?

what is "motion capture"? do you mean "image capture"?

since it seems like there some other mechanism to monitor rotation, what is the purpose of the encoder?

did you use interrupts as the example code in the link does?

Ground truth means: True value/ reference data.

Motion capture: Is the system which is used to track movements:

example: like avatar movie. you will see multiple white marker placed in the body, its just to track precise movements.

Yes, the encoder library uses interrupts, if you have read the documentation.

what does this mean. during a 30 year careers as an engineer i've never heard of it. what information does it provide?

so you're reviewing some image processing to determine that the encoders counts are incorrect?

what documentation? did that explain "ground truth"
you haven't posted what "you" did

I kindly request you to stick to the actual and very simple question.

I would like to count the rotation - both clockwise and anti-clockwise, using the z-phase.

I have already posted a code, which I'm able to solve this issue.

If you have anything to add to the code, your welcome to. Or-else, thank you.

From the 'user manual'

image

  • still unclear how your determined that the counts were off, presumably based on newPosition

  • not clear which processor your using. pins 11, 12 are only both interrupts for a "101"(?) processor. the Encoder library can work without interrupts. so using it may miss counts

  • zcycle will not necessarily match newPosition if newPosition increments more than 1, as well as if one is missed

That is not a problem I've had with quadrature encoders, so something is wrong with your code. Which you forgot to post, along with a wiring diagram.

Fix that first.

The Z channel is normally used for homing (setting a machine's zero position), use counter over or underflow for rotation counting.

thanks

It will give 10000 transitions per rotation between outputs A and B. whereas the Z phase will produce one transition per rotation.

they must mean 2 transitions per revolution, but for homing nonetheless

elsewhere it's described as a quadrature output (??)
Phase Z Yellow Quadrature encoded output Z

Even if Z covers several cycles of A&B, are the edges of Z on specific phases of A or B like:

image

You could do quadrature between Z an A in this trace to tell which way Z was turning. And it would even work if Z covered 10 cycles of A-- when Z changes, you check A to see if A is high or low.

You could even write code to say what A and B were when Z rose or fell clockwise, or rose or fell CCW.

I'd bet one of the signals is in quadrature with Z.

1 Like

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