element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project Videos
  • Challenges & Projects
  • element14 presents
  • Project Videos
  • More
  • Cancel
Project Videos
Documents Using PID (Proportional-Integral-Derivative) in Robotics - How Hard Could It Be? -- Episode 614
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Project Videos to participate - click to join for free!
Related
Recommended
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 2 Aug 2023 6:07 PM Date Created
  • Last Updated Last Updated: 4 Aug 2023 7:24 AM
  • Views 20784 views
  • Likes 9 likes
  • Comments 10 comments

Using PID (Proportional-Integral-Derivative) in Robotics - How Hard Could It Be? -- Episode 614

Adam has often wondered how PID controls work and how they are implemented. Is PID tuning challenging? Do external factors on the robot affect PID tuning? Watch Adam build a parking robot using PID to accelerate, decelerate, and keep track of the distance from other objects.

Watch the Video:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Adam takes on the challenge of using a PID (Proportional Integral Derivative) controller in a robotics project. He is interested in robotics and has experience with Halloween animatronics, but PID control presents a new level of complexity. PID is commonly used in advanced robotics projects. Examples include balancing robots or systems that require precise control to stay centered, such as a platform with a bouncing ping-pong ball. 

image

Adam's project involves creating a basic self-driving car that can accelerate and decelerate within a one-meter distance without overshooting the target. He has designed a robot with two beefy motors (120 RPM, 12 watts each) for the left and right sides. Power management is a concern, so he is considering using a cable instead of a battery. The robot will be driven by an Arduino Uno R4 Minima, which is a compact and capable microcontroller board that interfaces with the motor driver and an ultrasonic sensor to implement the PID control. 

3D CAD

To realize his design, Adam has iterated through various prototypes and 3D-printed parts for the robot. He used M3 screws for all components to avoid the need for hot glue or modifications. The robot features two large tires, and Adam plans to add electrical tape for better traction on hardwood surfaces. Despite the challenges during the design phase, he is excited about the potential success of the final product. 

3D Print

During the PID tuning process, Adam faces some difficulties. He turns to a chatbot for code assistance, but the provided code has some inaccuracies for his specific setup. Regardless, the code from the chatbot gives him valuable insights and prompts him to think about setting PWM limits and stopping when the target distance is reached. This process highlights the complexities involved in fine-tuning PID controllers for individual systems. 

Attempt 2

After adjusting his code and robot setup, Adam sees significant improvements in performance. Although there are still some issues with overcompensation and occasional tipping, the robot is now much closer to achieving its desired behaviour. PID tuning is an art form, it requires patience and understanding of numerous factors beyond just the constant values. 

...Hard

Throughout the project, Adam encounters challenges related to the ultrasonic sensor and weight distribution, but with the Arduino Uno R4 Minima at its core, he can efficiently program and fine-tune the PID controller to achieve the desired performance of the self-driving car. This powerful yet compact microcontroller empowers makers like Adam to explore advanced robotics concepts and experiment with PID control in their projects. Despite the difficulties, he is excited about the progress made and looks forward to further improvements in his robot's behaviour. 

Bonus Content:

  • Download Code and CAD Files!

Bill of Material:

Product Name Manufacturer Quantity Buy Kit
3D Printer Filament, PLA, White MULTICOMP 1 Buy Now
Sensor Board, Ultrasonic Distance Sensor, PING PARALLAX 1 Buy Now
ARDUINO UNO REV4 WIFI ROHS COMPLIANT: YES Arduino 1 Buy Now
 

Additional Parts:

2x 100 RPM 12V Gear Motor High Torque
DC Motor Driver, DROK L298
Various M3 Screws

element14 presents

element14 presents  |  About Adam |  Project Videos

  • robot design
  • advanced robotics
  • ultrasonic sensor
  • Self-Driving Car
  • e14p_AS
  • fine-tuning pid
  • arduino minima r4
  • 3D Printing
  • robitics tuning techniques
  • autonomous vehicles
  • robotics tutorial
  • PID Control
  • balancing robot
  • robotics project
  • motor driver
  • friday_release
  • maker's challenge
  • Share
  • History
  • More
  • Cancel
Actions
  • Share
  • More
  • Cancel
  • Sign in to reply
  • adamsoileau1
    adamsoileau1 over 2 years ago in reply to javagoza

    Very cool! I think it's really neat how you can use so many different sensors for the input of the PID controller, which makes sense for various applications. I think adding an accelerometer or gyroscope would be neat to have the robot try to stay going in a straight line. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • adamsoileau1
    adamsoileau1 over 2 years ago in reply to beacon_dave

    I agree! I think I could have even went with a lower rpm motor or designed a gearbox to reduce the speed. I think at full speed, it's too fast for the application.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • adamsoileau1
    adamsoileau1 over 2 years ago in reply to DAB

    Yep yep! I think LIDAR would help with delay problem with the ultrasonic sensor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 2 years ago

    Nice project.

    Given the distances, you might want to use a LIDAR sensor instead of the ultrasound.

    You get better accuracy and more distance.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • adamsoileau1
    adamsoileau1 over 2 years ago in reply to dougw

    Great points! I actually remember discussing the effects of time delays in feedback loops in a recent course I took -- finding the max time delay before instability. It's definitely important to lower the input delay as much as possible. Do you recommend any other kinds of sensors for the input of distance? Now that you mention it, maybe some kind of infrared sensor would have been better. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • adamsoileau1
    adamsoileau1 over 2 years ago in reply to baldengineer

    Great point! I didn't really wanna worry about power in the project, so I definitely overlooked that detail. I'm not sure how much the motor driver and the ultrasonic sensor draws? I powered the motors from a seperate power supply. They consumed around 24w total, so that was a yikes. I think I'm getting better at tuning for sure! Very glad this project let me be introduced to it, but it's for sure an art form. I remember hearing stories of people spending like a full day trying to tune their PID system, and I can now relate to that lol

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 2 years ago

    Great project, PID is hard!. I've made several attempts, some examples:

    One similar application, ToF Sensor for Obstacle Avoidance using PID control

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    Arty S7 50 ArtyBot ToF Sensor for Obstacle Avoidance. Vivado Hierarchical Blocks
    javagoza
    Arty S7 50 ArtyBot ToF Sensor for Obstacle Avoidance. Vivado Hierarchical Blocks
    Our Artybot already controls motors via PWM signals…
    By javagoza over 3 years ago in FPGA > Blog
    2 comments

    This one is more difficult since it uses a very slow sensor color, it was more complicated to adjust the PID

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    Arty S7 50 ArtyBot - Color sensing and line follower
    javagoza
    Arty S7 50 ArtyBot - Color sensing and line follower
    In this post we will add a Pmod COLOR sensor to our…
    By javagoza over 3 years ago in FPGA > Blog
    2 comments

    Controlling motor 

    Speed PID Controller: PID control with goal of maintaining the same target speed for both wheels

    Distance PID Controller: PID control with goal of maintaining the same traveled distance for both wheels

    (+) Arty S7 50 ArtyBot - Bot Application Framework - element14 Community

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    Arty S7 50 ArtyBot becomes Emubot, an educational robot for young children
    javagoza
    Arty S7 50 ArtyBot becomes Emubot, an educational robot for young children
    In this post I will introduce the Emubot project. Emubot…
    By javagoza over 3 years ago in FPGA > Blog
    4 comments

    And finally a crazy one using a magnetometer as sensor

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    The Quantenkompassinator
    javagoza
    The Quantenkompassinator
    The Quantenkompassinator is an over-engineered motorized…
    By javagoza over 3 years ago in Rube Goldberg Device > Blog
    5 comments

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 2 years ago

    Wide elastic bands can be used as makeshift tyres for solid plastic wheels like that. Although some wheelspin perhaps could be advantageous here to prevent flipping.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 2 years ago

    Interesting dive into robotics.

    Vehicle dynamics and tuning PID loops can get very involved as you are demonstrating. The distance output from an ultrasonic sensor is slow, which creates a long feedback cycle so there is not much feedback to work with in the time frame you need it. The motor response needs to be slowed down enough to give the feedback time to take effect. If you turn the proportional gain way down, it shouldn't respond so violently to feedback. If there is residual error, increase integral gain. Derivative gain can improve response time but is pretty dangerous, since it can easily make a system unstable.

    You may need to run the motors very slowly for this sensor and system to be easier to tune and work smoothly with PID.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 2 years ago

    Great project Adam. I like seeing the multiple attempts and their solutions.

    Most of my experience with PID tuning is for my reflow oven. Which has a very slow cycle time (since I have to wait for it to cool.) Learning about the algorithm with a motor/robot would probably be much easier.

    Since making the video, have you made any other discoveries or learnings to improve the coefficients?

    (Also, side note, that 9V battery triggered me. Don't forget those things are only good for 25-30 milliamps. Anything more, like from motors, and their voltage drops fast!)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube