# PID Velocity Control on Launcher

We understand how to use PID on the drive train, but we are confused on how to translate this onto our double flywheel launcher. We are aware that you have to use RPM instead of distance and we have to change constant values. Can someone help us with getting started? Also, should we use IME’s or quad encoders? Thanks!

With a pid loop, you are setting a target value. That target can be distance, rpm, etc. In any event, the formula is trying to change the output in such a way that it gets as close to target as possible. So again, that target isn’t necessarily distance.

Quad encoders seem to be more consistent, and not susceptible to shorting out from field static. However, I fully admit I’m not an expert.

Well I myself find the idea of PID & TBH loops super confusing, especially in relation to flywheels. Apparently (I can’t vouch for this as my team doesn’t have any IMES) IMES are more accurate. As far as I know, you could just set a target RPM value, then increase or decrease motor speed to match the RPM value, or thereabouts.

to calculate motor speed you could do something similar to this:
(Not my idea, found it somewhere on the forum)
(pseudo code)

``````
startcount;
endcount;'
waitTime

float flyweelRPM()
{
startcount = encoder value
wait(waitTime);
endcount = encoder value

return((endcount - startcount)/waitTime))
}
``````

If we are using IME’s, how would you calculate the target rpm for our launcher? We have 4 high speed motors in a vertical double flywheel arrangement. Would it just be the speed we tell the motor to run at? For example, 127. Our top wheel has a gear ratio of 1:10 and the bottom is 1:15. The top wheel is 2.75" and the bottom wheel is 5". Here is our reveal for more information.

To calculate the target RPM of your launcher, it’s really a matter of testing, especially because your launcher puts some spin on the ball as well. You can get a (very) ballpark value from this site if you know the initial angle and velocity of the ball and the height and distance between the launcher and the goal: http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html
You will still need to check this value, and correct it. Also, spin can drastically affect the flight path of a ball (ever seen a curveball?), so the velocity you get might be way off.

Also, you could use this site: http://vex.us.nallen.me/extras/nbn_shooting

AURA is awesome.