Advertisement
SemlerPDX

Example

Jun 3rd, 2025
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | Gaming | 0 0
  1. # --- Device Aliases ---
  2. alias gasSensor d0 # gas sensor to read room pressure
  3. alias leverSwitch01 d1 # lever to enable disable entire system
  4. alias leverSwitch02 d2 # lever to control filling/emptying
  5. alias pressureRegulator d3 # keep the intake pipe filled upto target pressure
  6. alias pipeAnalyzer d4 # Read pipe pressure for pressureRegulator
  7.  
  8. # --- Registers ---
  9. alias currentRoomPressure r8
  10. alias currentRoomTemperature r9
  11. alias leverState01 r10 # 0 for system disable, 1 for enable
  12. alias leverState02 r11# 0 for emptying, 1 for filling
  13. alias currentPipePressure r12
  14. alias targetPipePressure r13
  15. alias roomTargetPressure r14
  16. alias regulatorSwitch r15 # Switch for pressure regulator 0 or 1
  17.  
  18. # --- Constants ---
  19. define ActiveVentHASH -1129453144 # Hash for ActiveVent devices
  20. define TargetPipePressureKPA 5000 # 5MPa = 5000 kPa
  21. define TargetRoomPressureKPA 100 # Target room pressure
  22. define fillVentBatch HASH("ActiveVentExhaust") # Stores hash for "FillVent" batch
  23. define emptyVentBatch HASH("ActiveVentInlet") # Stores hash for "EmptyVent" batch
  24.  
  25. #Set the initial state of these vents - mode will never change, set it once here:
  26. sbn ActiveVentHASH fillVentBatch Mode 0
  27. sbn ActiveVentHASH emptyVentBatch Mode 1
  28.  
  29. IdleLoop:
  30. # Name the Vents with a Labeler to "ActiveVentExhaust" and "ActiveVentInlet"
  31. sbn ActiveVentHASH fillVentBatch On 0
  32. sbn ActiveVentHASH emptyVentBatch On 0
  33. sleep 1
  34.  
  35. StartLoop:
  36. # Read sensor inputs
  37. l currentRoomPressure gasSensor Pressure # Read room pressure
  38. l currentRoomTemperature gasSensor Temperature # Read room temperature
  39. # convert temperature to Celsius from Kelvin
  40. sub currentRoomTemperature currentRoomTemperature 273.15
  41. # Display current room pressure and temperature on IC Housing
  42. s db Setting currentRoomPressure
  43. sleep 2 #?! cannot be tick perfect with such instructions!
  44. s db Setting currentRoomTemperature
  45.  
  46. l leverState01 leverSwitch01 Open # lever state for system enable/disable
  47. # If leverState is 0, jump to IdleLoop else continue
  48. beqz leverState01 IdleLoop
  49.  
  50. l leverState02 leverSwitch02 Open # lever state for filling/emptying mode
  51. l currentPipePressure pipeAnalyzer Pressure # Read current pipe pressure
  52.  
  53. # Control Pressure Regulator for filling pipe
  54. # regulatorSwitch = 1 if currentPipePressure < TargetPipePressureKPA, else 0
  55. slt regulatorSwitch currentPipePressure targetPipePressure
  56. s pressureRegulator On regulatorSwitch # Set regulator On state
  57.  
  58. # If leverState is 1, Exhaust will be on and Inlet off, else vice-versa
  59. sbn ActiveVentHASH fillVentBatch On leverState02
  60. seqz r0 leverState02
  61. sbn ActiveVentHASH emptyVentBatch On r0
  62. sleep 3 #?! cannot be tick perfect with such instructions!
  63. j StartLoop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement