you've got a double "+=" going on there. you want to keep the one on line
66, and change the one on line 64 to just an "="
it looks like you went a little crazy on the derivative! not sure why you
introduced dErr into the mix. you should be fine with "dInput =
(input-lastInput) / timechange;"
also, remember to remove the sampletime adjustments from the tuning
parameters. this is both in SetTunings and in SetSampleTime.