Ascend
Coding
Ascend
  • 🚀Introduction
  • VEX Robotics
    • 🛠️Building
      • 📏CAD Design
      • 🔧Best Practices
      • 🏎️Drive Trains
        • 🔩Screw Joints
        • 🥊Boxing
        • 🔵Bearing flats
        • 🛤️Fixing Friction
        • 🔥450 RPM on 2.75"
      • 🏍️Motors
      • 🪨Metal
      • Plastic
      • 🎈Pneumatics
      • ➕Additional Mechanisms
        • 🖨️3D Printing
        • ↔️Ratchets
        • 🏹Catapults
        • 🎣Intakes
        • 🏋️Lifts
    • 💻Coding
      • ⚖️Choosing Your Coding Environment
      • 🔴VEXCode Pro
        • 🖥️Getting Started
        • 🚗Drive Code
        • 🚴Coding Motors
        • 🌬️Coding Pneumatics
        • 🎛️Advanced
          • 📡Coding Autonomous
          • 📈Coding PIDs
            • ⬆️Drive PID Tutorial
            • ↩️Turn PID Tutorial
            • 🎸Tuning PIDs
              • 🔢Ziegler-Nichols Method
              • 📊Graphing PIDs
          • 📋Tasks
          • 🚝Advanced Drive Code
      • 🟡PROS
    • 📗Engineering Notebook
      • 📔Formatting
      • ⭐Notebook Walkthrough
      • 💠Decision Matrices
        • 📌Decision Point
      • ➕Additional Resources
    • 🏆Tournaments
      • 🗣️Team Interviews
        • 🪙Interview Tips
        • ⛳Interview Scoring
        • 🤽‍♀️Interview Practice Questions
      • 🤹Skills
      • ℹ️Ranking and Stats
      • 📷Filming Matches
  • Other
    • 🧑‍💼Management
      • 🕑Time Management
      • 👨‍👩‍👧‍👦Team Management
        • 👮Delegation
        • ⚓Optimal Team Size
      • 🖇️Code Management (GitHub)
      • 🚋Resource Management
      • ⁉️Stuck?
    • 🍎Physics
      • ⚙️Torque
      • 😑Stress Forces
    • 👾Extra stuff
      • 📸96504 Gallery
      • ⛑️VEX Team Resources (High Stakes)
      • 🏎️Driving Simulator
Powered by GitBook
On this page

Was this helpful?

  1. VEX Robotics
  2. Coding
  3. VEXCode Pro
  4. Advanced
  5. Coding PIDs

Tuning PIDs

Perseverance makes perfect

PreviousTurn PID TutorialNextZiegler-Nichols Method

Last updated 1 year ago

Was this helpful?

At this point, you should have coded the PIDs fully. Now, you have to tune those three constants to make the PID work well on your specific robot. Here's a quick recap of each constant:

  • Proportional (kP): if the robot is far from the target, set the motor power high so the robot gets there faster. If the robot is close, set the motor power low so the robot doesn't overshoot.

  • Integral (kI): if the robot is close to the target, but not quite there, increase the motor power over time so the robot doesn't stall.

  • Derivative (kD): if the robot is rapidly approaching the target, apply the brakes so the robot doesn't go too far.

Remember, everything on the robot--drivetrain friction, gear ratio, weight distribution, center of gravity--influence the optimal PID values for the robot. That is, you might have to re-adjust the PID values if something major changes on the robot.

Let's say we're tuning the drive PID (the process is the same for the turn PID). We started with these values. Try out the drive PID. How well does it work?

//PID constants
float kP = 0.5;
float kI = 0;
float kD = 0;
Why are kI and kD both 0?

Right now, we want to start off with a P controller. This means that we only look at the inputs from the proportional part of the PID, and neglect the other two. In fact, sometimes a P controller is enough to make the robot's motion consistent.

Note that not all components of the PID are necessary. For example, a PD controller (kI = 0) works fairly well for Vex Robotics, but the integral term does allow the robot to be more precise.

If the robot barely moves, try increasing kP--this increases the motor power applied. If the robot jerks forward and goes too far, try decreasing kP.

Your goal should be the green line in the graph below, where the robot reached the setpoint (target) quickly and stays there. The graphs represent's the robot's current distance, compared to the target; this applies to both turn PIDs and drive PIDs.

If your robot acts like the orange line on the graph above, where the robot goes past the target and reverses direction, consider adding in the kD term. As a starting point, set this term to 5 times the value of the kP term. Adding in the integral term (start at about 1/10th the value of kP) may also help.

If your robot acts like the blue line on the graph above, where the robot takes a while to reach the target, increase kP or decrease kD.

These rest of PID tuning comes down to trial and error; it's your job to find the set of values that works best for your specific robot.

If you want a more mathematical approach to estimating kP, kI, and kD from the start, take a look at this page:

💻
🔴
🎛️
📈
🎸
🔢Ziegler-Nichols Method
Source: OscarLiang.com