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

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