231 lines
5.4 KiB
Tcl
231 lines
5.4 KiB
Tcl
# cf commands for driving sample environment
|
|
# ajs feb 2015
|
|
|
|
# cf namespace
|
|
# assumes tc1 and tc2 are the cf8 336 and 340 lakeshores for now
|
|
|
|
namespace eval cf {
|
|
variable wall_lag 10
|
|
variable wall_max 200
|
|
variable sample_tolerance 5
|
|
variable wall_tolerance 5
|
|
variable wall_set true
|
|
variable base_set true
|
|
variable base_control true
|
|
variable wall_control true
|
|
|
|
proc UseWall {_wall_set _wall_control} {
|
|
variable wall_set
|
|
variable wall_control
|
|
if {$_wall_set == false} {set wall_set false} else {set wall_set true}
|
|
if {$_wall_control == false} {set wall_control false} else {set wall_control true}
|
|
}
|
|
|
|
proc UseBase {_base_set _base_control} {
|
|
variable base_set
|
|
variable base_control
|
|
if {$_base_set == false} {set base_set false} else {set base_set true}
|
|
if {$_base_control == false} {set base_control false} else {set base_control true}
|
|
}
|
|
|
|
proc RampOn {rate} {
|
|
variable base_set
|
|
variable wall_set
|
|
|
|
hset /sample/tc1/control/ramp_Loop_1 1,$rate
|
|
if {$base_set} {hset /sample/tc1/control/ramp_Loop_2 1,$rate}
|
|
if {$wall_set} {hset /sample/tc2/control/ramp_Loop_1 1,$rate}
|
|
wait 5
|
|
}
|
|
|
|
proc RampOff {} {
|
|
variable base_set
|
|
variable wall_set
|
|
|
|
hset /sample/tc1/control/ramp_Loop_1 0,5
|
|
if {$base_set} {hset /sample/tc1/control/ramp_Loop_2 0,5}
|
|
if {$wall_set} {hset /sample/tc2/control/ramp_Loop_1 0,5}
|
|
wait 5
|
|
|
|
}
|
|
|
|
|
|
proc WallParams {_wall_lag _wall_max _wall_tolerance} {
|
|
variable wall_lag
|
|
variable wall_max
|
|
variable wall_tolerance
|
|
set wall_lag $_wall_lag
|
|
set wall_max $_wall_max
|
|
set wall_tolerance $_wall_tolerance
|
|
hset /sample/tc2/control/tolerance1 $wall_tolerance
|
|
}
|
|
|
|
proc TempSet {temp} {
|
|
variable wall_lag
|
|
variable wall_max
|
|
variable base_set
|
|
variable wall_set
|
|
set tempc [expr {$temp - $wall_lag}]
|
|
if {$tempc < 4} {set tempc 4}
|
|
if {$tempc > $wall_max} {set tempc $wall_max}
|
|
hset /sample/tc1/sensor/setpoint1 $temp
|
|
if {$base_set} {hset /sample/tc1/sensor/setpoint2 $temp}
|
|
if {$wall_set} {hset /sample/tc2/sensor/setpoint1 $tempc}
|
|
}
|
|
|
|
proc TempDrive {temp} {
|
|
variable wall_lag
|
|
variable wall_max
|
|
variable base_control
|
|
variable wall_control
|
|
TempSet $temp
|
|
set tempc [expr {$temp - $wall_lag}]
|
|
if {$tempc < 4} {set tempc 4}
|
|
if {$tempc > $wall_max} {set tempc $wall_max}
|
|
set drstr "drive tc1_driveable \$temp"
|
|
if {$base_control} {append drstr " tc1_driveable2 \$temp"}
|
|
if {$wall_control} {append drstr " tc2_driveable \$tempc"}
|
|
eval $drstr
|
|
}
|
|
|
|
proc Tolerance {sample} {
|
|
hset /sample/tc1/control/tolerance1 $sample
|
|
hset /sample/tc1/control/tolerance2 $sample
|
|
}
|
|
|
|
proc MakeCold {} {
|
|
variable sample_tolerance
|
|
variable wall_tolerance
|
|
Tolerance 20
|
|
hset /sample/tc2/control/tolerance1 20
|
|
hset /sample/tc2/sensor/setpoint1 4
|
|
TempDrive 4
|
|
Tolerance $sample_tolerance
|
|
hset /sample/tc2/control/tolerance1 $wall_tolerance
|
|
wait 300
|
|
}
|
|
|
|
|
|
proc TempRun {temp delay numsteps oscno} {
|
|
RampOff
|
|
TempDrive $temp
|
|
wait $delay
|
|
newfile HISTOGRAM_XY
|
|
for {set i 0} {$i < $numsteps} {incr i} {
|
|
oct oscillate_count $oscno
|
|
oct oscillate start
|
|
hmm countblock
|
|
save $i
|
|
}
|
|
}
|
|
|
|
proc StepRun {start step fin oscno delay} {
|
|
RampOff
|
|
histmem mode unlimited
|
|
newfile HISTOGRAM_XY
|
|
set loopvar 1
|
|
set i 0
|
|
while {$loopvar} {
|
|
set j [expr {$i*$step+$start}]
|
|
if {$j> $fin && $step > 0} {break}
|
|
if {$j< $fin && $step < 0} {break}
|
|
TempSet $j
|
|
wait $delay
|
|
oct oscillate_count $oscno
|
|
oct oscillate start
|
|
hmm countblock
|
|
save $i
|
|
incr i
|
|
}
|
|
}
|
|
|
|
proc StepWaitRun {start step fin oscno delay} {
|
|
RampOff
|
|
histmem mode unlimited
|
|
newfile HISTOGRAM_XY
|
|
set loopvar 1
|
|
set i 0
|
|
while {$loopvar} {
|
|
set j [expr {$i*$step+$start}]
|
|
if {$j> $fin && $step > 0} {break}
|
|
if {$j< $fin && $step < 0} {break}
|
|
TempDrive $j
|
|
wait $delay
|
|
oct oscillate_count $oscno
|
|
oct oscillate start
|
|
hmm countblock
|
|
save $i
|
|
incr i
|
|
}
|
|
}
|
|
|
|
|
|
proc RampRun {start rate fin oscno} {
|
|
|
|
RampOff
|
|
TempSet $start
|
|
wait 5
|
|
set tim1 [clock seconds]
|
|
set tlength [expr abs($start-$fin)/($rate/60.0)]
|
|
broadcast $rate $tlength
|
|
RampOn $rate
|
|
wait 5
|
|
TempSet $fin
|
|
set bool 0
|
|
set i 0
|
|
histmem mode unlimited
|
|
newfile HISTOGRAM_XY
|
|
while {$bool==0} {
|
|
oct oscillate_count $oscno
|
|
oct oscillate start
|
|
hmm countblock
|
|
save $i
|
|
incr i
|
|
set tim2 [expr [clock seconds]-$tim1]
|
|
broadcast $tim2
|
|
if {$tim2>$tlength} {set bool 1}
|
|
}
|
|
RampOff
|
|
|
|
}
|
|
|
|
proc HeaterOn {} {
|
|
variable base_set
|
|
variable wall_set
|
|
|
|
hset /sample/tc1/heater/heaterRange_1 4
|
|
if {$base_set} {hset /sample/tc1/heater/heaterRange_2 4}
|
|
if {$wall_set} {hset /sample/tc2/heater/heaterRange 5}
|
|
}
|
|
|
|
proc HeaterOff {} {
|
|
variable base_set
|
|
variable wall_set
|
|
|
|
hset /sample/tc1/heater/heaterRange_1 0
|
|
if {$base_set} {hset /sample/tc1/heater/heaterRange_2 0}
|
|
if {$wall_set} {hset /sample/tc2/heater/heaterRange 0}
|
|
}
|
|
|
|
proc GetTemp {} {
|
|
variable base_set
|
|
set t1top [hget /sample/tc1/sensor/sensorValueA]
|
|
broadcast "sample top : $t1top"
|
|
|
|
if {$base_set} {
|
|
set t1base [hget /sample/tc1/sensor/sensorValueB]
|
|
broadcast "sample base: $t1base"
|
|
}
|
|
set t1wall [hget /sample/tc2/sensor/sensorValueA]
|
|
broadcast "sample wall: $t1wall"
|
|
}
|
|
|
|
|
|
|
|
namespace export *
|
|
namespace ensemble create
|
|
}
|
|
|
|
publish cf user
|
|
|