Sina,
I've attached a file that describes how our solution deals with large positions. You should be able to modify the code in either lab 13a or 13b in order to accept your new changing reference. You need to make sure that your new changing reference respects how we are handling the position references. I've attached a file that gives a visual representation of how this is handled . We make the position to vary between -10 mechanical revolutions and 10 mechanical revolutions in order to maintain precision.
The function ST_runPosCtl is the function where we setup the references and feedback for the SpinTAC Position Controller. Form there you can modify where we reference is coming from.
(Please visit the site to view this file)