OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PID has no I?

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
dsandber



Joined: 01 Aug 2006
Posts: 52

PostPosted: Wed Sep 12, 2007 5:31 am    Post subject: PID has no I? Reply with quote

Looking at the pid.c file, I noticed that the IGAIN doesn't seem to be used. The relevant lines seem to be:

pwm_output += (int32_t) p_component * (int32_t) p_gain;
pwm_output += (int32_t) d_component * (int32_t) d_gain;

Am I looking at the wrong file or are we really ignoring the integral component of the PID loop? Isn't that necessary for the absolute position to be accurate ( lest the PWM doesn't ramp up enough from the P and D components )?

-Dan
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Wed Sep 12, 2007 7:20 am    Post subject: Reply with quote

Dan,

You are correct, there is no I calculation on the controller, making it a PD controller.

When Mike wrote the algorithm I believe he had some problems with using the integral term in the calculations.

I have started a new -dev branch of OpenServo in CVS that will be looking at these issues in due course.

Barry
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
dsandber



Joined: 01 Aug 2006
Posts: 52

PostPosted: Wed Sep 12, 2007 6:51 pm    Post subject: Reply with quote

Eeks, I'm surprised people haven't found this to be a problem. This makes it very hard to avoid little positioning errors unless the P term is very large. And if it is, it's hard to avoid crazy oscillations. Hmm.
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Wed Sep 12, 2007 7:02 pm    Post subject: Reply with quote

It hasn't been a major problem up to now because the servos don't generally carry a massive load over large distances. Hobby servos also move so fast as to not be a problem.
You might see some oscillation around the destination point unless you tune the PID nicely, but there is a deadband that takes care of some of that.

Integral windup is also a rather annoying problem when trying to tune the servos, so the I term was omitted for tuning sanity.

There will be a new, more advanced algorithm in the V3 code base that I will backport when ready,

Barry
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
DavidCary



Joined: 24 Oct 2007
Posts: 12
Location: Oklahoma and Kansas

PostPosted: Wed Oct 31, 2007 6:16 am    Post subject: Reply with quote

ginge wrote:
Integral windup is also a rather annoying problem when trying to tune the servos, so the I term was omitted for tuning sanity.

Yes, the standard tuning process sets the I term to zero, tunes the P and D parts first, and then (if necessary) tweaks the I term.

I've heard that some PID process controllers now come with "automatic tuning" algorithms.
Should we try to squeeze "automatic tuning" into the OpenServo software?
Back to top
View user's profile Send private message
robotjay
co-admin


Joined: 01 Aug 2006
Posts: 225
Location: Nebraska, USA

PostPosted: Wed Oct 31, 2007 6:54 am    Post subject: Reply with quote

DSandber,

Like Barry said, the I value will have little impact on the loads that a hobby servo can carry, but we are still working on making it a useful value to set.

Here's the way I've been tuning the OpenServo (Barry please comment on this method):
-Set P, I, and D to zero.
-Set P to a small number and command the servo to move to an arbitrary position.
-Typically, the servo will move to the commanded position (slowly, when the P value is low.)
-Continue to increase the P value until the servo begins to oscillate around the set point indefinitely. (Basically, find the lowest P value that causes the servo to go into indefinite oscillations.)
-Increase the D value until the servo settles in an appropriate amount of time after a move. (The higher the D value, the slower the servo moves, so you will have to determine an acceptable level of trade-off.)

David,

A perfect auto-tuning algorithm seems to be the holy grail of motion control. You are certainly welcome to investigate further, but even high-end, industrial servo controllers with so-called auto-tuning, don't work accurately under all loads. This has actually been discussed in another thread here. The consensus from that thread was that the best solution to implement was to use look-up tables for certain conditions, and adjust the gain values accordingly. I don't know your technical background, but maybe you can shed some new light on the subject... For my limited applications of the OpenServo, using the above tuning method seems to get the servo to work consistently across most small loads, even vertically against gravity.

-Jay
_________________
"Nothing is fool-proof; For we fools are ingenious and will find a way."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Wed Oct 31, 2007 9:12 am    Post subject: Reply with quote

Jay, David,

The Tuning of the servo is relatively simple. The method the Jay posted above is appropriate and correct. There are several ways to go about tuning, and the method above uses no complex math to get it right, and often gives the best results.

David,
Yes, autotuning would be nice. Jay is correct in saying that it is difficult to do this automatically for each application and load.

Barry
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
jharvey
co-admin


Joined: 15 Mar 2009
Posts: 352
Location: Maine USA

PostPosted: Mon Jul 06, 2009 3:57 pm    Post subject: Reply with quote

ginge wrote:
I have started a new -dev branch of OpenServo in CVS that will be looking at these issues in due course.

I seem to also recall a note that there was some other functioning I code. I'm looking at the V3-dev branch right now, but don't see a section for the I part of PID. Perhaps there is a section somewhere else that includes this?

For reference, here is some pseudo code that might help with the math problems.

http://www.embedded.com/2000/0010/0010feat3.htm
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group