Advertisement
Art1985

Atmos control

Jan 24th, 2021
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. define Heaters 24258244
  2. define Coolers -739292323
  3. define GasSensors -1252983604
  4. define kelvin 273.15
  5. define minT 20 #min temperature
  6. define maxT 35 #max temperature
  7. define T 25 #optimal temperature
  8. define minP 20 #min pressure
  9. define maxP 120 #max pressure
  10. define P 105 #optimal pressure
  11. define maxCO2 1 #max CO2
  12. define minCO2 0.25 #min CO2
  13. define maxO2 0.27
  14. define minO2 0.21
  15. define maxN2 1
  16. define minN2 0
  17. define maxH2O 0
  18. define minH2O 0
  19. define maxPollutants 0.001
  20. alias depressurize d0 #emergency depressuruze lever
  21. alias actIn d1 #active vent input
  22. alias actOut d2 #active vent output
  23. alias In d3 #input device on/off
  24. alias Out d4 #output device on/off
  25. alias targCool r0 #target temperature for coolers
  26. alias targHeat r1 #target temperature for heaters
  27. alias t r2 #temperature
  28. alias p r3 #pressure
  29. alias tOk r4 #temperature ok
  30. #alias pOk r5 #pressure ok
  31. alias inOnOff r6 #variable for enabling in devices
  32. alias outOnOff r7 #variable for enabling out devices
  33. alias targetP r8 #target pressure
  34. move targCool maxT #setup target for coolers
  35. move targHeat minT #setup target for heaters
  36. move targetP minP #setup target for pressure
  37. start:
  38. jal update
  39. jal temperature
  40. jal atmos
  41. jal onOff
  42. yield
  43. j start
  44. update:
  45. lb p GasSensors Pressure Average
  46. lb t GasSensors Temperature Average
  47. sub t t kelvin #to celsius
  48. s db Setting t
  49. j ra
  50. temperature:
  51. sgt r12 p minP #check pressure
  52. sgt r10 t targCool #temperature > targetColling
  53. and r10 r10 r12 #work only if enough pressure
  54. select targCool r10 T maxT #update cooling target
  55. sb Coolers On r10 #enable cooling if temp too high
  56. slt r11 t targHeat #temperature < targetHeating
  57. and r11 r11 r12 #work only if enough pressure
  58. select targHeat r11 T minT #update targetHeating
  59. sb Heaters On r11 #enable heating if temp too low
  60. nor tOk r10 r11 #if both coolers and heaters off
  61. j ra
  62. atmos:
  63. brdns depressurize 6 #if no lever connected ignore
  64. l r13 depressurize Setting #load state of lever
  65. breqz r13 4 #if lever state 0 then ignore
  66. move outOnOff 1 #enable out devices
  67. move inOnOff 0 #disable in devices
  68. bgtz r13 ra #exit this function if lever state 1
  69. slt r13 p P #pressure < target pressure
  70. and inOnOff r13 tOk #pressure and temperature is ok
  71. alias gas r14 #variable for gas
  72. lb gas GasSensors RatioCarbonDioxide Average
  73. bgt gas maxCO2 refresh
  74. blt gas minCO2 refresh
  75. lb gas GasSensors RatioOxygen Average
  76. bgt gas maxO2 refresh
  77. blt gas minO2 refresh
  78. lb gas GasSensors RatioNitrogen Average
  79. bgt gas maxN2 refresh
  80. blt gas minN2 refresh
  81. lb gas GasSensors RatioWater Average
  82. bgt gas maxH2O refresh
  83. blt gas minH2O refresh
  84. lb gas GasSensors RatioVolatiles Average
  85. bgt gas maxPollutants refresh
  86. lb gas GasSensors RatioPollutant Average
  87. bgt gas maxPollutants refresh
  88. lb gas GasSensors RatioNitrousOxide Average
  89. bgt gas maxPollutants refresh
  90. sgt outOnOff p maxP #pressure > max pressure
  91. j ra #exit function
  92. refresh:
  93. s db Setting 555
  94. mul r13 minP 2 #Minimal pressure to enable out
  95. min r13 r13 P #restrict minimal pressure
  96. sgt r13 p r13 #pressure > min pressure
  97. and outOnOff r13 1 #pressure enough and temp ok
  98. j ra #exit function
  99. onOff:
  100. brdns actIn 5 #if no device ignore
  101. s actIn Mode 0 #Outward
  102. s actIn PressureExternal maxP #maxPressure
  103. s actIn Lock 1 #lock device
  104. s actIn On inOnOff
  105. brdns actOut 5 #if no device ignore
  106. s actOut Mode 1 #Invard
  107. s actOut PressureExternal 0 #minPressure
  108. s actOut Lock 1 #lock device
  109. s actOut On outOnOff
  110. brdns In 2 #if no device ignore
  111. s In On inOnOff
  112. brdns Out 2 #if no device ignore
  113. s Out On outOnOff
  114. j ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement