Velocity for PID Loop?

Hey Vex forums! I currently have a single flywheel setup using 4 motors, 2 on each side of the flywheel going into a 84:36 compounded to a 60:12 with the 12 on the same axle as the flywheel. I’m using turbo internal gearing and an IME on one of the motors. My question is within robotc how would I calculate the current actual velocity from the IME? I’m trying to use this in a PID Loop to make my flywheel more accurate. Also would it be beneficial to have one IME on both sides of my single flywheel and run a PID Loop for both? Also which have you seen produce the most accurate results TBH, Written PID, or RobotC’s Internal PID Calculator? This is my schools first year competing in vex and any help is much appreciated! Im going to attach my current .c file for it but keep in mind I’m very new to coding for robots.

Here is a link to my google drive for my .c file
https://drive.google.com/file/d/0B9QaMceXrWZdUE1KRXJyZm9NXzg/view?usp=sharing

See this thread.
https://vexforum.com/t/how-to-calculate-motor-flywheel-velocity-in-robotc/32336/1

If you really want flywheel velocity then the total external gear ratio will be
(60:12) 5 x (84:36) 2.33 = 11.66 (I think that’s what you are trying to describe anyway)

I will look at you code later.

Did you ever get a chance to look at my code? @jpearman

I did look at the code, not sure what additional advise I can give you beyond that which is being given in the many other threads discussing PID.
https://vexforum.com/t/pid-theory-question/32289/1
https://vexforum.com/t/physics-of-the-flywheel-launcher/29357/1

I do notice that your “velocity” is really the absolute encoder value and not velocity.


long GetVelocity ()
{
	return( nMotorEncoder FROne ] );
}

<<snip>>

velocity = GetVelocity();

velocity is proportional to the change in encoder count, not the absolute encoder count.

@jpearman So If I used the velocity calculation you use in your TBH algorithm code would that work for this?

That would calculate velocity. There is also an in depth analysis of different ways to calculate velocity in this thread.
https://vexforum.com/t/velocity-calculation-traps/32267/1

You need to decide what your units are, all the code I post uses revs/minute, ie. angular velocity. If you use these then the “target” for the PID calculations needs to be in the same units. It looks like your existing code is trying to use something else.