Go Down

Topic: Arduino PID Library (Read 59 times) previous topic - next topic

psyber

#55
Aug 23, 2009, 09:58 pm Last Edit: Aug 23, 2009, 09:59 pm by psyber Reason: 1
Quote

foo.cpp
Code:

#include "PID_Beta6.h"
#include "foo.h"

foo::foo() : myPID(&Input, &Output, &Setpoint,2,5,1)
{
  // initialize foo
}




I had to look up initialization lists, in my real life I've never used them. In another environment I'd include a pointer to a PID object in my class and use new to create it in the constructor.



Nice!  I figured there was some way to do it without monkeying around with the original library.  I just wish there was a more intuitive method as my C/C++ is extremely rusty.  I don't think this is covered in any of my old textbooks either.   >:(

br3ttb:
As for the middle ground solution, I see no difference between you adding the code and then commenting it out, and having a developer simply add the code.  In either case someone still has to edit the class and rebuild the library.



 




 

spamiam

I hate to resurrect this old thread, but it is a good one, and the PID software looks really good.

Before finding this thread, I wrote my own.  I was particularly interested to see how wind-up was handled.  I saw that the Integral term was not incremented when the output was maxed.  

This seems like a great idea, but doesn't it cause a bit of a glitch when the output drops down from max?  Maybe the integral term is well below the value resulting in maximum output due to some other factor such as the differential.

Is this really going to make much of a glitch under these circumstances?  I suspect that a "properly" tuned loop will not have such odd behaviour that the differential can push the output that far up/down.

I attempted to limit wind-up by not allowing the integral term to exceed the value that results in full output on its own.  Is this not good enough?

-Tony

br3ttb

Quote
doesn't it cause a bit of a glitch when the output drops down from max?

I haven't noticed this.  the inclusion of the (err>0) and (err<0) are supposed to (and seem to) keep this from happening

Quote
limit wind-up by not allowing the integral term to exceed the value that results in full output on its own.  Is this not good enough?

the short answer is "yes."   It's not as simple with the form of the pid I'm using, because I have a bias term in the mix.  I'm in the process of migrating the library toward the method you describe.  

Brett

Datapolo

Brett, nice library and easy to use and tidies up my code nicely. Any news on the 'lite'version for basic functionality?

Cheers,
Mike

br3ttb

#59
Oct 16, 2009, 12:48 pm Last Edit: Oct 16, 2009, 01:06 pm by br3ttb Reason: 1
Quote
Any news on the 'lite'version for basic functionality?


I've actually decided to ditch the idea of a lite version.  Instead I'm working on reducing the footprint of the full version.  The next revision of the library is almost done.  it uses integer math throughout, so it's about half the size and 10X faster.

Brett

[edit]On second thought I may be able to add some preprocessor flags to remove a lot of the extra functionality, resulting in a lite library.  I'll see what I can do[/edit]

Go Up