PID controller
Posted: Tue Oct 10, 2023 12:23 am
I made this to control nuclear reactors but in principle it could be used for pretty much anything, though there isn't a high demand for that outside of nuclear.
What it does is applies additional power so to say in order to make input values match with the ones specified in the controller. For example you want a steady 20k steam in a nuclear reactor buffer tank. It'll keep getting exactly to it no matter if reactors are idling or running full power or swinging or spiking. The P part makes it hard to get too far away from the desired value. The I part makes it always give it more gas as long as it's still off target. And the D part makes it respond rapidly to fluctuations and especially to sharp spikes. For simplicity's sake a lot of math combinators were omitted at expense of having to work with extremely tiny I values and extremely huge D values, but that's OK, it works all the same in the end.
The values need tweaking though. It might be a good idea to install a fast-forward mod to tweak nuclear reactor control loops because it takes forever for any change to take effect. You can start by setting everything to zero except one of the values.
P value: if affects how strongly it reacts to just being away from desired values. Basically, it's rubberbanding. The further away you are from your target, the harder it pulls. But as soon as you start getting closer, it gets weaker. To tweak it, just make it pretty big, just see that small changes don't make it overshoot. With other values disabled, a good value normally makes it hover at 30-40% better than "nothing" where it's actually just empty.
I value: this makes it creep towards the desired value, the longer it was off target the stronger is the effect. It's like if you run but can't catch up to someone, you run even faster. It's usually a very small value and tweaking it is just a tradeoff between the speed (bigger values) and avoiding hard overshooting (smaller values).
D value: it momentarily gives it a hard kick if it sharply slows down for whatever reason. Like when someone shoves you, you instantly resist most of it and maintain balance, but not beyond that. In a perfect world, simply instantly resisting 100% of the external force would be all you ever need. But in reality there are all sorts of delays and momentum, so you need to pick a good optimal point between not enough reaction and losing balance, and too hard reaction and losing balance in the other direction. So just tweak it until it more or less instantly compensates for sharp changes, but it doesn't overdo it.
Anyway here it is.
The amount of combinators is probably suboptimal but on the other hand it can simultaneously control all signals except the 6 used internally (dot, white, P, I, D, X), they all share the same PID values though.
Lite version without clock and filtering.
Here's an inserter speed controller to go along with it, since it just outputs arbitrary numbers that don't actually mean anything other than "bigger number = faster speed".
What it does is applies additional power so to say in order to make input values match with the ones specified in the controller. For example you want a steady 20k steam in a nuclear reactor buffer tank. It'll keep getting exactly to it no matter if reactors are idling or running full power or swinging or spiking. The P part makes it hard to get too far away from the desired value. The I part makes it always give it more gas as long as it's still off target. And the D part makes it respond rapidly to fluctuations and especially to sharp spikes. For simplicity's sake a lot of math combinators were omitted at expense of having to work with extremely tiny I values and extremely huge D values, but that's OK, it works all the same in the end.
The values need tweaking though. It might be a good idea to install a fast-forward mod to tweak nuclear reactor control loops because it takes forever for any change to take effect. You can start by setting everything to zero except one of the values.
P value: if affects how strongly it reacts to just being away from desired values. Basically, it's rubberbanding. The further away you are from your target, the harder it pulls. But as soon as you start getting closer, it gets weaker. To tweak it, just make it pretty big, just see that small changes don't make it overshoot. With other values disabled, a good value normally makes it hover at 30-40% better than "nothing" where it's actually just empty.
I value: this makes it creep towards the desired value, the longer it was off target the stronger is the effect. It's like if you run but can't catch up to someone, you run even faster. It's usually a very small value and tweaking it is just a tradeoff between the speed (bigger values) and avoiding hard overshooting (smaller values).
D value: it momentarily gives it a hard kick if it sharply slows down for whatever reason. Like when someone shoves you, you instantly resist most of it and maintain balance, but not beyond that. In a perfect world, simply instantly resisting 100% of the external force would be all you ever need. But in reality there are all sorts of delays and momentum, so you need to pick a good optimal point between not enough reaction and losing balance, and too hard reaction and losing balance in the other direction. So just tweak it until it more or less instantly compensates for sharp changes, but it doesn't overdo it.
Anyway here it is.
The amount of combinators is probably suboptimal but on the other hand it can simultaneously control all signals except the 6 used internally (dot, white, P, I, D, X), they all share the same PID values though.
Lite version without clock and filtering.
Here's an inserter speed controller to go along with it, since it just outputs arbitrary numbers that don't actually mean anything other than "bigger number = faster speed".