![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Jun 2010
Location: Ireland
Posts: 107
|
OT: Basic Python PID Simulator
A simple PID simulator for my first steps with Python, might come in handy for some demos
https://github.com/Destination2Unkno...nPID_Simulator GUI.JPG PID_Trends.JPG Last edited by destination unknown; December 22nd, 2021 at 12:44 PM. |
![]() |
![]() |
#2 |
Supporting Member
|
This is pretty neat! I expect to see Peter and drbitboy in here shortly to bicker about it, as is customary
![]() |
![]() |
![]() |
#3 |
Lifetime Supporting Member
|
That's pretty cool! Basically 3 minutes until the process went stable.
__________________
"Instant success teaches one nothing. Failure provides the tools and instructions one needs to succeed." ![]() |
![]() |
![]() |
#4 | |
Lifetime Supporting Member
|
Quote:
I think it's sweet. I wonder if OP would be interested in adding another control algorithm class cf. here. Most Linux environments would run that out of the box, once the pre-requisites are installed. I wonder how many Windows 10 folks know that can be run as well in their environment, with a half-hour or so of setup (WSL, PuTTY, X server, etc.; or maybe that can run native Windows?).
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; December 22nd, 2021 at 02:27 PM. |
|
![]() |
![]() |
#5 |
Member
|
What are the units for the open loop gain? What are the units for the controller gains? Normally FOPDT systems have integrator and differentiator time constants.
IAE works but ITAE works better when the PV takes step jumps. The reason is the accumulated error is huge at the beginning and there is nothing that can be done about it. Later one the fine adjustments are small compared to the initial error. ITAE doesn't accumulate a lot of error at the beginning and amplifies the error as time goes on. It is a simple change.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
![]() |
![]() |
#6 | ||
Member
![]() ![]() Join Date: Jun 2010
Location: Ireland
Posts: 107
|
Quote:
You can create a portable exe when Python is setup with pyinstaller... Quote:
Ki is in seconds and Kd is 1/seconds. IAE was just for simplicity, changed it to ITAE and added noise. Here's a quick compare of two tunes, noise is the same for both runs. No1.JPG No2.JPG |
||
![]() |
![]() |
#7 |
Lifetime Supporting Member
|
Suggstions for additional features in the PID class:
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#8 | |
Member
|
Quote:
Filtering the derivative is OK it it isn't necessary if you use the other filters. I don't like the idea of a input dead band. It is a kludge. I would add having a steady state PV. I all it PVss. When the control output goes to 0 the temperature doesn't go to 0. I would add SOPDT. I had all these done 5 years ago and no one seemed to care. Also, since then Python has made little changes so I must modify my old code to work with the new python. I don't like that. My odeint didn't work. I looked up the documentation to see what had changed only to find out that odeint is/has been superseded by another function ![]() I haven't touched python since I became retarded, I mean retired. This is 10 years old. I show how to derive the controller gains for a FOPDT system. Unfortunately it is written in Mathcad so Mathcad is necessary to play around with it. https://deltamotion.com/peter/Mathca...PDT%20I-PD.pdf My example shows how to implement the PVss. It shows how to calculate the controller parameters given the plant parameter and a desired time constant. Notice that my formulas will compensate for very long dead times, 10 min in my example, but there is a limit. If the dead times are too long then a Smith Predictor is required. No one cared years back.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon Last edited by Peter Nachtwey; December 23rd, 2021 at 03:47 PM. |
|
![]() |
![]() |
#9 |
Lifetime Supporting Member
![]() ![]() Join Date: Sep 2017
Location: Wi
Posts: 64
|
Does this site allow you to attach the mcdx file or is it available somewhere for download?
|
![]() |
![]() |
#10 |
Member
|
What version of Mathcad do you have? The mcdx files can be zipped. Very few people have Mathcad and I wouldn't recommend buying it now. I would stick to Python now.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
![]() |
![]() |
#11 |
Lifetime Supporting Member
|
Though my memory is far less than perfect, I don't remember recommending an input filter for PID control, though I see no problem with it when applied appropriately. I did suggest adding an input filter as a feature to the Python PID class posted in this thread.
The primary reason for an input filter would be to smooth the display of a PV to shut up ignorant people (i.e. managers) who confuse the presence of noise (Common Cause Variation) with a failure to adequately control the process. I find extraordinary the claim that the effect of adding an input filter on the closed loop system is significantly more severe than a filter on the PID output: both will slow down the system response to unfiltered PID output changes. The primary precondition for filtering the input would be the presence normal (Gaussian) random noise in the PV i.e. variation in measurements that is present even if the CV is not changing the the process is otherwise in steady state. I.e. "Common Cause Variation." A dead band on PV will do the roughly same thing as an input filter, or an output filter for that matter, when the process is at setpoint, Again, this assumes normality of the measurement noise. The purpose is to avoid "chasing noise" i.e. trying to control that which cannot be controlled; in fact, if the is noise in the PV measurement of a process to CV changes, then the PID will actually increase the noise in the PV relative to the uncontrolled system i.e. with the PID turned off. Filtering the output, or the input for that matter, will, I suspect, also increase the noise relative to the uncontrolled system, because some noise will always make it through the filter; that increase will be far less than in the unfiltered situation, of course. A properly-set dead band will ignore the noise once the process is both at setpoint and at steady-state. The suggestion, in another thread, to oversample the PV, to pick up the highs and lows in order to estimate a mean or median value (PV) being controlled, is conceptually similar to using a dead band.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#12 |
Member
![]() ![]() Join Date: Apr 2015
Location: home
Posts: 364
|
sir BRBB, please see Scadda post and have a stress relieving sherry or 3, although l am loving the challenge between someone that has made hopefully a lot of money out of his knowledge against someone that knows his stuff and helped put rockets in space, it really is fun. ah 2022 should be interesting.
|
![]() |
![]() |
#13 |
Member
![]() ![]() Join Date: Apr 2015
Location: home
Posts: 364
|
The beauty of a non perfect memory (which l think you have) is that you don't need it, surprise e surprise you just look back at the previous post. snigger snigger you hadn't thought of that had you, snigger, snigger.
|
![]() |
![]() |
#14 | |||||||||
Member
|
Quote:
Quote:
Quote:
Quote:
https://deltamotion.com/peter/Mathca...%20vs%20FC.pdf I don't implement an input filter. I added noise, dead time, and feedback resolution so the temperature feedback has only 0.1 degree resolution. For the floating control I do implement a dead band the right way. The dead band is not wide enough to remove all the noise but since the integrator has such a long time constant, the noise really makes no difference. Quote:
Quote:
Quote:
Quote:
Quote:
I, my company, does a lot of hydraulic servo control. Some applications require doing force control. The ripples from the pumps are evident in small systems as in the thread above. This is one reason why I insist on using accumulators. Accumulators are like a low pass filter in a way but actually the integrate, store, energy in the form of compress nitrogen. This allows one pump to store energy for many actuators whereas servo motor systems must size each drive for the peak power required for each axis.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
|||||||||
![]() |
![]() |
#15 |
Member
![]() ![]() Join Date: Apr 2015
Location: home
Posts: 364
|
Sorry for my indulgency, this is how some people learn (of course l include me in that statement)
P watch out he is pretty(understatement) smart, poke the computer at your possible peareal You do know D an't going to lay down. |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PID loop question | Tom W | LIVE PLC Questions And Answers | 7 | August 21st, 2012 09:28 AM |
PID temperature excel simulator | rlawson | LIVE PLC Questions And Answers | 36 | February 14th, 2011 05:47 AM |
Use a PID? | MarBa | LIVE PLC Questions And Answers | 4 | May 8th, 2003 09:31 PM |
how often should I trigger the PID? | Ron Beaufort | LIVE PLC Questions And Answers | 11 | February 22nd, 2003 11:57 AM |
Cascading | Sparky | LIVE PLC Questions And Answers | 24 | February 17th, 2003 12:33 PM |