You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old July 11th, 2022, 04:43 AM   #1
Matjuhnl
Member
Netherlands

Matjuhnl is offline
 
Join Date: Jun 2020
Location: Somewhere
Posts: 23
PID Tuning tool

A few months ago, I started to look into PID controllers and the tuning of first order processes. This has, partly thanks to you, resulted in a PI(D) tuner. I am very happy with it.

However, I still have one challenge. And that is detecting a stable process value. At this moment, I do 4*ProcessTime. However, this is not very accurate. Do you have better suggestions?

If you have a model of a first order process, I will be happy to tune it. Challenge me!
  Reply With Quote
Old July 11th, 2022, 07:16 AM   #2
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
This will be fun.
Try this. It is a FOPDT or first order plus dead time temperature system
Kp*exp(-theta*s)/(tau*s+1)
Kp is the plant gain with units of 1% output per degree C of temperature error
tau is the plant time constant. Tau is 1 minute.
theta is the plant dead time. theta is 10 minutes
For simulation purposes, ambient temperature is 25 degrees C
The PV or actual temperature starts at ambient or 25 degrees C then ramps up top 90 degrees C.

This is your first test. However, I all my life I have NEVER seen a model of anything so I have had to compute the model using system identification. This is where the real challenge lies. Once you have the model, computing the controller parameters is easy. There are lots of posted solutions on the internet.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 12th, 2022, 04:25 AM   #3
Matjuhnl
Member
Netherlands

Matjuhnl is offline
 
Join Date: Jun 2020
Location: Somewhere
Posts: 23
I have thrown your example into my tuner.

Model:
Process gain: 1.0
Process time: 60s
Process delay: 600s

PID settings (4-5% overshoot):
Kp: 0.135
Ti: 149s.
Td: 0s.

In addition, I would always use a Smith Predictor. My experience is that a more aggressive tuning is possible.

Identifying a system is no longer a challenge for me. I do this by means of a step response. I have created a function for this in the PLC.
  Reply With Quote
Old July 12th, 2022, 02:19 PM   #4
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
Very good!This was a trick problem due to the long dead time.I include 3 plots of the response in a .docx file.
This first is yours using your tuning parameters.
Did you use a Smith Predictor?

The second plot uses IMC tuning.
The gains are way too high using the same closed loop time constant that I used.

The third uses my gains. I am not using a Smith Predictor. I used a Pade approximant to do simulate the dead time. I also used a closed loop time constant of 6 minutes. 5 minutes would work to and be a little tighter.

My gains are
Kc=0.09090909 %output/degree of error.
Ti=1.8333 minutes
Td=-8.636 minutes, Yet the derivative term is negative.

If I use a closed loop time constant of 5 minutes then the closed loop gains are
Kc=0.2 %output/degree of error
Ti=3.33333 minutes
Td=-2.5 minutes

Hopefully my .docx file shows.
Attached Files
File Type: docx PLCs.net.docx (41.9 KB, 85 views)
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 12th, 2022, 04:25 PM   #5
destination unknown
Member
Ireland

destination unknown is offline
 
Join Date: Jun 2010
Location: Ireland
Posts: 110
Here's another simulator:

https://github.com/Destination2Unkno...nPID_Simulator

It uses independent gains, to convert:
Kp = Kc
Ki = Kp/Ti ----Ti*60 if in minutes
Kd = Kp*Td ----Td*60 if in minutes
  Reply With Quote
Old July 12th, 2022, 06:15 PM   #6
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
Quote:
Originally Posted by destination unknown View Post
Here's another simulator:

https://github.com/Destination2Unkno...nPID_Simulator

It uses independent gains, to convert:
Kp = Kc
Ki = Kp/Ti ----Ti*60 if in minutes
Kd = Kp*Td ----Td*60 if in minutes
Why don't you show us how it works given the values I provided above.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 12th, 2022, 06:16 PM   #7
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
What about SOPDT, second order plus dead time, systems?
What if the system is under damped like controlling the position of a mass on a spring?
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 13th, 2022, 04:43 AM   #8
Matjuhnl
Member
Netherlands

Matjuhnl is offline
 
Join Date: Jun 2020
Location: Somewhere
Posts: 23
I do not have good experiences with calculating the values. However, I do have good experiences with simulating the values.

Is it possible to make an .exe of the PID simulator from Github and share it here? For many people, Python is not the answer.

In addition, I have alternative settings for Peter's problem here.

PID settings (2-3% overshoot):
Kp: 0.239
Ti: 220s.
Td: 0s.
  Reply With Quote
Old July 13th, 2022, 09:47 AM   #9
destination unknown
Member
Ireland

destination unknown is offline
 
Join Date: Jun 2010
Location: Ireland
Posts: 110
PI:

PI.PNG

PID:

PID.PNG

I did a SOPDT simulator but the FOPDT is easier for demonstration purposes.
I'm sure you have plenty of your own anyway
  Reply With Quote
Old July 13th, 2022, 10:06 AM   #10
destination unknown
Member
Ireland

destination unknown is offline
 
Join Date: Jun 2010
Location: Ireland
Posts: 110
Quote:
Originally Posted by Matjuhnl View Post
I do not have good experiences with calculating the values. However, I do have good experiences with simulating the values.

Is it possible to make an .exe of the PID simulator from Github and share it here? For many people, Python is not the answer.

In addition, I have alternative settings for Peter's problem here.

PID settings (2-3% overshoot):
Kp: 0.239
Ti: 220s.
Td: 0s.
https://github.com/Destination2Unkno...ases/tag/v1.00

Or you can create your own exe using pyinstaller
  Reply With Quote
Old July 13th, 2022, 05:12 PM   #11
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
Quote:
Originally Posted by Matjuhnl View Post
I do not have good experiences with calculating the values. However, I do have good experiences with simulating the values.
Does that mean you can simulate given the model but not if you don't know the model.

Quote:
Is it possible to make an .exe of the PID simulator from Github and share it here? For many people, Python is not the answer.
Yes! I have program that I use to size hydraulic systems. I wrote it in python and used a program called pyinstaller to make a .exe file from the .py files.
https://pypi.org/project/pyinstaller/

Quote:
In addition, I have alternative settings for Peter's problem here.
PID settings (2-3% overshoot):
Kp: 0.239
Ti: 220s.
Td: 0s.
Are you using trial and error?
Where are your plots?


There are formulas for calculating the controller parameters I was a mean and nasty person and provided an example with a long, too long, dead time for most tuning methods you see on the internet. Obviously the IMC gains found on the controlguru website won't work.

Did you notice my negative derivative time constant? It works but you need to think outside the box.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon

Last edited by Peter Nachtwey; July 13th, 2022 at 05:15 PM.
  Reply With Quote
Old July 13th, 2022, 05:27 PM   #12
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
Is that the same problem? That I presented above?


Quote:
Originally Posted by destination unknown View Post
I did a SOPDT simulator but the FOPDT is easier for demonstration purposes.
I'm sure you have plenty of your own anyway
Yes, I have files from 2005. In 2005 Ron Beaufort used what he called "hotrods" which were wood burning irons with a temperature sensor on the tip. The students had to use a PLC/5 to control the temperature at the tip of the iron. Ron was nice enough to collect the data from a test and send it too me. I used this data to compute a model of his "hotrod" and determined the gains for his PLC/5 PID.


I have this done for both FOPDT and SOPDT. The dead time is reasonable in Ron's.


Also, in the download/misc section there is a file called hotrod.zip. At that time I was using a SLC500 and ML1500 to test with.



Lets see what you come up with.
Attached Files
File Type: zip Hotrod.zip (3.6 KB, 5 views)
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 13th, 2022, 06:20 PM   #13
Matjuhnl
Member
Netherlands

Matjuhnl is offline
 
Join Date: Jun 2020
Location: Somewhere
Posts: 23
I can also tune without a model. But practice has shown that this is not the most ideal method. This is because tuning is time-consuming and (sometimes) expensive (especially with slow processes). Just doing a step response and getting a model out of it is much more interesting.

In the attachment, I have done a plot. This plot has been accelerated 200 times. I can enter this speed myself.

The negative D-factor is certainly interesting! I am going to take a look at this.

By the way. The process tuner is completely made in TIA Portal, including visualisation and plot.
Attached Images
File Type: png Plot.png (9.5 KB, 564 views)
  Reply With Quote
Old July 14th, 2022, 02:06 AM   #14
Peter Nachtwey
Member
St Kitts and Nevis

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: No income tax, no capital gains tax. Freedom!
Posts: 8,306
Quote:
Originally Posted by Matjuhnl View Post
I can also tune without a model. But practice has shown that this is not the most ideal method. This is because tuning is time-consuming and (sometimes) expensive (especially with slow processes). Just doing a step response and getting a model out of it is much more interesting.
+1000

Quote:
In the attachment, I have done a plot. This plot has been accelerated 200 times. I can enter this speed myself.
This isn't clear too me.

Quote:
The negative D-factor is certainly interesting! I am going to take a look at this.
Try my controller parameters in you simulator just like I tried your controller parameters in my simulator.

This is my results to the "hotrod.txt" data. I am computing a SOPDT model. The process variable is the actual recorded data. The estimated value is is generated by my model from the system identification.
If the estimated and process values are close to the same then my model is good.

final_simplex: (array([[ 3.75738871, 0.68459748, 2.8492896 , 77.84212178, 0.35403269],
[ 3.75738895, 0.68459766, 2.84928924, 77.8420959 , 0.35403266],
[ 3.75738776, 0.68459769, 2.84928958, 77.84219321, 0.35403292],
[ 3.75738878, 0.6845977 , 2.84929003, 77.84211757, 0.35403232],
[ 3.75738864, 0.68459843, 2.84928914, 77.84212303, 0.35403212],
[ 3.75738929, 0.68459787, 2.84928892, 77.84207222, 0.35403256]]), array([250.31411453, 250.31411796, 250.31413401, 250.31413445,
250.31413467, 250.31421152]))
fun: 250.31411452756277
message: 'Optimization terminated successfully.'
nfev: 204
nit: 105
status: 0
success: True
x: array([ 3.75738871, 0.68459748, 2.8492896 , 77.84212178, 0.35403269])
RMS error = 0.436
The open loop gain = 3.757 PV/%CO
Time constant 0 = 0.685 minutes
Time constant 1 = 2.849 minutes
Ambient PV = 77.842 in PV units
Dead time = 0.354
Time units are the same as provided in input file
The closed loop time constant = 0.285
The controller gain = 1.472 %CO/unit of error
The integrator time constant = 3.534 minutes
The derivative time constant = 0.552 minutes
Attached Images
File Type: png temp.png (43.7 KB, 558 views)
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon

Last edited by Peter Nachtwey; July 14th, 2022 at 02:21 AM.
  Reply With Quote
Old July 14th, 2022, 03:40 AM   #15
Matjuhnl
Member
Netherlands

Matjuhnl is offline
 
Join Date: Jun 2020
Location: Somewhere
Posts: 23
I have processed your data:

Model:
Process gain: 3.7
Process time: 210s
Process delay: 37s

PID settings (4-5% overshoot):
Kp: 0.736
Ti: 202s.
Td: 0s.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Slow Acting Long Time Interval PID Tuning GrizzlyC LIVE PLC Questions And Answers 141 March 30th, 2021 07:04 AM
PID tuning methods OysterMan LIVE PLC Questions And Answers 4 March 21st, 2021 11:59 AM
Micrologix 1400 Timed Proportioned Output PID Tuning Paul Begley LIVE PLC Questions And Answers 3 January 13th, 2014 05:26 PM
PID Tuning and Process Modeling kdcui LIVE PLC Questions And Answers 14 October 15th, 2009 02:27 PM
PLC PID Auto Tuning Problem monet LIVE PLC Questions And Answers 6 May 26th, 2009 10:50 AM


All times are GMT -4. The time now is 08:32 AM.


.