Our team’s code is far from consistent as it changes by a large degree every time. We have attempted to code a PID off of Caution Tapes video, but it did not work. We are desperately in need of a PID, so can anyone please tell me how to develop/code a PID that works? Even a code for us to build off of (which we tried with Caution Tape’s) would be helpful.
I suggest
- Use the search bar, there are over 100 posts about PID.
- Post your code. If you followed the Caution Tape Video, it’s most likely something minor in your code.
a) Post the code
b) Post a picture of the robot
c) Write at least 50 words on what you expect the robot to do and what it does with the CODE THAT YOU POSTED. ( * )
You can do number 2 first and then number 1 to fill in the time while you wait.
( * I spent 30 mins trying to debug code where they sent me a pretty complete description of what the robot was doing, but neglected to say that the code they sent was 3+ versions before what they were describing. )
First off, 100% what Foster posted.
Next, it’s important to keep in mind too that CTR’s code is technically just a ‘P’ loop, there’s no ‘I’ or ‘D’ term.
One of the key bits to making their code work for your robot is to adjust the Kp
value so that your robot doesn’t oscillate (number too high), or not end up actually doing anything (number too low). This will change as your robot changes as well; changing weight, CG, drivebase configuration, etc. will all generally drive a need to refine your Kp
.
I have a new type of robot that I (personally) think is a better design than most, not to sound ignorant though. It is a heavy robot, a bit over 12 pounds. This is a picture of my code.
What I want THIS code to do is make my code more consistent by adding a PID control into it. I want it to have very precise turns so it doesn’t get off. What happens in THIS code is it goes forward how I want it to, but then when it turns, one motor completely turns off while the other keeps running for the turn. The turn never stopped though and it kept running. Is it that I need to change my Ki, Kp, or Kd value to higher or lower? Any help on how to fix this problem in this code would be appreciated.