This readme provides a comprehensive guide to the Simple PID Motor Control code. It enables users to understand the setup, functionality, and customization options of the code.
- Introduction
- Components
- Setup
- Ultrasonic Sensor
- Potentiometer
- PID Controller
- PWM Output
- Adjustable Parameters
- Usage
- Troubleshooting
The Simple PID Motor Control code is designed for Arduino-based projects, implementing a basic Proportional-Integral-Derivative (PID) controller to regulate the movement of a motor. The system uses an ultrasonic sensor to measure distance and adjusts the motor's speed based on a setpoint.
- Arduino Board
- Ultrasonic Sensor (HC-SR04)
- Potentiometer
- Motor
- Wires and Breadboard
- Connect the components according to the provided pin configurations in the code.
- Upload the code to your Arduino board.
The ultrasonic sensor measures distance (in cm) and influences the PID controller's behavior based on the setpoint.
The potentiometer adjusts the setpoint, allowing users to define the desired distance for the motor to maintain.
The PID controller calculates the error, integral, and derivative terms to determine the appropriate PWM output for motor control.
The PWM output is adjusted based on the PID calculation, controlling the motor's speed. The PWM range is constrained between 143 and 154.
- Setpoint: Adjusted using the potentiometer.
- Kp, Ki, Kd: Fixed values set in the code to define the Proportional, Integral, and Derivative gains.
- Power up the system.
- Adjust the potentiometer to set the desired distance (setpoint).
- Observe serial monitor for setpoint, actual distance, PWM value, and PID value.
- Monitor motor behavior based on adjustments.
- No Serial Output: Check connections and ensure the Arduino is connected to the computer.
- Incorrect Sensor Readings: Inspect ultrasonic sensor and wiring.
- Motor Not Responding: Verify PWM values and motor connections.
This project is licensed under the MIT License.