Hi John,
Now I understand what is happening inside the loop. The CO pulse ticks is not from the motor encoder. That's why the system doesn't acquire more samples even when the motor is spinning.
I'll carry on experiments with the calculation of the control input. I hope this won't introduce too much calculation and the system would be able to update on time.
Thanks so much for the help!
-Lucy