Flywheel RPM

Currently, we have a flywheel that shoots at rpm of ~1200 for bar shots.
I have a program that puts the rpm onto the lcd, but the lcd display is only flickering between values 1200 and 1500.
It does not give us anything more accurate than this.
Does anybody know how to make the rpm more accurate?

Here is a copy of our code:

void OperatorControl ( unsigned long ulTime )
StartQuadEncoder ( 1 , 2 , 0 ) ;
while ( 1 ) // Insert Your RC Code Below
PresetQuadEncoder ( 1 , 2 , 0) ;
Wait ( 25 ) ;
count = GetQuadEncoder ( 1 , 2 ) ;
rps = (count / 0.025) / 360 ;
rpm = rps * 60 ;
rpm_flywheel = rpm * 5
SetLCDText ( 1 , 2 ) “rpm=%d” , rpm_flywheel ) ;

Any help would be great.

Sounds like your flywheel oscillates a lot. You can try making a running average to filter out values that are higher or lower than expected with an array.

Im not really concerned about that right now.
I just want to have a more accurate rpm that i can use for velocity control.

… The values are accurate. You are getting oscillation, which your encoder picks up.

So the lcd cant get more accurate values for the rpm such as 1250?

The rpm of your flywheel is constantly changing, which your encoder reads. It’s not a matter of accuracy; the values you are reading off the LCD are perfectly fine. If you want the value not to change as much, tune your velocity control until it doesn’t oscillate.

The thing is, i dont have velocity control yet.
The reason i want to get the rpm is for the vcontrol.

Oh, OK. Try blowing the encoder with compressed air. I’ve found that over time the encoder gets dust inside the disc and starts to jump around a lot. Smoothing the velocities like I mentioned earlier will also help get more consistent values.

I got the flywheel rpm to work, but i dont understand why my bang bang code is not working.
Ive attached it below in both c and block programming.
The variable shootSpeed is the variable for my toggle.