Thanks FvM. Both EA and EB are attached to the system and I do not modify the mechanical setup. Yes... I just switch the encoder input from either EA or EB.
In fact, there is a coupling between the DCM and EB as follows:
EA <-> MOTOR <-CA-> DCM <-CB-> EB
CA and CB are couplings shown in attached figure below. If I'm not mistaken, CB is resilient type of coupling.
Until now, I still don't understand why I need different values of PI when my program runs with EA and EB. For example:
[1] When program runs with EA, Kp=0.001, Ki=0.001
[2] When program runs with EB, Kp=0.0001, Ki=0.005 (It just didn't work with Kp=0.001, Ki=0.001)
However, when program runs with EA, similar Kp and Ki values (e.g. Kp=0.0001, Ki=0.005) are OK.
When program runs with EB (Kp=0.0001, Ki=0.005), the motor runs not stably (as if the speed regulation is not good). When I remove the speed loop, i.e. runs the motor with constant current demand, then the motor runs perfectly stable. I really wish to know what actually causes such a big different in system dynamic when EA and EB are used.