From b37f2bac2800041b275b4a14be91e85d70daf896 Mon Sep 17 00:00:00 2001 From: tasp Date: Thu, 14 Sep 2023 11:39:31 +0200 Subject: [PATCH 01/14] ILL5: improve nv pid --- tcl/ill5.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcl/ill5.config b/tcl/ill5.config index 703deec..f6fdc39 100644 --- a/tcl/ill5.config +++ b/tcl/ill5.config @@ -13,5 +13,8 @@ tt set/limit 310 makeCCU4 ill5 nv n2 he nv set 1 +nv ctrl/prop_o 0.05 +nv ctrl/prop_c 0.03 + source maxi_orange.table From 3773bb98b31cb9516e2b3a1fb2cb416cf35ab08d Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 15 Sep 2023 10:37:13 +0200 Subject: [PATCH 02/14] fix autofill with extrnal level meter when no value is available, filling must be inhibited. this patch checks whether a value newer than 30 sec is available --- tcl/17tf.config | 2 +- tcl/drivers/ccu4ext.tcl | 66 +++++++++++++++++++++++++++++----------- tcl/startup/autofill.tcl | 4 +-- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/tcl/17tf.config b/tcl/17tf.config index 195505e..8dde30d 100644 --- a/tcl/17tf.config +++ b/tcl/17tf.config @@ -28,7 +28,7 @@ GraphAdd 17tf.nlevel % N2_lev black #makeCCU4 blank nv #GraphAdd nv.flow mbar nv_flow red -makenv ln2fill -driver ccu4ext n2 "17tf nlevel" +makenv ln2fill -driver ccu4ext n2 /17tf/nlevel #make17tfNv diff --git a/tcl/drivers/ccu4ext.tcl b/tcl/drivers/ccu4ext.tcl index 4292795..c3b15d9 100644 --- a/tcl/drivers/ccu4ext.tcl +++ b/tcl/drivers/ccu4ext.tcl @@ -3,7 +3,7 @@ namespace eval ccu4ext { } # automatic fill with level reading from external source -proc stdConfig::ccu4ext {type {readlevel 0}} { +proc stdConfig::ccu4ext {type {readpath 0}} { variable node variable ctrl @@ -27,13 +27,14 @@ proc stdConfig::ccu4ext {type {readlevel 0}} { node state upd -text - node readlevel -text par $readlevel + node readpath -text par $readpath prop visible false node lowlevel par 10 node highlevel par 100 node smooth upd prop fmt %.7g + prop geterror undefined default -1 node minfillminutes par 3.0 @@ -89,7 +90,7 @@ proc ccu4ext::changestate {type state} { proc ccu4ext::calcsmooth {level minspeed maxspeed} { if {![string is double $level]} { - return 999.9 + return 199 } set now [clock seconds] set lasttime [silent 0 sct lasttime] @@ -98,10 +99,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} { } set delta [expr $now - $lasttime] sct lasttime $now - set smooth [hvali [sct]/smooth] - if {$smooth < 0} { - set smooth $level - } + set smooth [silent $level hvali [sct]/smooth] set gs [expr $smooth + $delta * $maxspeed] if {$level > $gs} { set smooth $gs @@ -126,6 +124,7 @@ proc ccu4ext::calcsmooth {level minspeed maxspeed} { } } hupdate [sct]/smooth $smooth + hdelprop [sct]/smooth geterror return $smooth } @@ -148,7 +147,8 @@ proc ccu4ext::fillExt {type} { } } set errtxt "" - set sm [expr [DoubleTime] > [silent 0 sct change_time] + 10] + set now [DoubleTime] + set sm [expr $now > [silent 0 sct change_time] + 10] switch -- $valve { 0 { set txt "fill valve off" @@ -178,6 +178,12 @@ proc ccu4ext::fillExt {type} { set errtxt "unknown error" } } + set rdpath [hvali [sct]/readpath] + set level [hvali $rdpath] + set levelerror [silent "" hgetpropval $rdpath geterror] + if {$levelerror ne "" && $errtxt eq ""} { + set errtxt "$txt ($rdpath $levelerror)" + } if {$errtxt eq ""} { updateval [sct]/state $txt hupdate [sct]/status "" @@ -189,11 +195,6 @@ proc ccu4ext::fillExt {type} { changestate $type fill return idle } - set level [silent invalid result [hvali [sct]/readlevel]] - if {! [string is double $level]} { - hsetprop [sct]/readlevel geterror "illegal $type level reading" - return idle - } set state [sctval [sct]] set now [clock seconds] set lowlevel [hvali [sct]/lowlevel] @@ -219,6 +220,7 @@ proc ccu4ext::fillExt {type} { return idle } 0 { # watching + validated_level set minspeed [expr - 100.0 / [hvali [sct]/minholdhours] / 3600.] set maxspeed [expr - 100.0 / [hvali [sct]/maxholdhours] / 3600.] set s [calcsmooth $level $minspeed $maxspeed] @@ -231,13 +233,18 @@ proc ccu4ext::fillExt {type} { } # start fill hset [sct] 1 - clientput "$type level low - start fill" + clientput "$type level low ($level smooth $s) - start fill" } else { changestate $type stop } return idle } - 1 { + 1 { # filling + if {[validated_level] eq ""} { + hset [sct] 2 + changestate $type off + return idle + } set vcmd [silent 0 sct vessel_cmd] # check that vessel command works if {$vcmd ne "0" && [catch {[result $vcmd]}]} { @@ -246,7 +253,7 @@ proc ccu4ext::fillExt {type} { set vmd 0 } set now [clock seconds] - set s [hvali [sct]/smooth] + set s [silent $level hval [sct]/smooth] sct minlevel [silent 999 sct minlevel] if {$s < [sct minlevel]} { sct minlevel $s @@ -321,12 +328,30 @@ proc ccu4ext::fillExt {type} { return idle } +proc ccu4ext::validated_level {} { + set rdpath [hval [sct]/readpath] + if {[DoubleTime] < [silent 0 hgetpropval $rdpath read_time] + 30} { + return [hval $rdpath] + } + if {[silent "" hgetpropval $rdpath geterror] eq ""} { + clientlog "ERROR: no reading of $rdpath within 30 sec" + } + hsetprop $rdpath geterror not_available + return "" +} + proc ccu4ext::writeExt {type {activate 1}} { sct update [sct target] - hupdate [sct]/smooth [silent 0 result [hvali [sct]/readlevel]] switch -- [sct target] { # watching 0 { + set level [validated_level] + if {$level eq ""} { + changestate $type off + sct update 2 + return idle + } + hupdate [sct]/smooth $level catch {logsetup [sct]/vext clear} hupdate [sct]/status "" eval [silent "expr 0" sct slow_cmd] @@ -350,6 +375,13 @@ proc ccu4ext::writeExt {type {activate 1}} { } # fill 1 { + set level [validated_level] + if {$level eq ""} { + changestate $type off + sct update 2 + return idle + } + hupdate [sct]/smooth $level hupdate [sct]/status "" set vcmd [silent 0 sct vessel_cmd] if {$vcmd ne "0"} { diff --git a/tcl/startup/autofill.tcl b/tcl/startup/autofill.tcl index ebb203a..6cbbf6c 100644 --- a/tcl/startup/autofill.tcl +++ b/tcl/startup/autofill.tcl @@ -19,7 +19,7 @@ proc makeHeFill {levcmd} { if {$levcmd eq "ccu"} { makenv hefill he_ext_ccu ccu } elseif {$levcmd eq "ccu4ilm"} { - makenv hefill -driver ccu4ext he lev + makenv hefill -driver ccu4ext he /lev lappend fast_cmd {lev mode 1} lappend slow_cmd {lev mode 0} } else { @@ -90,7 +90,7 @@ proc makeN2Fill {{option ccu} {code 0}} { GraphAdd n2.upper K_2 N2_Upper red GraphAdd n2.lower K_2 N2_Lower green } elseif {$option eq "ccu4ilm"} { - makenv ln2fill -driver ccu4ext n2 "lev n2" + makenv ln2fill -driver ccu4ext n2 /lev/n2 GraphAdd lev.n2 % "N2_level" black if {! $c} { # switch silently to inactive From 9ea4107be3f11877b410060ccfc2651cfd13f8d7 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Mon, 18 Sep 2023 10:44:31 +0200 Subject: [PATCH 03/14] add missing dilpars proc --- tcl/startup/dilpars.tcl | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tcl/startup/dilpars.tcl diff --git a/tcl/startup/dilpars.tcl b/tcl/startup/dilpars.tcl new file mode 100644 index 0000000..6d97a17 --- /dev/null +++ b/tcl/startup/dilpars.tcl @@ -0,0 +1,8 @@ +proc apply_dilpars {} { + catch { + ts auto/condenseflow [hval dilpars/condenseflow] + } + catch { + ts auto/circulateflow [hval dilpars/circulateflow] + } +} From 93ebf716babf59d0d9b5d0512876852df84bcab4 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 19 Sep 2023 10:32:15 +0200 Subject: [PATCH 04/14] preped error message of frappy_config with ERROR: more robust with different versions frappy/sea --- tcl/startup/frappy.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/startup/frappy.tcl b/tcl/startup/frappy.tcl index 748a3b5..4621fa6 100644 --- a/tcl/startup/frappy.tcl +++ b/tcl/startup/frappy.tcl @@ -177,7 +177,7 @@ proc get_param_values {hp} { } proc check_or_do {doit service cfgs} { - # result: 1: no change needed, 0: change needed, 2: failure + # result: 1: no change needed, 0: change needed, "ERROR:...": failure set result 1 set config "" set stick "" @@ -199,7 +199,7 @@ proc check_or_do {doit service cfgs} { if {$doit} { if {[hval /device/confirmed] eq [hval /device/name]} { set msg "do not allow frappy to change from [hval /device/name] to $config" - clientlog $msg + clientlog ERROR:$msg return $msg } clientlog 0 From a35befe2004c992239591cca246d68c8b4d4dfc5 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 19 Sep 2023 10:34:02 +0200 Subject: [PATCH 05/14] MB11: make extra sea config files --- tcl/mb11.config | 3 +-- tcl/mb11.stick | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tcl/mb11.stick diff --git a/tcl/mb11.config b/tcl/mb11.config index bef6fac..9478384 100644 --- a/tcl/mb11.config +++ b/tcl/mb11.config @@ -1,4 +1,4 @@ -deviceDesc = FRAPPY history recorder, with stick +deviceDesc = MB11 Frappy history recorder set ::secop_version 4 @@ -11,6 +11,5 @@ if {[string match "prep*" $ins]} { error "runs on instruments or prep0-9 only" } else { makenv frappy_main -driver secop -port localhost:15101 - makenv frappy_stick -driver secop -port localhost:15201 makeHePump } diff --git a/tcl/mb11.stick b/tcl/mb11.stick new file mode 100644 index 0000000..613f28f --- /dev/null +++ b/tcl/mb11.stick @@ -0,0 +1,13 @@ +deviceDesc = MB11 stick Frappy history recorder + +set ::secop_version 4 + +set ins [result instrument] +if {[string match "prep*" $ins]} { + set nr [string range $ins end end] + makenv frappy_stick -driver secop -port localhost:1521$nr +} elseif {[lindex [split [info hostname] .] 0] ne $ins} { + error "runs on instruments or prep0-9 only" +} else { + makenv frappy_stick -driver secop -port localhost:15201 +} From 1d3bac2eff45cf97a3e545c51692a17cc3090846 Mon Sep 17 00:00:00 2001 From: camea Date: Tue, 19 Sep 2023 11:13:49 +0200 Subject: [PATCH 06/14] dil5.stick is now a secop connection to frappy --- tcl/dil5.stick | 61 +++++++++----------------------------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/tcl/dil5.stick b/tcl/dil5.stick index 2200687..3df72ae 100644 --- a/tcl/dil5.stick +++ b/tcl/dil5.stick @@ -1,54 +1,13 @@ -stickDesc = 100 mm dilution +deviceDesc = DIL5 Frappy history recorder -set box linse-dil5 +set ::secop_version 4 -proc triton {kind obj name db col {htrdb ""}} { - upvar box box - makenv $obj -driver itc$kind -port ${box}:33576 -controller _tritondil $db $htrdb - switch $kind { - temp { - GraphAdd $obj K_3 T_$name - # GraphAdd $obj.raw Ohm_3 R_$name - } - press { - GraphAdd $obj mbar_2 p_$name - } - } +set ins [result instrument] +if {[string match "prep*" $ins]} { + set nr [string range $ins end end] + makenv frappy_stick -driver secop -port localhost:1521$nr +} elseif {[lindex [split [info hostname] .] 0] ne $ins} { + error "runs on instruments or prep0-9 only" +} else { + makenv frappy_stick -driver secop -port localhost:15201 } - -proc itcchan {obj name dbt dbh col setcol} { - upvar box box - makenv $obj -driver itctemp -port ${box}:3000 -controller _itcdil ${dbt}.T1 ${dbh}.H1 - GraphAdd $obj K_5 T_$name - GraphAdd $obj.set K_5 T_${name}_set $setcol - # GraphAdd $obj.pow W_3 pow_$name - # GraphAdd $obj.raw Ohm_3 R_$name -} - -itcchan twstill wupstill MB1 MB0 blue cyan - -itcchan tonek oneK DB5 DB3 red orange - -itcchan twmix wupMix DB6 DB1 green lightgreen - -itcchan twivc wupIVC DB7 DB2 magenta violet - -itcchan tcond cond DB8 DB3 yellow grey - -triton temp tsorb sorb T1 dark_violet -triton temp tivc IVC T2 brown -triton temp tstill still T3 orange -triton temp tcp cond T4 grey -triton temp tmix mix T5 cyan H1 - -triton press pdump dump P1 cyan -triton press pcond cond P2 blue -triton press pstill still P3 black -triton press pfore fore P4 green -triton press pback back P5 red - -makenv tmixdrv -driver drvpar /tmix - -defineTemperature tmixdrv - - From 4a930149c264834c83cf736696a6d5933a36ea59 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Thu, 21 Sep 2023 10:52:34 +0200 Subject: [PATCH 07/14] dil: remove "there might be some mixture" message --- tcl/drivers/dil12.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/drivers/dil12.tcl b/tcl/drivers/dil12.tcl index baef43a..4aa078e 100644 --- a/tcl/drivers/dil12.tcl +++ b/tcl/drivers/dil12.tcl @@ -821,8 +821,8 @@ proc dil12::autostep {phase init} { dil12::msg "pump for 15 more seconds" } } - } elseif {[sct pumptime] != 0} { - dil12::msg "there might be some mixure in TRAP A, please check" + # } elseif {[sct pumptime] != 0} { + # dil12::msg "there might be some mixure in TRAP A, please check" } } init_pipes_ready { From 931ff58a2d7ef596d26f168a92a185ed9f3d865a Mon Sep 17 00:00:00 2001 From: tasp Date: Mon, 25 Sep 2023 13:20:22 +0200 Subject: [PATCH 08/14] make nv flow ctrl more conservative - reduce prop_o / prop_c - increase Tmin from 1.5 to 10 (for autoflow) --- tcl/drivers/ccu4flow.tcl | 4 ++-- tcl/startup/flow_ctrl.tcl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tcl/drivers/ccu4flow.tcl b/tcl/drivers/ccu4flow.tcl index ef0bbfe..7405c73 100644 --- a/tcl/drivers/ccu4flow.tcl +++ b/tcl/drivers/ccu4flow.tcl @@ -59,10 +59,10 @@ proc stdConfig::ccu4flow {args} { prop label status prop width 40 - node prop_o par 0.1 + node prop_o par 0.05 prop help {prop [sec/mbar] when opening. above 4 mbar a 10 times lower value is used} - node prop_c par 0.05 + node prop_c par 0.03 prop help {prop [sec/mbar] when closing. above 4 mbar a 10 times lower value is used} node deriv_o par 30 diff --git a/tcl/startup/flow_ctrl.tcl b/tcl/startup/flow_ctrl.tcl index a2dc8b0..450166c 100644 --- a/tcl/startup/flow_ctrl.tcl +++ b/tcl/startup/flow_ctrl.tcl @@ -151,7 +151,7 @@ proc flow::make {{getT flow::tmts} {getS "result tt tr"} {getF "result nv flow"} node difRange par 7 node flowSize par 10 node convTime par 30 - node Tmin par 1.5 + node Tmin par 10 node script -text par "flow::task" prop width 24 node getTemp -text par "$getT" From 2c13e9b091f639abd0527f47d8d088d20498dd37 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Thu, 28 Sep 2023 14:42:46 +0200 Subject: [PATCH 09/14] catch the case when sensirion is not working - add use_pressure to nv control for selecting whether nv control is using the flow from the sensirion sensor or the pump pressure - this is triggered when sensirion is reading 0 (incl. stddev) --- tcl/drivers/ccu4flow.tcl | 69 ++++++++++++++++++++++----------------- tcl/drivers/hepump.tcl | 46 ++++++++++++++------------ tcl/drivers/nvstep.tcl | 60 ++++++++++++++++++++++------------ tcl/drivers/sensirion.tcl | 10 +++--- tcl/startup/ccu4make.tcl | 6 ++-- 5 files changed, 113 insertions(+), 78 deletions(-) diff --git a/tcl/drivers/ccu4flow.tcl b/tcl/drivers/ccu4flow.tcl index 7405c73..56c32ea 100644 --- a/tcl/drivers/ccu4flow.tcl +++ b/tcl/drivers/ccu4flow.tcl @@ -8,7 +8,7 @@ proc stdConfig::ccu4flow {args} { obj ccu4flow wr prop write ccu4flow::setmode - prop read "ccu4flow::read [silent 0 result instconfig sensirion]" + prop read ccu4flow::read prop dir 1 prop enum fixed=0,controlled=1,automatic=2,close=3,open=4 prop filter 0 @@ -28,10 +28,14 @@ proc stdConfig::ccu4flow {args} { prop lastmov 0 prop hystpulse 0 prop lastist 0 + set sensirion 0 foreach arg $args { if {$arg eq "release_blocked"} { prop release_blocked 1 } + if {$arg eq "1"} { + set sensirion 1 + } } default 0 kids "needle valve" { @@ -48,29 +52,35 @@ proc stdConfig::ccu4flow {args} { node flowmax par 20 prop label "flow maximum" - + node flowp upd + prop help "flow calculated from pressure before pump" + node span upd - + + node use_pressure par -int [expr !$sensirion] + prop enum 1 + prop help "use pressure instead of flow meter for control" + node ctrl -none kids "control parameters" { node regtext upd -text default regulate prop label status prop width 40 - + node prop_o par 0.05 prop help {prop [sec/mbar] when opening. above 4 mbar a 10 times lower value is used} node prop_c par 0.03 prop help {prop [sec/mbar] when closing. above 4 mbar a 10 times lower value is used} - + node deriv_o par 30 prop help {convergence target time [sec] when opening} node deriv_c par 30 prop help {convergence target time [sec] when closing} - + node minpulse_o out default 0.05 prop help {minimum close pulse [sec]} @@ -92,11 +102,11 @@ proc stdConfig::ccu4flow {args} { node tol par 0.25 prop label tolerance prop help {valid below 3 mbar} - + node tolhigh par 0.5 prop label tol. above 4 prop help {valid above 4 mbar} - + node openpulse par 60 prop help {time to open from completely closed to a significant opening} @@ -104,7 +114,7 @@ proc stdConfig::ccu4flow {args} { prop enum 1 prop help {adjust minpulse automatically} } - + node autoflow -none kids "autoflow control parameters" { flow::make ccu4flow::tmts {result tt set/reg} @@ -112,7 +122,7 @@ proc stdConfig::ccu4flow {args} { node calib -none kids calib { node ln_per_min_per_mbar par 0.9 - node mbar_offset par 0.5 + node mbar_offset par 0.8 } } } @@ -158,21 +168,19 @@ proc ccu4flow::check_minpulse {dir} { sct update [sct target] } -proc ccu4flow::read {{sensirion 0}} { +proc ccu4flow::read {} { hsetprop /cc/fa nvpath [sct] _cc updatescript /cc/fa ccu4flow::updatemode hsetprop /cc/f nvpath [sct] - if {$sensirion} { - hsetprop /nvflow flowsource flowmeter + hsetprop /cc/f nvctrl [sct controller] + hsetprop /cc/f flowsource pressure + _cc updatescript /cc/f ccu4flow::updateflow + catch { + hsetprop /nvflow flowsource flow hsetprop /nvflow nvpath [sct] hsetprop /nvflow nvctrl [sct controller] _hemot updatescript /nvflow ccu4flow::updateflow - hsetprop /cc/f flowsource pressref - } else { - hsetprop /cc/f nvctrl [sct controller] - hsetprop /cc/f flowsource flowpress } - _cc updatescript /cc/f ccu4flow::updateflow return unpoll } @@ -220,11 +228,10 @@ proc ccu4flow::updatemode {value} { proc ccu4flow::updateflow {value} { # flowsource: - # pressref: just update nv/flowp - # flowmeter: update nv/flow - # flowpress: flow from pressure + # pressure: this is a pressure + # flow: this is a flow from a flowmeter - set source [silent pressure sct flowsource] + set source [silent none sct flowsource] set n [silent 9 sct filter_n] set filter [lrange "[silent $value sct filter] $value" end-$n end] sct filter $filter @@ -257,9 +264,9 @@ proc ccu4flow::updateflow {value} { } } sct filtered $flow - if {$source eq "flowmeter"} { + if {$source eq "flow"} { updateval [sct nvpath]/flow $flow - } else { + } elseif {$source eq "pressure"} { if {$flow < -50} { set flow -62.5 } else { @@ -267,12 +274,10 @@ proc ccu4flow::updateflow {value} { set fpm [hval [sct nvpath]/calib/ln_per_min_per_mbar] set flow [expr ($flow - $off) * $fpm] } - if {$source eq "pressref"} { - hupdate [sct nvpath]/flowp $flow - return - } - updateval_e [sct nvpath]/flow $flow -62.5 no_sensor + updateval_e [sct nvpath]/flowp $flow -62.5 no_sensor hupdate [sct nvpath]/span $span + } else { + error "[sct] illegal flowsource: $source" } [sct nvctrl] queue [sct nvpath] read ccu4flow::ctrl } @@ -384,7 +389,11 @@ proc ccu4flow::ctrl {} { } set regstate [sct regstate] set now [DoubleTime] - set ist [hvali [sct]/flow] + if {[hval [sct]/use_pressure]} { + set ist [hvali [sct]/flowp] + } else { + set ist [hvali [sct]/flow] + } set tol [hvali [sct]/ctrl/tol] set tolhigh [hvali [sct]/ctrl/tolhigh] set closestate 0 diff --git a/tcl/drivers/hepump.tcl b/tcl/drivers/hepump.tcl index 5f0a952..fe86974 100644 --- a/tcl/drivers/hepump.tcl +++ b/tcl/drivers/hepump.tcl @@ -160,29 +160,33 @@ proc hepump::set_calib {} { hsetprop /nv off_reason "pump mode changed" sct print "pump mode change: suspend needle valve control for 20 sec." } - return idle + return idle } proc hepump::read {} { - 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 / 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} { - sct health_cnt 0 - hupdate [sct]/health [format %.1f $health] - } else { - 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 - } + set p [silent 0 result nv flowp] + set f [silent 0 result nv flow] + set p_buf [silent 0 sct p_buf] + set f_buf [silent 0 sct f_buf] + lappend p_buf $p + lappend f_buf $f + sct p_buf [lrange $p_buf end-30 end] + sct f_buf [lrange $f_buf end-30 end] + set pmin [tcl::mathfunc::min {*}$p_buf] + set pmax [tcl::mathfunc::max {*}$p_buf] + set fmin [tcl::mathfunc::min {*}$f_buf] + set fmax [tcl::mathfunc::max {*}$f_buf] + if {[silent 0 hval [sct]/eco] == 0 && $pmin >= 1 && $fmin >= 0.5 && $fmin < 25} { + set hmax [expr round(100 * $fmax / ($pmin - 0.4))] + set hmin [expr round(100 * $fmin / ($pmax - 0.4))] + set health [silent 100 hval [sct]/health] + if {$hmax < $health} { + set health $hmax + } elseif {$hmin > $health} { + set health $hmin } - } else { - # reset filter - hdelprop [sct] health + hupdate [sct]/health $health + catch {prep0 / pump_health_update [result instrument] [expr min($health, 100)]} msg } return [hepump::set_calib] } @@ -400,7 +404,9 @@ proc hepump::get_auto {} { if {$auto && $oldeco != 2} { set eco [sctval [sct parent]/eco] set lim [sctval [sct parent]/eco_t_lim 7] - if {[silent 10 hval /tt/target] < $lim && [silent 10 hval /tt] < 2 * $lim} { + if {[silent 0 result nv use_pressure]} { + set ecoset 0 + } elseif {[silent 10 hval /tt/target] < $lim && [silent 10 hval /tt] < 2 * $lim} { set ecoset 0 } elseif {[silent 10 hval /tt/target] > $lim || [silent 10 hval /tt] > 3 * $lim} { set ecoset 1 diff --git a/tcl/drivers/nvstep.tcl b/tcl/drivers/nvstep.tcl index 67541d3..c257f67 100644 --- a/tcl/drivers/nvstep.tcl +++ b/tcl/drivers/nvstep.tcl @@ -1,7 +1,7 @@ namespace eval nvstep { } -proc stdConfig::nvstep {} { +proc stdConfig::nvstep {args} { variable name controller syncedprot @@ -9,7 +9,7 @@ proc stdConfig::nvstep {} { obj NvStep wr prop write nvstep::write - prop read "nvstep::read [silent 0 result instconfig sensirion]" + prop read nvstep::read prop enum fixed=0,controlled=1,automatic=2,close=3,open=4 prop write nvstep::write prop lastpulse 0 @@ -22,6 +22,13 @@ proc stdConfig::nvstep {} { prop maxflow 0 default 0 + set sensirion 0 + foreach arg $args { + if {$arg eq "1"} { + set sensirion 1 + } + } + kids "needle value" { node flow upd @@ -39,6 +46,10 @@ proc stdConfig::nvstep {} { node flowp upd prop help "flow calculated from pressure before pump" + node use_pressure par -int [expr !$sensirion] + prop enum 1 + prop help "use pressure instead of flow meter for control" + node ctrl -none kids "control parameters" { node prop par 10 @@ -172,7 +183,11 @@ proc nvstep::poll {} { hupdate [sct]/status $umsg } } - set ist [hvali [sct]/flow] + if {[hval [sct]/use_pressure]} { + set ist [hvali [sct]/flowp] + } else { + set ist [hvali [sct]/flow] + } set tol [hvali [sct]/ctrl/tol] set a [sct amplitude] set t [sct t_after_delay] @@ -270,29 +285,26 @@ proc nvstep::poll {} { return idle } -proc nvstep::read {{sensirion 0}} { +proc nvstep::read {} { hsetprop /cc/fa nvpath [sct] _cc updatescript /cc/fa nvstep::updatemode hsetprop /cc/f nvpath [sct] - if {$sensirion} { - hsetprop /nvflow flowsource flowmeter + hsetprop /cc/f nvctrl [sct controller] + hsetprop /cc/f flowsource pressure + _cc updatescript /cc/f nvstep::updateflow + catch { + hsetprop /nvflow flowsource flow hsetprop /nvflow nvpath [sct] hsetprop /nvflow nvctrl [sct controller] _hemot updatescript /nvflow nvstep::updateflow - hsetprop /cc/f flowsource pressref - } else { - hsetprop /cc/f nvctrl [sct controller] - hsetprop /cc/f flowsource flowpress } - _cc updatescript /cc/f nvstep::updateflow return unpoll } proc nvstep::updateflow {value} { # flowsource: - # pressref: just update nv/flowp - # flowmeter: update nv/flow - # flowpress: flow from pressure + # pressure: this is a pressure + # flow: this is a flow from a flowmeter set source [silent pressure sct flowsource] set filter [lrange "[silent $value sct filter] $value" end-9 10] @@ -317,21 +329,27 @@ proc nvstep::updateflow {value} { } } sct filtered $flow - if {$source eq "flowmeter"} { + if {$source eq "flow"} { + if {$flow < 1} { + # avoid negative flow values, but it smooth] + set flow [expr exp($flow - 1)] + } updateval [sct nvpath]/flow $flow - } else { + } elseif {$source eq "pressure" { if {$flow < -50} { set flow -62.5 } else { set off [hval [sct nvpath]/calib/mbar_offset] set fpm [hval [sct nvpath]/calib/ln_per_min_per_mbar] set flow [expr ($flow - $off) * $fpm] + if {$flow < 1} { + # avoid negative flow values, but keep it smooth] + set flow [expr exp($flow - 1)] + } } - if {$source eq "pressref"} { - hupdate [sct nvpath]/flowp $flow - return - } - updateval_e [sct nvpath]/flow $flow -62.5 no_sensor + updateval_e [sct nvpath]/flowp $flow -62.5 no_sensor + } else { + error "[sct] illegal flowsource: $source" } [sct nvctrl] queue [sct nvpath] read nvstep::poll } diff --git a/tcl/drivers/sensirion.tcl b/tcl/drivers/sensirion.tcl index 3806849..6e8438e 100644 --- a/tcl/drivers/sensirion.tcl +++ b/tcl/drivers/sensirion.tcl @@ -61,11 +61,11 @@ proc stdConfig::sensirion {} { proc sensirion::updateFlow {} { lassign [sct result] flow stddev - if {$flow == 0 && $stddev == 0} { - if {[hgetpropval /nvflow flowsource] eq "flowmeter"} { - hsetprop /nvflow flowsource flowpress - hepump eco 0 - error "invalid flow -> switched to pressure" + if {$flow == 0 && $stddev == 0 || [silent 0 sct simerror]} { + set use_pressure [silent 0 hval /nv/use_pressure] + if {! $use_pressure} { + hset /nv/use_pressure 1 + clientput "ERROR: invalid flow -> switched to pressure" } } sct update $flow diff --git a/tcl/startup/ccu4make.tcl b/tcl/startup/ccu4make.tcl index 2143b2a..1a12085 100644 --- a/tcl/startup/ccu4make.tcl +++ b/tcl/startup/ccu4make.tcl @@ -20,13 +20,14 @@ proc makeCCU4 {args} { set badargs [list] set cfgdev "0" set hepump 0 + set sensirion [silent 0 result instconfig sensirion] foreach arg $args { switch $arg { nv - nv_release_blocked { if {$arg eq "nv_release_blocked"} { - makenv nv -driver ccu4flow release_blocked + makenv nv -driver ccu4flow release_blocked $sensirion } else { - makenv nv -driver ccu4flow + makenv nv -driver ccu4flow $sensirion } # GraphAdd cc.f mbar nv_flow red GraphAdd nv.flow ln/min nv_flow magenta @@ -117,6 +118,7 @@ proc makeCCU4 {args} { } if {$hepump} { makeHePump + hsetprop /nv hepump /hepump } set cfg [ccu4_get_device_config $cfgdev codesfile] if {$cfg eq "" || [llength $badargs] > 0} { From 8fcd4f8e1a25b26b3a314fbb3ab92f3b86864c17 Mon Sep 17 00:00:00 2001 From: zebra Date: Thu, 5 Oct 2023 08:22:50 +0200 Subject: [PATCH 10/14] fix stick sensors on reload it seems stick sensors are not installed properly sometimes after restart. fix_stick_sensors is triggered for execution on creation of an lsc object --- tcl/drivers/lsc.tcl | 3 ++- tcl/seacom.tcl | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tcl/drivers/lsc.tcl b/tcl/drivers/lsc.tcl index 176ff80..b89ac9d 100644 --- a/tcl/drivers/lsc.tcl +++ b/tcl/drivers/lsc.tcl @@ -895,7 +895,7 @@ proc lsc::set_curve {} { } #write action, direct -proc lsc::check_header {id} { +proc lsc::check_header {{id unknown}} { upvar #0 lsc::cache_$id cache if {[lsc::hdreq $cache([sct curveno]) [sct result]]} { sct oldhdr [sct result] @@ -4626,6 +4626,7 @@ proc stdConfig::lsc_end {} { if {$lsc(samplesensor) eq ""} { set lsc(samplesensor) $lsc(mainsensor) } + dolater 0 fix_stick_sensors hsetprop $path getcmd "hvali $path/$lsc(mainsensor)" hsetprop $path getsample "hvali $path/$lsc(samplesensor)" if {[silent "" set lsc(setsample)] ne ""} { diff --git a/tcl/seacom.tcl b/tcl/seacom.tcl index eadf5de..b1bfb82 100644 --- a/tcl/seacom.tcl +++ b/tcl/seacom.tcl @@ -652,6 +652,16 @@ proc stick_sensors {sensor1 sensor2} { } } +proc fix_stick_sensors {} { + # fix stick sensors + foreach path {/tt/ts/curve /tt/ts_2/curve} { + set curv [silent "" hval $path] + if {$curv ne ""} { + hset $path $curv + } + } +} + proc ts_sensor {sensor} { catch { catch { From 33296cc03b8ed643b59eb70f132bbbe4a35d9713 Mon Sep 17 00:00:00 2001 From: zebra Date: Thu, 5 Oct 2023 08:24:52 +0200 Subject: [PATCH 11/14] do not trigger error on level reading when inactive --- tcl/drivers/ccu4ext.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcl/drivers/ccu4ext.tcl b/tcl/drivers/ccu4ext.tcl index c3b15d9..5e3e837 100644 --- a/tcl/drivers/ccu4ext.tcl +++ b/tcl/drivers/ccu4ext.tcl @@ -181,7 +181,7 @@ proc ccu4ext::fillExt {type} { set rdpath [hvali [sct]/readpath] set level [hvali $rdpath] set levelerror [silent "" hgetpropval $rdpath geterror] - if {$levelerror ne "" && $errtxt eq ""} { + if {$levelerror ne "" && $errtxt eq "" && [hvali [sct]] < 2} { set errtxt "$txt ($rdpath $levelerror)" } if {$errtxt eq ""} { From 55c17cc04d235493522bbe39bf2848d52225b627 Mon Sep 17 00:00:00 2001 From: zebra Date: Thu, 5 Oct 2023 08:27:21 +0200 Subject: [PATCH 12/14] ma6: increase flow --- .gitignore | 2 ++ tcl/ma6.config | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 87933ac..71cc3c6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ CVS /focus /hifi /hrpt +/hrpt2 /morpheus /poldi /ppms @@ -40,6 +41,7 @@ CVS /seaman /tasp /zebra +/zebra2 /logger_tar cheat_chart tcl/stuff_before_2022 diff --git a/tcl/ma6.config b/tcl/ma6.config index 27c7ad0..7686898 100644 --- a/tcl/ma6.config +++ b/tcl/ma6.config @@ -12,7 +12,7 @@ makenv tt -driver [lsdriver] { lsc_sensor ts_2 C -sensor code -sensorname sample2 lsc_loop set -loop 1 -channel A -maxheater 32W -resist 80Ohm -color green if {[lsdriver] eq "336_lsc"} { - lsc_loop setsamp -loop 2 -channel C -maxheater 62.5W -resist 20Ohm -color dark_green -loopname sample + lsc_loop setsamp -loop 2 -channel D -maxheater 62.5W -resist 20Ohm -color dark_green -loopname sample } } @@ -20,7 +20,7 @@ makenv tt -driver [lsdriver] { makeCCU4 ma6 nv he_ilm -hupdate /nv/set 1.2 +hupdate /nv/set 1.5 makeN2Fill ccu4ilm { ln2fill lowlevel 10 ln2fill highlevel 100 From 6c4e7989afdb3e62412e8ebd80a3b4b378c11f74 Mon Sep 17 00:00:00 2001 From: zebra Date: Wed, 18 Oct 2023 14:59:23 +0200 Subject: [PATCH 13/14] MA^: stick sample sensor o.k., sensor2 defect --- tcl/ma6.config | 10 +++++----- tcl/ma6.stick | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tcl/ma6.config b/tcl/ma6.config index 7686898..3c34aef 100644 --- a/tcl/ma6.config +++ b/tcl/ma6.config @@ -5,14 +5,14 @@ device stick_menu "ma6 dil2 dil3 dil4 coil" makenv tt -driver [lsdriver] { lsc_sensor tm A -sensor x48581 -sensorname VTI + lsc_sensor ts C -sensorname sample + lsc_sensor ts_2 D -sensor code -sensorname sample2 # 2023-07-06: sample sensor seems defect, use hx sensor -# lsc_sensor ts C -sensorname sample -# lsc_sensor ts_2 D -sensor code -sensorname sample2 - lsc_sensor ts D -sensorname sample - lsc_sensor ts_2 C -sensor code -sensorname sample2 +# lsc_sensor ts D -sensorname sample +# lsc_sensor ts_2 C -sensor code -sensorname sample2 lsc_loop set -loop 1 -channel A -maxheater 32W -resist 80Ohm -color green if {[lsdriver] eq "336_lsc"} { - lsc_loop setsamp -loop 2 -channel D -maxheater 62.5W -resist 20Ohm -color dark_green -loopname sample + lsc_loop setsamp -loop 2 -channel C -maxheater 62.5W -resist 20Ohm -color dark_green -loopname sample } } diff --git a/tcl/ma6.stick b/tcl/ma6.stick index 9870b81..a1fbd2c 100644 --- a/tcl/ma6.stick +++ b/tcl/ma6.stick @@ -1,4 +1,4 @@ stickDesc = standard MA6 stick -stick_sensors x63163 undefined -# stick_sensors x63161 x63163 +stick_sensors x63161 undefined +#stick_sensors x63161 x63163 # sensor 2 wiring defect From 759f7ac06c38aba45495d0e2fc05d1c6d9a61a5e Mon Sep 17 00:00:00 2001 From: zebra Date: Wed, 18 Oct 2023 15:15:16 +0200 Subject: [PATCH 14/14] fix sitck sensor stuff - code not found in stick table -> must match with code undefined - fix_stick_sensors must use sctval, not hval --- tcl/seacom.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/seacom.tcl b/tcl/seacom.tcl index b1bfb82..260c381 100644 --- a/tcl/seacom.tcl +++ b/tcl/seacom.tcl @@ -628,7 +628,7 @@ proc stick_sensors {sensor1 sensor2} { source config/stick.list if {[string match "code*" $sensor2]} { set code [lindex [split $sensor2=0 =] 1] - set table_code [silent -1 set stick_cfgtable($stick_name)] + set table_code [silent 0 set stick_cfgtable($stick_name)] if {$table_code != $code} { clientput "ERROR: code $code in $stick_name.stick does not match value from config/sticklist: $table_code" } @@ -655,7 +655,7 @@ proc stick_sensors {sensor1 sensor2} { proc fix_stick_sensors {} { # fix stick sensors foreach path {/tt/ts/curve /tt/ts_2/curve} { - set curv [silent "" hval $path] + set curv [silent "" sctval $path] if {$curv ne ""} { hset $path $curv }