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)
This commit is contained in:
l_samenv
2023-09-28 14:42:46 +02:00
parent 882c55e95a
commit 2c13e9b091
5 changed files with 113 additions and 78 deletions

View File

@ -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
}