Whenever I set my flywheel speed to below 100 percent, the flywheel fluctuates above and below the target RPM. I’ve heard that PID control can help, but I have never coded something like this. Could someone direct me to some resources that could help me learn how to code PID?
PID is not the only “control algorithm” and is probably not even the best one for a velocity controller such as your FlyWheel. Purdue has documentation on a couple that may be both easier and more appropriate for your application:
Hey @Dave-TBR! So you actually can’t run the PID in the background during driver control like this. There’s something called “Task” in PROS that you use so you can run it in the background. It essentially introduces the topic of threading, which allows you to run several things simultaneously. It is very useful and can be implemented very easily.
An issue you may run into is that if one of the motors on your flywheel is slightly worse than the other it requires more voltage to run. When you speed the weaker motor up it will increase the speed of the stronger motor since they are on the same gear train. Now the stronger motor will attempt to slow down which will bring the weaker motor down to. This will go back and forth causing oscillation.
I think it’s the case sometimes. For example, last year my team ran into the same problem when we tried to control our 6m drivetrain (all geared together) with percent. We didn’t notice any oscillation but observed the issue by printing the motor speeds to the brain. There was a improvement when we switched to a voltage controller.