From e7e2e87b83b7ee74349d1afb93084429ce597fca Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 13 Mar 2015 11:54:50 +1100 Subject: [PATCH] Copy changes from ics1-wombat --- .../instrument/config/commands/hvcommands.tcl | 29 +-- .../hipd/config/commands/cfcommands.tcl | 166 ++++++++++++++++++ .../hipd/config/commands/hvsteps.tcl | 109 ++++++++++++ .../hipd/config/hmm/hmm_configuration.tcl | 2 +- .../config/motors/motor_configuration.tcl | 4 +- .../instrument/hipd/wombat_configuration.tcl | 3 +- 6 files changed, 299 insertions(+), 14 deletions(-) create mode 100644 site_ansto/instrument/hipd/config/commands/cfcommands.tcl create mode 100644 site_ansto/instrument/hipd/config/commands/hvsteps.tcl diff --git a/site_ansto/instrument/config/commands/hvcommands.tcl b/site_ansto/instrument/config/commands/hvcommands.tcl index 6af48388..971f6afa 100644 --- a/site_ansto/instrument/config/commands/hvcommands.tcl +++ b/site_ansto/instrument/config/commands/hvcommands.tcl @@ -45,7 +45,7 @@ proc VoltSetStep {start step fin delay} { set i [expr {$start*1.0}] set loopvar 1 SetVolt $i - if {($start == $fin) || ($step == 0)} {break} + if {($start == $fin) || ($step == 0)} {break} while {$loopvar} { wait $delay if {($start < $fin)} { @@ -56,7 +56,7 @@ proc VoltSetStep {start step fin delay} { } } if {($start > $fin)} { - set i [expr {$i - abs($step)}] + set i [expr {$i - abs($step)}] if {$i <= $fin} { set i $fin set loopvar 0 @@ -65,7 +65,7 @@ proc VoltSetStep {start step fin delay} { SetVolt $i } } - + proc GetVolt {} { sct_pulser transact VOLT:OFFS? @@ -102,6 +102,7 @@ proc VoltRamp {start step fin oscno} { SetVolt $j oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -112,14 +113,14 @@ proc SingleVTexScan {mot tstart tstep tfin oscno} { broadcast in singlevtexscan set loopvar 1 set i_bool 0 - histmem mode unlimited + histmem mode unlimited if {$motdir == 1} { set currentmot $tstart set i 0 } else { set currentmot $tfin set i [expr {int(($tfin-$tstart)/$tstep)}] - } + } newfile HISTOGRAM_XY while {$i_bool==0} { drive $mot $currentmot @@ -140,9 +141,9 @@ proc SingleVTexScan {mot tstart tstep tfin oscno} { } set motdir [expr {(-1*$motdir)}] } - + proc VListTexScan {voltlist mot tstart tstep tfin oscno} { - global rampstep rampdelay + global rampstep rampdelay set curvolt [lindex $voltlist 0] broadcast $curvolt SetVolt $curvolt @@ -167,6 +168,7 @@ proc SquarePulseTexture {motor start step numsteps volt freq bins oscno} { drive $motor [expr $i*$step+$start] oct oscillate_count $oscno oct oscillate start + hmm countblock save $i } } @@ -185,7 +187,8 @@ proc UniPulseTexture {motor start step numsteps volt freq bins oscno} { drive $motor [expr $i*$step+$start] oct oscillate_count $oscno oct oscillate start - save $i + hmm countblock + save $i } } @@ -201,6 +204,7 @@ proc BehlkePulseTexture {motor start step numsteps freq bins oscno} { drive $motor [expr $i*$step+$start] oct oscillate_count $oscno oct oscillate start + hmm countblock save $i } } @@ -228,6 +232,7 @@ proc SquarePulseVolt {start step fin freq bins oscno} { } oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -247,6 +252,7 @@ proc SquarePulseFreq {volt freqlist bins oscno} { # sct_pulser send "APPL:SQU $freq,$pulservolt,0" oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -264,6 +270,7 @@ proc BehlkePulseFreq {freqlist bins oscno} { PulserOn oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -282,6 +289,7 @@ proc SinePulseFreq {volt freqlist bins oscno} { PulserOn oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -306,6 +314,7 @@ proc UniPulseFreq {volt freqlist bins oscno} { # sct_pulser send "APPL:SQU $freq,$pulservolt,[expr {$pulservolt/2}]" oct oscillate_count $oscno oct oscillate start + hmm countblock save $i incr i } @@ -324,9 +333,9 @@ proc UniPulseFatigue {volt freq bins oscno reps runs} { for {set j 0} {$j<$reps} {incr j} { oct oscillate_count $oscno oct oscillate start + hmm countblock save $j } - oscmd stop } PulserOff set pulserstate 0 @@ -439,5 +448,5 @@ publish BehlkePulseTexture user publish BehlkePulseFreq user publish UniPulseTexture user publish VoltSetStep user - + diff --git a/site_ansto/instrument/hipd/config/commands/cfcommands.tcl b/site_ansto/instrument/hipd/config/commands/cfcommands.tcl new file mode 100644 index 00000000..067db49d --- /dev/null +++ b/site_ansto/instrument/hipd/config/commands/cfcommands.tcl @@ -0,0 +1,166 @@ +# 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 300 + 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 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 $tempc} + 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 \$tempc"} + 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} { + 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 RampRun {start step fin oscno delay} { + 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 StepRun {start step fin oscno delay} { + 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 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 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 + diff --git a/site_ansto/instrument/hipd/config/commands/hvsteps.tcl b/site_ansto/instrument/hipd/config/commands/hvsteps.tcl new file mode 100644 index 00000000..e3a7c8a8 --- /dev/null +++ b/site_ansto/instrument/hipd/config/commands/hvsteps.tcl @@ -0,0 +1,109 @@ + +proc SetVoltPosStep {steps} { + +# set llen 16384 +# set steplen [expr{int($llen/(2*$steps))}] +# set phaselen + + set l {} + for {set i 0} {$i < $steps} {incr i} { + lappend l [expr {($i*2.0/$steps)-1.0}] + } + for {set i $steps} {$i > 0} {incr i -1} { + lappend l [expr {($i*2.0/$steps)-1.0}] + } + set s "DATA VOLATILE, " + for {set i 0} {$i < [expr {[llength $l] -1}]} {incr i} { + append s [format "%1.3f" [lindex $l $i]] "," + } + append s [format "%1.3f" [lindex $l [expr {[llength $l] -1}]]] + sct_pulser send $s + broadcast $s + +} + +proc SetVoltBiStep {steps} { + set l {} + for {set i 0} {$i < $steps} {incr i} { + lappend l [expr {$i*1.0/$steps}] + } + for {set i $steps} {$i > [expr {$steps * -1}]} {incr i -1} { + lappend l [expr {$i*1.0/$steps}] + } + for {set i [expr {$steps * -1}]} {$i < 0} {incr i} { + lappend l [expr {$i*1.0/$steps}] + } + + set s "DATA VOLATILE, " + for {set i 0} {$i < [expr {[llength $l] -1}]} {incr i} { + append s [format "%1.3f" [lindex $l $i]] "," + } + append s [format "%1.3f" [lindex $l [expr {[llength $l] -1}]]] + sct_pulser send $s + broadcast $s + + +} + +proc VoltPosStep {volt freq voltsteps} { + PulserOff + newfile HISTOGRAM_XYT + + SetVoltPosStep $voltsteps + sct_pulser send "VOLT:LOW [VoltScale 0.0]; LOW?" + sct_pulser send "VOLT:HIGH [VoltScale [expr {$volt*1.0}]]; HIGH?" + sct_pulser send "FREQ $freq;:FREQ?" + sct_pulser send "FUNC: USER VOLATILE" + sct_pulser send "FUNC USER" + +} + + +proc UniZigTexture {motor mstart mstep mnum volt freq vstep binmult oscno} { + histmem mode unlimited + newfile HISTOGRAM_XYT + set bins [expr {$vstep * 2 * $binmult}] + histmem_period_strobo $freq $bins + wait 3 +# set pulservolt [VoltScale [expr {$volt*1.0}]] +# set pulseroffs [VoltScale [expr {$volt*0.5}]] + VoltPosStep $volt $freq $vstep + + PulserOn + + for {set i 0} {$i < $mnum} {incr i} { + drive $motor [expr $i*$mstep+$mstart] + oct oscillate_count $oscno + oct oscillate start + hmm countblock + save $i + } + PulserOff +} + + +proc VoltBiStep {volt freq steps} { + PulserOff + newfile HISTOGRAM_XYT + + SetVoltBiStep $steps + sct_pulser send "VOLT:LOW [VoltScale [expr {$volt*-1.0}]; LOW?" + sct_pulser send "VOLT:HIGH [VoltScale [expr {$volt*1.0}]; HIGH?" + sct_pulser send "FREQ $freq;:FREQ?" + sct_pulser send "FUNC: USER VOLATILE" + sct_pulser send "FUNC USER" + set bins [expr {$steps * 4}] + histmem_period_strobo $freq $bins + wait 3 + + PulserOn + oct oscillate_count $oscno + oct oscillate start + save 0 +} + +publish SetVoltPosStep user +publish SetVoltBiStep user +publish UniZigTexture user +publish VoltPosStep user +publish VoltBiStep user diff --git a/site_ansto/instrument/hipd/config/hmm/hmm_configuration.tcl b/site_ansto/instrument/hipd/config/hmm/hmm_configuration.tcl index 58300baa..45c94986 100644 --- a/site_ansto/instrument/hipd/config/hmm/hmm_configuration.tcl +++ b/site_ansto/instrument/hipd/config/hmm/hmm_configuration.tcl @@ -28,7 +28,7 @@ proc ::histogram_memory::init_OAT_TABLE {args} { hmm configure fat_frame_source INTERNAL -# set resolution "double_x" + set resolution "double_x" switch $resolution { "hires" { diff --git a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl index 8c11242a..0e9b3283 100644 --- a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl @@ -293,7 +293,7 @@ Motor mom $motor_driver_type [params \ absEnc 1\ absEncHome $mom_Home\ cntsPerX -2048] -setHomeandRange -motor mom -home 59.5066 -lowrange 5 -uprange 165 +setHomeandRange -motor mom -home 0 -lowrange 5 -uprange 165 #setHomeandRange -motor mom -home 60.08 -lowrange 5 -uprange 165 mom speed 1 mom movecount $move_count @@ -417,7 +417,7 @@ oct long_name oct ############################ # -set mf_config 1 +set mf_config 2 switch $mf_config { diff --git a/site_ansto/instrument/hipd/wombat_configuration.tcl b/site_ansto/instrument/hipd/wombat_configuration.tcl index 9e1c1460..b61a68aa 100644 --- a/site_ansto/instrument/hipd/wombat_configuration.tcl +++ b/site_ansto/instrument/hipd/wombat_configuration.tcl @@ -64,13 +64,14 @@ fileeval $cfPath(commands)/hvcommands.tcl fileeval $cfPath(commands)/vactex.tcl fileeval $cfPath(commands)/eulerscan.tcl fileeval $cfPath(commands)/cfcommands.tcl +fileeval $cfPath(commands)/hvsteps.tcl fileeval $cfPath(anticollider)/anticollider.tcl fileeval $cfPath(beamline)/sct_he3_polanal.tcl fileeval $cfPath(hmm)/hmm_rapid.tcl source gumxml.tcl # Wombat only change to hvcommands' scaleval variable -SetVoltScale 2000.0 +SetVoltScale 1000.0 # The Alice Thing