why is it called drivePID if it controls ArmMotor?
this looks to be starting two tasks doing the same thing.
void autonomous(void) {
vex::task bill(drivePID);
vex::task::sleep(2000); // this belongs in the task, but with shorter interval
vex::task billl(drivePID); // this instance of the task never ends
}
for now don’t make drivePID a task. get it working as a function that takes the setpoint as a global variable so you can make it a task later.
the while loop needs a wait(n) where n is usually between 20 and 100 ms. Without a delay you’ll be accumulating the integral way too fast (but you do have a very small number for Ki). Kd is also dependent on the time interval since, well, de/dt. Also, the sensor values (encoders) don’t update within the time of a short loop (it seams its about 5ms).
look at @anon4126930 PID tutorial here. he shows you how to make it a task. when that is done i can help you optimize the PID code for live tuning and preventing run-away speed values.
ed: just noticed that usercontrol spinFor does not have a velocity so it may be 0