Stormworks: Build and Rescue

Stormworks: Build and Rescue

Simple AFR Controller
40 Comments
Emerald 27 Mar, 2024 @ 2:07pm 
They finally fixed the issue in today's update
Emerald 17 Mar, 2024 @ 8:00am 
Fair enough (gotta love stormworks devs)
Adester  [author] 17 Mar, 2024 @ 1:19am 
Yes, the devs changed a core mechanic... again. Sorry, i don't play this game anymore. I am fed up having to re-engineer everything over and over again.
Emerald 15 Mar, 2024 @ 12:43pm 
All my engines that I run supercharged, that use this design somehow run much much worse than 2 weeks ago, where the non-afr controlled engines are better than this
Stricken 22 Jan, 2024 @ 11:32pm 
Saw this on a tutorial came straight on here to look for it as im just getting into building my own engines atm. Inspired as im trying to make a plane and the regular engine is just too wide so im making and inline. Havnt tried this yet but thanks for the effort, i already know its not easy as i messed aroun for 3 hours with air and fuel levers just to get my engine to kick up without stalling.
MrCreeperman147 12 Sep, 2023 @ 5:42pm 
I must thank you for this controller and the hard work you've putted into it.
I'll make sure to credit you on my ECU and if I ever post something in the workshop using parts of
your controller
Adester  [author] 28 May, 2023 @ 11:33pm 
You can leave the stoichiometric input empty. The input regulates how lean or how fat the air to fuel ratio is. Most people use a constant with 0.2 on this input, because the engine will run most fuel efficient and therefore the coolest.

Important is to set the number somewhere between -1 and 1 (excluding -1 and 1).

You can also test which stoichiometric works best for your engine with a throttle lever on this input
heyviper123 28 May, 2023 @ 8:13am 
Where do I attach the stoichiometric input?
cryptofurball75 19 May, 2023 @ 1:10pm 
I don't know why but I got a zero air-to-fuel ratio when using this????? How to solve?
CaptainCheesy 2 Apr, 2023 @ 6:16am 
Awesome, thanks for the clarification.
Adester  [author] 22 Mar, 2023 @ 1:46am 
The AFR sensibility defines how fast the fuel multiplier will be adjusted. The controller calculates how much the actual AFR is off from the target AFR, then multiplies the result with the AFR Sensibility and finally adds that to the fuel multiplier.

There should be no reason to change that number. If the AFR of a engine oscillates, then it is very most likely due to inconsistent pressure on the air intake. Once i found a suitable value (0.05) for the AFR Sensibility, i have never experienced a situation where i had to change that number. Not for my engines nor for any engine i helped with.

I used a property value for this number to make the development process easier for me as it is good practice to give values a name. If i ever have to touch the controller again, i will know what this number does.
CaptainCheesy 22 Mar, 2023 @ 12:57am 
AFR sensibility.. what is that, and is it needed?
Adester  [author] 12 Dec, 2022 @ 2:36pm 
The temperature output is only a info thing you can hook up to a dial.
Rifnee 12 Dec, 2022 @ 5:49am 
where am i supposed to hook the temperature bit to?
Adester  [author] 21 Oct, 2022 @ 9:40am 
That sounds like a exphaust problem (the dieing engine). Look at what the cylinder info says about exhaust (should be 100%, add more exhaust manifolds or check the ones you have for piping and the atached fluid ports) The oscillating AFR can come from a pump on the air intake that is either insufficient in delivering enough air (small impeller, small fluid pump, belt pump) or is shuting down itself from delivering to much air (large fluid pump). This topic is somewhat complex... if there is a pump on the air intake, then add a pressure sensor to the air intake and test if the pressure is oscillating.
SlipperMan 21 Oct, 2022 @ 4:32am 
looks like a good afr controller but when i use it on my engine it starts and then it immediately dies and dont want to start again and also the stoichiometric changes violently
Frag2000 30 Sep, 2022 @ 8:03am 
Hi Adester,

I did play a lot with your ECU but there is something I am missing.

I created a plain MEDIUM 3 cylinder engine that output its power to a medium generator (for testing purpose). From the engine, I have a 3:2 ratio gearbox

With your ECU, with FULL THROTTLE

Naturally aspirated (just air filter on the air intake) -> Generator output: 826 watt
Supercharged (Large airpump on the air intake-> Generator output: 1190 watt
Engine blows up after 119 seconds (keep track to see how good it manage the temps.

Without your ECU, just by using the old THROTTLE x 2 (double the air amount of the fuel provided), I get 1212 watt and the engine blows up after 123 seconds.

So briefly, I do produce more power without the ECU. Fuel economy is similar.

There is surely a gain somewhere to play with the AFR at every tick. What is it?
CitrusS5 4 Aug, 2022 @ 5:35pm 
Well it turns out now it just started working good ecu :steamthumbsup:
CitrusS5 4 Aug, 2022 @ 5:34pm 
Does this still work ive put tested it on all my veichles that workes before i tested this (because i want to supercharge) Could you maybe explain what i should do with the Stoich and throttel?
:steamhappy:
Adester  [author] 17 Jun, 2022 @ 12:50pm 
TL DR: set it to 0.2 if you have a supercharged engine and to 0.45 if you have a natural aspirated engine.

stoichiometric is the ratio between fuel and oxygen (air). a positive stoichiometric means that there will be more fuel in the cylinders than air to burn it, this is good to run the engine cool. a negative stoichiometric means more air than fuel, which is good for fuel economy (in reality).

there is no reason to run anything below a stoichiometric of 0.2 in stormworks. Modular engines are most fuel efficient, run the coolest and are most powerfull (when supercharged) at a stoichiometric of 0.2. Natural aspirated engines are most powerfull at a stoichiometric of around 0.45. The stoichiometric has to be between -1 and 1 (excluding -1 and 1) for a modular engine to work.
Adester  [author] 17 Jun, 2022 @ 12:49pm 
This controller uses the temperature of the engine (provided by a composite signal from a cylinder, don't forget to connect that) and the number from the stoichiometric input (default 0 if you don't input anything) to calculate the required afr and then adjusts the fuel or air multiplicator to achive that afr. (the air multiplicator is an obsolete relict from the release of modular engines, but i leave it in, who knows when the devs will mess modular engines up (im looking at you steam boilers)).
jestor 16 Jun, 2022 @ 1:03am 
what does stoichiometric mean and where to attach?
Adester  [author] 19 May, 2022 @ 12:15pm 
thanks, go ahead, use it, no credit needed
diesel_spongebob 18 May, 2022 @ 8:23am 
best simple engine controller I've found so far. awarded you some points cause this deserves it, its so much simpler and more effective than most controllers. i also really like it cause it works very well with controllers for tank steering. would it be cool if i used this in one of my creations and posted it? i can link this in the description
Adester  [author] 16 May, 2022 @ 1:34am 
The temperature is only for your information. After the controller was finished, there was unused space for 1 more logic connection, so i used that space to output the engine temperature. Connect it to a dial if you want or just ignore it.
Ham 15 May, 2022 @ 1:33pm 
What does the tempature go into?
GrumpyOldMan 29 Jan, 2022 @ 12:31am 
Hey mate, long time fan of this MC. Would you happen to have a lua version of this at hand?
StikDonkey 17 Jan, 2022 @ 7:55pm 
ty I really appreciate it. Ever since I found this controller it has made modular engines cake.
Adester  [author] 16 Jan, 2022 @ 12:48am 
@StikDonkey Sure, go ahead. No credit needed.
StikDonkey 15 Jan, 2022 @ 8:59am 
I would like to use your A/F controller in one of my builds that I want to put on the steam workshop. I'm trying to reach out and see if that would be alright?
Jodian 18 Sep, 2021 @ 3:46pm 
Thanks for the reply, makes a lot more sense now. :gearthumbsup:
Adester  [author] 18 Sep, 2021 @ 2:36pm 
The controller calculates the required afr for the engine to run at your requested stoichiometric. you don't need any additional calculations to run your engine. I can't remember if the controller checks the stoichiometric input to be valid (e.g. if you are inputing 5, the controller will likeley try to run the engine at a stoichiometric of 5, which won't work).

All you need to do is input 0.2 into the stoichiometric for best efficiency (or 0.45 if you run your engine na and want power) and then input the throttle and don't forget to connect the composite signal from one of the cylinders.
Adester  [author] 18 Sep, 2021 @ 2:36pm 
The modular engines work between a stoichimetric of -1 and 1 (excluding -1 and 1). A stoicihiometric of 0.2 will give you the most power/fuel and most power/heat.

If you run a na engine, then you can use 0.45 for most power, but the higher the air pressure on the air intake manifold, the closer you need to run the engine at 0.2 for most power. The perfect (stormworks) engine runs only on a stoichiometric of 0.2.

This doesn't translate well to real engines, i think the devs made compromises to not overload your computer with calculations and also their understanding of engines might not be as advanced as yours.
Jodian 18 Sep, 2021 @ 12:58pm 
This looks like an awesome setup, just one question. It's got a Stoichiometric input and I'm not sure what number to put there. I'm assuming it's a straight AFR input number like 14.6

Also, how should this number adjust based on the throttle input? Being a mechanic I know you should push it closer to 12.2-ish if you're looking for heavy power at high-load. Diesel you can even dump it down as low as 9 if you wanna really dump power in exchange of "rolling coal".

Does your controller automatically adjust the stoichiometric input based on throttle, or does it constantly maintain whatever is input? If it's the latter would it maybe be smart to run a "14.6 - (Throttle x 2)" calculation prior to inputting into your controller? That way it'd be 14.6 at zero throttle and 12.6 at full....

Little help please.
Adester  [author] 15 Jul, 2021 @ 5:31am 
thank you.

First i formed a theory: The AFR for a specific stoichiometric is dependend on the engine temperature.

Then i gathered data, that would proof my theory. I controlled the air and fuel of a modular engine manually at different temperatures and for different stoichiometrics. I wrote the AFR for each temperature and stoichiometric combination down until i had enough data.

With this data i reconstructed a function to calculate the needed afr to achive a stoichiometric:
Adester  [author] 15 Jul, 2021 @ 5:31am 
( -3*y*x ) + x - ( 2*y ) + 14
where x is the stoichiometric you want
and y comes from another function (to keep it human readable):
clamp( x*0.01, 0, 1 ) <- x is the engine temperature

the temperature is clamped because i noticed that the game does the same during the data gathering.

The rest is pretty easy, take the composite data from one of the cylinders, divide the air through the fuel volume, compare the result of the function from above to the actual afr of the engine and then use a pid or something similar to adjust the fuel intake throttle multiplicator until the afr is right.
Muvusch 15 Jul, 2021 @ 4:09am 
Amazing work ! It is possible to explain how did you do to find the equation ?
Geralt of Rivia 25 Mar, 2021 @ 3:12pm 
just found this after going to the redit for help, this thing works great. Thanks for making this
Adester  [author] 21 Feb, 2021 @ 12:37am 
you are welcome. i am glad, i could help.
A_Tenebris 20 Feb, 2021 @ 12:16am 
I asked a question on reddit about AFR and you answered it. Thank you for helping solve the headache of trying to hunt and find the right answers!:steamthis: