thanks for the quick reply

the setpoint is a word variable, and resets itself from 65535 to 0 and vice versa.
there must have been an error when i copied and pasted, because the sentence reads:

pid_error = setpoint - position

this is a very buggy piece of code, and when i get it working, im going to rearrange and clean it up good.