Skip to content

Commit

Permalink
Update furnace scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsso committed Aug 1, 2021
1 parent ec355e8 commit cb7cd26
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
31 changes: 15 additions & 16 deletions myps/test-scripts/factory/furnace/furnace.myps
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,24 @@ def nHfactor = (6100) / 6000

# (NOTE: MAY NEED TO ADJUST)
# PD (proportional, derivative) term coefficients
# (furnace)
def kPF = 0.09
def kDF = 0.06
# (cold source)
def kPC = 0.09
def kDC = 0.06
# (hot source)
def kPH = 0.09
def kDH = 0.06
def kPF = 0.01
def kDF = 0
def kPC = 0.1
def kDC = 0
def kPH = 0.1
def kDH = 0

# Acceptable error amounts for
# (a) the removal of gas from the furnace,
# (b) the transfer of cold CO2 (i.e. removal from source)
# (c) the transfer of hot CO2
def ERRORF = 0.5
def ERRORC = 0.5
def ERRORH = 0.5
def ERRORF = 0.25
def ERRORC = 0.25
def ERRORH = 0.25

db.Setting = -1
furnace.SettingInput = 0
furnace.SettingOutput = 0
loop:
yield()
input = db.Setting
Expand Down Expand Up @@ -105,8 +104,8 @@ loop:
# (f.1) Calculate the furnace output control value (uF) and update error (eFPrev)
nF = furnace.TotalMoles
eF = nF - rF
uF = max(0, min(100, (kPF * eF) + (kDF * (eF - eFPrev) / dt))) # (kPF, kDF)
#uF = (kPF * eF) + (kDF * (eF - eFPrev) / dt) # (kPF, kDF)
#uF = max(0, min(100, (kPF * eF) + (kDF * (eF - eFPrev) / dt))) # (kPF, kDF)
uF = (kPF * eF) + (kDF * (eF - eFPrev) / dt) # (kPF, kDF)
eFPrev = eF

# (f.2) Calculate the cold source control value (uC) and update error (eCPrev)
Expand All @@ -125,15 +124,15 @@ loop:

# (f.4) Set housing to current progress (total error / initial error)
eTotal = (eF + eC + eH) / eTotal0
db.Setting = 1 - eTotal # set progress
db.Setting = 1.05 - eTotal

# (f.5) Set rates from control values, and loop if any error is above limit
FNotDone = (eF > ERRORF)
CNotDone = (eC > ERRORC)
HNotDone = (eH > ERRORH)

furnace.SettingOutput = FNotDone ? uF : 0
furnace.SettingInput = FNotDone ? 0 : 1000
#furnace.SettingInput = FNotDone ? 0 : 1000
nCPump.Setting = CNotDone ? uC : 0
nHPump.Setting = HNotDone ? uH : 0

Expand Down
30 changes: 18 additions & 12 deletions myps/test-scripts/factory/furnace/starter.myps
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
importantStartButton = d0
# importantStartButton = d0
validatorControl = d1
furnaceControl = d2
tTDisp = d3
pTDisp = d4
progressDisp = d5

def ImportantButton = 1668452680

def BLUE = 0
def GREEN = 2

tTDisp.Color = GREEN
pTDisp.Color = GREEN
progressDisp.Color = BLUE
progressDisp.Mode = 1
tTDisp.Color = GREEN
pTDisp.Color = GREEN
progressDisp.Color = BLUE
progressDisp.Mode = 1
progressDisp.Setting = 0

fix i = 0
loop:
yield()
targetCode = validatorControl.Setting
importantStartButton.On = (targetCode > 0)
ImportantButton.all.On = (targetCode > 0)

if importantStartButton.Setting and furnaceControl.Setting == -1:
if ImportantButton.all.On.min and ImportantButton.all.Setting.max and furnaceControl.Setting == -1:
tT = (targetCode % 1000) * 10
pT = trunc(targetCode / 1000) * 100

Expand All @@ -34,10 +38,12 @@ loop:
while furnaceControl.Setting != -1:
progressDisp.Setting = furnaceControl.Setting
yield()
pTDisp.On = 0
tTDisp.On = 0
progressDisp.On = 0
progressDisp.Setting = 0
i = 6
else:
tTDisp.On = 0
pTDisp.On = 0
progressDisp.On = 0
if i == 0:
tTDisp.On = 0
pTDisp.On = 0
else:
i -= 1

0 comments on commit cb7cd26

Please sign in to comment.