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:
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:
And even more flywheel related info:
Finally, there is a code repository that @jpearman collected after Nothing But Net season based on the submissions from multiple teams:
Unrelated to flywheels, but still more code examples: