From 6fa7cf88673a0fda0b2973e678cfd0d62a64e182 Mon Sep 17 00:00:00 2001 From: dmc Date: Tue, 22 Oct 2024 10:28:58 +0200 Subject: [PATCH] dblctrl: smart selection of mode (up, down, stable) when switching from inactive to active --- tcl/drivers/trun.tcl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tcl/drivers/trun.tcl b/tcl/drivers/trun.tcl index 7390b86..6597218 100644 --- a/tcl/drivers/trun.tcl +++ b/tcl/drivers/trun.tcl @@ -447,7 +447,16 @@ proc trun::read_run {} { } if {$dblctrl} { if {[hval [sct]/dblctrl/mode] == 0} { # inactive -> stable - hupdate [sct]/dblctrl/mode 1 + set tol [hvali [sct]/tolerance] + set tg [silent $tsample sct target] + if {$tg > $tsample + $tol} { + set dmode 2 ;# up + } elseif {$tg < $tsample - $tol} { + set dmode 3 ;# down + } else { + set dmode 1 ;# stable + } + hupdate [sct]/dblctrl/mode $dmode } set value $tsample } else {