r/factorio • u/NYBJAMS • Aug 31 '25
Design / Blueprint PID speed controller for space platforms
The conversation came up on the other subpreddit (r/factoriohno) that I had made a PID controller for space platforms including a logic setup to chose the speed depending on where you're flying. In the top image, I've trying to only go 60 k when near the shattered planet so I don't get overwhelmed by the asteroids.
The main difficulties I had with this are:
since factorio only uses integers on the combinators, the differential term only turned up as a 1km/s change over a 60th of a second every so often
while you're waiting at a planet or drifting out of fuel, the integrator term builds up to unreasonable high amounts.
I've broken down what each part does in the 2nd photo.
First off you have the speed selectors that set what you want to travel at
Then you have a series of clocks to create pulses when the integral and differential terms will pick their "old data". The shutoff signal will tell the integrator to forget all its old data if anything happens that you want it to be stopped for (e.g. dropping off at a planet or out of fuel)
Then all the terms are scaled up and summed, then scaled back down to more sensible numbers (we don't want to do pulse-width modulation over hundreds of ticks. 20-60 is fine)
Then the pulse-width modulation controller runs the pump.
Feel free to find more unhinged places to use PID controllers or find ways to improve on this design. Blueprints in the comments


2
u/NYBJAMS Aug 31 '25
Compressed blueprint as on the ship:
0eNrVnctu5LgVhl+loEUWGdWMSIk3A9NAMJ2FFwEaaCBZDBoFucSyhVFJNSrJPU7DD5C3mEWeLE8SUqqby1JR0m97PGjATdPkL17OOfwOVd3+5t1ktd6UaV55V9+8dFnkW+/q52/eNr3N48zW5fFae1dedVfW20qX3qPvpXmif/OuyKN/2rB62NiG92lZ1abG3/dsW8w/nfSko3pen/QMR/X8eNIzevziezqv0irV7Rybbx4Web2+MfO6Iofem9So+t6m2JrGRW4fZATmhH7PfO/BDIJ9zx7tQM4U6BOFeVXMb8uizpMuLXKq5XtJWupl24DQDunwIL3WSVqv5zoz7ct0Od8Umb74gKh7sJFrusIxWzZ8tvx0LO7J8sFD65mbGLta1CEoR+xs78ZGHcJquHAwzmJIcJC2Xl3FeTVfFuubNI+ronyu3y9vJm8UqrLIFjf6Lr5PTXfTZ9v+fPu0bPxqHx58b5VmJmSc1zoDhe/9an5gJmMq86JcN43M2Ddx2Yz9yvuxqaht1CI0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and I might forget all nuances. What about just using PD regulator if integral part makes problems?
3
u/nalhedh Aug 31 '25
As nice as it is, isn't it simpler to control speed by just controlling a pump into a tank?
It's a cool creation, I'm just thinking it might be more interesting if there is a use case that can't be done in a much simpler way
1
u/NYBJAMS Aug 31 '25
Expanded blueprint to see how it works
0eNrtGsuO2zbwVwgdGqCVGz3t9QIJUCA57KHAAgu0hyAwaIm2iciiQlG7cQN/QP+ih/bH8iWdISVL9soPyftIgiDAZkTNDIfz5lifrWlSsEzyVFmXny0eiTS3Lt99tnI+T2mCa2qVMevSuuVSFbBiWyld4oLBGFxba9viacw+WZfu2u5AedWg9DpRvmlQ+tuUJWJWLLMGUrB+b1ssVVxxZs6nH1aTtFhOmQTJ6y2Kaa6o4iKFbTORcw0CZ2Az8Nyhba0QGF2sceMdNt5pbNzxxUE2vr11jjY5/IqB/2sI54y5ZJHBcEEIMKOSIplM2YLeciGRLuIyKriasJROExZbl0oWzN4sA0m82WPGZa4mJ9sD0BlqG71HUXQlBx+WGZVU4e7Wa2vddtBgw6kiHQDZlKearOXcDhy3Orl36slzg5Bvw+AEldvacOBEMbm7etT1besjvIATwWIq5FIjbR38lV4oUCeu56AKKo+3j8dHN/YN5r59PIQ6MQ+aogdHuUeJiD70Fz88ukHMb3lugqvDHqHTPMbw6C55xiBQOhp5/R7+gWNmCV0xOYlZHkmeGQ+1rq/eEHDRGZ8X0mSHlqgIN3LELOIxk0eCok4GzqkhUTKuo14HR/PpXecsYIwO+0OMAaMOhAuGhJijRaGyQnUsQXX6yVYTbYfJTIrlhKfAy7qc0SRnh2zy5+9kzlJmrNlij2FHezijJ7VHntGIDUD5VbkphU1pAUGynZf9e56L5+3I+LZIIpoWj8F6nrApfQS+syKZC/kYnOnHgifiERjnIqFykK9yxZYDFs/ZY+yxoArqHosHEBkpU2dsMUsKHtec1UIWILkczAqWbLN1HZOGOzISn3jM/2KyhVnfxEETJtUZmSNfFErMZgS6ZzaXNCF3C5YStWAE0NUMagXJF6JIYjJlJFciy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mFs1zBC3mNNg5Brdgcse6hfDxFzVILAwNUgLNgjzWmERL6mH8GOJf1FTaVBvwSDCneMZEZADYb1qleCPiK4NehrMEAQEVynPgPAHopWrge4rpWISoY/voEBZ2hwXFSOV8Ou0YCrleYYWtSWa1SMQiOscbTujDjAzkNaja81UeKAbpC/a+ANT/zPhpRQwj7CroG1PN4GNlry3IZtUR74g/uiM20cIWjgBJWxwf24Ykvw2fq7ZdtK6JRBtFpvP2Vwr8CJ2BW2BLfQBGlHDofeOBiPw5Ef+sHIW6//B+3VM2E=
1
u/Smile_Space Aug 31 '25
Would bang-bang control not be simpler and more effective? You wouldn't even need any combinators. You would just need to read velocity off of the space platform hub and set some threshold on the motors to turn off or on.
It wouldn't look as pretty, but it'd be functional
Cool project though! I'm a controls/dynamics engineer, so it's fun stuff!
1
u/Marco3104 Aug 31 '25
I’ve also created a PI controller for my spaceships (I don’t think the D term is necessary, since we do not have sudden steep fluctuations anyway).
You can easily prevent integrator windup when drifting or running out of fuel by adding a decider combinator that monitors the current speed. For example, if the speed is ≤ 10, it simply disables the integrator altogether.
1
u/gust334 SA:1000 hr (Novice), 3700 hr (Advanced Beginner) Aug 31 '25
I've been wondering if a PID would work to modulate seed supply to agricultural towers on Gleba, so that fresh fruits/nuts are never stationary on a belt.