RPM readout issues

I have a 10000 rpm 37D Pololu motor and I’m trying to read the RPM with encoder outputs. I keep getting an RPM of about 6000 and I was hoping someone might be able to help me debug this issue. My code is attached. Thanks so much!

Also my PID control isn’t really working – it keeps printing PWM output values of 0 so if anyone has any ideas for that too, I’d really appreciate it.

sketch_nov10a.ino (3.0 KB)

Hello.

Which particular 37D gearmotor are you using, and is it under load (e.g. is anything connected to the output shaft)? What are you using as your operating voltage and motor driver? To test that your driver is not limiting the motor, you might try powering the motor directly from your power source and measuring the encoder output.

I suspect the problem with your PID output always being 0 is specific to the PID library you are using. I am not very familiar with the PID library in detail, but with a quick Internet search, I found this post on the Arduino forum that seems to be related.

Brandon