Hi,
I'm not sure I understand....sorry....

First of all, the SETPOINT variable you have - is it declared as a LONG or as a WORD? If declared as a WORD then I'm not sure how this...
Code:
select case setpoint ; Circular count for Setpoint condition
case is > 65535 ; Circular count for Setpoint condition
...will work or what it'll evalute to. A word variable will "automatically" wrap around from 65535->0 and from 0 to 65535. If setpoint is declared as a LONG that seems not needed since you're trying to reset it 0 once it goes above 2^16.

Then there's this line:
Code:
IF POSITION pid_Error = setpoint - position
Does it really compile like that?

If you have code that compiles correctly, please post it and I promise I'll do my best to help you. You may also be interested in this thread

/Henrik.