go away spammer

Author Topic: PID Questions  (Read 1777 times)

0 Members and 1 Guest are viewing this topic.

Offline dualTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
PID Questions
« on: October 29, 2009, 12:57:54 PM »
Hi, I have a few questions regarding PID control. I am using a basic algorithm I found in wiki and here it is:

previous_error = 0
integral = 0
start:
  error = setpoint - actual_position
  integral = integral + (error*dt)
  derivative = (error - previous_error)/dt
  output = (Kp*error) + (Ki*integral) + (Kd*derivative)
  previous_error = error
  wait(dt)
  goto start

So my questions are:

1.) Does the sum of kp, ki and kd have to equal 1? meaning should for example kp = .5, ki = .3, kd = .2?
2.) According to wiki, the system becomes stable if the oscillations decay. So if i have an array of inputs - say, 30, 31, 32,29,29,30,30,30,30. which of these set of outputs make a stable system
a.)0,20,40,-20,-10,10,0,0,0,0.
b.)0,20,40,-20,-10,10,1,-1,1,-1.
c.)0,20,40,-20,-10,6,-4,1,0,-1.

My guess is (c) since it is decaying to 0, but I'm not quite sure.
3.) Is the dt or time period supposed to also be found by experiments? or can it be any value? right now I'm using .05secs and .1secs as my dt. Are my dt too big or too small?

Thanks all

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: PID Questions
« Reply #1 on: October 30, 2009, 07:53:18 AM »
Since no one has answered I'll give you a few hints.
The coefficients can be calculated IF you can calculate all the mechanical dynamics. Since this is rarely the case the coefficients are very often determined by experimentation.

2nd Hint: In many simple systems the Integral term is not used. There is an issue can "wind up" from the integral term that may need 'resetting'. Do some more googling on PID to find details, I have seen some good app notes on tuning a PID loop for temperature controllers.

3rd: The sum of the three coefficients do not need to be 1. Each coefficient is fairly independent.

If you plot your outputs verse time it is easy to see the loop stability.

The dt depends on your system. I've worked on tuning a PID loop for a temperature control on a 2 liter glass vessel. In this case a dt on 10seconds was plenty fast due to the slow response of the any temperature change. Now on a robot motor control the dt may need to be in the milliseconds or shorter.

Hope that is some help.

Offline dualTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: PID Questions
« Reply #2 on: October 30, 2009, 08:37:51 AM »
You're right, I've found some really good consants through experimenting. I'm doing a wall following and from reading the stuff that I found online, the integral term really isn't needed. However, I'm not sure if it's just my experiments but the Integral term really helps smooth the movement of my robot.

I will do some research on integral windup. Right now, the only situation that I found that the integral winds up and needs reset is whenever the process value is the same as the set point for more than two cycles, in which the integral error remains constant even when the error is zero.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: PID Questions
« Reply #3 on: October 30, 2009, 10:57:33 AM »
Sounds like you are learning and progressing very well.

 


Get Your Ad Here