We have a pretty decent bot, making almost 100 points on skills. Using a horizontal dual-flywheel launcher. it is very well built, but we have no shaft encoders/IME programming. We now have a shaft encoder linked to a gear going as fast as the motors.
Can someone explain to me how to program a PID loop for this?
If you’re running Robot C 4.X, Robot C has a built in Library for this. Input the motor into the motors and sensors input, and then assign it an encoder using the encoder ports. Then enable PID by clicking the PID check box. You can then assign the motor a speed (0-100).
If you are interested in the above method, jpearman has made a very good thread about the in built PID on RobotC, which also covers why the motors can only be assigned a value from 0-100 as well as explaining the use of the function SlaveMotor and how to edit PID settings.
Hey man! The key for PI control on your flywheel is figuring out how many ticks of your encoder u want for a set period of a time. You’re gonna take the error in your velocity and multiply it by a gain (u gotta tune that though) and that’ll give you your power. RobotC has velocity control however, you may want to look into that.habe fun! If you need any more help we’re close by
I personally have found figuring out the code yourself is an immense learning experience and how I’ve come to understand programming more and more. I’m here if you need me to help you but I personally feel you would be best off searching around the different threads on the forum and figuring it out. Trust me, you’ll be glad you did!