sct_julabo_lh45.tcl

Add bath temperature to feedback.   Allow switching between reading the
bath or external sensor for the sensor value. Check the data type of
replies from the Julabo because it can return values like "___.__" if
you're reading the wrong sensor.

sct_lakeshore_340.tcl, sct_lakeshore_336.tcl
Use the tolerance set on the control/tolerance node so the user can
change it while running.

r3348 | ffr | 2012-01-20 15:25:46 +1100 (Fri, 20 Jan 2012) | 10 lines
This commit is contained in:
Ferdi Franceschini
2012-01-20 15:25:46 +11:00
committed by Douglas Clowes
parent 2d56b5ea5f
commit f498b3ce6a
3 changed files with 56 additions and 15 deletions

View File

@@ -14,6 +14,13 @@ namespace eval ::scobj::lh45 {
sct send $cmd
return $nextState
}
proc getTemp {nextState} {
if [hpropexists [sct] geterror] {
hdelprop [sct] geterror
}
sct send [sct tempsensor]
return $nextState
}
proc setValue {nextState cmd} {
set par [sct target]
sct send "$cmd $par"
@@ -34,22 +41,33 @@ namespace eval ::scobj::lh45 {
# }
hset $tc_root/power 1
hset $tc_root/status "busy"
if {[sct writestatus] == "start"} {
# Called by drive adapter
hsetprop $tc_root/setpoint driving 1
}
sct send "$cmd $par"
sct setpoint_pending 0
return $nextState
}
proc rdValue {} {
proc rdValue {{type "wordchar"}} {
set data [sct result]
switch -glob -- $data {
"ASCERR:*" {
sct geterror $data
}
default {
if {$data != [sct oldval]} {
sct oldval $data
sct update $data
sct utime readtime
if [string is $type $data] {
if {$data != [sct oldval]} {
sct oldval $data
sct update $data
sct utime readtime
}
} else {
set errmsg "[sct] Expected $data to be of type $type"
sct geterror $errmsg
error $errmsg
}
}
}
@@ -175,6 +193,7 @@ namespace eval ::scobj::lh45 {
default {
hset $tc_root/remote_ctrl UNKNOWN
hset $tc_root/lh45_lasterror $data
error $data
}
}
}
@@ -231,7 +250,7 @@ namespace eval ::scobj::lh45 {
hsetprop $scobj_hpath/setpoint read ${ns}::getValue rdValue "in_sp_00"
hsetprop $scobj_hpath/setpoint write ${ns}::setPoint $scobj_hpath noResponse "out_sp_00"
hsetprop $scobj_hpath/setpoint check ${ns}::check $scobj_hpath
hsetprop $scobj_hpath/setpoint rdValue ${ns}::rdValue
hsetprop $scobj_hpath/setpoint rdValue ${ns}::rdValue "double"
hsetprop $scobj_hpath/setpoint noResponse ${ns}::noResponse
hsetprop $scobj_hpath/setpoint oldval UNKNOWN
hsetprop $scobj_hpath/setpoint driving 0
@@ -246,23 +265,31 @@ namespace eval ::scobj::lh45 {
hfactory $scobj_hpath/overtemp_warnlimit plain user float
hsetprop $scobj_hpath/overtemp_warnlimit read ${ns}::getValue rdValue "in_sp_03"
# hsetprop $scobj_hpath/overtemp_warnlimit write ${ns}::setValue noResponse "out_sp_03"
hsetprop $scobj_hpath/overtemp_warnlimit rdValue ${ns}::rdValue
hsetprop $scobj_hpath/overtemp_warnlimit rdValue ${ns}::rdValue "double"
hsetprop $scobj_hpath/overtemp_warnlimit noResponse ${ns}::noResponse
hsetprop $scobj_hpath/overtemp_warnlimit oldval UNKNOWN
hfactory $scobj_hpath/subtemp_warnlimit plain user float
hsetprop $scobj_hpath/subtemp_warnlimit read ${ns}::getValue rdValue "in_sp_04"
# hsetprop $scobj_hpath/subtemp_warnlimit write ${ns}::setValue noResponse "out_sp_04"
hsetprop $scobj_hpath/subtemp_warnlimit rdValue ${ns}::rdValue
hsetprop $scobj_hpath/subtemp_warnlimit rdValue ${ns}::rdValue "double"
hsetprop $scobj_hpath/subtemp_warnlimit noResponse ${ns}::noResponse
hsetprop $scobj_hpath/subtemp_warnlimit oldval UNKNOWN
hfactory $scobj_hpath/sensor plain spy none
hfactory $scobj_hpath/sensor/value plain internal float
hsetprop $scobj_hpath/sensor/value read ${ns}::getValue rdValue "in_pv_02"
hsetprop $scobj_hpath/sensor/value rdValue ${ns}::rdValue
# Default to bath temperature sensor
hsetprop $scobj_hpath/sensor/value tempsensor "in_pv_00"
hsetprop $scobj_hpath/sensor/value read ${ns}::getValue rdValue {[sct tempsensor]}
hsetprop $scobj_hpath/sensor/value rdValue ${ns}::rdValue "double"
hsetprop $scobj_hpath/sensor/value oldval UNKNOWN
hsetprop $scobj_hpath/sensor/value units "C"
hfactory $scobj_hpath/sensor/bathtemp plain internal float
hsetprop $scobj_hpath/sensor/bathtemp read ${ns}::getValue rdValue "in_pv_00"
hsetprop $scobj_hpath/sensor/bathtemp rdValue ${ns}::rdValue "double"
hsetprop $scobj_hpath/sensor/bathtemp oldval UNKNOWN
hsetprop $scobj_hpath/sensor/bathtemp units "C"
hfactory $scobj_hpath/sensor/start_temperature plain user float
hfactory $scobj_hpath/sensor/end_temperature plain user float
# proc ${ns}::OnFirstSave {} [subst -nocommands {
@@ -342,6 +369,7 @@ namespace eval ::scobj::lh45 {
$sct_controller poll $scobj_hpath/power
$sct_controller write $scobj_hpath/power
$sct_controller poll $scobj_hpath/sensor/value
$sct_controller poll $scobj_hpath/sensor/bathtemp
$sct_controller poll $scobj_hpath/lh45_state 5 halt read
}
@@ -381,12 +409,25 @@ namespace eval ::scobj::lh45 {
# @param name, then name of the temperature controller (eg tc1)
# @param IP, the IP address of the device, this can be a hostname, (eg ca5-quokka)
# @param port, the IP protocol port number of the device
# @param sensor (optional), select the 'bath' sensor or an external sensor 'ext'
# @param _tol (optional), this is the initial tolerance setting
proc add_lh45 {name IP port {_tol 5.0}} {
proc add_lh45 {name IP port {sensor "bath"} {_tol 5.0}} {
if {[SplitReply [environment_simulation]]=="false"} {
makesctcontroller sct_lh45 std ${IP}:$port "\r"
}
mk_sct_julabo_lh45 sct_lh45 environment $name $_tol
set scobj_hpath /sics/$name
switch $sensor {
"bath" {
hsetprop $scobj_hpath/sensor/value tempsensor "in_pv_00"
}
"ext" {
hsetprop $scobj_hpath/sensor/value tempsensor "in_pv_02"
}
"default" {
return -code error "ERROR: sensor should be 'bath' or 'ext'"
}
}
makesctemon $name /sics/$name/emon/monmode /sics/$name/emon/isintol /sics/$name/emon/errhandler
}

View File

@@ -634,9 +634,9 @@ proc inTolerance {tc_root rdCmd CtrlLoopIdx} {
set temp [hval $nodename]
set diff [expr {abs($setpt - $temp)}]
# [get_param $tc_root ls336_driveTolerance] = 0.2 Kelvin
set tol [get_param $tc_root ls336_driveTolerance1]
set tol [hval $tc_root/control/tolerance1]
if {$CtrlLoopIdx == 2} {
set tol [get_param $tc_root ls336_driveTolerance2]
set tol [hval $tc_root/control/tolerance2]
}
# if $diff > $tol
if {$intol==0} {

View File

@@ -738,9 +738,9 @@ proc inTolerance {CtrlLoopIdx} {
# puts "inTolerance(): comparing sensor/setpoint$CtrlLoopIdx=$setpt with actual sensorValue$iSensor=$temp"
set diff [expr {abs($setpt - $temp)}]
# $::scobj::ls340::ls340_driveTolerance = 0.2 Kelvin
set tol $::scobj::ls340::ls340_driveTolerance1
set tol [hval $tc_root/control/tolerance1]
if {$CtrlLoopIdx == 2} {
set tol $::scobj::ls340::ls340_driveTolerance2
set tol [hval $tc_root/control/tolerance2]
}
# puts "inTolerance(): diff=$diff tol=$tol"
# if $diff > $tol