Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: davidbgtx on August 17, 2021, 09:47:22 AM
-
Do I get better performance if scaling the PV from my 4095 raw to eng. min and max in the PID instruction? I've always left the box unchecked in the past and only scaled the output, but maybe I'm missing something.
-
What PLC scan time are you needing to hit? Do you have a ton of PID loops?
Write your code so it makes sense, THEN decide to optimize if it is too slow.
It sounds like you are simply moving the raw WX analog into the PID .PV floating point member? Working in Engineering Units is much easier than raw analog (tuning, monitoring, etc.). The PID calculations are floating point, so even raw analog 0-4095 are converted to 0.0 to 4095.0 anyway, so I recommend scaling inside the PID instruction itself for the .PV. The PID .Output is always a float 0.0 to 100.0 (percentage), so it most likely needs to be scaled regardless. If you need to do any CLAMPing on the .Output or WY, or RAMPSOAKing on the .PV, or non-linear scaling on the PV (e.g. need to use MATH or LERP on raw analog to help "linearize" it), definitely do that OUTSIDE the PID instruction. The hit to PLC scan for all of these is minimal, unless you have 10, 20, 50 PID loops and your PLC scan time is getting too high, then you need to analyze your code a little first before addressing one specific area.
The point here is that where you think you want to optimize is usually not the "slowest" code.
If the PLC scan is too slow, you need to apply Pareto Analysis (80/20 rule - 80% of the PLC scan time is in 20% of the code). Scaling a floating point number in a SCALE vs. PID vs. MATH is minimal compared to a bunch of STRING operations or copying a ton of bits in a range (for example). Hence, spending a bunch of engineering time on something that is not that much of a hit to PLC scan time is not productive.
Here's a previous post about optimization that could be of help (if actually needed):
https://forum.hosteng.com/index.php?topic=3138.msg24233#msg24233
-
Thanks, I guess I should have said precision instead of performance
Scan time not an issue, only 2 PID loops
Yes just moving the WX value into the PV
So the algorithm isn't affected by the PV scaling inside the PID instruction?
Usually my Gain winds up being .Oxx or maybe .xx at the most, thought maybe the scaling was the reason, not an issue though
-
PID calculation is all floating point, so the algorithm itself is not affected by the PV always being whole floating point numbers.
And yes, the tuning constant values will DEFINITELY be affected by scale vs. non-scale.
FYI, this hidden feature might be useful, but any time the tuning constants are change from Designer's auto-tune or modifying the values from the PID View form, they get logged to a .CSV file below your Public Documents folder:
C:\Users\Public\Documents\Do-more\Designer2_8\Bin\PID.csv
It never gets cleared by the software, only appended to, so it should have logged any raw/scaled/whatever tuning constants since you installed 2.8 (2.7 has a similar file below its Bin folder below Public Documents, 2.6, etc.)
I've gone down "bunny trails" tuning loops and wanted to "revert" back. There are values logged within the Designer instance itself, but those are lost once you close Designer - this is the same data that is written to a file on your PC - they're there forever.
-
Thanks, good to know on the hidden feature