AFAIK EMC like Mach does not input an encoder into the parallel port, you might look at wether EMC does interface a Manul Pulse Hand Wheel, this is typically a 100p/turn encoder for manual motion and adapt this routine.
EMC also has the option of add-on cards for servo operation.
Otherwise you would have to use the A & B pulses and write an algorithm that detects one pulse as counts and the other for direction. You may run into a timing issue, depending on how fast the parallel port was read and the encoder speed.
You may not necessarily need home or limit switches as the hydraulics could simply bottom out on a stop.
For home registration, you could just bottom to a stop, and when motion was zero for so many seconds, make this zero reference.
Al.
CNC, Mechatronics Integration and Custom Machine Design
“Logic will get you from A to B. Imagination will take you everywhere.”
Albert E.