Reworked heating-cooling

This commit is contained in:
Snorre Selmer 2021-11-10 17:29:01 +01:00
parent 2a50ecf864
commit 10769caaab

View File

@ -1,6 +1,11 @@
alias gas_sensor d0 alias gas_sensor d0
alias thermostat d1 # Logic Switch, Dial variant (Max=30) # d1= Logic Switch, Dial variant (Max=30)
alias temp_variance d2 # Logic Memory, must be more than 0 (2 is a good value) alias thermostat d1
# d2 = Logic Memory, must be more than 0
alias temp_variance d2
# d3 = Console, LED Display variant, optional
alias temp_disp d3
alias curr_temp r0 alias curr_temp r0
alias target_temp r1 alias target_temp r1
alias variance r2 alias variance r2
@ -9,10 +14,10 @@ alias max_temp r4
alias cooling_active r5 alias cooling_active r5
alias heating_active r6 alias heating_active r6
define wall_heaters 24258244 # Wall Heaters define wall_heaters 24258244
define wall_coolers -739292323 # Wall Coolers (Gas) define wall_coolers -739292323
define liquid_wall_coolers -1369060582 # Wall Coolers (Liquid) define liquid_wall_coolers -1369060582
define temp_convert 273 define temp_convert 273.15
start: start:
yield yield
@ -30,47 +35,49 @@ l target_temp thermostat Setting
l curr_temp gas_sensor Temperature l curr_temp gas_sensor Temperature
sub curr_temp curr_temp temp_convert sub curr_temp curr_temp temp_convert
# update display
brdns temp_disp 2
jal display
# compare current temp to max/min temp and # compare current temp to max/min temp and
# initiate cooling or heating if needed # initiate cooling or heating if needed
bgt curr_temp max_temp cooling bgt curr_temp max_temp cooling
blt curr_temp min_temp heating blt curr_temp min_temp heating
# Go to start again
j start j start
cooling: display:
yield s temp_disp Setting curr_temp
# read ambient temp from sensor and convert to C
l curr_temp gas_sensor Temperature
sub curr_temp curr_temp temp_convert
j ra
cooling:
# test if coolers need to be on or not # test if coolers need to be on or not
sgt cooling_active curr_temp target_temp sgt cooling_active curr_temp target_temp
# update display
brdns temp_disp 2
jal display
# send state to coolers # send state to coolers
sb wall_coolers On cooling_active sb wall_coolers On cooling_active
sb liquid_wall_coolers On cooling_active sb liquid_wall_coolers On cooling_active
# if curr_temp is higher than target, keep cooling bgtz cooling_active cooling
bgt curr_temp target_temp cooling
# ...if not, go to start again
j start j start
heating: heating:
yield
# read ambient temp from sensor and convert to C
l curr_temp gas_sensor Temperature
sub curr_temp curr_temp temp_convert
# test if heaters need to be on or not # test if heaters need to be on or not
slt heating_active curr_temp target_temp slt heating_active curr_temp target_temp
# update display
brdns temp_disp 2
jal display
# send state to heaters # send state to heaters
sb wall_heaters On heating_active sb wall_heaters On heating_active
# if curr_temp is lower than target, keep heating bgtz heating_active heating
blt curr_temp target_temp heating
# ...if not, go to start again
j start j start