[mashprep]
new bool mashongoing
new bool heatongoing
new bool mashoutheating
new bool mashoutstarted
new string Status
new value lastMLTpumprate
new value mashpumprate
mashpumprate = 80
new value heatrate
heatrate = 100
new value mashrate
mashrate = 50
new value preboilvolume
preboilvolume = 0
new value stuckmashlimit
stuckmashlimit = 8
"BKL PID" enabled = false
"Dough in" state = false
"Pauser" state = false
"Mash timer" Type = CountDown
"Mash timer" ResetValue = 01:00:00
reset "Mash timer"
reset "Sparge timer"
stop "Mash timer"
Status = "PrEboiL vOl "
wait preboilvolume > 1
Status = "AcK MaSh tiMeR"
wait "Pauser" state == true
"Pauser" state = false
Status = "CHecK vaLvEs"
wait "Pauser" state == true
"Pauser" state = false
Status = "MasHinGPrEp"
"RIMS PID" Enabled = true
"HLT vlv" value = 0
"HLT vlv return" state = on
"BKL vlv" value = 0
sleep 2000
"MLT vlv" value = heatrate
"MLT pump" value = mashpumprate
"HLT pump" value = 80
sleep 7000
heatongoing = true
Status = "HEaTing"
goto heat
[heat]
lastMLTpumprate = "MLT pump" value
if "Pauser" state == true
"Pauser" State = false
goto stopmash
endif
if "Dough in" state == true
goto stopmash
endif
if "MLT volume" value < stuckmashlimit
"Stuck mash" Active = true
goto stopmash
endif
sleep 1000
goto heat
[mash]
lastMLTpumprate = "MLT pump" value
"MLT vlv" value = mashrate
if "Pauser" state == true
goto stopmash
endif
if "MLT volume" value < stuckmashlimit
"Stuck mash" Active = true
goto stopmash
endif
if "Mash timer" value <= 00:00:00
stop "Mash timer"
"RIMS PID" Target = 76
"Mash timer" Type = CountDown
"Mash timer" ResetValue = 00:05:00
reset "Mash timer"
Status = "MaSH oUt"
mashoutheating = true
goto mashout
endif
sleep 1000
goto mash
[mashout]
lastMLTpumprate = "MLT pump" value
"MLT vlv" value = mashrate
if "Pauser" state == true
"Pauser" State = false
goto stopmash
endif
if "MLT volume" value < stuckmashlimit
"Stuck mash" Active = true
goto stopmash
endif
if "MLT temp" value >= "RIMS PID" Target
if mashoutstarted == false
start "Mash timer"
mashoutstarted = true
endif
endif
if "Mash timer" value <= 00:00:00
if mashoutstarted == true
stop "Mash timer"
"RIMS PID" Enabled = false
goto spargeprep
endif
endif
sleep 1000
goto mashout
[stopmash]
Status = "StoPPiNg"
stop "Mash timer"
"RIMS PID" Enabled = false
"MLT vlv" value = 0
sleep 10000
"MLT pump" value = 0
"Pauser" state = false
if heatongoing == true
if "Dough in" state == true
"Dough in" state = false
Status = "aDD gRaiN"
wait "Pauser" state == true
"Pauser" state = false
Status = "AcK maSh tEMp"
wait "Pauser" state == true
"Pauser" state = false
Status = "StaRTinG"
"Stuck mash" Active = false
"MLT vlv" value = mashrate
"MLT pump" value = lastMLTpumprate
sleep 5000
"RIMS PID" Enabled = true
start "Mash timer"
Status = "MaShiNg"
heatongoing = false
mashongoing = true
goto mash
endif
endif
if heatongoing == true
Status = "PaUsED"
wait "Pauser" state == true
Status = "StaRTinG"
"Pauser" state = false
"Stuck mash" Active = false
"MLT vlv" value = heatrate
"MLT pump" value = lastMLTpumprate
sleep 5000
"RIMS PID" Enabled = true
Status = "HEaTing"
goto heat
endif
Status = "PaUsED"
wait "Pauser" state == true
Status = "StaRTinG"
"Pauser" state = false
"Stuck mash" Active = false
"MLT vlv" value = mashrate
"MLT pump" value = lastMLTpumprate
sleep 5000
"RIMS PID" Enabled = true
if mashoutheating == true
if mashoutstarted == true
start "Mash timer"
endif
Status = "MaSH oUt"
goto mashout
endif
if mashongoing == true
start "Mash timer"
Status = "MaShiNg"
goto mash
endif
[spargeprep]
delete heatongoing
delete mashongoing
delete mashoutstarted
delete mashoutheating
delete lastMLTpumprate
delete mashrate
delete mashpumprate
delete heatrate
delete stuckmashlimit
new bool boilstart
new bool finished
new value MLTintegrator
new value MLTSP
new value MLTtoplevel
new value MLTlowlevel
new value lastMLTlevel
new value MLTleveldiff
new value averageMLTlevel
new value averagecounter
new value lasthltvlv
new value lastbklvlv
new value spargeloopcounter
new value flowcounter
flowcounter = -20
new value flowmin
flowmin = 0,9
new value flowmax
flowmax = 1,4
"Pauser" state = false
"HLT pump" value = 0
"MLT pump" value = 0
"HLT vlv" value = 0
"BKL vlv" value = 0
"MLT vlv" value = 0
"HLT vlv return" state = off
Status = "SpArgEPrEp"
sleep 30000
"HLT pump" value = 50
"MLT pump" value = 50
"HLT vlv" value = 40
"BKL vlv" value = 39
sleep 15000
MLTSP = "MLT volume" value
lastMLTlevel = "MLT volume" value
MLTtoplevel = MLTSP + 0,1
MLTlowlevel = MLTSP - 0,1
start "Sparge timer"
Status = "SpArgE"
goto sparge
[sparge]
if "Pauser" state == true
lasthltvlv = "HLT vlv" value
lastbklvlv = "BKL vlv" value
"Pauser" state = false
goto stopsparge
endif
if "BKL volume" value >= 25
if boilstart == false
"BKL PID" enabled = true
"BKL PID" Target = 98
boilstart = true
endif
endif
if "BKL volume" value >= preboilvolume
lasthltvlv = "HLT vlv" value
lastbklvlv = "BKL vlv" value
finished = true
goto stopsparge
endif
if spargeloopcounter >= 40
averageMLTlevel = averagecounter / 40
averagecounter = 0
MLTleveldiff = averageMLTlevel - lastMLTlevel
MLTintegrator = MLTleveldiff * 3
"BKL vlv" value += MLTintegrator
if averageMLTlevel > MLTtoplevel
if MLTleveldiff > 0,02
"BKL vlv" value += 0,5
endif
endif
if averageMLTlevel < MLTlowlevel
if MLTleveldiff < -0,02
"BKL vlv" value -= 0,5
endif
endif
lastMLTlevel = averageMLTlevel
spargeloopcounter = 0
endif
if flowcounter >= 20
if "RIMS flow" rate <= flowmin
"HLT vlv" value += 0,5
endif
if "RIMS flow" rate >= flowmax
"HLT vlv" value -= 0,5
endif
flowcounter = 0
endif
averagecounter += "MLT volume" value
spargeloopcounter += 1
flowcounter += 1
sleep 500
goto sparge
[stopsparge]
Status = "StoPPiNg"
"HLT vlv" value = 0
"BKL vlv" value = 0
sleep 7000
"HLT pump" value = 0
"MLT pump" value = 0
stop "Sparge timer"
if finished == true
Status = "ReADy tO BoiL!"
"The end" Active = true
sleep 7000
"The end" Active = false
endif
Status = "PaUsED"
wait "Pauser" state == true
"HLT pump" value = 50
"MLT pump" value = 50
"HLT vlv" value = lasthltvlv
"BKL vlv" value = lastbklvlv
"MLT vlv" value = 0
"HLT vlv return" state = off
"Pauser" state = false
start "Sparge timer"
Status = "SpArgE"
goto sparge