Hi, I am trying to create a program to be able to track the RPM of a flywheel using an encoder…can anyone help explain or send me a pic of a nbn flywheel program? Thank you!
I don’t have one to send, but I can outline one quickly. You can create a task that keeps looping, and within the task you query two things: the angular displacement from the IME or the optical shaft encoder, and the time. You’ll want to watch out for the angular displacement value going past the maximum. Other than that, record the prior two values for use with the new two values. Then do a calculation: (newAngle-oldAngle)/(newTime-oldTime) and write that wherever you want it. Finally, replace the old values with the new ones.
@dsibal I am not sure if you need basic help on how to get started or want to learn this topic in-depth…
Below are the links to some of the threads back from NbN season that deal specifically with measuring RPM (angular velocity) of the flywheel. There is an issue of measurement noise and @jpearman posted several examples on how to deal with it:
https://vexforum.com/t/moving-average/32007/1
https://vexforum.com/t/velocity-calculation-traps/32267/1
https://vexforum.com/t/how-to-calculate-motor-flywheel-velocity-in-robotc/32336/1
Also, here are more threads that have discussed all aspects of controlling flywheels, including Bang-Bang controller, TBH (Take Back Half) algorithm, that was popular during NbN, and some good flywheel centered PID discussion with sample code posted toward the end:
https://vexforum.com/t/bang-bang-code/32000/1
https://vexforum.com/t/flywheel-velocity-control-revisited/30480/1
https://vexforum.com/t/pid-theory-question/32289/1
And even more flywheel related info:
https://vexforum.com/t/tbh-tuning/30908/1
https://vexforum.com/t/trial-and-error-pid/45224/1
https://vexforum.com/t/pid-controller-help/30718/1
https://vexforum.com/t/flywheel-consistency/32020/1
https://vexforum.com/t/velocity-control-using-just-battery-voltage/32823/1
https://vexforum.com/t/physics-of-the-flywheel-launcher/29357/1
Finally, there is a code repository that @jpearman collected after Nothing But Net season based on the submissions from multiple teams:
https://vexforum.com/t/nbn-teams-post-your-code/34592/1
Unrelated to flywheels, but still more code examples:
https://vexforum.com/t/starstruck-season-code-request/41524/1