I am trying to code a basic PID loop for my teams robot next year. We want to use a PID loop for controlling the drivetrain with the optical shaft encoders. I have coded something on replit but I don’t think it will work in reality (obviously changing the syntax a little). Unfortunately, I do not have a robot to test this on. Will this work? Is there anything I should change?
Click here for the replit link
VEXCode? Pros? Robotc? Robotmesh? Please tell us what software you’re using and if you’re VEX IQ, V4, or V5.
this is what i used to make my first pid loop
it seems like you have 3 cases for if you overshoot your target, are below your target, or on your target. There should only be one case. The PID loop is something that just plugs and chugs, no special cases necessary. for a simple move forward or move backwards case.
I can’t really make sense of the code, so I’ll show you some sudo code.
i hope that helps. Ask if you need anymore help
I will be using VEXcode (C++) for the V5 system
There’s a lot of coding tutorials me and other people have made that are on the wiki