Anything you modify in an interrupt and use elsewhere, such as encoderpos, should be declared volatile.
I'd be inclined (if you haven't already) to write something simpler to just ensure that you can read the encoders correctly before trying to debug your full sketch.