Writing my own PID

Here we are. It looks very much like all they've done is move the Kp to the outside of the parenthesis.

For the integral error term, the coefficient is 1/(60*Ti), not simply kI. In dependent PID, a larger integral tuning parameter (called reset in dependent form) actually results in integral affecting the final change in controlled output less. It is a common mistake I have seen before and I myself have made.

The reason the coefficient in front of the accumulated error is (1/60*Ti), also sometimes simply represented as (1/Ti), and not simply kI has to do with how the PID equation is derived. The derivation isn't too bad but it uses transfer functions and an inverse Laplace transform so it does rely on some fields of theory that aren't typically taught outside of a 4 year degree program. The math ends up with the tuning parameter for integral being in the denominator of the coefficient and engineers, in all their wisdom, didn't bother to move the tuning parameter to the numerator.

Another reason the integral tuning parameter is in the denominator of the accumulated error coefficient is manually calculating the theoretical ideal tuning parameters gives you the value of denominator of the integral term coefficient. It's trivial to convert coefficient forms, but it is important to know (even though I have manually calculated tuning parameters all of once in my professional life).

2 unrelated things - sorry for making you re-explain why convincing your customer FBD isn't worth it. That customer definitely seems like one worth keeping happy! Lastly, I highly recommend using the velocity form of the PID equation instead of the position form. The velocity form is the one that calculates the change in your controlled output, where the position form is the one that calculates the controlled output directly. Velocity tends to behave better overall and will transition smoothly when the PID loop is taken into and out of manual control as well as when the setpoint is updated.

One last thing - do any of your customers even use dependent forms of the PID equation? I have worked with only one customer who uses it (and they hate it, but they decided it was too late to change). Everyone else uses the much more intuitive independent form.
 
Sorry, forgot to attach image. Here, in the dependent form of the PID equation, you can see the integral tuning parameter in the denominator of the coefficient.

2021-10-29 10_52_45-Writing my own PID - Page 3 - PLCS.net - Interactive Q & A.png
 
BTW, what do poles and zeros do? I really don't expect a response.

Not sure if just quizzing to see if the people giving suggestions have the background to do so or if you are genuinely curious.

When a system has an output you want to control based on an input (be it feedback or feed-forward), you have a series of transfer functions (equations in the time domain) that represent physical phenomena within the system. You have a transfer function that represents the duration it takes for the controlled element (valve, pump, etc.) to reach the controlled variable's value, you have a transfer function for the time it takes for this controlled output to actually affect the system, you have a transfer function for the time it takes for the change in the system to be measured, etc.

Collectively these functions are a mess to work with, so you convert to the Laplace domain with a Laplace transfer (converting to Laplace domain is a bit of a misnomer, you often start in the Laplace domain). These mess of time-domain equations generally take the form in the Laplace domain of H=(N/D) were N and D are typically first or second order polynomials and all are a function of independent variable "s" (analogous to time in the time domain). The roots are the values of s where N(s)=0 and the poles are the values of s where D(s)=0.

You tinker with where the zeros and poles lie in the complex plane to achieve stability (get the poles to the real quadrants of the complex plane to do this, generally) and to determine how the system will reach steady state and what steady state looks like. It has been a while since I did this by hand so I apologize for glossing over this more than I would prefer.

I hope this is something like what you are looking for.
 
1. Personaly, I prefer my PID gains to be in Engineering Units/CV%. Just gotta make sure the Americans don't come and change your units between C and F (4°F / CV% != -15°C / CV%). But I find Engineering Units change less frequently than AI Input range. If one minute you have a transmitter ranged 0-100°C, someone will come along and re-range it 20°C to 50°C (better resolution? new sensor? Continuous improvement? who knows!). Often this person doesn't know that they must alter all or some of the gains.
This is a great point that I hadn't considered. You're absolutely right, I think I'll change that.

4. I would hate to be the only one who didn't say "If PIDE has the features you need, you should wrap it in a ladder AOI."
Fine, fine, I mean you all have a point :confused: but this wouldn't be the first time I've decided that I can write a function better than Rockwell and done it regardless of what anyone else says, and I doubt it'll be the last. Maybe I'm just too self-confident for my own good :whistle:
 
For the integral error term, the coefficient is 1/(60*Ti), not simply kI. In dependent PID, a larger integral tuning parameter (called reset in dependent form) actually results in integral affecting the final change in controlled output less. It is a common mistake I have seen before and I myself have made.

The reason the coefficient in front of the accumulated error is (1/60*Ti), also sometimes simply represented as (1/Ti), and not simply kI has to do with how the PID equation is derived. The derivation isn't too bad but it uses transfer functions and an inverse Laplace transform so it does rely on some fields of theory that aren't typically taught outside of a 4 year degree program. The math ends up with the tuning parameter for integral being in the denominator of the coefficient and engineers, in all their wisdom, didn't bother to move the tuning parameter to the numerator.

Another reason the integral tuning parameter is in the denominator of the accumulated error coefficient is manually calculating the theoretical ideal tuning parameters gives you the value of denominator of the integral term coefficient. It's trivial to convert coefficient forms, but it is important to know (even though I have manually calculated tuning parameters all of once in my professional life).
Thanks for the detailed explanation! As you can probably guess, I don't quite follow all of it, but I think I have a basic grasp of what you're getting at.

2 unrelated things - sorry for making you re-explain why convincing your customer FBD isn't worth it. That customer definitely seems like one worth keeping happy!
No worries! It's a frequent discussion on this forum (ST vs LAD vs FB and the various factors) and I have quite a strong opinion on it because (as I described) it's been a big factor in the trajectory of my career, and my enjoyment of it. I try not to get too caught up in those discussions but sometimes I can't help myself!

Lastly, I highly recommend using the velocity form of the PID equation instead of the position form. The velocity form is the one that calculates the change in your controlled output, where the position form is the one that calculates the controlled output directly. Velocity tends to behave better overall and will transition smoothly when the PID loop is taken into and out of manual control as well as when the setpoint is updated.
Interesting! If it's something you can explain without going back into the high-level math that's a little over my head, why is this? Do you think that the "bumpless transfer" measures I described in post #31 would mitigate this?


One last thing - do any of your customers even use dependent forms of the PID equation? I have worked with only one customer who uses it (and they hate it, but they decided it was too late to change). Everyone else uses the much more intuitive independent form.
Well, one of my customers does, but they have their own program structures so wouldn't be using my AOI's regardless. They don't get great results with it, in my opinion.

I much prefer independent gains - maybe if it's as uncommon as you suggest I'll just ditch the dependent gains function and simplify things.

Thanks a lot for the detailed response and the interesting considerations. I really appreciate it! 🍻
 
Interesting! If it's something you can explain without going back into the high-level math that's a little over my head, why is this? Do you think that the "bumpless transfer" measures I described in post #31 would mitigate this?
One nice thing about the velocity form is that you can change gains on the fly without suddenly affecting the CV. This is useful for some processes, such as heating PIDs where the load suddenly changes, like the flow rate halves and you need the gains to halve to keep your tune correct.
 
Use the pide, customer can get over it. There's a reason why everyone uses the pide over pid.

I just put the PIDE block, and nothing else in that FBD sheet.
I have all the ladder for hooks in and out of the PIDE FB.

I use the PAx PIDE.

"D is for danger" - Dr. Bob.

I also found out that the Integral is different between the PIDE and PAx PIDE...factor of 10 I believe.
 
Last edited:

Similar Topics

I have 3 parameters for a product: Diameter Lengte Hoek (corner) all reals... I need some batching system with a batchlist. Something...
Replies
8
Views
2,743
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
5
Views
262
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
101
Hello All: I have a Windows 10 PC running a FTView ME Station 10.00. I have a .mer file version 6.00. It has been running well on it for a long...
Replies
1
Views
173
My R55 Ingersollrand is tripping on motor overload and im falling to see the trip history it is writing Acquarring texts
Replies
0
Views
137
Back
Top Bottom