PID Reset?

I m using the PID library from the arduino playground. And i m using it on a robot. However, every time I stop and turn the robot and start driving again, the PID controller just stops functioning. Yet I v reset everything. I also tried changing myPID.SetMode(AUTOMATIC ); to myPID.SetMode(MANUAL); and back to AUTOMATIC to reset the PID library internal variables but this didnt seem to work either. Has anyone experience reseting a PID controller? Whats really frustrating is the conditions for when it works to when it doesnt work seem to be the exact same. I printed out everything to the serial monitor and nothing seems to be different.
2 + 2 = 5. :frowning:

41 posts and you still haven't read up on or figured out how to ask a sensible question on this forum?
Start here: http://forum.arduino.cc/index.php/topic,148850.0.html

What do you mean its not a sensible question? Of course its a sensible question. I m looking for advice on reseting internal PID variables for people who have experience in that area. I asked it under the motor section.

You won't get an answer to your problem if you don't show us the code and explain how things are
wired up. Post all the details and explain what you think should be happening and what is actually
happening.

This is a forum.

An Internet forum, or message board, is an online discussion site where people can hold conversations in the form of posted messages.

  • Wikipedia

That doesnt mean its a necessity to post code. I am not expecting a direct answer to my problem. The code I have is quite lengthy and would take a lot of time to explain. I m looking for general ways that people restart their PID controllers.

If you don't want an answer, perhaps this is the wrong place to ask the question?

It doesnt have to be an answer. Its a discussion. Thus the name forum.

Interesting. I am experiencing similar strange results. I have two uno’s talking to each other. One is reading distance, the other is controlling output.

When I first load the program, I get normal results. When I power down and up, the PID is giving full output of 255 creating a 0 for the controller. This is observed in the cart because it starts going in circles. I then load another program the the board running the PID and then load back the PID code, and it works again while connected to computer until I restart power. Any advice on what could cause this phenomenon when powered down?

Here is the code. Trying to keep a car in the middle between two objects.

void loop()
{
  InputR = dist[2] - dist[1];
  InputL = dist[1] - dist[2];
  myPID_L.Compute();
  myPID_R.Compute();

  if (InputR < 0) {
    speedR = setSpd - OutputR;
  }
  else {
    speedR = setSpd;
    myPID_R.SetMode(MANUAL);
    OutputR = 0;
    myPID_R.SetMode(AUTOMATIC);
  }
  if (InputL < 0) {
    speedL = setSpd - OutputL;
  }
  else {
    speedL = setSpd;
    myPID_L.SetMode(MANUAL);
    OutputL = 0;
    myPID_L.SetMode(AUTOMATIC);
  }
  analogWrite(mtrL, speedR);
  analogWrite(mtrR, speedL);
  Serial.print(dist[0]); Serial.print("  "); Serial.print(dist[1]); Serial.print("  "); Serial.print(dist[2]); Serial.print("  ");
  Serial.print(InputL); Serial.print("  "); Serial.print(InputR); Serial.print("  "); Serial.print(speedL); Serial.print("  "); Serial.print(speedR); Serial.print("  "); Serial.println("  "); //}

}

This is desired output. (front distance-not used, Left, Right, PID Left, PID Right, Speed Left, Speed Right).

20:20:26.702 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.702 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.702 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 255.00
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 245.70
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 245.70
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 245.70
20:20:26.737 → 40.00 25.00 17.00 8.00 -8.00 255.00 245.70

After reboot, I get this. Then reloading and it works again. Doesn’t matter how many board resets or power cycles I do, it doesn’t work until I reload code, and then it only works until power is cycled. The key to look at is the 255 swapping back and forth in last two columns from 255 to zero.

20:19:01.066 → 20.00 13.00 14.00 -1.00 1.00 0.00 255.00
20:19:01.066 → 20.00 13.00 14.00 -1.00 1.00 0.00 255.00
20:19:01.066 → 20.00 13.00 14.00 -1.00 1.00 0.00 255.00
20:19:01.066 → 20.00 13.00 14.00 -1.00 1.00 0.00 255.00
20:19:01.101 → 20.00 12.00 7.00 5.00 -5.00 255.00 255.00
20:19:01.101 → 20.00 12.00 7.00 5.00 -5.00 255.00 0.00
20:19:01.101 → 20.00 12.00 7.00 5.00 -5.00 255.00 0.00