Stormworks: Build and Rescue

Stormworks: Build and Rescue

maestro Jun 29, 2020 @ 8:44pm
Good PID settings for underwater props?
I'm trying to get a sub to use a PID to hold at a current depth but it is way overshooting no matter what I do. It's because the props take so long to spin up and slow back down. Anybody done this before and have their PID settings I could see?
< >
Showing 1-15 of 17 comments
GrumpyOldMan Jun 29, 2020 @ 9:45pm 
Every PID has to be tweaked for its purpose, depending on which values you use to control it and what the desired output value has to be.

Plenty of (stormworks unrelated) youtube videos that explain how PIDs work and how to tweak them, so you can achieve your wanted results without anyone suggesting the typical 0.1, 0.000001, 0.01 nonsense values you see on every stormworks PID video.

PID settings also depend on the vessel, so there's no such thing as general values to use.

As for submarines you only need to achieve neutral buoyancy, then the sub will stay at its current depth.
XLjedi Jun 30, 2020 @ 4:37am 
I will be working on Dive Control MC for my submarine project. I don't mind sharing the MC logic when I get to that point. I just don't have anything to share ATM.

izmebee Jun 30, 2020 @ 4:58am 
I chased "hovering " in a sub with a PID for a while. As soon as I tossed the PID it was really simple to do in a very Neutral sub.
Erik Peter Jun 30, 2020 @ 9:16am 
Usually I just wire the P and D values to two keypads, and keep tweaking them in the craft until I find a value that finally works. As Grumpy said, every PID is different, and finding the right values can take a while.
Also, what do you mean by "props take a so long to spin up and slow back down again"? You shouldn't need to control the props, as long as the control surfaces are doing the right thing you will get to the right depth.
Note that you need to invert the PID output if you are also controlling the surfaces from the player input, since "S" = -1, but holding S will make you go up, rather than down (I hope that makes sense).
XLjedi Jun 30, 2020 @ 9:50am 
Originally posted by Erik Peter:
Also, what do you mean by "props take a so long to spin up and slow back down again"? You shouldn't need to control the props, as long as the control surfaces are doing the right thing you will get to the right depth.

Assume your speed is zero and attempting to manage depth with a combination of vertical thrust and ballast tanks. In which case, control surfaces have no impact.
GrumpyOldMan Jun 30, 2020 @ 11:52am 
Originally posted by XLjedi:
Assume your speed is zero and attempting to manage depth with a combination of vertical thrust and ballast tanks. In which case, control surfaces have no impact.

If control surfaces are perpendicular to the axis you're trying to move in, they'll apply huge amounts of drag (all control surfaces and wing sections to similar extends).

XLjedi Jun 30, 2020 @ 12:07pm 
Originally posted by GrumpyOldMan:
Originally posted by XLjedi:
Assume your speed is zero and attempting to manage depth with a combination of vertical thrust and ballast tanks. In which case, control surfaces have no impact.

If control surfaces are perpendicular to the axis you're trying to move in, they'll apply huge amounts of drag (all control surfaces and wing sections to similar extends).

I can't speak for OP, but my sub has no control surfaces. Just fixed 6-DOF thrusters. I wasn't implying the shape of the sub has no impact on hydrodynamics. Rather, moving them around has no real corrective influence at zero speed in a depth leveling PID control logic sense.
Last edited by XLjedi; Jun 30, 2020 @ 12:13pm
maestro Jun 30, 2020 @ 2:22pm 
Originally posted by Erik Peter:
Usually I just wire the P and D values to two keypads,
Wait.. how do you do this when PID only has setpoint and variable inputs? I have long thought what a godsend it would be to not have to constantly change numbers and respawn over and over.

XLjedi:
My sub also has no control surfaces. It has 2 azimuth thrusters for up/down, one for back/forward and a small prop on each side for turning. Every prop has a small motor. It runs all on power via winch from a mother ship.

I recently tested it out on some ocean landmarks and it's usuable but only just.

Turning has same issue PID does as there's a 5+ second delay because of prop spin-up that causes lots of oversteering.

I ended up turning the depth hold off because of my main issues with the PID, sub goes up and down 20+ meters past the depth you select for it.

Should also mention sub is basically neutrally buoyant as is and doesn't use ballast tank. I've used them on other subs but yeah.. buoyancy isn't really a factor right now as props are more than enough to compansate for any tiny difference.
Erik Peter Jul 1, 2020 @ 2:15am 
Originally posted by Erik Peter:
Usually I just wire the P and D values to two keypads,


Microcontrollers have a internal component called an "advanced PID". They can have variable P, I and D settings.
Try using two PIDs, one for calculating where the craft needs to go, and the other for bringing it to that depth. I think this is called Cascading and is useful for regulating the speed at which you want to descend at.
Last edited by Erik Peter; Jul 1, 2020 @ 2:16am
maestro Jul 1, 2020 @ 3:15am 
Originally posted by Erik Peter:
Originally posted by Erik Peter:
Usually I just wire the P and D values to two keypads,


Microcontrollers have a internal component called an "advanced PID". They can have variable P, I and D settings.
Try using two PIDs, one for calculating where the craft needs to go, and the other for bringing it to that depth. I think this is called Cascading and is useful for regulating the speed at which you want to descend at.

Thanks for the info I'll give this a try. I get that one PID is going to match target depth against current depth however could you elaborate on what the "where craft needs to go" part of the second PID?
XLjedi Jul 1, 2020 @ 3:47am 
Originally posted by MCBMaestro:
Thanks for the info I'll give this a try. I get that one PID is going to match target depth against current depth however could you elaborate on what the "where craft needs to go" part of the second PID?

I didn't quite follow that either... are we talkin' speed/power for how fast the craft gets to the depth?

I was contemplating having something to temper or regulate the control input the closer you get to your target depth. So the closer you get to your depth, the finer the control input. Which would hopefully resolve any potential overshooting. I was thinking more in terms of a linear or binomial equation for power output rather than secondary PID.
Last edited by XLjedi; Jul 1, 2020 @ 3:50am
Erik Peter Jul 1, 2020 @ 8:31am 
Originally posted by XLjedi:
I didn't quite follow that either... are we talkin' speed/power for how fast the craft gets to the depth?

I was contemplating having something to temper or regulate the control input the closer you get to your target depth. So the closer you get to your depth, the finer the control input. Which would hopefully resolve any potential overshooting. I was thinking more in terms of a linear or binomial equation for power output rather than secondary PID.

Sorry, I guess that wasn't very clear. I think, XLjedi, that you have the right idea by "having something to temper or regulate the control input", which is the secondary PID. All the secondary PID will do is fine-tune the first PID's output to make it more manageable. For example, if you are 100m from your target depth, the first PID will be controlling your props to get to your depth. However, over time you will start to speed up. The second PID looks at the speed and goes "Ok, we are descending quite quickly. Let's tone the input down a bit, and make our descent tiny a bit slower so that our descent is more consistent. This makes it less likely to overshoot our target".

Basically, the second PID takes into account the speed at which you descend at. If it thinks you are going to fast, it makes an adjustment, making it less likely to overshoot your target.

You can have a look at Example 1 for Cascading Regulation on Timothy's guide here
He explains it a lot better than I can.
I know it is for controlling fuel tanks, but the principle is the same.
Last edited by Erik Peter; Jul 1, 2020 @ 8:33am
maestro Jul 1, 2020 @ 5:06pm 
Erik thanks for that link to that guide. Very helpful stuff.

I actually stumbled upon a very ghetto way to get the sub to sink and rise better in that at least the PID is holding the depth now to within +/1 one meter of the target depth. I just put on some fin rudders horizontally on each side. They have no power or control input, they don't even face forwards.

They just seem to disrupt the excessive acceleration. They act like brakes almost, always reducing speed in any direction they are perpendicular with making movement more responsive as a consequence.

It helps with my over steering problem the same way, creating a braking force against the propellers.
Last edited by maestro; Jul 1, 2020 @ 7:39pm
Originally posted by izmebee:
I chased "hovering " in a sub with a PID for a while. As soon as I tossed the PID it was really simple to do in a very Neutral sub.
Could you tell me your secret? My sub either rises or sinks ... due to that I wanted to be at the bottom (many times) anyways I did put wheels under it ... which fell apart in one particular deep portion ... where I sank through one ground (had a second below). I was horrible. Thing was my balast in and outs where under that ground so the sub didn't blew them anymore ... luckily I went for a design that was powered by a boi containing a diesel engine ... as soon as I reeled in (enough of) the cable it pulled me out of the ground.
Downside of this design is I tow a very clunky boi behind me till I reach destination.

Originally posted by GrumpyOldMan:
[...]
Plenty of (stormworks unrelated) youtube videos that explain how PIDs work and how to tweak them [...]
Totally out of the loop here, never even heard of of PIDs before Stormworks.
And I have a few years on my back already ... well you learn something new every day.

Originally posted by Erik Peter:
[...]
Try using two PIDs, one for calculating where the craft needs to go, and the other for bringing it to that depth. I think this is called Cascading and is useful for regulating the speed at which you want to descend at.[...]
Blackmagic² ? I need a real idiot prooved tutorial on that one.

Originally posted by Erik Peter:
[...]Also, what do you mean by "props take a so long to spin up and slow back down again"? [...]
Well, that also made me wonder if he made a sub without balast tanks.


Originally posted by MCBMaestro:
Erik thanks for that link to that guide.[...]
Thanks for pointing the link out, otherwise I would have missed it.

Originally posted by Erik Peter:
[...]You can have a look at Example 1 for Cascading Regulation on Timothy's guide here[...]
Thanks, for the link. Tho, the use of "here" as the text of a link is usually frowned upon, and now I know why.
Last edited by ~* BiZZ Keryear *~; Jul 1, 2020 @ 10:57pm
Chronic Nov 28, 2024 @ 12:07am 
To control a submarine's depth with a PID controller in Stormworks, you need to set up a feedback loop where the submarine's current depth is constantly compared to your desired depth, and the PID controller calculates the necessary adjustment to the vertical thruster power based on the difference (error) to maintain the target depth, adjusting for both the current error and its rate of change (derivative) to achieve smooth and stable control.
Key Steps:
Set up the PID controller block:
Access the "Logic" tab in the building menu and find the "PID Controller" block.
Connect the input of the PID controller to the submarine's current depth sensor output (usually a "Depth" sensor).
Set the desired depth as the "Setpoint" value in the PID controller settings.
Connect the output to the vertical thrusters:
Connect the PID controller's output to the vertical thruster control input.
Adjust the "Gain" values (Proportional, Integral, Derivative) in the PID controller settings to fine-tune the response based on your submarine design and desired behavior.
Tuning the PID values:
Proportional (P): Controls the immediate response to the error. Higher P means faster reaction to depth changes, but can lead to overshooting.
Integral (I): Accumulates the error over time, helps eliminate steady-state errors but can cause overshoot if too high.
Derivative (D): Responds to the rate of change in error, helps dampen oscillations and improve stability.
Important Considerations:
Sensor accuracy:
Ensure your depth sensor is accurate and has a suitable update rate for smooth control.
Thruster response:
Consider the responsiveness of your vertical thrusters, as it can affect how quickly your submarine reacts to PID adjustments.
Environmental factors:
Adjust PID values depending on the water conditions (currents, waves) to maintain stable depth control.
< >
Showing 1-15 of 17 comments
Per page: 1530 50

Date Posted: Jun 29, 2020 @ 8:44pm
Posts: 17