Velocity Control PID in CompatLogix

...I dug up an old Mathcad worksheet I did 15 years ago...

I've had Mathcad since before it was in color running on a DOS machine back in the 80's.

I remember upgrading to V3.1 and the cancelled check (what are those?) was stamped by a bankruptcy court in Boston.

Oh, I really did like that program and wrote quite a few ME applications for a lot of custom equipment.

I think the last upgrade I got from MathSoft was like V11 or to maybe V14 before they sold to PTC.

The free version of PTC MathCad is actually really good. 30 days of all functions working 100% and you can convert the old *.mcd files you created from the past to run on the PTC stuff.

This type of software really does save a heck of a lot of time because you can run countless scenarios in short order.

Well, just don't tell your Mom you wrote a random application out of thin air that calculates the number of the beast by typing in someones name. My Mom made me promise that I destroyed that one. Playing with fire... think there is a floppy or tape that may still be in existence.
 
It isn't clear what the time scale is on your plots. The log error plot looks strange.



This is the way it should be done.
I am using the same open loop gain of 1 psi for 100% speed and a time constant of 10 seconds.


I wanted the closed loop time constant to be 1 second. This way the controller is doing some good by reducing the open loop time constant of 10 seconds to a closed loop time constant of 1 second.
My controller gain is MUCH higher than yours. That is due to having a faster response and also my controller gain is really a proportional gain whereas your gain is more of an integrator gain.
Notice that the PV takes 5 seconds or 5 time constant to get within 1% of the SP. Also, since the open loop gain is 1 PSI/100% the controller output is 10% when the set point is 0.1 psi and 20% when the set point is 0.2.
https://deltamotion.com/peter/Mathcad/Mathcad - t0p1 pi tc direct synthesis drbitboy.pdf
 
Well, just don't tell your Mom you wrote a random application out of thin air that calculates the number of the beast by typing in someones name. My Mom made me promise that I destroyed that one. Playing with fire... think there is a floppy or tape that may still be in existence.

Lol. When I was a kid, some wild eyed preacher handed me a pamphlet that claimed that the COMPUTER was the mark of the beast. It explained that if A=6, B=12, C=18 and so forth, that if you add up the values of the word COMPUTER the result is ... you guessed it ...

When I was in my teens I wrote a program that would take a text file and parse words, run the math (position in the alphabet times 6...add them up), and print out words that came out to that magic number. It was a good exercise in parsing and grouping words using ATASCII code. My little Atari 400 was not much of a source of text files to input so nothing much turned up except the word COMPUTER a couple of other meaningless phrases.

Later in life, I found that old Atari PC still working and sold it at a garage sale for twenty five bucks. It fired up and ran some game I had made as a teenager that was supposed to look like Phoenix. In the box was a cassette with that "satan.bas" program on it which gave me a chuckle. I was in Maintenance tech school at the time and had access to QuickBasic, so I wrote that same program again on a PC and figure out how to stuff all sorts of text files into it. This PC was also hosting a bunch of rockwell software. Guess what value you get when you plug in the words ALLEN BRADLEY?

Again, even with thousands of words from dozens of files, the only meaningful phrases my little satan program spit out were Allen Bradley and Computer...

Coincidence?
https://www.youtube.com/watch?v=7-iRf9AWoyE
 
Last edited:
It isn't clear what the time scale is on your plots. The log error plot looks strange.



This is the way it should be done.
...

Of course time scale is missing, and I am as carked (not a typo;)) by unlabeled axes as the next person, but the advancedhmi trend control doesn't have labels on the abscissa. it's around 10-20s per error zero crossing, so to get near the setpoint and stable takes of order a minute; there are at most 7m4s of data on those plots (1024 samples @ just under 1Hz- ), which I knew right away was not even close to what is possible with a proper PID controlling fan speed directly.

Of course it looks strange as a log error plot, because it's a log of absolute value of the error plot, just like it's labeled for anyone privy to what I thought was common mathematical notation. So it looks as it should, and perfectly normal to me.

Of course it should not be done this way. The point of what I have done is not to suggest it should be done this way, it is to
  • play with advancedhmi

  • see what it would be like if it had to be done this way.

Of course it would be better to do this with a PI controller using fan speed, not ramp, as the CV; if I-only controllers were practical, then someone would have noticed and they would be more common. But anyone with a modicum of ability, or at least access to the Google, can tune a level PID, which is essentially what this is.

Of course the gains are different:. the control schemes are completely different and you have no clue as to how I scaled the 0-100% CV to ramp slope.
 
Last edited:
Lol. When I was a kid, some wild eyed preacher handed me a pamphlet that claimed that the COMPUTER was the mark of the beast. It explained that if A=6, B=12, C=18 and so forth, that if you add up the values of the word COMPUTER the result is ... you guessed it ...

When I was in my teens I wrote a program that would take a text file and parse words, run the math (position in the alphabet times 6...add them up), and print out words that came out to that magic number. It was a good exercise in parsing and grouping words using ATASCII code. My little Atari 400 was not much of a source of text files to input so nothing much turned up except the word COMPUTER a couple of other meaningless phrases.

Later in life, I found that old Atari PC still working and sold it at a garage sale for twenty five bucks. It fired up and ran some game I had made as a teenager that was supposed to look like Phoenix. In the box was a cassette with that "satan.bas" program on it which gave me a chuckle. I was in Maintenance tech school at the time and had access to QuickBasic, so I wrote that same program again on a PC and figure out how to stuff all sorts of text files into it. This PC was also hosting a bunch of rockwell software. Guess what value you get when you plug in the words ALLEN BRADLEY?

Again, even with thousands of words from dozens of files, the only meaningful phrases my little satan program spit out were Allen Bradley and Computer...

Coincidence?
https://www.youtube.com/watch?v=7-iRf9AWoyE


Oh, I agree... try this... https://www.youtube.com/watch?v=uEtMwWchNkA


I love it where Alice says this is where we pay the whore...
 
Last edited:
Of course time scale is missing, and I am as carked (not a typo;)) by unlabeled axes as the next person, but the advancedhmi trend control doesn't have labels on the abscissa. it's around 10-20s per error zero crossing, so to get near the setpoint and stable takes of order a minute; there are at most 7m4s of data on those plots (1024 samples @ just under 1Hz- ), which I knew right away was not even close to what is possible with a proper PID controlling fan speed directly.
Excuses, excuses. You should have used Matplotlib.
Really, I think it is good.

If I were teaching a class I would go deeper. The leakage is is going to be proportional to the square root of the pressure drop and the fan flow would require more power
https://www.axair-fans.co.uk/news/applications/understanding-basic-fan-laws/

Since, for being a good sport look at this
https://deltamotion.com/peter/py/HydSim.zip
This is old and I have been side tracked but I will get back on it. I have been learning tkinter.
 
Last edited:
You should have used Matplotlib.






The Python script uses Matplotlib; I had more control there and those plots are reasonably labeled:


dsdt_pressure_control.png


It's interesting that gain only affects the time of the first setpoint crossing; the envelope containing the extrema is the same for all gains' cases once they make that first crossing.



The leakage is is going to be proportional to the square root of the pressure drop


Bzzt! Thanks for playing, but no, that is wrong.



IIRC both my Python script and my AdvancedHMI code do that i.e.


  • P = K1 leakageFlow**2

But in this case:


  1. if it's leakage, then more leakage = bigger and more expensive fan, plus higher operating costs, so leakage will be minimized in the enclosure, so any leakage will involve small passages (passage size, D, is small)
  2. if it's an enclosure, the pressure difference will be low, so the speed of air through the passages will be slow (V is small)
  3. Reynolds number for flow: Re = D V / ν

  • D is small
  • V is small
  • ν is large; kv is kinematic viscosity of air, which is ~15 times that for water
  • So Re will be small, which means laminar flow, which means flowrate is proportional to ΔP, and will not be proportional to sqrt(ΔP)
    • it would be the latter if Re were large and the flow were turbulent. But it's not.
 
The Python script uses Matplotlib; I had more control there and those plots are reasonably labeled:
Yes, matplotlib is very good for quick plots.


It's interesting that gain only affects the time of the first setpoint crossing; the envelope containing the extrema is the same for all gains' cases once they make that first crossing.

That is because there are two closed loop poles. There is a value of Kc that will result in a critically damped response with no overshoot. If Kc is increased beyond that point the response will be under damped with overshoot. Increasing Kc, the integrator gain, only results in moving the imaginary part of complex poles poles away from the the negative real axis. The real part of the complex poles does not become more negative as you increase Kc so it does no good to increase Kc. It doesn't change the decay term. I have mathematical proof.


Bzzt! Thanks for playing, but no, that is wrong.

IIRC both my Python script and my AdvancedHMI code do that i.e.


  • P = K1 leakageFlow**2

But in this case:


  1. if it's leakage, then more leakage = bigger and more expensive fan, plus higher operating costs, so leakage will be minimized in the enclosure, so any leakage will involve small passages (passage size, D, is small)
  2. if it's an enclosure, the pressure difference will be low, so the speed of air through the passages will be slow (V is small)
  3. Reynolds number for flow: Re = D V / ν

  • D is small
  • V is small
  • ν is large; kv is kinematic viscosity of air, which is ~15 times that for water
  • So Re will be small, which means laminar flow, which means flowrate is proportional to ΔP, and will not be proportional to sqrt(ΔP)
    • it would be the latter if Re were large and the flow were turbulent. But it's not.
You are assuming laminar leakage. It could or could not be. The only way to know is to do a system identification to see which model fits the best.


Extra credit, What value of the integrator, your Kc, results in a critically damped response with no overshoot?
 
Last edited:
Yes, we know that but how do you achieve that by varying Kc?

What value of your Kc results in a critically damped response?
I would have thought you would have tried trial and error. One can get a close approximation from your matplotlib plot.



Using your example the decay term is exp(-t/(2*Tc))
Basically your control is making the closed loop time constant twice as long, 20 secs, whereas I reduced it by a factor of 10 to 1 second.
 

Similar Topics

The is the first system that uses complex or imaginary poles. Complex poles oscillate. RLC circuits, masses on springs, pendulums, masses on...
Replies
19
Views
16,980
So you thought you would take the weekend off! No way. The link below is saying download me! Give me a try! The link is to a spreadsheet that...
Replies
15
Views
23,424
A query for the motion control experts: I have an app where I measure the position (encoder ∝ K * angle) of a rotating device, and use that along...
Replies
15
Views
3,686
A bit of background here: We use an incremental encoder with a counting module in our PLC configuration. Using dual phase / quadrature counting...
Replies
26
Views
8,771
I have a 1746-QV. I just replaced one that had gone bad. I am looking for an electrical schematic for it so I can attempt to repair it just for...
Replies
0
Views
1,601
Back
Top Bottom