Stationeers

Stationeers

Greenhouse Monitor
rottielover 17 Nov, 2022 @ 12:25pm
Is it possible to add a "Schmitt Trigger" to this code?
First, let me just say I have only made it to your 3rd IC programming tutorial video on Youtube, but I'm already using IC chips in my game all over the place, so thank you!!!

Unfortunately, I'm stuck in my greenhouse on mars during a storm with my (ingame) laptop and my greenhouse cooler is clicking on / off /on /off because it's right up against that maxtemperature.

What I used to do for my greenhouses a long time ago was use the "Schmitt Trigger" logic chip design, where you would create 2 memory chips with a Max and Min for each "side" of the loop (cool and heat). So in Logic Chips it was 12 chips to control heating and cooling..

I'm hoping to add a few lines of code that will essentially do the same thing... I really suck at this!!!! I found someone else's code where they do this with some math...

Edit: As my understanding grow's I'm going to mark this up a bit with comments for the benefit of others...

label d0 sensor
label d1 LoMem
label d2 HiMem
label d3 cooler
label d4 heater

start:
l r0 d0 Temperature # Load the temp from the sensor on pin D0, this is done by the " l temperature sensor Temperature" line of Cow's code

sub r0 r0 273.15 # subtract 273.15 off of whatever the current temp reading is

l r1 d1 Setting # He's using memory chips to get the min and max temps but Cow's code has it hard coded in - this one gets the low temp from a memory chip

l r2 d2 Setting # this one gets the Hi temp from the memory chip

sub r3 r2 r1 # subtract the set Hitemp from the set low temp and store into register 3
div r3 r3 3 # divide the result above by 3 and re-store that result into register 3
add r4 r1 r3 # add the number from above to the low temp setting and store to register 4
sub r5 r2 r3 # subtract the number from above from the hightemp setting and store to register 5

slt r6 r0 r7 # this sets Register 6 to 1 (true) if the currenttemp is less than r7 (but I dont' know where r7 came from ??

select r7 r6 r4 r1 # according to the documentation, Register 7 will be set to either the register 4 or register 1 depending on if Register 6 is a non-zero value or not. In otherwords if Register6 is zero it will set Register7 to be the value of Register1

### annnnndddddd... my brain hurts, I'll be back later ###


s d4 On r6

sgt r8 r0 r9
select r9 r8 r5 r2
s d3 On r8

yield
j start


I don't suppose this could be another youtube video in your IC Programming class??

Sorry I'm just so bad at this :(
Last edited by rottielover; 17 Nov, 2022 @ 12:39pm
< >
Showing 1-5 of 5 comments
rottielover 17 Nov, 2022 @ 12:59pm 
I think I'm going to give up on the "in line comments" sorry for the terrible reading...

I managed to hunt down this awesome web-tool at stationeering.com that's helping me a little bit.. I realized the old code I found will no longer run, but I was able to start re-working it so that it does run again. You have to re-do the first lines to be like "alias sensor d0" then I started going through and I replaced the "d0" in later lines with the alias "sensor" and the code is starting to become readable :) Sorry, but I'm going to keep posting because I hope this might help others who are in the same situation as me, where I just can't seem to grasp this and I so badly want to.
rottielover 17 Nov, 2022 @ 1:43pm 
See what you think about this:
EDIT - there is a bug, it didn't kick on my cooler when the greenhouse got too hot, I have to figure out what I did wrong

alias heater d0
alias cooler d1
alias sensor d2

alias temp r0
alias cushion r3

define MAXTEMP 300
define MINTEMP 280
define HOUSINGHASH -128473777

start:
l temp sensor Temperature
sub temp temp 273.15
sub cushion MAXTEMP MINTEMP
div cushion cushion 3
add r4 MINTEMP cushion
sub r5 MAXTEMP cushion
slt r6 temp r7
select r7 r6 r4 temp
s heater On r6
sgt r8 temp r9
select r9 r8 r5 MAXTEMP
s cooler On r8

blt temp 288 notSafe
bgt temp 323 notSafe
l r10 sensor RatioCarbonDioxide
blt r10 0.01 notSafe
l r10 sensor Pressure
blt r10 20 notSafe
bgt r10 140 notSafe
l r10 sensor RatioVolatiles
bge r10 0.01 notSafe
l r10 sensor RatioPollutant
bge r10 0.01 notSafe
sb HOUSINGHASH Setting 1
j start

notSafe:
sb HOUSINGHASH Setting 0
j start
Last edited by rottielover; 17 Nov, 2022 @ 2:52pm
rottielover 17 Nov, 2022 @ 6:06pm 
Couple hours later I have this, testing on stationeering's IC checker seems to be working, time to text in my savegame...

#Greenhouse monitor
alias heater d0
alias cooler d1
alias sensor d2

alias temperature r1

alias heaton r2
alias coolon r3

alias heatselect r4
alias coolselect r5

define MAXTEMP 300
define MINTEMP 290

define HOUSINGHASH -128473777

start:
l temperature sensor Temperature
select heatselect r2 MAXTEMP MINTEMP
select coolselect r3 MINTEMP MAXTEMP
slt r2 temperature heatselect
brdns heater 2
s heater On r2

select coolselect r3 MINTEMP MAXTEMP
select heatselect r2 MAXTEMP MINTEMP
sgt r3 temperature coolselect
brdns cooler 2
s cooler On r3

blt temperature 288 notSafe
bgt temperature 323 notSafe
l r0 sensor RatioCarbonDioxide
blt r0 0.01 notSafe
l r0 sensor Pressure
blt r0 20 notSafe
bgt r0 140 notSafe
l r0 sensor RatioVolatiles
bge r0 0.01 notSafe
l r0 sensor RatioPollutant
bge r0 0.01 notSafe
sb HOUSINGHASH Setting 1
yield
j start

notSafe:
sb HOUSINGHASH Setting 0
yield
j start
rottielover 17 Nov, 2022 @ 6:31pm 
fyi, it needs tweaking... Right now it will heat till it hits 300 and then the cooler will kick on till it hits 290 and that keeps repeating, but I think I just have to define different min and max temps for heat and cool sides... back to testing :(
rottielover 17 Nov, 2022 @ 9:22pm 
totally back to basics still struggling but I think this one works, basically I'm just looping looking for the temp to be greater than the max or less than min if those are met, it kicks on the heater or the cooler (and off the other side). It also looks for a Middle temp, if the room temp is equal it will reset everything back to off.

now here's where I wonder if the game is ever going to register the room temp as exactly equal to my 295 or if it's always going to have some little decimal value and the trigger will be skipped, leaving my greenhouse too hot or too cold

EDIT i was right, and the decimals messed me up but I just added that round line to round off the room temp and that seemed to do the trick



alias sensor d0
alias heater d1
alias cooler d2

alias roomtemp r1
alias activate r2

define MINTEMP 290
define MAXTEMP 300
define MIDTEMP 295

start:
l roomtemp sensor Temperature
round roomtemp roomtemp
blt roomtemp MINTEMP COLD_START
bgt roomtemp MAXTEMP HOT_START
beq roomtemp MIDTEMP RESET
yield
j start

COLD_START:
s heater On 1
s cooler On 0
j start

HOT_START:
s cooler On 1
s heater On 0
j start

RESET:
s cooler On 0
s heater On 0
j start
Last edited by rottielover; 17 Nov, 2022 @ 10:11pm
< >
Showing 1-5 of 5 comments
Per page: 1530 50