Stormworks: Build and Rescue

Stormworks: Build and Rescue

Frag2000 Sep 30, 2020 @ 1:38pm
PID on engine throttle with no load question ...
Hi guys,

for the PID gurus out here.

Let's say I have a MEDIUM engine, no load (clutch is at 0).

- Max RPS of the engine is limited at at 35

If I set a microcontroller that control the throttle of the engine, based on its RPS. Should I expect being able to get a stable RPS if there is no load?

Example.

- I set the PID Control Ouput as the Engine Throttle
- I set the setpoint to 20 (for 20 RPS)
- I set the process variable as the Engine RPS
- I set the Proportional Gain of the PID at 0.1

When executed, the RPS of the engine will vary quickly between 18 and 25.

I tried playing around with the integral and derivative gain, but I am not sure what to put there and I was not able to achieve it to be stable.

Any hint? Actually I am wondering if it can be achieved on an engine with no load.
Last edited by Frag2000; Sep 30, 2020 @ 1:39pm
< >
Showing 1-8 of 8 comments
Pete Sep 30, 2020 @ 2:39pm 
It is entirely possible to do. However, that is way too much P for an idle controller.

If the setpoint is 20, and the actual rps is 18, the error is 2. Multiply that by P, you get 0.2 That is how much throttle it is going to add to try and correct. Obviously that is too much for no load.

What you need to do is use the advanced PID, and change the P according to the load. Lets say you keep it very simple.. take the raw throttle input from the controls as your load measurement, and multiply P by some multiple of that.

Or even simpler, have an idle mode, and a running mode. Or alter P according to clutch position.

Clamping P is also a good idea.

The general rule is to get P right first. If you cant get it working more or less okay with just P, messing with I and D usually wont help unless you get lucky.
Frag2000 Sep 30, 2020 @ 5:08pm 
Originally posted by Pete:
It is entirely possible to do. However, that is way too much P for an idle controller.

If the setpoint is 20, and the actual rps is 18, the error is 2. Multiply that by P, you get 0.2 That is how much throttle it is going to add to try and correct. Obviously that is too much for no load.

What you need to do is use the advanced PID, and change the P according to the load. Lets say you keep it very simple.. take the raw throttle input from the controls as your load measurement, and multiply P by some multiple of that.

Or even simpler, have an idle mode, and a running mode. Or alter P according to clutch position.

Clamping P is also a good idea.

The general rule is to get P right first. If you cant get it working more or less okay with just P, messing with I and D usually wont help unless you get lucky.

Thanks Pete, it help me to try to figure out the nature of those tuning parameters.

Actually what I would like to do in the end is ... at full power, the boat accelerate as fast as it can. But when it jumps a wave, the engine wont over rev. So it makes thing a bit difficult since the surge is powerfull, therefore needing a big correction. But if the correction is big, it tends to make that up and down rev effect.
Last edited by Frag2000; Sep 30, 2020 @ 5:09pm
Pete Sep 30, 2020 @ 5:38pm 
Oh, there are other ways to do that. A tilt sensor will prevent porpoising. Subtract your allowable nose up, then multiply the remainder by a suitable number, and subtract that from the throttle.

And/Or use a fluid meter on the outside of the boat. If not enclosed, they show height relative to the water level. This can give an easy indication of when the prop is going to come out of the water.

The other obvious thing to do is set a sensible RPS limit at the engine. If this limit is only just above full power RPS, it wont bounce off the limiter under normal use, but wont go much higher if the prop lifts.

If you are using horizontal roll stabilisers, those can be hooked up to an altimeter. This works well for speedboats.
-VG- Napster Oct 1, 2020 @ 2:28am 
Originally posted by stephanedaigle2000:
Hi guys,

for the PID gurus out here.

Let's say I have a MEDIUM engine, no load (clutch is at 0).

- Max RPS of the engine is limited at at 35

If I set a microcontroller that control the throttle of the engine, based on its RPS. Should I expect being able to get a stable RPS if there is no load?

Example.

- I set the PID Control Ouput as the Engine Throttle
- I set the setpoint to 20 (for 20 RPS)
- I set the process variable as the Engine RPS
- I set the Proportional Gain of the PID at 0.1

When executed, the RPS of the engine will vary quickly between 18 and 25.

I tried playing around with the integral and derivative gain, but I am not sure what to put there and I was not able to achieve it to be stable.

Any hint? Actually I am wondering if it can be achieved on an engine with no load.

Set your actual throttle range from 0-20 on the throttle itself
PID
1
0
0.01

If you want anything else then these settings wich work okayisch you may loose 0.20 rps at the end of the lever but other settings good luck in finding it these pid things are a mysterium i tried it for 3-4 days to get any other setting working and then i just stopped trying it.
if youre willing to tinker with it connect a digital display to the pit < then u will see what happens when you change the integral gain on the pid ( wich is a setting i don´t understand why its there at all)
Last edited by -VG- Napster; Oct 1, 2020 @ 2:29am
GrumpyOldMan Oct 1, 2020 @ 3:37am 
Read some guides on how to tweak PIDs, these things have been around for at least 70 years, plenty of info out there.

In general you want to use a PID aiming for a setpoint of 0, so your PID will work against the difference of target and current value, this way you can get it accurate to the 6th decimal point on any desired input, barring outside factors of course.

Say you want an altitude hold PID.

Your current altitude is 50m and you want to ascend to 100m.

By subtracting 50-100 that leaves you with a negative 50m. This will be sent to the processing variable.

The setPoint will not be connected to anything, this will make it read 0 as default.

So the PID gets a -50 in the process variable input and notices it's 50 below 0 and starts putting out a positive value, until it reaches 0. How fast and how accurate always depends on P, I and D values and on the mechanism it's trying to control.
There is no such thing as using 1, 0 and 0.01. The PID has to be tweaked for every single application.
Last edited by GrumpyOldMan; Oct 1, 2020 @ 3:46am
pontfogel Oct 1, 2020 @ 7:01am 
My biggest issue with PIDs is that the I value doesn't seem to do what it's supposed to be doing. I've read a lot about PIDs since I started using them here in Stormworks and I just can't figure out how the in-game I value works. In fact, I rarely use it at all.
Randox Oct 1, 2020 @ 9:41am 
The standard formula for I is:

I = I + ((Ki * error) / time)

I starts at zero. Ticks are a 60th of a second I think (or a 20th?), so time would be 1/60 (or 1/20).

In real applications it is often useful to conditionally reset I to zero.
Siegfried67 Oct 3, 2020 @ 5:16am 
P (Proportionnal) : How much you want the PID to correct the error. Example, will output 2 if the target is 20 and the variable is currently at 18 and P =1.

I (integral) : how much you want the PID to correct the error over time. Example, will increase the output by 0.1 every tick if the target is 10, the variable is at 9 and I = 0.1. It's like P, but adding substracting itself every unit of time.
Usefull to slowly go to the exact target value, but might cause some overshooting, the same time is needed to come back to 0 after reaching the target.

D (Derivative) : How much you want the PID to resist to value change. If P is too much ( imagine you're far from your target altitude on an altitude controler, the PID might output a huge number and make everything overreact), D will slow down to change, and be able to anticipate overshooting. It will limit the PIDs output the faster you go close to the target (in case of an alt hold logic, will limit your ascending speed).

Increasing P will usually get you closer to the target value. If you want to reach 100, but only get to 90, increase P and it might go to 99.

If the variable keeps oscillating ( altitude oscillating between 90 and 110 m when target is 100), you'll need to increase D, so it slows down when going near 100m, to avoid overshooting. If your vehicle starts shaking quickly, decrease D.

I never use I, because i just never needed it so far, and i don't see any example where it could be used.

That what i got about PIDs after experimenting with those bad boys. I might be wrong on some aspects of it.


To set a target RPS for an engine, the greater P is, the closer you'll get to the target value (without ever reaching it perfectly, because that would mean a PID output of 0, and the engine would go down again). It will then oscillate, the engines not reacting instantly: it tends to go to 20, then goes down since the throttle goes down, then up again, the PID correcting the RPS loss... To limit the oscillation, slowly increase D. D will be usefull when you have a changing load on the engine, to avoid the PID overcompensating when the RPS drops or raises. There is not "default value", it'll depend on each engine setup and load.
Last edited by Siegfried67; Oct 3, 2020 @ 5:33am
< >
Showing 1-8 of 8 comments
Per page: 1530 50

Date Posted: Sep 30, 2020 @ 1:38pm
Posts: 8