Insightful Ink Walk
Friday, September 5, 2025
বাংলা
  • Home
  • Discover South Korea
    • All
    • Culture of Korea
    • Hiking in Korea
    • Korean Language
    • Study in South Korea

    Lost in the Autumn Hues of Gatbawi Mountain

    Witness South Korea’s Breathtaking Flower Spectacle: A Year-Round Guide

    Witness South Korea’s Breathtaking Flower Spectacle: A Year-Round Guide

    Hyundai’s Global Takeover: How a Korean Brand Became a Household Name in Cars

    Hyundai’s Global Takeover: How a Korean Brand Became a Household Name in Cars

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Millim cafe

    Unleash Your Inner Explorer at MILLIM Cafe: Award-Winning Design Meets Reptilian Charm in Daegu

    Beauty of Ulsan

    Discover the Beauty of Ulsan: A Seaside Paradise Awaits

    The South Korean Education System: A Model for the Knowledge-Based Society?

    The South Korean Education System: A Model for the Knowledge-Based Society?

  • Engineering
    • All
    • 3D Design & Simulation
    • Arduino Project
    • Control Engineering
    • DIY Electronics & Robotics
    • Micro-Controller Engineering
    Basic of Control-session 12

    Basic of Control Theory: Session 12 – Cutting the Cord – Wireless Control and the Road Ahead

    Basic of Control-session 11

    Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

    Basic of Control-session 10

    Basic of Control Theory: Session 10 – The Art of Tuning – Calibrating Your PID Controller

    Basic of Control-session 9

    Basic of Control Theory: Session 9 – Closing the Loop – Coding Your First PID Controller

    Basic of Control-session 8

    Basic of Control Theory: Session 8 – From Ticks to Speed – Calculating RPM

    Basic of Control-session 7

    Basic of Control Theory: Session 7 – Your First Robot Program

    Basic of Control-session 6

    Basic of Control Theory: Session 6 – From Parts to Robot – The Assembly Guide

    Basic of Control-session 5

    Basic of Control Theory: Session 5 – Assembling Your Robot’s Body

    Basic of Control-session 4

    Basic of Control Theory: Session 4 – The Robot’s Rulebook – An Introduction to Kinematics

  • Perspective of life
    • All
    • Global Topic
    • Islam
    • Perspective Brainstorming
    • Political Perspective
    many faces of Islam

    Many Faces of Islam: Unity in Diversity

    War that reshaped Middle East

    The War that Reshaped the Middle East Forever

    Trusting in Allah: Overcoming the Social Pressures of Having a Male Child

    Trusting in Allah: Overcoming the Social Pressures of Having a Male Child

    Social Media: A Journey from Word-of-Mouth to Global Networks

    Social Media: A Journey from Word-of-Mouth to Global Networks

    Metaverse Technology: A New Dimension of the Future

    Metaverse Technology: A New Dimension of the Future

    The Dark Side of Evolution Theory: Flaws that Enabled Atrocities

    The Dark Side of Evolution Theory: Flaws that Enabled Atrocities

    The Meaning of Luck in the Eye of Islam

    The Meaning of Luck in the Eye of Islam

    Does Islam Ensure the Rights of Non-Muslims? A Look at Religious Tolerance and Coexistence

    Does Islam Ensure the Rights of Non-Muslims? A Look at Religious Tolerance and Coexistence

    Remove Racism: Understanding and Addressing a Persistent Issue

    Remove Racism: Understanding and Addressing a Persistent Issue

  • Tours & Travel
    • All
    • Cafe Blog
    • Landscape and Sea
    • Life in South Korea

    Lost in the Autumn Hues of Gatbawi Mountain

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Millim cafe

    Unleash Your Inner Explorer at MILLIM Cafe: Award-Winning Design Meets Reptilian Charm in Daegu

    Rise of Islam in Bangladesh

    Unveiling the Rise of Islam in Bangladesh: A Historical Tapestry

    Beauty of Ulsan

    Discover the Beauty of Ulsan: A Seaside Paradise Awaits

  • About Me
  • Contact
No Result
View All Result
Insightful Ink Walk
  • Home
  • Discover South Korea
    • All
    • Culture of Korea
    • Hiking in Korea
    • Korean Language
    • Study in South Korea

    Lost in the Autumn Hues of Gatbawi Mountain

    Witness South Korea’s Breathtaking Flower Spectacle: A Year-Round Guide

    Witness South Korea’s Breathtaking Flower Spectacle: A Year-Round Guide

    Hyundai’s Global Takeover: How a Korean Brand Became a Household Name in Cars

    Hyundai’s Global Takeover: How a Korean Brand Became a Household Name in Cars

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Millim cafe

    Unleash Your Inner Explorer at MILLIM Cafe: Award-Winning Design Meets Reptilian Charm in Daegu

    Beauty of Ulsan

    Discover the Beauty of Ulsan: A Seaside Paradise Awaits

    The South Korean Education System: A Model for the Knowledge-Based Society?

    The South Korean Education System: A Model for the Knowledge-Based Society?

  • Engineering
    • All
    • 3D Design & Simulation
    • Arduino Project
    • Control Engineering
    • DIY Electronics & Robotics
    • Micro-Controller Engineering
    Basic of Control-session 12

    Basic of Control Theory: Session 12 – Cutting the Cord – Wireless Control and the Road Ahead

    Basic of Control-session 11

    Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

    Basic of Control-session 10

    Basic of Control Theory: Session 10 – The Art of Tuning – Calibrating Your PID Controller

    Basic of Control-session 9

    Basic of Control Theory: Session 9 – Closing the Loop – Coding Your First PID Controller

    Basic of Control-session 8

    Basic of Control Theory: Session 8 – From Ticks to Speed – Calculating RPM

    Basic of Control-session 7

    Basic of Control Theory: Session 7 – Your First Robot Program

    Basic of Control-session 6

    Basic of Control Theory: Session 6 – From Parts to Robot – The Assembly Guide

    Basic of Control-session 5

    Basic of Control Theory: Session 5 – Assembling Your Robot’s Body

    Basic of Control-session 4

    Basic of Control Theory: Session 4 – The Robot’s Rulebook – An Introduction to Kinematics

  • Perspective of life
    • All
    • Global Topic
    • Islam
    • Perspective Brainstorming
    • Political Perspective
    many faces of Islam

    Many Faces of Islam: Unity in Diversity

    War that reshaped Middle East

    The War that Reshaped the Middle East Forever

    Trusting in Allah: Overcoming the Social Pressures of Having a Male Child

    Trusting in Allah: Overcoming the Social Pressures of Having a Male Child

    Social Media: A Journey from Word-of-Mouth to Global Networks

    Social Media: A Journey from Word-of-Mouth to Global Networks

    Metaverse Technology: A New Dimension of the Future

    Metaverse Technology: A New Dimension of the Future

    The Dark Side of Evolution Theory: Flaws that Enabled Atrocities

    The Dark Side of Evolution Theory: Flaws that Enabled Atrocities

    The Meaning of Luck in the Eye of Islam

    The Meaning of Luck in the Eye of Islam

    Does Islam Ensure the Rights of Non-Muslims? A Look at Religious Tolerance and Coexistence

    Does Islam Ensure the Rights of Non-Muslims? A Look at Religious Tolerance and Coexistence

    Remove Racism: Understanding and Addressing a Persistent Issue

    Remove Racism: Understanding and Addressing a Persistent Issue

  • Tours & Travel
    • All
    • Cafe Blog
    • Landscape and Sea
    • Life in South Korea

    Lost in the Autumn Hues of Gatbawi Mountain

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Explore Busan’s Architectural Identity: A Recap of the 2021 World Architecture Festival

    Millim cafe

    Unleash Your Inner Explorer at MILLIM Cafe: Award-Winning Design Meets Reptilian Charm in Daegu

    Rise of Islam in Bangladesh

    Unveiling the Rise of Islam in Bangladesh: A Historical Tapestry

    Beauty of Ulsan

    Discover the Beauty of Ulsan: A Seaside Paradise Awaits

  • About Me
  • Contact
No Result
View All Result
Insightful Ink Walk
No Result
View All Result
Home Engineering Control Engineering

Basic of Control Theory: Session 10 – The Art of Tuning – Calibrating Your PID Controller

by ahmedneaz
August 3, 2025
in Control Engineering, DIY Electronics & Robotics
1
Basic of Control-session 10

Basic of Control-session 10

126
SHARES
1.4k
VIEWS

Welcome back! In our last session, we reached a monumental milestone: we wrote and implemented a full PID control loop. Our robot now has a brain that can measure its speed, compare it to a goal, and compute a correction. It is officially a closed-loop system.

However, if you uploaded the code, you probably noticed the wheel’s behavior was less than perfect. It might have been sluggish, overshot the target speed wildly, or oscillated back and forth without ever settling down. A working controller is one thing; a well-behaved controller is another entirely.

The difference lies in the art and science of PID tuning. Today, we’re going to become control system artists. We will learn how to adjust our three magic knobs—the gains Kp, Ki, and Kd—to transform our robot’s response from clumsy and chaotic to crisp, stable, and precise. 1

What Makes a “Good” Tune?

Before we start turning the knobs, we need to define our goal. What does a perfect response look like? In control theory, we’re generally aiming for a system that is: 2

  • Fast: It reaches the target speed (the setpoint) quickly.
  • Stable: It doesn’t oscillate wildly out of control.
  • Accurate: It settles exactly at the target speed with zero steady-state error.
  • Minimally Overshot: It doesn’t fly past the target speed too much before settling down.

Achieving the perfect balance of these traits is the core challenge of tuning.

The Personality of the Gains

To tune effectively, you must have an intuitive feel for what each gain does to the system’s behavior. Let’s revisit our three specialists from Session 3 and see what happens when they are too aggressive or too timid. 3

GainRoleToo LowToo High
Kp (Proportional)The “Right Now” ResponderThe system is slow and sluggish; it takes a long time to react to errors.The system reacts very fast but becomes unstable, oscillating wildly around the setpoint.
Ki (Integral)The “Past-Focused” HistorianIt takes a very long time to eliminate the final steady-state error.The system builds up too much momentum, causing significant overshoot and oscillations. This is “integral windup.”
Kd (Derivative)The “Future-Predicting” DamperThe system overshoots the setpoint and takes longer to settle.The system becomes overly sensitive to sensor noise, leading to jittery, nervous movements.

Tuning is the process of finding the “Goldilocks” value for each gain—not too high, not too low, but just right.

A Practical Method: Manual Tuning by Trial and Error

There are many advanced, mathematical methods for PID tuning, but the most common, intuitive, and effective method for a project like ours is manual tuning. 4 We will systematically adjust each gain while observing the wheel’s response.

For this process, it’s invaluable to get visual feedback. The Arduino IDE has a wonderful built-in tool called the Serial Plotter. It turns printed data into a live graph. To use it, we just need to modify the Serial.println line in our code from Session 9 to print the target and actual RPM, separated by a comma.

Change this line:

Serial.println(motor_power);

To this:

C++

Serial.print(target_rpm);
Serial.print(",");
Serial.println(actual_rpm);

Now, when you upload the code and open Tools > Serial Plotter, you’ll see a live graph of your target speed and the wheel’s actual speed, making it easy to see overshoot and oscillations.

Let’s begin the tuning process. Place your robot on blocks so the wheel can spin freely.

Step 1: Zero Out Ki and Kd

First, we want to isolate the Proportional term. In your code, set Ki and Kd to zero, and set Kp to a small, safe value, like 1.0.

C++

float Kp = 1.0;
float Ki = 0.0;
float Kd = 0.0;

Upload the code. The wheel will likely spin up very slowly and settle at a speed far below your target_rpm. This is expected.

Step 2: Tune the Proportional Gain (Kp)

The goal here is to find a Kp value that gives a fast response without being too unstable.

  • Gradually increase Kp (e.g., from 1.0 to 2.0, then 3.0, 5.0, etc.), uploading the code after each change.
  • Watch the wheel and the Serial Plotter. You will see the wheel get faster and the response time shorten.
  • Keep increasing Kp until the wheel starts to oscillate—meaning it consistently overshoots the target, then undershoots, then overshoots again in a sustained wave.
  • Once you find the Kp value that causes sustained oscillation, set your final Kp to about half of that value. For example, if it starts oscillating at Kp = 10.0, a good starting point for your final Kp is 5.0.

At this point, you should have a system that responds quickly but likely has a noticeable steady-state error (it settles below the target).

Step 3: Tune the Integral Gain (Ki)

Now we’ll bring in our historian to eliminate that steady-state error. Keep your new Kp value and Kd at zero.

  • Start increasing Ki from a very small value (e.g., 0.1).
  • Upload and observe. You should see the steady-state error slowly disappear as the integral term builds up and pushes the speed to the target.
  • Your goal is to find a Ki value that eliminates the error in a reasonable amount of time without causing too much overshoot. If you see the RPM swing wildly past the target, your Ki is too high.
  • Keep tweaking Ki until the wheel settles nicely at the target RPM.

Step 4: Tune the Derivative Gain (Kd)

Finally, we’ll use our strategist to dampen any remaining overshoot from the P and I terms. Keep your Kp and Ki values.

  • Start increasing Kd from a very small value (e.g., 0.01).
  • Upload and observe. The Kd term should act like a brake as the wheel approaches the target speed, reducing the overshoot and helping it settle faster.
  • Be very careful with Kd. Too much can make the motor sound “jittery” or “nervous” as it overreacts to tiny fluctuations in the RPM reading. Find a value that smooths the response without introducing instability.

This is an iterative process. After adding Kd, you might find you can slightly increase Kp for a faster response, which might then require a small tweak to Ki or Kd again. Play with the values until you are happy with the performance.

What’s Next?

Congratulations! You have successfully tuned your first PID controller. You’ve taken a raw algorithm and calibrated it to the unique physics of your specific motor, transforming chaotic motion into controlled, predictable behavior.

You now have one, perfectly tuned, intelligent wheel. The next and final step in our software journey is to scale this up. We need to manage four PID controllers simultaneously and integrate the inverse kinematics from Session 4 to translate high-level commands like “move forward” or “strafe right” into the correct target RPMs for each of our four tuned wheels.

In our next session, we will write the final, complete program for our mecanum robot.

Tags: Basic of control theoryControl theoryPID Tuning
Share50Tweet32SendShare9Send
Previous Post

Basic of Control Theory: Session 9 – Closing the Loop – Coding Your First PID Controller

Next Post

Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

Next Post
Basic of Control-session 11

Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

Basic of Control-session 12

Basic of Control Theory: Session 12 – Cutting the Cord – Wireless Control and the Road Ahead

Comments 1

  1. Georgeagolo says:
    1 month ago

    Hola, volia saber el seu preu.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Basic of Control-session 12
Control Engineering

Basic of Control Theory: Session 12 – Cutting the Cord – Wireless Control and the Road Ahead

by ahmedneaz
August 3, 2025
2

Hello and welcome, for one last time, to our series on the secret brains of everything. Over the past eleven...

Read more
Basic of Control-session 11

Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

August 3, 2025
Basic of Control-session 10

Basic of Control Theory: Session 10 – The Art of Tuning – Calibrating Your PID Controller

August 3, 2025
Basic of Control-session 9

Basic of Control Theory: Session 9 – Closing the Loop – Coding Your First PID Controller

August 3, 2025
Basic of Control-session 8

Basic of Control Theory: Session 8 – From Ticks to Speed – Calculating RPM

August 3, 2025

Recent News

Basic of Control-session 12

Basic of Control Theory: Session 12 – Cutting the Cord – Wireless Control and the Road Ahead

August 3, 2025
Basic of Control-session 11

Basic of Control Theory: Session 11 – The Grand Finale – Orchestrating the Four-Wheel Symphony

August 3, 2025

Follow Us

Site

  • About
  • Privacy & Policy
  • Cookies Consent
  • Terms & Conditions
  • Contact

Motive

The beauty of ink lies not only in its permanence on paper but in its ability to capture fleeting thoughts and emotions, leaving a tangible record of our innermost selves.

  • About
  • Privacy & Policy
  • Cookies Consent
  • Terms & Conditions
  • Contact

© 2025 The Insightful Ink Walk by AHMED NEAZ.

No Result
View All Result
  • Home
  • Engineering
  • Perspective of life
  • Discover South Korea
  • Tours & Travel
  • About Me
  • Contact

© 2025 The Insightful Ink Walk by AHMED NEAZ.

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.