Arduino Mega 2560 - Receiving Signals from Rotary Encoder

I am trying to implement an Arduino Mega 2560 to receive signals from a rotary encoder. The encoder outputs A, B and C phases using standard TTL positive logic (+5V = 1, approx. 0V to GND = 0), A and B together they form two-phase pulse train with 90° phase differential signals that determines position and direction (+/-). C phase outputs a zero-point signal (end/start of a revolution). The total number of wires to the Arduino Mega 2560 is 3 wires.
From my understanding from the manual, the two-phase pulse train with 90° phase differential signals indicates forward rotation when phase B leads by 90 degree, and indicates reverse rotation when phase A leads by 90 degree. All phases have the same pulse width. There is a page of the manual in the attachment:
Feasibility Questions:

  1. Each pulse represents a point, the application that uses the rotary encoder requires that each revolution to have a resolution of at least 150K points/rev, and at that encoder resolution the motor would turn 1/3 rev per second (20 rpm). Is it feasible to use Arduino Mega 2560 at least 50K inputs per A and B phase per second (total around 100K per second)? What is the minimum detectable pulse width for Arduino Mega 2560?

  2. If Arduino Mega 2560 can handle the above number of inputs, I am still having trouble implementing a way to read the signal to determine forward and reverse rotation. For now I think for forward rotation, phase B would delay a time equals to (pulse width/2), and for reserve rotation, phase A would delay the same amount of time. The question is: what is the correct logic to process the two phases’ inputs in order to correctly output the number of points turned and their respective direction?

Currently I am sinking into this logic: I am not sure if the following assumption is correct, but if phase A leads by 90 degree, does that mean phase B’s duty cycle is 50% less than phase A within a time period, and vice versa for if phase B leads by 90 degree? Is there a way to compare the pulse width of two inputs by setting a timer period for reference…?

I am still new to the Arduino community and electronics in general, thanks in advance.

  1. Each pulse represents a point, the application that uses the rotary encoder requires that each revolution to have a resolution of at least 150K points/rev, and at that encoder resolution the motor would turn 1/3 rev per second (20 rpm). Is it feasible to use Arduino Mega 2560 at least 50K inputs per A and B phase per second (total around 100K per second)? What is the minimum detectable pulse width for Arduino Mega 2560?

Are you sure you have 150'000 points per revolution? That is an immense resolution. Anyway, it would give an impulse every 10us. The Arduino is making about 160 instructions within these 10us, so an interrupt based system should be able to keep up with that, although it will use a remarkable portion of the CPU power (depending a bit on what you do with it). The minimum detectable pulse is much shorter, the question is how steep the edge of the signal is. The interrupts are usually triggered by a rising or falling edge of the signal, so the pulse duration is not really important here.

  1. If Arduino Mega 2560 can handle the above number of inputs, I am still having trouble implementing a way to read the signal to determine forward and reverse rotation. For now I think for forward rotation, phase B would delay a time equals to (pulse width/2), and for reserve rotation, phase A would delay the same amount of time. The question is: what is the correct logic to process the two phases’ inputs in order to correctly output the number of points turned and their respective direction?

Put both signal to an external interrupt pin and attach an interrupt handler for the rising edge of both pins. In the interrupt handler just get the state of the other pin and you have the direction. Get the time difference for let's say 50 points (the time difference of 2 points is not exact enough, you get more accuracy by having a longer time period) and you have the speed.

Thank You for the pointers, @pylon. I will read more into external interrupts. What function do I use to get the time difference between two pulses?

micros().