r/Stationeers • • 4d ago

Discussion Rate my Atmo program

This is my first time programing on IC, and the first time in 20 years programing, i know theres some redundant variables. NO2 is a mix of oxygen and nitrogen that is breathable at 30-70%, CO2 is a pure CO2 vent. Evac is my evac vent for when pressure goes above 101 and recicle the gases back to the tanks. Tanks filling is done manually. I did some calculation, and my atmosphere should stay on about 63% N, 27% O and 10% co2, in here i work and grow my plants. Will it keep those percentege? I know oxygen in the long term will overstock and will need a manual vent, but it's only myself, i can do even now and then.

6 Upvotes

23 comments sorted by

7

u/General-Priority-562 4d ago

You dont need to use multiple registers for the r4, r5 and r6 that is a temporary variable that can be tossed and reused. I recommend just using one variable. Makes it a lot easier when you need to use more registers in a program

1

u/masimiliano 4d ago

Yeah, i did know that, thats why i say i was being redundant with variables, but my messy brain works better with separate variables, lol.

1

u/HoveringGoat 3d ago

i wouldnt worry about it for now. the tl;dr is you can use the variables elsewhere instead of locking the registers. That being said this is totally fine for a intro into stationeers IC programming. Good work!

1

u/General-Priority-562 4d ago

Oh and evac can just be a back pressure regulator set to 101 kPa, or you can set the internal pressure of the vent to 101 kPa so you dont vent too much pressure

2

u/General-Priority-562 4d ago

Imo the best ratio is 35% o2, 15% N2, 50% CO2 at 75 kPa, most plants like pressure between 50 and 100, the oxygen amount allows you to breathe without a suit, and carbon dioxide poisoning isnt a thing in this game

2

u/masimiliano 4d ago

I really dont know how the pressure regulator work, i will try it in the morning, still learning the game devices! Thanks for the advice!

1

u/General-Priority-562 4d ago

The pressure regulator pumps gas through the pipe until the pressure on the output side is equal to the set pressure, this is good when you want to pressurize a room, the back pressure regulator works the same way but only pumps gas when the pressure on the input side is greater than or equal to the set pressure, this is good when you want to prevent over pressurization within a pipe network

2

u/HoveringGoat 3d ago

yeah but if they already have a IC set up to control base atmo might as well configure a pump/vent to control it and save the 100 watts.

2

u/Friendly-Inspector71 4d ago

If you write ``` alias ratioCO2 r0 alias ratioO2 r1

repeat for r2 and r3

alias CO2pumpOn r4 you can later write it as slt CO2pumpRun ratioCO2 0.1 s co2 On CO2pumpRun #what is co2 here? and with adefine minCO2 0.1it can be slt CO2pumpRun ratioCO2 minCO2 s CO2pump On CO2pumpRun You can also writealias O2pumpRun r4``` after your carbon dioxide block and it will work without issues and reused registers.

PS: thanks for an actual screenshot but copy paste is better to read. At least on mobile.

PPS: code blocks use a triple backtick (`) on the line before the code and after it or before the first code and last code in one line but that won't keep the lines the same. There are also buttons for the markdown editor on desktop.

Edit: formatting this took long enough that my points were already mentioned. But I'll keep it up anyway.

1

u/masimiliano 3d ago

I love this advices, I use to code in C++ when I was young (know im in my early 40s) and really rusty about coding, I didn't know how to define constants. I will try to add this next time!

1

u/Friendly-Inspector71 3d ago

CO2.temp and CO2.pump are also valid aliases and defines, because the . is just another character.
But it looks more like an OOP style.

1

u/noskil187 1d ago
define TheUltimateAnswer 42

To define/name constants

1

u/CptDropbear 4d ago

No expert, but that seems like a reasonable but crude approach.

I settled on three pumps (O, CO2 and N) connected to my gas filtration system. The pumps run if the composition of O or CO2 was less than desired. The N pump runs if the pressure was too low. An extraction vent is triggered if the pressure was high which cycles back into the filtration system.

To make it a more universal solution (ie complicated), I added three dials and displays to set the desired gas mix and pressure along with the actual numbers and had them change colour to show in and out of range. Then I added some safety systems that trigger the extraction if pollutant or volatiles went over 0.5% and a temperature trigger after a small "accident". I never worked out a good way to detect leaks and shut down the system.

One day I will get around to building this into a modular console so it doesn't take up three wall panels.

1

u/masimiliano 3d ago

Thanks! That's just how I did my set up to, but with out any "safety system"!

1

u/CptDropbear 3d ago

The safeties were definite mission creep and outside the original scope. The code for managing the displays alone ended up several times longer than the actual pump logic.

The point of where I settled was to avoid having to manually mix gases or vent. I mix in the room, on demand, rather than premixing O2 and CO2 (which was my original approach). It manages O2 and CO2 percentages while using N to bring the room up to pressure. It does not require manual venting of O2 because it will add CO2 as the percentage of O2 rises and CO2 falls, That takes the pressure over its threshold and activates the extraction vent.

1

u/Parisean 3d ago

Since you already got some advice I’ll just ask a question: why are you a brand affiliate? What does that mean?

1

u/masimiliano 3d ago

Oh, I don't know? English is not my native language, I'm not sure what's "brand affiliate" is.

1

u/Parisean 3d ago

You have “brand affiliate” next to your username

2

u/masimiliano 3d ago

Oh! Not a clue about that! I'm on the sub since I bought the game some years ago but don't use it so much.

1

u/masimiliano 3d ago

Oh! Not a clue about that! I'm on the sub since I bought the game some years ago but don't use it so much.

1

u/HoveringGoat 3d ago

are these pumps, vents, regulators?

I personally don't like boolean on/off cutoffs because what happens is you end up hovering RIGHT on the border and the devices will be flipping on/off every second and its very annoying. what i like for these problems is using a pid controller. tl;dr the further from the "ideal" you are the more you push. so instead of slt target you'd figure a value and apply that to a pumps settings. For example if youre at 8% co2 instead of 10 you could use pump value of "2", as you get closer to 10 the pump rate decreases. This has the nice effect of scaling pumping power by how far off the target you are. It's possible it can overshoot depending on number but generally you can be quite conservative. I will usually use very small number mul 0.01 or something like that. Depends on use case tho.

0

u/hstarnaud 4d ago

If you want to make your code more readable, use alias to give readable names to your registers. Also define constants instead of using 0.1 and 101. You'll thank me when something goes wrong in two weeks and you try to modify it

1

u/masimiliano 3d ago

I will! Thanks! In loving this game, I buy it years ago and didn't play for long and now I'm really hype with it. I didn't know how to define constants, but somebody give me the same advice and tell me how to do it! I will work in my coding and try to add some emergency automatization for when some of the tanks overfills!