Merge branch 'master' of gitlab.psi.ch-samenv:samenv/sea

This commit is contained in:
2023-07-04 08:41:48 +02:00
368 changed files with 348 additions and 40168 deletions

View File

@ -382,12 +382,19 @@ proc stdConfig::ccu4 {{title CCU4} args} {
node ax upd
node axs upd
node axd upd -int
} elseif {$a eq "valve"} {
} elseif {[string match valve* $a]} {
set nvalve [string range $a 5 end]
for {set ch 1} {$ch <= 12} {incr ch} {
node v$ch upd
prop enum valve_off,valve_on,no_valve,timeout,timeout1,boost
if {$ch > $nvalve} {
prop visible false
}
node vc$ch out -int
prop enum valve_off,valve_on
if {$ch > $nvalve} {
prop visible false
}
}
} elseif {$a ne "multiHe"} {
error "ERROR: unknown argument '$a' to ccu4"

View File

@ -257,6 +257,9 @@ proc stdConfig::dil12 args {
prop label "remove mixture status"
prop check dil12::check_removephase
prop write stdSct::completeUpdate
node ignore_vti_temp -int par 0
prop enum 1
}
}
hset $name/heatermode 0
@ -992,10 +995,15 @@ proc dil12::autostep {phase init} {
dil12::openvalves v1 v6 v12 v13 vm_open
sorb mode 0
dil12::set_VtiT 1.25
hset [sct]/onekstate 0
nv set [silent 5 hvali [sct]/circulateflow]
nv 2 ;# auto
if {[hval [sct]/ignore_vti_temp]} {
dil12::set_VtiT 0
nv 1 ;# controlled
} else {
dil12::set_VtiT 1.25
nv 2 ;# auto
}
dil12::msg ""
}
circulate {
@ -1034,7 +1042,11 @@ proc dil12::autostep {phase init} {
sct optimize [clock seconds]
clientput "reduced VTI flow to [hvali [sct]/circulateflow]"
nv set $circulateflow
nv 2 ;# auto
if {[hval [sct]/ignore_vti_temp]} {
nv 1 ;# controlled
} else {
nv 2 ;# auto
}
}
}
}

View File

@ -1,5 +1,5 @@
# furnace control (for now used by FI blue ILL type furnace)
# for Arduino fictrl_11 (not fictrl_12!!)
# furnace control, version for FI furnace after modification by Jael Lorenzana 03.2023
# Arduino Firmware fictrl_13
namespace eval fictrl {
}
@ -29,11 +29,6 @@ proc stdConfig::fictrl {body} {
prop @voltscale $arguments(voltscale)
prop @min_resist $arguments(min_resist)
prop @max_resist $arguments(max_resist)
prop @offset_I $arguments(current_offset)
prop @offset_U $arguments(voltage_offset)
prop @offset_h 0
prop @power_supply_off 0
if {[info proc stdConfig::tdrive] eq ""} {
namespace eval :: {
source drivers/trun.tcl
@ -43,6 +38,8 @@ proc stdConfig::fictrl {body} {
hsetprop $path/set check fictrl::check_set
kids "fi control ($name)" {
node limit par 1000
foreach ch {1 2 3 4} {
node t$ch upd
@ -64,37 +61,48 @@ proc stdConfig::fictrl {body} {
hfactory $path/points plain mugger floatvarar 1
}
node valid rd
node valid rd -int
prop enum 1
prop readcmd s$ch
prop readfmt s$ch=%d
}
}
node tref rd
prop readcmd t2
prop readcmd tr
prop update fictrl::update_ref
# prop readfmt "s$ch=%g"
prop old 0
node tout rd
prop readcmd t1
prop readcmd tw
prop update fictrl::update_out
node toutmax wr
prop write fictrl::write_lim
prop readcmd wh
prop update fictrl::update_out
node toutmin wr
prop readcmd wl
prop write fictrl::write_lim
prop update fictrl::update_out
# prop readfmt "s$ch=%g"
node ctrlmode wr
prop writecmd s=%d
prop readcmd s
prop readfmt s=%d
prop enum ok,off,illegal_channel,no_sensor,no_waterflow,above_alarm,bad_vacuum,power_supply_off
prop enum ok,off,illegal_channel,no_sensor,no_waterflow,bad_vacuum,tc_overflow,wall_T_overflow
prop update fictrl::update_c
node ramp par 20
node smooth par 60
node prop par 0.5
node prop par 0.005
prop help "proportional gain for T slope control"
node int par 0.1
node int par 0.2
prop help "time constant for T slope control"
node powerset out
default 0
@ -118,7 +126,11 @@ proc stdConfig::fictrl {body} {
prop readcmd o
prop readfmt o=%g
node manualpower -int par 0
prop enum 1
node ctrlchan wr -int
default 1
prop writecmd c=%d
prop readcmd c
prop readfmt c=%d
@ -126,30 +138,36 @@ proc stdConfig::fictrl {body} {
node interlock_state rd -int
prop readcmd is
prop readfmt is=%d
prop enum ok=0,no_waterflow=1
# ,no_vacuum=2,no_water_no_vacuum=3
prop enum ok=0,no_waterflow=1,bad_vacuum=2,no_waterflow_bad_vacuum=3
node interlock_mask wr -int
prop readcmd im
prop readfmt im=%d
prop writecmd im=%d
prop enum check_water_flow=0,no_check=1
# ,check_vacuum_only=2,check_all=3
prop enum no_check=0,check_water_only=1,check_vacuum_only=2,check_all=3
node sramp upd
node slope upd
node v_htr upd
node v_htr rd
prop readcmd U
prop readfmt U=%g
prop update fictrl::update_offset
prop offset 0
node i_htr upd
node i_htr rd
prop readcmd I
prop readfmt I=%g
prop update fictrl::update_offset
prop offset 0
node htr rd
prop readcmd "h U I"
prop readcmd h
prop readfmt h=%g
prop update fictrl::update_power
node powerprop upd
}
}
@ -158,77 +176,51 @@ proc fictrl::check_power {} {
if {$p > 0} {
set r [hval [sct parent]/resist]
set s [sct @voltscale]
set output [format %.2f [expr 100 * sqrt($p * $r) / $s]]
# clientput "output $output"
hset [sct parent]/output $output
hset [sct parent]/output [format %.2f [expr 100 * sqrt($p * $r) / $s]]
} else {
# clientput "output 0"
hset [sct parent]/output 0
}
}
proc fictrl::update_power {} {
array set keyval {h 0 U 0 I 0}
foreach item [sct result] {
lassign [split $item =] key val
set keyval($key) [expr $val + [silent 0 sct @offset_$key]]
}
sct update $keyval(h)
set v $keyval(U)
set i $keyval(I)
set pow [expr max(0, $v * $i)]
set vout [expr $keyval(h) * 0.01 * [sct @voltscale]]
# set vpercent [expr $v * 100.0 / [sct @voltscale]]
# difference output voltage % - read voltage %
clientput "v $v vout $vout last [silent None sct last_v]"
if {abs($v - $vout) > 0.5} {
if {abs($v - [silent 100 sct last_v]) > 100.02} {
clientput "power supply feedback does not follow"
enum_decode [sct parent]/ctrlmode power_supply_off new
sct @power_supply_off 1
if {$new != [sctval [sct parent]/ctrlmode]} {
hset [sct parent]/ctrlmode $new
}
return idle
}
sct last_v $v
set pow [expr max(0, $vout * $i)]
}
sct @power_supply_off 0
if {[sctval [sct parent]/ctrlmode]} {
updateval [sct parent]/power 0
return idle
}
updateval [sct parent]/v_htr $v
updateval [sct parent]/i_htr $i
updateval [sct parent]/power $pow
if {$i > 1 && $v > 0.05} {
stdSct::update
set v [silent 0 hval [sct parent]/v_htr]
set i [silent 0 hval [sct parent]/i_htr]
set p [expr $i * $v]
updateval [sct parent]/power $p
if {$i > 1 && $v > 0.1} {
set r [hval [sct parent]/resist]
set r1 [expr ($v - 0.005) / double($i + 0.1)]
set r2 [expr ($v + 0.005) / double($i - 0.1)]
if {$r1 > [sct @max_resist]} {
clientput "ERROR: resistance $r1 too high"
error "resistance $r too high"
}
if {$r2 < [sct @min_resist]} {
clientput "ERROR: resistance $r2 too low"
error "resistance $r too low"
}
if {$r < $r1} {
# set r $r1
set r [expr $r * 0.9 + $r1 * 0.1]
set r $r1
# set r [expr $r * 0.9 + $r1 * 0.1]
} elseif {$r > $r2} {
set r [expr $r * 0.9 + $r2 * 0.1]
# set r $r2
# set r [expr $r * 0.9 + $r2 * 0.1]
set r $r2
}
hupdate [sct parent]/resist $r
}
updateval [sct parent]/power $p
return idle
}
proc fictrl::check_set {} {
sct @switch_on 1
sct @power_supply_off 0
hupdate [sct parent]/status ""
hset [sct parent]/ctrlmode 0
if {[sct target] > [hval [sct parent]/limit]} {
error "set T > limit ([hval [sct parent]/limit])"
}
hupdate [sct parent]/target [sct target]
if {[string match switched* [hval [sct parent]/status]]} {
hupdate [sct parent]/status ""
}
sct update [sct target]
}
proc fictrl::cmds {} {
@ -266,9 +258,6 @@ proc fictrl::to_mvolt {ch value} {
proc fictrl::ctrl_slope {} {
if {[sct @switch_on]} {
if {[hvali [sct parent]/ctrlmode]} {
hupdate [sct parent]/powerset 0
}
set init "s=0 "
} elseif {[hvali [sct parent]/ctrlmode]} {
# error state
@ -281,10 +270,11 @@ proc fictrl::ctrl_slope {} {
return idle
}
# set ta [expr [hval [sct parent]/t$ch] + 20]
set ta 1370
set valarm [to_mvolt $ch $ta]
# alarm when T is increasing by more than 50 K within 5 sec or T > limit + 20
set ta [expr min([hval [sct parent]/t$ch] + 50, [hval [sct parent]/limit] + 20)]
set valarm [format %g [to_mvolt $ch $ta]]
sct @switch_on 0
#clientput "ctrl talarm=$ta"
sct send "${init}a=$valarm c=$ch dx vx sx"
return fictrl::ctrl_do
}
@ -323,8 +313,6 @@ proc fictrl::ctrl_do {} {
set sramp [expr -$sramp]
}
hupdate [sct parent]/sramp $sramp
# filter slope
set slope [expr [silent $slope hval [sct parent]/slope] * 0.9 + $slope * 0.1]
hupdate [sct parent]/slope $slope
set last_dif [silent 0 sct last_dif]
set dif [expr $sramp - $slope]
@ -334,7 +322,7 @@ proc fictrl::ctrl_do {} {
set maxpower [hval [sct parent]/maxpower]
set r [hval [sct parent]/resist]
set s [sct @voltscale]
hset [sct parent]/maxheater [expr sqrt($maxpower * $r) * 100.0 / $s]
hset [sct parent]/maxheater [format %.5g [expr sqrt($maxpower * $r) * 100.0 / $s]]
if {$out < 0} {
if {$dif > 0} {
set out 0
@ -349,14 +337,15 @@ proc fictrl::ctrl_do {} {
}
}
# clientput "dif $dif powerset $out"
hset [sct parent]/powerset [format %.5g $out]
hupdate [sct parent]/powerprop [expr $prop * $dif]
return idle
}
proc fictrl::update_ref {} {
[sct controller] queue [sct] slow fictrl::ctrl_slope
if {[hval [sct objectPath]/manualpower] == 0} {
[sct controller] queue [sct] slow fictrl::ctrl_slope
}
set v [lindex [split [sct result] =] 1]
set t [format %.1f [expr $v + 273.15]]
sct update $t
@ -370,62 +359,69 @@ proc fictrl::update_out {} {
return idle
}
proc fictrl::write_lim {} {
sct send [format "[sct readcmd]=%.1f" [expr [sct target] - 273.15]]
return read
}
proc fictrl::update_v {} {
stdSct::update
updateval [sct parent] [to_kelvin [sct channel] [hvali [sct]]]
set temp_k [to_kelvin [sct channel] [hvali [sct]]]
updateval [sct parent] $temp_k
if {([hval [sct objectPath]/manualpower] || [hvali [sct objectPath]/ctrlmode]) &&
[sct channel] == [hval [sct objectPath]/ctrlchan]} {
updateval [sct objectPath] $temp_k
}
return idle
}
proc fictrl::update_offset {} {
lassign [split [sct result] =] name v
if {$v > 0} {
set v [expr $v + [silent 0 sct offset]]
}
if {[silent "" sct geterror] ne "powersupply_switched_off"} {
sct update $v
}
return idle
}
proc fictrl::update_c {} {
set value [stdSct::scanresult]
set old_status [hvali [sct objectPath]/status]
enum_decode [sct] $value _ old_mode
set new $old_mode
lassign [split [hvali /pv/sps] ","] pstate
set pstate 1 ;# HACK: when comm to TPG does not work
if {$pstate eq ""} {
set pstate 0
}
if {!$pstate} {
# bad_vacuum
enum_decode [sct] bad_vacuum num
sct update $num
if {$old_mode eq "ok" || $old_mode eq "off"} {
hset [sct] $num
set new bad_vacuum
}
hsetprop [sct parent]/v_htr geterror powersupply_switched_off
hsetprop [sct parent]/i_htr geterror powersupply_switched_off
} else {
sct update $value
catch {
hdelprop [sct parent]/v_htr geterror
hdelprop [sct parent]/i_htr geterror
}
}
if {$new eq "power_supply_off"} { # HACK
set new "ok"
stdSct::update
if {[sct @switch_on]} {
return idle
}
set o [sct objectPath]
set old [hvali $o/status]
set new [enum_txt [sct]]
if {$new ne "ok"} {
switch $new {
bad_vacuum {
if {$pstate} { set new "off after bad_vacuum" }
}
no_waterflow {
if {[hval [sct parent]/interlock_state] == 0} { set new "off after no_waterflow" }
}
power_supply_off {
if {![sct @power_supply_off]} { set new "off after power_supply_off" }
if {$new != [silent 0 sct oldval]} {
clientput "ERROR: $new"
sct oldval $new
}
set interlock_state [expr [hval $o/interlock_state] & [hval $o/interlock_mask]]
set summary [list]
if {$interlock_state & 1} {
lappend summary "no waterflow"
}
if {$interlock_state & 2} {
lappend summary "bad vacuum"
}
if {[hval $o/tout] > [hval $o/toutmax]} {
lappend summary "wall T too high"
} elseif {[hval $o/tout] < [hval $o/toutmin]} {
lappend summary "missing wall sensor"
}
set summary [join $summary ", "]
if {$summary eq ""} {
if {$new eq "off"} {
set summary "switched off"
} else {
set summary "switched off because of $new"
}
}
if {$new ne $old_status} {
hupdate [sct parent]/powerset 0
if {[lindex $new end] ne [lindex $old_status end]} {
clientput "ERROR: $new"
}
}
hupdate [sct objectPath]/status $new
} elseif {$old_status != ""} {
hupdate [sct objectPath]/status $summary
} elseif {$old != ""} {
hupdate [sct objectPath]/status ""
}
return idle

View File

@ -10,7 +10,7 @@ proc stdConfig::hepump {{motname hemot}} {
obj HePump -int wr
default 0
prop enum xds35_auto,xds35_manual,sv65,other,no=-1
prop enum neodry=8,xds35_auto=0,xds35_manual=1,sv65=2,other=3,no=-1
prop help "xds35: scroll pump, sv65: leybold"
prop read hepump::read
prop write hepump::set_type
@ -67,17 +67,26 @@ proc hepump::visible {pumpcode} {
} else {
set rv true
}
set runv true
} elseif {$pumpcode == 8} {
set rv false
set runv true
set v true
} else {
set v false
set rv false
set runv false
}
foreach node "valve [sct @motname]" {
if {[silent true hgetpropval [sct]/$node visible] ne $v} {
hsetprop [sct]/$node visible $v
}
}
foreach node "running eco auto eco_t_lim" {
if {[silent true hgetpropval [sct]/running visible] ne $runv} {
hsetprop [sct]/running visible $runv
}
foreach node "eco auto eco_t_lim" {
if {[silent true hgetpropval [sct]/$node visible] ne $rv} {
hsetprop [sct]/$node visible $rv
}
@ -125,6 +134,19 @@ proc hepump::set_calib {} {
} else {
set f 0.6 ;# 0.95 at 30 mbar
}
} elseif {$pumpcode == 8} { # neodry
set status [string trim [_[sct @motname] status]]
if {$status eq "disconnected" || $status eq "offline"} {
# clientput [_[sct @motname] hostport]
_[sct @motname] reconnect
}
if {$status eq "no response"} {
set pumpcode 1 ;# treat as manual
hsetprop [sct]/[sct @motname] group "hepump valve motor (not connected)"
} else {
hsetprop [sct]/[sct @motname] group "hepump valve motor"
}
set f 0.55
} elseif {$pumpcode == 3} { # other
hsetprop [sct]/[sct @motname] group "hepump valve motor"
set f [hval [sct]/calib]
@ -142,10 +164,10 @@ proc hepump::set_calib {} {
}
proc hepump::read {} {
set p [silent 0 result cc f]
set p [expr [silent 0 result cc f] * [silent 0.6 hvali /nv/calib/ln_per_min_per_mbar]]
set f [silent 0 result nvflow]
if {[hvali [sct]/eco] == 0 && $p > 1 && $f > 0.5 && $f < 25} {
set health [expr 100 * $f / ($p * 0.5 - 0.5)]
set health [expr 100 * $f / ($p / 1.2 - 0.5)]
set health [expr [silent $health sct health] * 0.95 + 0.05 * $health]
sct health $health
if {abs($health - [silent 0 hval [sct]/health]) > 1} {
@ -155,7 +177,7 @@ proc hepump::read {} {
sct health_cnt [expr [sct health_cnt] + 1]
if {[sct health_cnt] == 10} {
if {$health > 100} {set health 100}
catch {prep0 / "pump_health_update [result instrument] [format %.0f $health]"} msg
catch {prep0 / pump_health_update [result instrument] [format %.0f $health]} msg
}
}
} else {
@ -182,7 +204,7 @@ proc hepump::check_valve {} {
}
proc hepump::set_valve {} {
if {[sctval [sct parent]] != 0} return
if {[sctval [sct parent]] % 8 != 0} {return idle}
set val [hvali [sct]]
if {[sct target] < 2} {
if {[hvali [sct parent]/[sct @motname]/encoder] > 20} {
@ -216,7 +238,7 @@ proc hepump::slow_close {} {
}
proc hepump::get_valve {} {
if {[sctval [sct parent]] != 0} {return idle}
if {[sctval [sct parent]] % 8 != 0} {return idle}
set p [sct parent]/[sct @motname]
set stat [hgetpropval $p status]
set pos [hvali $p/encoder]
@ -274,7 +296,7 @@ proc hepump::get_valve {} {
}
proc hepump::chk_running {} {
if {[sctval [sct parent]] != 0} return
if {[sctval [sct parent]] % 8 != 0} return
if {[sct target]} {
hset [sct parent]/[sct @motname]/output0 1
} else { # off
@ -292,8 +314,8 @@ proc hepump::chk_running {} {
}
proc hepump::get_running {} {
# only for xds35
if {[sctval [sct parent]] != 0} {return idle}
# only for xds35 and neodry
if {[sctval [sct parent]] % 8 != 0} {return idle}
set running [sctval [sct parent]/[sct @motname]/output0]
set pumpoff [silent 1 hval [sct parent]/[sct @motname]/input3]
@ -339,6 +361,7 @@ proc hepump::get_running {} {
}
proc hepump::set_eco {} {
# xds35 only, not for neodry
if {[sctval [sct parent]] != 0} {return idle}
if {[sct target] != [hvali [sct]]} {
hset [sct parent]/auto 0
@ -352,7 +375,11 @@ proc hepump::set_eco {} {
}
proc hepump::get_eco {} {
if {[sctval [sct parent]] != 0} {return idle}
# xds35 only, not for neodry
if {[sctval [sct parent]] != 0} {
sct update 0
return idle
}
set eco [sctval [sct parent]/[sct @motname]/output1]
sct update $eco
[sct controller] queue [sct parent] write hepump::set_calib
@ -360,11 +387,13 @@ proc hepump::get_eco {} {
}
proc hepump::set_auto {} {
# xds35 only, not for neodry
if {[sctval [sct parent]] != 0} {return idle}
sct update [sct target]
}
proc hepump::get_auto {} {
# xds35 only, not for neodry
if {[sctval [sct parent]] != 0} {return idle}
set auto [hvali [sct]]
set oldeco [sctval [sct parent]/eco]

View File

@ -552,10 +552,10 @@ proc lsc::read_curve_inp {} {
excit - range - rang {
error "[sct Data_File]: replace 'excit' and 'range' by 'intype'"
}
form - intype - loadfmt {
form - intype - loadfmt - calibrange {
}
default {
error "[sct Data_File]: unknown keyword"
error "[sct Data_File]: unknown keyword $keyword"
}
}
sct $keyword $value

View File

@ -758,7 +758,7 @@ proc secop::update_ {} {
}
error_update {
lassign $val etype erepr
set etext erepr
set etext $erepr
regexp {.*'(.*)'} $erepr -> etext
hsetprop $path geterror "${etype}: $etext"
}

View File

@ -32,9 +32,8 @@ proc stdConfig::sensirion {} {
prop writecmd "str7 n%-6d int 10 / str9"
node offset wr
prop check sensirion::checkCalib
prop read stdSct::read
prop complete sensirion::update
prop complete sensirion::update_and_check
prop update sensirion::update
prop write stdSct::write
prop readcmd "str1 o int 10 / str9"
@ -42,15 +41,15 @@ proc stdConfig::sensirion {} {
node scale wr
prop read stdSct::read
prop complete sensirion::update
prop update sensirion::update
prop check sensirion::checkCalib
prop complete sensirion::update_and_check
prop update sensirion::updateScale
prop write stdSct::write
prop readcmd "str1 g int 10 / str9"
prop writecmd "str7 g%-6.4f int 10 / str9"
node save out
node save wr
prop enum 1
prop read sensirion::readSave
prop write sensirion::saveCalib
prop help "unchecked: current calib is not saved. set checked: save calib"
@ -75,14 +74,6 @@ proc sensirion::currentCalib {} {
return [format {%.4f %.4f} [hval [sct objectPath]/offset] [hval [sct objectPath]/scale]]
}
proc sensirion::checkCalib {} {
if {[silent "" currentCalib] ne "[silent 0 sct saved]"} {
hupdate [sct parent]/save 0
} else {
hupdate [sct parent]/save 0
}
}
proc sensirion::saveCalib {} {
if {[sct target]} {
sct send "str1 s int 10 / str1"
@ -99,3 +90,31 @@ proc sensirion::update {} {
sct update [sct result]
return idle
}
proc sensirion::update_and_check {} {
sct update [sct result]
[sct controller] queue [sct parent]/save progress read
return idle
}
proc sensirion::readSave {} {
set current [silent "" currentCalib]
set saved [silent "" sct saved]
if {$current eq $saved} {
sct update 1
} else {
sct update 0
}
return idle
}
proc sensirion::updateScale {} {
if {[sct result] == 1 && [silent 0 sct target] != 1} {
# probably an uncalibrated sensor was replaced and not initialized
sct target 2.3
clientput "change nvflow scale from 1 to 2.3"
return write
}
sct update [sct result]
return idle
}

View File

@ -496,10 +496,12 @@ proc trun::read_run {} {
}
set now [DoubleTime]
set tr [silent none sct target]
set prev_tr [silent $tr sct prev_tr]
sct prev_tr $tr
if {$tr eq "none"} {
set tr $tmain
} else {
set dif [expr abs($tr) - [hvali [sct]/target]]
set dif [expr $tr - $prev_tr]
updateval_u [sct]/target $tr 0
set dblmode [silent -1 hval [sct]/dblctrl/mode]
if {$dblmode >= 0} { # not disabled