Table of Contents

Set PID Constants

Description

This block configures the three constants used by the PID controller.

Constant Description
Kp – Proportional Determines the correction based on the current line-position error.
Ki – Integral Corrects persistent errors accumulated over time.
Kd – Derivative Responds to changes in error to reduce oscillation and overshooting.

How It Works

The robot calculates how far the detected line is from the centre of the sensor array.

The PID controller uses the configured constants to determine the required steering correction and adjusts the motor speeds accordingly.

Python Function – Quarky and Quarky Intellio:

lf5ir.setpidconstants(0.6, 0.0, 0.9)

Example: Set Kp = 0.6, Ki = 0.0, and Kd = 0.9 to configure the PID controller using the values shown in the block.

These are example values and may need adjustment depending on the robot and track.

Understanding PID Control

Proportional (P): Responds to the current line-position error. A larger error produces a stronger correction.

Integral (I): Accumulates errors over time to help correct persistent drift.

Derivative (D): Responds to changes in the error to reduce sudden corrections and improve stability.

Recommended PID Tuning

  1. Begin with Ki and Kd set to 0, using a moderate Kp value.
  2. Increase Kp gradually if the robot corrects too slowly.
  3. Decrease Kp if the robot oscillates excessively.
  4. Introduce Kd to reduce overshooting and improve stability.
  5. Add a small Ki value only if the robot continues to drift consistently towards one side.

Note: Test the robot at a low speed while adjusting PID parameters.

Example

There are no examples documented for this article.