Arduino Forum

Development => Other Software Development => Topic started by: br3ttb on Apr 15, 2011, 10:02 pm

Title: Arduino PID Library: Out of Beta
Post by: br3ttb on Apr 15, 2011, 10:02 pm
After being in Beta for way too long, the Arduino PID Library is ready (I think) for prime time. The new and improved PID_v1 can be downloaded here (http://www.arduino.cc/playground/Code/PIDLibrary).

I made some major changes to the internal code, but what I hope the end-user notices most is that I tried to simplify things.  The two biggest examples of this:
 

The biggest improvement this time around, and by far the most difficult, is that I've explained myself (http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/).  In excruciating detail.  If you want to know how and why I did things in the code, it's all there.

As always, questions and comments are greatly appreciated.

-Brett

Update: the previous PID thread (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1226431507) became a rather unwieldy place for Q&A.  In an attempt to have things be a little more organized, I've created a google group (http://groups.google.com/group/diy-pid-control). 
Title: Re: Arduino PID Library: Out of Beta
Post by: Coding Badly on Apr 16, 2011, 02:39 am

First, thank you!  I appreciate the work you've done.

Second, are you interested in specific technical comments?  If "yes", would you prefer them posted here, on your blog, or something else?
Title: Re: Arduino PID Library: Out of Beta
Post by: br3ttb on Apr 16, 2011, 03:01 am
Quote
are you interested in specific technical comments?

Yeah absolutely.  If it pertains to something addressed in one the blog posts, it probably makes the most sense to post there, so I can respond in context.  For more general stuff, here probably makes more sense.  But no huge deal. I'm more interested in the feedback than where it's delivered.
Title: Re: Arduino PID Library: Out of Beta
Post by: graynomad on Apr 16, 2011, 03:47 am
Thanks br3ttb, I skimmed your tute and already know 10x what I used to about PID, I'll have a better read later.

______
Rob
Title: Re: Arduino PID Library: Out of Beta
Post by: Coding Badly on Apr 16, 2011, 09:41 am

Done.  On the blog.
Title: Re: Arduino PID Library: Out of Beta
Post by: mowcius on Apr 16, 2011, 10:51 am
Neat - I was just implementing the beta version - looks like I'll switch to this now :)

Nice writeup - I'm learning a lot too.
Title: Re: Arduino PID Library: Out of Beta
Post by: br3ttb on Apr 16, 2011, 01:54 pm
@Coding Badly.  Excellent, thank you.  responded.
@mowcius, @Graynomad  I'm not the biggest fan of the work involved in doing a writeup.  The fact that it's useful to you makes all the difference.  thanks.
Title: Re: Arduino PID Library: Out of Beta
Post by: mowcius on Apr 16, 2011, 02:00 pm
Oh that writeup really makes the difference - To most people using the arduino platform, code without a writeup is as useful as no code - they wouldn't know how to use it and therefore wouldn't be able to.

Your writeup obviously goes into a lot more than just how to use it but that's much appreciated - educates us all :)
Title: Re: Arduino PID Library: Out of Beta
Post by: mowcius on Apr 16, 2011, 03:08 pm
I think DIRECT implies other things but i can't think of anything to change it to. Obviously FORWARD would be no better.

Perhaps you want to mention the point that double is acting with the same precision as a float but presumably is there in case double is added with full precision in the future.
Title: Re: Arduino PID Library: Out of Beta
Post by: br3ttb on Apr 16, 2011, 03:39 pm
Quote
I think DIRECT implies other things but i can't think of anything to change it to
agreed.  when there's a question about naming I fall back to industrial standards.  I did the same thing with "sample time"

Quote
Perhaps you want to mention the point that double is acting with the same precision as a float but presumably is there in case double is added with full precision in the future.
yes!  can't believe I forgot to do that.  True double-precision is WAY overkill for PID.  Now I just need to figure out where to put it...
Title: Re: Arduino PID Library: Out of Beta
Post by: mowcius on Apr 16, 2011, 03:44 pm
It's almost as bad as things like 'proper time'... but I can live with DIRECT - makes sure people read your documentation :)

I'll let you know if I find any actual issues with it rather than me nitpicking ;)
Title: Re: Arduino PID Library: Out of Beta
Post by: retrolefty on Apr 16, 2011, 08:31 pm

It's almost as bad as things like 'proper time'... but I can live with DIRECT - makes sure people read your documentation :)

I'll let you know if I find any actual issues with it rather than me nitpicking ;)


Having worked in the process control industry I can state that the concept of direct/reverse acting controller can be hard for newcomers to grasp at first. An example might be a simple level controller for a vessel where there is a pump forcing liquid into a vessel and a PID controller reading the level and manipulating a control valve to keep the vessel level at a fixed level. Now depending on if the valve is on the inlet side to the vessel or on the outlet of the vessel will dictate with control action one requires, direct or reverse.

Also control valves come in direct and reverse acting versions and that can also require a flipping of the controller action. In the 'old days' it could be quite confusing to see one valve that would move to full open with 100% output and another valve that would move to fully closed with 100% controller output. Most control valves in industrial service have a 'fail safe' requirement defined by the process engineers for each specific control valve in the plant that would determine which way a pnumatic valve would move with a loss of all control power via internal spring force. Modern computer process control systems have kind of eleminated the confusion for the control operators such that it's always clear on the computer screen what the position of a control valve is regardless of it's control action. But of course the complexity is still where, just transfeered to the control system engineers to configure each controller properly.

Lefty
Title: Re: Arduino PID Library: Out of Beta
Post by: mmcp42 on Apr 18, 2011, 05:09 pm
just skimmer through the explanations
stunning bit of reading
have marked for in-depth study!

thanks