Arduino PID Code for Line Following Robot
Intro: Arduino PID Code for Line Following Robot
In this instructable, you will learn how to make Arduino PID codes for any task, some mathematics, and design robots that are more efficient than others.
To start, watch the video above to see how the PID line following operates, in this example, we used a sophisticated infrared sensor to read the line, however, with this code, you can control it using a simple LDR (Light Dependent Resistor).
STEP 1: P: the Proportional Term
The proportional term makes the current Error Multiplied with a gain (Kp), the result will be the output signal.
So OUTPUT-SIGNAL=Kp*Error-signal
Most 8-bit Microcontrollers can do this mathematical problem, it wouldn't be necessary to look further from an Arduino or a PIC.
STEP 2: I: the Integral Term
The Integral Term makes the current Error signal value and duration multiplied with a gain, the result will be the output signal.
(the math is shown above);
where K1 is the integral gain, t is the instantanious time, e(t) is the error signal.
The integral of a signal is the sum of all the instantaneous values that the signal has been, from whenever you started counting until you finished counting.
The Integral Term when added to the proportional term accelerates the movement of the process towards set-point.
STEP 3: D: the Derivative Term
The derivative term makes the rate of change of the error signal multiplied with a gain (Kd). The result will be the output signal value.
Where Kd is the derivative gain, and e(T) is the error signal.
The derivative term slows the rate of change of the controller output and this effect is most noticeable close to the controller's setpoint.
12 Comments
LongH25 5 years ago
MeesumM 6 years ago
hi i need the code for the pid controlled line following robot using arduino uno for 4 ir sensors and its urgent
BivekG 7 years ago
please inbox me the code at bivekgris@gmail.com
BivekG 7 years ago
i need code of this line following robot please
poncos 8 years ago
Josaiphe 8 years ago
In the video it was a first virgin that i designed 6 months ago, but I wanted to make simpler for everybody, so I used just the A0 pin of the arduino, and it works like a charm, also if you like it don't forget to vote for it in the robotics contest.
poncos 8 years ago
Josaiphe 8 years ago
poncos 8 years ago
Josaiphe 8 years ago
In the PID control you set the robot to see the thin line between black and White, but you need to set constants to work with your lighting. Also, Please vote for this if you like it in the robotics contest, to vote just press the "Vote" button in the Up right corner, and choose the contest.
poncos 8 years ago
Josaiphe 8 years ago