Stormworks: Build and Rescue

Stormworks: Build and Rescue

117 ratings
Advanced tuning of PID's
By Timothy
This guide will cover advanced tuning of PID's, IE Ziegler & Nichols' methods, cascade tuning, WAG/SWAG method, and etc.
I'll be updating this when I have some free time on my hands.
2
4
   
Award
Favorite
Favorited
Unfavorite
Introduction
I'm going to assume you know the basics behind each part of the three letters P, I, and D.

Please check out this guide if you don't: https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=1366955561

This GIF might help newcomers to PID's


Abbreviations used in this guide:
  • LT - Level transmitter
  • VT - Velocity transmitter
  • TIC / PIC - Temperature Indicator Controller, Pressure Indicator Controller, etc.
  • PT - Pressure transmitter
  • PV - Proccess value (Current value)
  • SP - Setpoint (target value)



If you have any questions hit me up on discord Timothy#6693
WAG / SWAG methods
The most common way to get a basic tune of a pid loop is use the WAG / SWAG method:
I only recommend these methods if it's for a menial task or other methods are too coplex for the application.

WAG - Wildass Guess

This proccess is what I assume most people use in Stormworks to get their PID's where they want them more or less.
It involves guessing values for P, I, and D, then increasing/decreasing each one until the proccess behaves the way you want.
This method is very time consuming and the end PID values might not be optimal for the application they are used.


SWAG - Scientific Wildass Guess

This method is very similar to the first one, the scientific part comes from prior experience with other PID loops, allowing you a more accurate guess for the starting values.
This one is less time consuming, but still suffers from the issues WAG method has.
Critically dampened
Quick & Dirty
This is a quick and dirty tuning method for fast acting proccesses like boat rolling and other things that require a quick correction value.

As with all these, start with all PID parameters at 0!

Increase P using WAG method until you get a critical oscillation (Same step as Ziegler & Nichols' method).
Increase D until oscillation stops.

Congratulations It's now critically dampened.

You can continue doing these two steps until increment of D doesn't stop the oscillation.

End notes Quick & Dirty
This method is more time consuming than Z&N's method, however I recommend doing this and using Z&M method to get a starting point for your D parameter, then tuning from there.
Ziegler & Nichols First method
Introduction
This method involves finding a critical P value that makes the proccess oscillate at a constant max/minimum PV.

This method usually results in a 1/4 swing decay of the PV.

This is done by starting with I and D at 0 and increasing P until the PV starts swinging at a constant rate, for example every second it hits +13PV and -11PV.

Once you have your critical P value take out your stopwatch/phone/etc and note the time between each top or bottom value, the time it takes for your proccess to go from +1 to -1 for example.

With these two values we can calculate for the Integral and Derivative parameters.

Actual math
I will use Pcrit as 2.5 and T0 as 5.49seconds for these examples:
We can calculate 3 different tunes with these values, a P regulator, a PI regulator, and a PID regulator.
For most uses I'd recommend a PID regulator.

I usually decrease these values by 30% if I don't require a aggressive tune.

P regulator:
Take your Pcrit and multiply by 0.5, getting you 1.25 as your only paramter.
Don't use this one.
Resulting in:
P=1.25

PI regulator
This one uses Pcrit and T0 and is used for slow proccesses such as keeping diesel fuel tanks all at the same values.

P= Pcrit*0.45
I= (T0*0.85)/60

Resulting in:
P=1.125
I=0.077775

PID regulator
This one uses Pcrit and T0 and results in a fast acting proccess that keeps a contant value.
P= Pcrit*0.5
I= (T0*0.6)/60
D= (T0*0.12)/60

Resulting in:
P=1.25
I=0.0549
D=0.01098

Alternative formulas for Ziegler & Nichols 1. method
TLC tuning parameters is intended to be an improvement on Ziegler & Nichols' method.
P=Pcrit/2.2
I=T0/2.2
D=T0/6.3

Your milage may vary, I personally prefer the original Z&M method -30% of all values.

End notes
These calculations are taken from the real world, meaning I'm probably going to have to revise these formulas for Stormworks as I and D time isn't the exact same as a reglator uses in real life.
Ziegler & Nichols' second method
To be expanded
Cascade regulation
The basics of cascade regulation

Cascade regulation takes the proccess and splits it in half, where the Slave PID is first tuned using any method, then the setpoint of this becomes the output of another PID (Master).

This cascading will allow the slave loop to act quickly to changes in the proccess and the master loop to oversee that a global variable is held constant.

Advantages of cascade regulation is that it can compensate for changes in the proccess regulation output like degrading pipes, differences in outputs, mechanical wear, and such real world applications.

Example 1:
We have a boat with 2 fuel tanks, one on each side that we want to use in order to keep the roll of the boat down.

The master uses a roll signal from the boat to output -1 to +1 that it forwards to the first slave's Setpoint

The first slave would set how much each tank needs to hold in order to keep the boat level.

The second slave controllers would keep the level in each tank according to their setpoint.


These cascading effects allow the boat to quickly react to changes in wave direction and such, the master will simply give it's order and the slaves will using their own proccess variables compensate and execute order.

Cascade regulation I don't see much use of in Stormworks right now, might be more useful later.

Example 2:

If you have a submarine that's got three ballast tanks, one in the front, rear, and middle.
You got an anlge sensor for Pitch, and a depth sensor, as well as tank volume sensors.

There are two masters in this scenario, one that controls pitch and one that controls depth.
The tanks are of different volumes so each pid has to convert the maximum volume range to for example 0-100.
If the boat starts to pitch up it will move ballast forward from the rear tank in order to compensate.
If it starts to dive it will compensate by emptying the tanks at the same time while it moves ballast forward and backwards to keep ballance.

See my ♥♥♥♥♥♥ diagram:




Will be continued when I get more time
33 Comments
Kindmanathome 5 Nov, 2023 @ 2:59pm 
make a workshop link pelase?
Brygun 18 Aug, 2023 @ 4:48pm 
Once again your helping me out. Espically with that GIF. Im a visual learner. It really helps understand how to WAG to some basic settings for a new PID
LeBathtubFishe 11 Mar, 2023 @ 7:32pm 
What do I do if I can't get a constant swing on with just P, and the swing I can get only get's worse over time. I am working on a helicopter controller. Using a tilt sensor as the process variable for pitch.
Bro 14 May, 2022 @ 11:52pm 
I am a proud user of the WAG (wildass) doctrine
Sabro Stuart Sprozazo of Paper 16 Jul, 2021 @ 1:03am 
Still having trouble tuning a laser guided missile following a still laser dot.
Chashmodai 30 May, 2021 @ 5:22am 
My head hurts
Staalby 9 Oct, 2020 @ 10:43am 
What we need is an option for editing PID on the move and perhaps a simulator that tests different PID settings for an optimal behavior
R2go 14 Sep, 2020 @ 8:09pm 
Where did you generate that PID gif at the start?
Timothy  [author] 10 Feb, 2020 @ 9:03am 
Pcrit is the actual P value that has the lowest constant swing.
ierdna100 9 Feb, 2020 @ 10:35pm 
I'm confused on how you obtain Pcrit on the ziegper and nichola method? Is it the average between the maximum and minimum PV or the actual P value on the controller?