I want to program the vex optical shaft encoders for my single flywheel launcher, and my problem is that whenever we shoot a ball the launcher wheel slows down, and we want the motors to speed up so that the wheel gets to the speed we want it to be. The ports are 9 positive and 2 negative, and the speed of the motors is 83. The gear ratio is 49:1(84-12,84-12). I have no idea how to program this so that when we launch a ball the motors speed up so that the wheel keeps a constant speed, thankyou so much in advance.

What is a PID?

PID is a form of velocity control which uses three terms: Proportional, Integral, and Derivative. Basically, you calculate the difference (error) between the flywheel’s actual speed and its target speed (target - actual = error). Then you multiply that by an arbitrary coefficient kP to get your Proportional term (prop = error * kP). To get the Integral term, you add the value of the error multiplied by the arbitrary coefficient kI to the value of the Integral term (integ += error * kI).

To get the derivative term, you use a timer and determine how long it has been between the last calculation and the current one. Then you find how much the error has changed in that time. Divide your change in error by time elapsed, multiply by kD (another arbitrary coefficient), and that’s your Derivative term (deriv = kD * (errNow - errLast) / (nPgmTime - timeLast) )

Then you add the three terms together to calculate the motor output (mtrPwr = prop + integ + deriv)

There are many other threads on the subject on Vex Forum.