Stormworks: Build and Rescue

Stormworks: Build and Rescue

187 ratings
MODULAR ENGINES: perfect stoichiometry
By Il_simo
A simple guide to run your modular engine with the desired stoichiometric coefficient in every working condition (no matter if you have a naturally aspirated engine or a supercharged one).

FEATURES:
-Always works
-Immediate response to changes in operating conditions (throttle, load, temperature, manifold pressure, etc.)
-Very simple
-NO PID
-NO LUA
8
5
4
4
4
2
   
Award
Favorite
Favorited
Unfavorite
Introduction
In this guide will be presented the equation that I found to link the stoichiometric coefficient (the one that you see when looking the cylinders of your modular engine) to the ratio between the fuel manifold throttle and the air manifold throttle.

Please, if you find this guide useful, consider to leave a feedback or a positive review: the solution that I found is simple but it took my spare time during the last 3 weeks to obtain this equation, thank you.
Some math (don't worry I have done the work for you)
During the last 3 weeks I read a lot of guides/discussions on Steam and Reddit about modular engines AFR (Air-Fuel Ratio) and I found what seems to be a well-known equation relating the stoichiometric coefficient and the corresponding AFR, for a given engine temperature:

AFR(s,T) = (14-2s)*(1-0.01T)+(15-5s)*(0.01T)

where:
AFR(s,T) is the Air-Fuel Ratio in function of the desired stoichiometric coefficient and engine temperature
s is the desired stoichiometric coefficient (a number between -1 and +1, use +0.2 to maximize engine efficiency)
T is the engine temperature measured in °C and clamped between 0°C and 100°C

If you do the math you will find that the equation above can be written in this shorter form:

AFR(s,T) = 14+0.01T-2s-0.03Ts

The only thing we miss, at this point, is the relationship between air pressure and the ratio between fuel throttle and air throttle: after some hypothesis and a lot of data collections, tests and curve fittings I found the following (and last) equation:

(F/A) = (6.88+(0.0625p))/AFR(s,T)

where:
F is the fuel manifold throttle
A is the air manifold throttle
p is air pressure at the air manifold inlet, capped at 90 (I prefer to clamp it between -1 and 90)

Don't forget to multiply the ratio obtained from the last equation by the air throttle value to calculate the fuel throttle you need!

F = A*(6.88+(0.0625*p))/AFR
A practical example (how to build a microcontroller that really works without PIDs and LUA scripts)
Build your engine: doesn't matter the size (1x1, 3x3, 5x5) and the number of cylinders provided that you are using enough exhaust manifolds.
Complete it with battery, fuel tanks, throttle lever, starter key etc.

At this point we need:

  • a temperature measurement system (a temperature sensor on the engine crankshaft or the 3rd channel of the composite output of one of your cylinders)
  • a numeric value for the stoichiometric coefficient that you want to obtain (example: a keypad)
  • a pressure sensor (can be avoided in case of a naturally aspirated engine) linked to the pipe between your compressor (if you have a supercharged engine) and the air manifold inlet

I haven't forgotten rps, air and fuel readings from the cylinder: we don't need them!

Now, in a few steps, we can build a simple microcontroller :

1. design a 3x2 microcontroller
2. add:
a numeric input for engine temperature to be linked to your temperature measurement system
a numeric input for air manifold pressure to be linked to the pressure sensor (if you have one)
a numeric input for your engine throttle
a numeric input for your desired stoichiometric coefficient (0.2 for maximum efficiency)
a numeric output for your air manifold throttle
a numeric output for your fuel manifold throttle
3. use a clamp between 0 and 100 for the temperature input, connect it to a first numerical function block f(x,y,z) at the x input
4. connect the stoichiometric coefficient input to the y input of your function block
5. put into the function block the following formula 14+(0.01*x)-(2*y)-(0.03*x*y)
6. connect the first function block output to the x input of a second function block
7.connect the air manifold pressure input to the y input of your second function block, by using a clamp between -1 and 90
8.put into the second function block the formula (6.88+(0.0625*y))/x
9.using a multiplier block, multiply your engine throttle input by the output of the second function block
10.link the output of the multiplier block to the fuel manifold throttle output
11.also link the the engine throttle input directly to the air manifold output

Turn on the key and watch your cylnders stoichiometric coefficient keeping the value you wanted.


Final hints:
-use the same number of air manifolds and fuel manifolds
-in case of a supercharged engine, if you experience some air manifold pressure instability: consider to use a variable valve, positioned between the "compressor" (pump) and the pressure sensor, that remains partially open and discharge the excess air into the ambient.

Here you can find a link to a simple microcontroller that works with my equations:
https://steamcommunity.com/sharedfiles/filedetails/?id=2786934052

Here there is a link to a test dyno to show how you have to connect the microcontroller above:
https://steamcommunity.com/sharedfiles/filedetails/?id=2786928037

A picture from a my microcontroller very similar to the one described above:

Credits
A special thanks to Lupus the Canine and his awesome "CSV logger" microcontroller
https://steamcommunity.com/sharedfiles/filedetails/?id=2408195283

Another special thanks to all the people that wrote something on modular engines AFR and stoichiometry
Guide update(s)
  • April 5, 2022
Manifold pressure reading must be capped at 90 in the equation (A/F)=((6.88+(0.0625*p))/AFR(s,T)
51 Comments
Shadowcub Jan 27 @ 4:18pm 
@etzabo I ran a test for this. I found it to be slightly more efficient directly from the cylinder composite (using Dazzed's updated formula). I don't recall this being the case before, so it may have been affected by an update somewhere.
joshisonline4434 Jan 10 @ 4:41pm 
Da UWU
etzabo Sep 25, 2024 @ 9:32am 
Why not get the amount of air in the cylinders from the cylinder composite instead of having a hefty pressure sensor?
Shadowcub Aug 22, 2024 @ 9:42pm 
@Dazzed
While developing a new ECU using the above, I ran a test between your updated formula and the original. I initially found it to be slightly worse; this was before getting further into the ECU and adding load (medium gen to a flat 6 test engine). I ran a final test when I was done with everything and found that yours was indeed slightly better. Just to add to your claim and make others aware.
Dazzed May 15, 2024 @ 9:40pm 
in the current version, the 2nd equation needs to be adjusted slightly, these values work perfectly for me (tested on 2 different vehicles with different engines):

(F/A) = (7+(0.07p))/AFR(s,T)

AFR calculation is still the same
fuel pressure is still irrelevant afaik
Brygun Feb 25, 2024 @ 2:05am 
For reference what i did to update fix from old to the pressure fluid update
Found that I had
air intake -> pressure sensor -> pump -> manifold getting AFR 14.9
moved sensor to be next to manifold
air intake -> pump -> pressure sensor -> manifold getting AFR 13.7
observed air pressure ~11 and fluid ~33-44
Added to my microcontroller a property to multiply the manifold
Used 0.932 normal fuel manifold to get to 14.7
Why 0.932? just dividing 13.7 seen by 14.7 desired

Im assuming the pressure update somehow gets more fuel down the manifold
Brygun Feb 25, 2024 @ 12:06am 
Query:
If the pressure of fluids now being a thing do we need to include the fuel pressure as part of the equations?
Brygun Feb 24, 2024 @ 10:39pm 
This was a great help and worked into my SAFE minded ECU, which includes auto shut offs in case of over heat, external input etc.
After the pressure gasses update I came back to an earlier built boat. The actual AFR is coming in at 14.9 - 15 rather than the 14.7 target. Have your or others seen this since that update? Have you done something particular to restore getting to the target? Is it over charging the air on the super charger or not getting enough fuel pulled in? Not sure which of the update changes it might be.
Robs_Reef Dec 29, 2023 @ 4:00pm 
I love it when stormworkers take advantage of the freedom microcontrollers give us and make cool systems like this.
Il_simo  [author] Dec 2, 2023 @ 3:45am 
Dj-Quiet, this is an interesting question.
My approach was to try to replicate what a real life Ecu does: it measures inlet air temperature and pressure and, on the basis of its map, it calculates how much fuel the engine needs at the given time.
My first try to do that was to use the air volume coming from the cylinder's data, then I realised that this process was too difficult because I needed a stable engine to do the testing. Now, with my actual system, I have a quite stable engine but I don't have time to test a solution based only on the cylinder's data.
I also think we always have to take into account for the air throttle in our formula, because without that we will need a PID to regulate the fuel throttle.
I'm glad you have got the point of my formula/ECU system. Thank you for your question.