PID Control of a Line Following Robot - Lab Report

Categories: Technology

INTRODUCTION

The objective of this laboratory experiment was to design and implement a PID (Proportional-Integral-Derivative) controller for the Spark V robot. The goal was to make the robot autonomously follow continuous lines on the ground using the onboard IR sensors. This task mimics real-world applications such as autonomous navigation and industrial automation where precise control is required.

The PID control algorithm is widely used in robotics and automation due to its ability to provide accurate control by continuously adjusting motor speeds based on sensor feedback.

In this experiment, we aimed to achieve the following objectives:

  1. Implement a digital PID controller on the ATMEGA16A microcontroller-based Spark V robot.
  2. Use three IR sensors to detect and track continuous lines on the ground.
  3. Ensure that the robot can complete a predefined track within a specified time frame of 30 seconds.

This report details the challenges faced, the methodology employed, the results obtained, and the inferences drawn from the experiment.

Components Used:

  • Spark V robot based on ATMEGA16A microcontroller

Peripherals:

  • AC adaptor with exact 12VDC with 1Amp.

    Get quality help now
    Doctor Jennifer
    Doctor Jennifer
    checked Verified writer

    Proficient in: Technology

    star star star star 5 (893)

    “ Thank you so much for accepting my assignment the night before it was due. I look forward to working with you moving forward ”

    avatar avatar avatar
    +84 relevant experts are online
    Hire writer

    current rating for battery charging

Control Algorithm:

Digital PID controller

CHALLENGES FACED

Sensors and Errors

The problem we encountered was how to get error values. There are two approaches for getting error. First, take the error to be the difference between left and right sensors.

Although this approach looks good, the left and right sensors may not read the same value of intensity even after great calibration effort.

So, we assigned a common threshold to all sensors to differentiate between black and white.

Get to Know The Price Estimate For Your Paper
Topic
Number of pages
Email Invalid email

By clicking “Check Writers’ Offers”, you agree to our terms of service and privacy policy. We’ll occasionally send you promo and account related email

"You must agree to out terms of services and privacy policy"
Write my paper

You won’t be charged yet!

Further, we gave weights to each sensor.

3.2 Loss of Robust Control due to LCD Printing

The bot behaves differently when we try to run it along with values being printed on LCD for debug/observation, for the same logic of code. This might be due to sampling time issues which occur when we try to print values on LCD as the time to execute the code is much higher than the time to execute without printing any values on LCD.

For the final testing, part of the code responsible for LCD display was commented.

Flow Chart

The flow chart illustrates the logic and control flow of the PID control algorithm used to guide the Spark V robot along a continuous line. While the exact details of the flow chart may vary depending on the specific implementation, the following key steps and components are typically included:

  1. Start: The program execution begins here.
  2. Initialize PID Constants: Set the values of Kp, Ki, and Kd, which are the proportional, integral, and derivative constants of the PID controller.
  3. Initialize Sensors: Configure and calibrate the IR sensors to detect the contrast between the black line and the white background.
  4. Read Sensor Values: Continuously read data from the three IR sensors to determine the current position of the robot relative to the line.
  5. Calculate Error: Calculate the error value by comparing the sensor readings to the desired position on the line. The error is the difference between the desired position (typically the center of the line) and the actual position.
  6. Calculate Control Output: Utilize the PID algorithm to compute the control output, which represents the adjustment needed for the robot's left and right motors to correct its position.
  7. Adjust Motor Speeds: Modify the speed of the left and right motors based on the control output. This ensures that the robot moves in the correct direction to stay on the line.
  8. Check Completion: Determine whether the robot has completed the specified track within the given time frame (e.g., 30 seconds).
  9. End: Terminate the program execution once the objective is achieved or the time limit is reached.

The flow chart provides a visual representation of the PID control algorithm's operation and helps in understanding how the robot continuously adjusts its movement to stay on the desired path. It is a crucial tool for debugging and fine-tuning the controller's parameters for optimal performance.

RESULT

The Spark V line follower robot completed the track in 29.02 seconds.

Kp, Ki, and Kd values used were 5, 0, and 1 respectively.

6. INFERENCE

If Kp value is too low, the bot failed to follow the path due to a large turning radius.

When the Kp is very high, the bot follows the path but with rapid jerks.

With only Kd, Kp, and Ki to be zero, the bot was unable to take turns but was able to move in straight lines.

Choosing proper values of Kp and Kd, the bot is able to complete the given track within 30 seconds.

DISCUSSION

Implementation of PID Control: The heart of this experiment lies in the implementation of the PID control algorithm. PID control is based on three components: proportional, integral, and derivative terms. The proportional term (Kp) controls the immediate response to the error, the integral term (Ki) deals with accumulated errors over time, and the derivative term (Kd) handles the rate of change of error. By tuning these constants, we can control the robot's behavior.

Sensor Challenges: One of the major challenges faced during the experiment was obtaining accurate error values from the IR sensors. Initially, we considered taking the error as the difference between the readings of the left and right sensors. However, due to sensor variability and calibration difficulties, this approach proved unreliable. To address this, we assigned a common threshold for all sensors and applied sensor weighting to improve the accuracy of error calculation.

Loss of Robust Control: Another interesting observation was the loss of robust control when attempting to print values on the LCD for debugging purposes. It became evident that the time required for printing on the LCD significantly affected the robot's performance. This suggests the importance of considering real-time constraints when implementing control algorithms in practical applications.

Tuning of PID Constants: The choice of PID constants (Kp, Ki, and Kd) played a crucial role in achieving successful line following. A too low Kp resulted in the robot being unable to make sharp turns, while a very high Kp caused rapid and jerky movements. By fine-tuning these constants, we found a balance that allowed the robot to complete the track within the desired time frame.

CONCLUSION

This laboratory experiment successfully demonstrated the implementation of a PID controller for the Spark V robot, enabling it to autonomously follow continuous lines on the ground. The use of three IR sensors, error calculation methods, and PID tuning allowed us to achieve precise control of the robot's movement.

The challenges faced, such as sensor accuracy and real-time constraints during debugging, provided valuable insights into the practical considerations of control system design. These challenges underscored the importance of robust sensor calibration and the need for efficient code execution in real-time applications.

In conclusion, by carefully tuning the PID constants, we were able to ensure that the Spark V robot completed the predefined track within the specified time frame of 30 seconds. This experiment highlights the practical application of control theory in robotics and automation, laying the foundation for further exploration and development in this field.

Updated: Jan 04, 2024
Cite this page

PID Control of a Line Following Robot - Lab Report. (2024, Jan 04). Retrieved from https://studymoose.com/document/pid-control-of-a-line-following-robot-lab-report

PID Control of a Line Following Robot - Lab Report essay
Live chat  with support 24/7

👋 Hi! I’m your smart assistant Amy!

Don’t know where to start? Type your requirements and I’ll connect you to an academic expert within 3 minutes.

get help with your assignment