Files
sea/tcl/linear_ramp.tcl
2022-08-18 15:04:28 +02:00

48 lines
924 B
Tcl

# linear ramp for keithley 2450
proc first {old target} {
# called first on run / drive
# throw an error if not in limits
# <old> the actual measured value
# <target> the value to go to
# make the first step
hset [sct]/set $old
}
proc check {voltage current} {
# called every second
# <v> measured voltage
# <i> measured current
return 1
}
proc step {set step target} {
# called every <delay> seconds
# <set> <step> <target> from object
# [sct objectName] is the name of the calling object
if {$target > $set} {
set step [expr abs($step)]
} else {
set step [expr -abs($step)]
}
if {$step == 0} {
# loop forever
return 1
}
set next [expr $set + $step]
set remaining [expr ($target - $next) / $step]
if {$remaining <= 0.01} {
[sct objectName] set $target
return 0
}
[sct objectName] set $next
return 1
}
proc halt {} {
# script called on stop
}