Go Down

Topic: line following white background (Read 137 times) previous topic - next topic

hhamza54

Hi, what kind of PID algorithm should be used for white background and black line tracking robot? The sensor can be QTRC or QTRA.

sahirudilan

There is a detailed guide here.
Or you can simply use a method similar to this;

Code: [Select]
  ReadSensor();
  PreviousError = Error; // save previous error for differential
  Error = AvgSensor - 4.5; // Count how much robot deviate from center
  TotalError += Error; // Accumulate error for integral

  Power = (Kp * Error) + (Kd * (Error - PreviousError)) + (Ki * TotalError);


You have to adjust the values for PID.

hhamza54

Can we find the PID values ​​in a different way in trial and error? Where should I start the experiment?

zhomeslice

Can we find the PID values in a different way in trial and error? Where should I start the experiment?
Start with Kp, adjust it till it oscillates then back off till it just stops.  [ Kp Adjust, Ki = 0, Kd = 0 ]
Next use Kd  Kd provides a kick to quickly get the bot back on track   Start small like 0.1, if it jitters you have too much Kd [ Kp Oscillation stops value, Ki = 0 , Kd 0.01 or >]
Now consider Ki you probably won't need this especially because it is prone to windup which unless you reset it (Zero integral output offset) each time you start, the control it will cause issues

Once you get decent control , fine tune Kp an Kd 

While this video of mine is a balancing bot it has similar principles as a line following bot. 
https://youtu.be/uyHdyF0_BFo

Z
HC

Go Up