Looking for tips and tricks for the PID library

Hello community,

Currently I am working on a heating plate with four 200W cartridge heaters, that are supplied by an 24V and up to 30A DC powersupply. Maximum heating point will be 300°C (572°F).

The linear controlling of the heating is working properly (so for example give 15A until 100°C is reached, than turn the current off, ofcourse I have than an overshoot of 10-15°C, not what i want).

Now i intend to controll it with the PID library to steer it to the needed tempature without any overshoot as fast as possible an keep it at this point as exact as possible.

Now i wanted to ask if anybody has any experience or tips how I can calculate the Kd, Ki and Kp and how I could start with some experiments? Or should I use the PID autotune library instead? Any experiences with the Proportion on Measurement method and if it would suit my project?

The main problem is that it needs way to long to cool down, so that I have only a limited amount of test that I can drive.

I would be happy if any of you could support me with their knowledge :slight_smile:

Best regards,
Wosche

PID should of cource work after trimming is complete.
What about a stair regulation controlled by the current temperature? The closer to target temperature the less Amps You send.

how I can calculate the Kd, Ki and Kp and how I could start with some experiments?

Google "PID tuning" for tutorials.

i was thinking about a stair controlling to with like an 100% value (so 70% of the way- 25Amps, 15% of the way 12Amps etc) but i think the PID would be mouch nicer especially in holding the temperature.

I know about to it like the Ziegler-Nichols- Methode, but i wanted to know if any of you has experiences with it and can answer some questions about it

PID has most people thoroughly confused.
the thing that is being controlled is critical. it could be a damper, a butterfly valve, a needle valve, or as you have, a heater.

speed of response. how long goes it take to light the room after you turn on a switch ?
how long does it take for the noise to reach you after your turn on the alarm ?
how long does it take for the noise to reach you in air ? in water ?
how long does it take for the room to get hot after you turn on the heater ?

first answer is the speed of light
second is the speed of sound
last could be hours.

maybe that might give you some insight into why PID is baffling to most.

P I and D are only used for some things. some times it is P and I only,
some times it is P I and I/D or inverse derivative.

the PROCESS dictates the functions.

for heating you do not need D, so you can put that aside

the tutorials for setting P and I are pretty simple, you set P so it is dead, then tighten it up until it goes unstable.
there are your extremes. set in the middle then start to tighten up your I.
you might need to tweek your P one way or the other, but it should only take a few trials to get is close enough.

as for your process, your heater adds joules. your process consumes them. if you add 100 , but the process needs 110, you will never get there. if you add 100, but your process overshoots with 20, you are putting in too much.
This is the other part as to why so many people are baffled. You need to get the parts of the process correct and do not expect that you can fix things in software.

as for the steps, you could play with 3 steps, 75%, 90% and 99%
run full power till you get to 75%, then run at 50% power to get to 90% of the way there, then put in 10% power to see how long it takes to get to 99% of the goal.

this should be done before you try to add PID so you have a clue if you have enough power or too much

Just a note / question: isn't the D part the one that reduces the overshoot?

@OP are you confusing the overshoot with the steady state error?

If I remember correctly it went something like this:

P controller will have a steady error or if you shut off then you will probably end up with some kind of a zig zag function.

I will eliminate the ss error but introduce an overshoot.

D will eliminate/reduce the overshoot. So if your requirement is no ss error and no overshoot you will probably need the PID.

An excerpt from Wikipedia on Nichols Ziegler

It yields an aggressive gain and overshoot[2] – some applications wish to instead minimize or eliminate overshoot, and for these this method is inappropriate

So you can't use that either.

Without further research on my side I would look into Matlab (commercial product, probably you won't have access to that) or Octave (free) or python and look at the step response of a PID controller for different parameters. Preferably you can derive a transfer function for your problem and then look at the closed loop function for your problem with the PID controller and take it from there. You should find information on thumb rules of tuning PID on the web, but I would advise you time it by hand. Isn't that where the fun is anyway? :wink:

dave-in-nj:
P I and D are only used for some things. some times it is P and I only,
some times it is P I and I/D or inverse derivative.

the PROCESS dictates the functions.

It seems to me that the effort to make a PID library that works for every situation has just complicated and obscured what is a relatively simple system.

The essence of PID is 3 equations

iTerm += error * iFraction
pTerm = error * pFraction
dTerm = (error - prevError) * dFraction

output = iTerm + pTerm + dTerm

and the fractions determine the extent to which that part is taken into account. Start with fractions of about 25% and change the values in coarse steps until you get a sense of the responsiveness.

And, as @dave-in-nj has said, just omit the dTerm for a heating system.

...R

Yep. PID is proportional plus integral plus derivative control. Often confusing due to most misleading general descriptions of it.... including the one I wrote above. It is really proportional plus proportional integral plus proportional derivative control. And the way it is commonly used among a lot of is the blind trial and error method...... which involves having a system that we haven't characterised or hard to characterise.... then we fiddle with the three multiplying factors kp and ki and kd until the closed loop system approaches the desired behaviour... hopefully.

You can trim the kP, kI and kD or You can trim the factors in the step modell...… The beginning steps mostly cover the kP and the last used steps the kI….
PID Control is needed when fast reching of the target is needed. If the process is allowed use some more time the step method is easier to understand and quite handy.

Hey thanks for your responses!

As I understood compensatets the D term the overshoot the I term introduces?

So you are advicing that I run an PI. With the PIDLibrary I would start with lets say kP= 3, kI=1, kD=0.
Then I turn up the kP until i get the pitch I want. After this I turn up (or turn down) kI until I get my set point with no (or nearly no) overshoot?

What does the controller when the tempature is sinking again? does he heat it up with a small current until setpoint is reached again?

Does the calculated output of the PID reach negative values too? Just asking because then I have to "catch" them so the power supply doesn't get inappropiate values.

what kind of values can the output get? If I want to have a high temperature, so the starting and end values are far apart, does the output reach maximum in the first seconds an sets it down after this?

Best regards, and thanks for your help and advice!
Wosche

Wosche:
What does the controller when the tempature is sinking again? does he heat it up with a small current until setpoint is reached again?

Does the calculated output of the PID reach negative values too? Just asking because then I have to "catch" them so the power supply doesn't get inappropiate values.

what kind of values can the output get? If I want to have a high temperature, so the starting and end values are far apart, does the output reach maximum in the first seconds an sets it down after this?

IMHO if you have all those questions (which are quite reasonable) it would make more sense to write your own code and not bother with the PID library.

...R

Robin2:
IMHO if you have all those questions (which are quite reasonable) it would make more sense to write your own code and not bother with the PID library.

...R

The reason that I ask these questions here, instead of just trying, is that i can make tests again on Monday, but it would be easier if I know more today :slight_smile:

I can imagine what the PID will do. Especially when I set the Output limits to ~350 to 4000 (approximatly what the DAC (MCP4725) needs to controll the equivalent of the output current of the power supply with the 0-5V from the DAC)
So the PID won't fall under the 350 right? or would he shut down completly to 0 (what I don't think it will do)

And i personally want to do it with the PID library, because it would bring me so much if I (nearly) completely understand the concept, the tuning and after this the consequences on a real application

So I hope you will help me further :slight_smile:

Kind regards,
Wosche

Wosche:
And i personally want to do it with the PID library, because it would bring me so much if I (nearly) completely understand the concept, the tuning and after this the consequences on a real application

So I hope you will help me further :slight_smile:

I am not suggesting that you abandon the PID concept.

I can't help you further with the PID library because I asked all the same questions that you are asking and never got any satisfactory explanation so I gave up and just wrote my own PID code - the essence of which is in Reply #6, above.

...R

Robin2:
I am not suggesting that you abandon the PID concept.

I can't help you further with the PID library because I asked all the same questions that you are asking and never got any satisfactory explanation so I gave up and just wrote my own PID code - the essence of which is in Reply #6, above.

...R

I know that PID can give someone a hard time. Sadly the descriptions of the library aren't that precise as I would wish they were. If its possible I would extend the desprictions a bit if i figure out some questions of mine? :slight_smile:

Are there any experiences with possible starting parameters of the kP, kI, kD or in which range of values should they be? Or should I just try, export the values into excel and plot them to figure it out?

And one more question. I would test is up to a setpoint of 100°C or 130°C or so. Can there be any big differences of the PID when i set it up for these tempertures and try it with 250°C or 300°C after this?

Kind regards,
Wosche

But in general, if I use the PID autotune, I use it in addition of the PID library and the PID autotune should (theoretically) give me examples of kp, ki, kd?
And then I take these constants and put them in the PID library and adjust it ??

Did I get this right or did I understand something completely wrong?

Best regards,
Wosche