Eric,
Thanks for the comments.
Each loop has separate tuning values. They are set in the Loop Tuning section of the code by writing them to the scratch pad RAM on initialization.
The tuning values are:
Proportional Gain
Integral Time (number of program cycles)
Integral Step (gain)
Derivative Gain
The integral is the tricky part since it requires time to implement. The program cycle time is the only timing function available, so if your program varies in cycle time the integral part may not work as expected.
I have updated to code to use mechanical limit switches. They will stop the movement and prevent integral windup.
The ZIP file with the code is now in the White Paper section.
http://www.chiefdelphi.com/forums/papers.php?s=