Self Balancing Robot

Hi again after a big interrupt )
well I read the links on PID and got to it, but I have to implement it to see. I started to analyze your code, but some moments are still unclear to me. KF parts are crystal clear, just are following the KF formulation from mathematics. PID has some of your own secrets :wink:
I write them here if you can kindly explain them it greatly helps :wink:

I cant understand these:

  1. please let me know, what calibration here means, and why -4.5, and why added to your myangle (converted to degree? yes?)
  float calibration = -4.5; // read from a pot or something
  float myangle=(angle*57.2957795130823)-90.0 + calibration;
  1. You mean, when time is more than 6 sec. LED goes high? why? (
if ((millis()-startmillis) > 6000 )
  1. why P and I have pot/100, but D has pot/10?
P = (myangle * (pot1 / 100.0)); // pot/10
D = (myangle-oldAngle) * (pot2 / 10.0);
  1. why 128? why 250 and 5?
    float motors = 128.0 - (pid+(sgn(pid)*sqr(pid/18)));
    // cap the value
    if (motors>250.0) motors = 250.0;
    if (motors<5.0) motors = 5.0;
  1. What is this if-block for? else is comming from having info in motorInput, but this if speakc about?
    if ((myangle > 80) || (myangle < -80))

sorry for I'm this much novice )))