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:
-
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?
-
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.
