Sorry, but to test I would need to know the actual encoder/step counts that were being fed into the component at the point of failure.
But, I am sure that the code linked above is very wrong, and is likely to be the problem.
Can you:
1) Make sure that you have the linuxcnc-uspace-dev package installed.
2) Download the attached carousel.comp file
3) From the folder where you saved the file
Code:
sudo halcompile --install carousel.comp
And see if the problem is fixed?