From 71b71e262c32300bd9e1bbcdb4e94052ffd30a64 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 25 Feb 2011 19:12:19 +1100 Subject: [PATCH] Added eulerscan.tcl from ics1-wombat Updated to get in-situ changes to motor configurations (eg monochromator resolvers) r3072 | ffr | 2011-02-25 19:12:19 +1100 (Fri, 25 Feb 2011) | 2 lines --- .../hipd/config/commands/eulerscan.tcl | 107 +++++++++ .../hipd/config/commands/hvcommands.tcl | 208 ++++++++++++++++-- .../hipd/config/commands/pulser.tcl | 19 +- .../config/motors/motor_configuration.tcl | 49 +++-- .../hipd/config/motors/tilt_configuration.tcl | 12 +- .../instrument/hipd/wombat_configuration.tcl | 7 +- 6 files changed, 353 insertions(+), 49 deletions(-) create mode 100644 site_ansto/instrument/hipd/config/commands/eulerscan.tcl diff --git a/site_ansto/instrument/hipd/config/commands/eulerscan.tcl b/site_ansto/instrument/hipd/config/commands/eulerscan.tcl new file mode 100644 index 00000000..cf65f137 --- /dev/null +++ b/site_ansto/instrument/hipd/config/commands/eulerscan.tcl @@ -0,0 +1,107 @@ + +# Euler cradle scan commands for texture runs +# AJS Dec 2010 + + +# SetHistoSync: sets the histogram to receive $framenum worth of frames on receiving +# TTL pulse in frame sync input. Note: Framebuffer should be set to OFF for long runs + +proc SetHistoSync {framenum} { + histmem stop + bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum + bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 } + fat_table -set NOS_PERIODS $framenum + oat_table -set T {0 2200000} NTC 1 + histmem loadconf + histmem fsrce EXTERNAL +} + +publish SetHistoSync user + +# SetHistoNormal: resets the histo for standard operation + +proc SetHistoNormal {} { + histmem stop + bat_table -set NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 + bat_table -set NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0 PERIOD_INDICES { 0} + fat_table -set NOS_PERIODS 1 + oat_table -set T {0 2200000} NTC 1 + histmem loadconf + histmem fsrce INTERNAL + proc ::histogram_memory::pre_count {} {} +} + +# continous scan for EPHI- the euler cradle phi stage (innermost axis) +# note make sure controller 2 has the PHISCAN code in it + +publish SetHistoNormal user + + +proc EphiCtsScan {start step range steptime} { + +# magic number: steps per rotation for phi + set ephisteps -12500 + set ephispeed [expr {($step*1.0)/$steptime}] + set numsteps [expr {round($range/$step)}] +# broadcast $omspeed $numsteps + +# run ephi to start angle -1 so that first pulse signals as ephi crosses 0 angle +# at correct velocity + ephi accel 1 + ephi decel 1 + ephi speed 3 + drive ephi [expr {$start-1}] + ephi speed $ephispeed + ephi accel [expr {$ephispeed*1.2}] + +# now set ephi parameters to galil and clear the bit + + set scval [expr {($range+2.2)*$ephisteps}] + set stval [expr {$ephisteps * $step}] +broadcast $scval $stval + som send CTLEN=$scval + som send CTSTEP=$stval +# som send OMN = [expr {$numsteps+1}] + som send CB5 + + proc ::histogram_memory::pre_count {} { + ephi send "XQ #EPHSCAN,2" + } + + histmem mode unlimited + histmem start block + + newfile HISTOPERIOD_XY + for {set i 0} {$i<$numsteps} {incr i} {save $i} + ephi speed 1 + + +# this we needed when it didn't work properly +# proc ::histogram_memory::pre_count {} {} +# ephi send SHC +# ephi send SPC=25000 +# ephi send BCG +# wait 3 +# ephi send "XQ #THREAD0,0" +# wait 3 +# ephi reset +} +publish EphiCtsScan user + +proc EulerCtsScan {range step steptime} { + set numsteps [expr {round($range/$step)}] + SetHistoSync $numsteps + foreach chi {0 15 30 45 60 75 90} { + drive echi $chi + EphiCtsScan [expr {-$range/2}] $step $range $steptime + } +# SetHistoNormal +} + +publish EulerCtsScan user + +proc KillEphi {} { + ephi send HX2 + ephi send STC + ephi reset +} diff --git a/site_ansto/instrument/hipd/config/commands/hvcommands.tcl b/site_ansto/instrument/hipd/config/commands/hvcommands.tcl index b5cf0551..f8948a63 100644 --- a/site_ansto/instrument/hipd/config/commands/hvcommands.tcl +++ b/site_ansto/instrument/hipd/config/commands/hvcommands.tcl @@ -1,3 +1,17 @@ +proc SetVolt {volt} { + if {$volt== 0} { + PulserOff + } else { + set pulservolt [expr {($volt*1.0)/1000.0}] + pulser send VOLT:OFFS $pulservolt + pulserDC $pulservolt + PulserOn + } +} + +proc GetVolt {} { + pulser send VOLT:OFFS? +} proc SingleVolt {volt oscno} { histmem mode unlimited @@ -5,10 +19,10 @@ proc SingleVolt {volt oscno} { if {$volt== 0} { PulserOff } else { - set pulservolt [expr {($volt*1.0)/4000.0}] + set pulservolt [expr {($volt*1.0)/1000.0}] pulser send VOLT:OFFS $pulservolt -# PulserOn -# pulser send "APPL:DC DEF,DEF,$pulservolt" + pulserDC $pulservolt + PulserOn } oscmd start $oscno hmm countblock @@ -25,7 +39,7 @@ proc SetDC {} { proc VoltRamp {start step fin oscno} { histmem mode unlimited - set waszero 0 + newfile HISTOGRAM_XY set loopvar 1 set i 0 @@ -35,15 +49,10 @@ proc VoltRamp {start step fin oscno} { if {$j< $fin && $step < 0} {break} if {$j== 0} { PulserOff - set waszero 1 } else { - set pulservolt [expr {($j*1.0)/4000.0}] - pulser send VOLT:OFFS $pulservolt - if {$waszero==1} { - PulserOn - set waszero 0 - } -# pulser send "APPL:DC DEF,DEF,$pulservolt" + set pulservolt [expr {($j*1.0)/1000.0}] + pulserDC $pulservolt + PulserOn } oscmd start $oscno hmm countblock @@ -53,6 +62,43 @@ proc VoltRamp {start step fin oscno} { oscmd stop } +proc VoltTextureRamp {start step fin mot tstart tstep tfin oscno} { + histmem mode unlimited + + + 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} + if {$j== 0} { + PulserOff + } else { + set pulservolt [expr {($j*1.0)/1000.0}] + pulserDC $pulservolt + PulserOn + } + sampledescription voltage $j + broadcast voltage $j + newfile HISTOGRAM_XY + set m 0 + while {1} { + set n [expr {$m*$tstep+$tstart}] + if {$n> $tfin && $tstep > 0} {break} + if {$n< $tfin && $tstep < 0} {break} + drive $mot $n + oscmd start $oscno + hmm countblock + save $m + incr m + } + oscmd stop + incr i + } +} + + proc SquarePulseVolt {start step fin freq oscno} { histmem mode unlimited newfile HISTOGRAM_XYT @@ -65,7 +111,7 @@ proc SquarePulseVolt {start step fin freq oscno} { if {$j== 0} { PulserOff } else { - set pulservolt [expr {($j*1.0)/4000.0}] + set pulservolt [expr {($j*1.0)/1000.0}] PulserSquare $freq $pulservolt PulserOn # pulser send "APPL:SQU $freq,$pulservolt,0" @@ -84,7 +130,7 @@ proc SquarePulseFreq {volt freqlist bins oscno} { set loopvar 1 set i 0 foreach freq $freqlist { - set pulservolt [expr {($volt*1.0)/4000.0}] + set pulservolt [expr {($volt*1.0)/1000.0}] histmem_period_strobo $freq $bins wait 3 PulserSquare $freq $pulservolt @@ -98,16 +144,38 @@ proc SquarePulseFreq {volt freqlist bins oscno} { oscmd stop } +proc SinePulseFreq {volt freqlist bins oscno} { + histmem mode unlimited + newfile HISTOGRAM_XYT + set loopvar 1 + set i 0 + foreach freq $freqlist { + set pulservolt [expr {($volt*1.0)/1000.0}] + histmem_period_strobo $freq $bins + wait 3 + PulserSin $freq $pulservolt + PulserOn + oscmd start $oscno + hmm countblock + save $i + incr i + } + oscmd stop +} + + + proc UniPulseFreq {volt freqlist bins oscno} { histmem mode unlimited newfile HISTOGRAM_XYT set loopvar 1 set i 0 foreach freq $freqlist { - set pulservolt [expr {($volt*1.0)/4000.0}] + set pulservolt [expr {($volt*1.0)/2000.0}] histmem_period_strobo $freq $bins wait 3 - PulserSquareOffs $freq $pulservolt [expr {$pulservolt/2}] +# PulserSquareOffs $freq $pulservolt [expr {$pulservolt/2}] + PulserSquareOffs $freq $pulservolt $pulservolt PulserOn # pulser send "APPL:SQU $freq,$pulservolt,[expr {$pulservolt/2}]" oscmd start $oscno @@ -118,9 +186,117 @@ proc UniPulseFreq {volt freqlist bins oscno} { oscmd stop } +proc UniPulseFatigue {volt freq bins oscno reps runs} { + histmem mode unlimited + set pulservolt [expr {($volt*1.0)/1000}] + set halfvolt [expr {$pulservolt/2.0}] + histmem_period_strobo $freq $bins + wait 3 + PulserSquareOffs $freq $halfvolt $halfvolt + PulserOn + for {set i 0} {$i<$runs} {incr i} { + newfile HISTOGRAM_XYT + for {set j 0} {$j<$reps} {incr j} { + oscmd start $oscno + hmm countblock + save $j + } + oscmd stop + } + PulserOff + Histmem_strobo_off + +} + + + + +proc PulserBurst {} { + pulser send BURS:MODE TRIG + pulser send TRIG:SOUR BUS + pulser send BURS:STAT ON + PulserOn + pulser send *TRG + while {1} { + set sval [pulser send *OPC?] + if {[string first 1 $sval] >-1} {break} + } + PulserOff + +} + + +proc VoltPulseRun {vlo vhi freq cycl} { + PulserOff + + pulser send VOLT:LOW [expr {$vlo/1000.0}] + pulser send VOLT:HIGH [expr {$vhi/1000.0}] + pulser send FREQ $freq + pulser send BURS:PHAS [expr {90.0 - ($vhi*180.0)/(($vhi-$vlo)*1.0)}] + pulser send BURS:MODE TRIG + set ploop [expr {int($cycl/50000)}] + set prem [expr {$cycl % 50000}] + if {$ploop >0} { + for {set i 0} {$i< $ploop} {incr i} { + Pulser send BURS:NCYC 50000 + PulserBurst + } + } + pulser send BURS:NCYC $prem + PulserBurst + PulserOff + pulser send BURS:STAT OFF + +} + + +proc VoltPulses {vlo vhi freq cycl} { + PulserOff + pulser send FUNC SQU + VoltPulseRun $vlo $vhi $freq $cycl +} + +proc VoltTriPulses {vlo vhi freq cycl} { + PulserOff + pulser send FUNC RAMP + pulser send FUNC:RAMP:SYMM 50 + VoltPulseRun $vlo $vhi $freq $cycl +} + +proc OneTri {volt period} { + PulserOff + if {$volt > 0} { + pulser send VOLT:LOW 0 + pulser send VOLT:HIGH [expr {$volt/1000.0}] + pulser send BURS:PHAS -90 + } else { + pulser send VOLT:LOW [expr {$volt/1000.0}] + pulser send VOLT:HIGH 0 + pulser send BURS:PHAS 90 + } + pulser send FUNC RAMP + pulser send FUNC:RAMP:SYMM 50 + pulser send FREQ [expr {1.0/$period}] + + pulser send BURS:MODE TRIG + + pulser send BURS:NCYC 1 + PulserBurst + PulserOff +} + + + +publish GetVolt user publish SetDC user +publish SetVolt user publish SingleVolt user publish VoltRamp user publish SquarePulseVolt user publish SquarePulseFreq user publish UniPulseFreq user +publish VoltTextureRamp user +publish VoltPulses user +publish VoltTriPulses user +publish OneTri user +publish UniPulseFatigue user diff --git a/site_ansto/instrument/hipd/config/commands/pulser.tcl b/site_ansto/instrument/hipd/config/commands/pulser.tcl index 6ccbeaf4..4d1a59bd 100644 --- a/site_ansto/instrument/hipd/config/commands/pulser.tcl +++ b/site_ansto/instrument/hipd/config/commands/pulser.tcl @@ -9,7 +9,10 @@ proc PulserOff {} { } proc PulserSin {Freq Volt} { - pulser send FUNC SIN + set resp [pulser send FUNC?] + if {[string first "SIN" $resp ] == -1 } { + pulser send FUNC SIN + } pulser send VOLT $Volt pulser send FREQ $Freq pulser send VOLT:OFFS 0 @@ -17,7 +20,10 @@ proc PulserSin {Freq Volt} { } proc PulserSquare {Freq Volt} { - pulser send FUNC SQU + set resp [pulser send FUNC?] + if {[string first "SQU" $resp ] == -1 } { + pulser send FUNC SQU + } pulser send VOLT $Volt pulser send FREQ $Freq pulser send VOLT:OFFS 0 @@ -25,7 +31,10 @@ proc PulserSquare {Freq Volt} { } proc PulserSquareOffs {Freq Volt Offs} { - pulser send FUNC SQU + set resp [pulser send FUNC?] + if {[string first "SQU" $resp ] == -1 } { + pulser send FUNC SQU + } pulser send VOLT $Volt pulser send FREQ $Freq pulser send VOLT:OFFS $Offs @@ -36,7 +45,7 @@ proc PulserSquareOffs {Freq Volt Offs} { proc PulserDC {Volt} { set resp [pulser send FUNC?] broadcast $resp - if {$resp != "DC"} { + if {[string first "DC" $resp ] == -1 } { pulser send FUNC DC } pulser send VOLT:OFFS $Volt @@ -51,4 +60,4 @@ publish PulserOff user publish PulserSin user publish PulserSquare user publish PulserDC user -publish PulserSquareOffs user \ No newline at end of file +publish PulserSquareOffs user diff --git a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl index b6822502..7d376317 100644 --- a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl @@ -34,14 +34,19 @@ if {$sim_mode == "true"} { #Measured absolute encoder reading at home position #set mx_Home 7464891 -set mx_Home 23263535 -set mom_Home 9274794 +#set mx_Home 23263535 +set mx_Home 8390583 +#set mom_Home 9274794 +set mom_Home 8391038 set mtth_Home 19927837 #set mphi_Home 7613516 -set mphi_Home 27847793 +#set mphi_Home 27847793 +set mphi_Home 8384818 #set mchi_Home 9050090 -set mchi_Home 25561619 -set my_Home 6767221 +#set mchi_Home 25561619 +set mchi_Home 8389526 +#set my_Home 6767221 +set my_Home 8378212 set som_Home 17214054 set stth_Home 2896180 set oct_Home 7743768 @@ -103,8 +108,14 @@ set slit2HGroup second/horizontal # hnotify messages to a reasonable level set move_count 10 -fileeval $cfPath(motors)/tilt_configuration.tcl -#fileeval $cfPath(motors)/euler_configuration.tcl + +# CHOOSE HERE for sample stage configuration + +#fileeval $cfPath(motors)/tilt_configuration.tcl +fileeval $cfPath(motors)/euler_configuration.tcl +#fileeval $cfPath(motors)/small_omega_config.tcl + + ############################ # Motor Controller 1 # Motor Controller 1 @@ -148,7 +159,7 @@ Motor mphi $motor_driver_type [params \ stepsPerX -25000\ absEnc 1\ absEncHome $mphi_Home\ - cntsPerX -8192] + cntsPerX 4096] setHomeandRange -motor mphi -home 0 -lowrange 2.5 -uprange 2.5 mphi speed 1 mphi movecount $move_count @@ -169,7 +180,7 @@ Motor mchi $motor_driver_type [params \ stepsPerX 25000\ absEnc 1\ absEncHome $mchi_Home\ - cntsPerX 8192] + cntsPerX 4096] setHomeandRange -motor mchi -home 90 -lowrange 2.5 -uprange 2.5 mchi speed 1 mchi movecount $move_count @@ -190,7 +201,7 @@ Motor my $motor_driver_type [params \ stepsPerX 25000\ absEnc 1\ absEncHome $my_Home\ - cntsPerX 8192] + cntsPerX 4096] setHomeandRange -motor my -home 0 -lowrange 14 -uprange 16 my speed 1 my movecount $move_count @@ -211,7 +222,7 @@ Motor mx $motor_driver_type [params \ stepsPerX -25000\ absEnc 1\ absEncHome $mx_Home\ - cntsPerX -8192] + cntsPerX -4096] setHomeandRange -motor mx -home 0 -lowrange 20 -uprange 20 mx speed 1 mx movecount $move_count @@ -232,7 +243,7 @@ Motor mom $motor_driver_type [params \ stepsPerX -12500\ absEnc 1\ absEncHome $mom_Home\ - cntsPerX -4096] + cntsPerX -2048] setHomeandRange -motor mom -home 0 -lowrange 5 -uprange 95 mom speed 1 mom movecount $move_count @@ -292,9 +303,9 @@ Motor som $motor_driver_type [params \ absEnc 1\ absEncHome $som_Home\ cntsPerX 4096] -setHomeandRange -motor som -home 0 -lowrange 80 -uprange 105 +setHomeandRange -motor som -home 0 -lowrange -71 -uprange 111 som speed 1 -som precision 0.01 +som precision 0.02 som part sample som long_name rotate @@ -303,7 +314,7 @@ Motor stth $motor_driver_type [params \ asyncqueue mc2\ axis F\ units degrees\ - hardlowerlim 5\ + hardlowerlim -0.3\ hardupperlim 30\ maxSpeed 0.5\ maxAccel 0.1\ @@ -312,7 +323,7 @@ Motor stth $motor_driver_type [params \ absEnc 1\ absEncHome $stth_Home\ cntsPerX -93207] -stth softlowerlim 5 +stth softlowerlim -0.3 stth softupperlim 30 stth home 0 stth speed 0.5 @@ -376,15 +387,15 @@ Motor mf2 $motor_driver_type [params \ asyncqueue mc3\ axis A\ units degrees\ - hardlowerlim 0\ + hardlowerlim -2\ hardupperlim 2\ maxSpeed 0.1\ maxAccel 0.1\ maxDecel 0.1\ stepsPerX 22000\ absEnc 1\ - absEncHome 350\ - cntsPerX 14000] + absEncHome 8384341\ + cntsPerX -3500] setHomeandRange -motor mf2 -home 0 -lowrange 0 -uprange 2 mf2 speed 0.02 mf2 precision 0.005 diff --git a/site_ansto/instrument/hipd/config/motors/tilt_configuration.tcl b/site_ansto/instrument/hipd/config/motors/tilt_configuration.tcl index 4f403e5b..e0442777 100644 --- a/site_ansto/instrument/hipd/config/motors/tilt_configuration.tcl +++ b/site_ansto/instrument/hipd/config/motors/tilt_configuration.tcl @@ -1,17 +1,17 @@ # This must be loaded by motor_configuration.tcl -set sphi_Home 7937974 -set schi_Home 7585956 -set sy_Home 7557524 -set sx_Home 7557304 +set sphi_Home 7938520 +set schi_Home 7586052 +set sy_Home 7790194 +set sx_Home 7556649 # Sample Tilt 1, upper, phi Motor sphi $motor_driver_type [params \ asyncqueue mc2\ axis A\ units degrees\ - hardlowerlim -15\ - hardupperlim 15\ + hardlowerlim -360\ + hardupperlim 360\ maxSpeed 1\ maxAccel 1\ maxDecel 1\ diff --git a/site_ansto/instrument/hipd/wombat_configuration.tcl b/site_ansto/instrument/hipd/wombat_configuration.tcl index 4749aae2..2d87064b 100644 --- a/site_ansto/instrument/hipd/wombat_configuration.tcl +++ b/site_ansto/instrument/hipd/wombat_configuration.tcl @@ -36,6 +36,7 @@ fileeval $cfPath(scan)/scan.tcl fileeval $cfPath(commands)/commands.tcl fileeval $cfPath(commands)/pulser.tcl fileeval $cfPath(commands)/hvcommands.tcl +fileeval $cfPath(commands)/eulerscan.tcl fileeval $cfPath(anticollider)/anticollider.tcl fileeval $cfPath(hmm)/hmm_rapid.tcl source gumxml.tcl @@ -51,9 +52,9 @@ source gumxml.tcl # add_sct_ls336 tc1 137.157.201.86 7777 "\r\n" 5.0 5.0 # The Alice Thing -# add_qlink qlink 137.157.201.86 4004 5 -# add_sct_ls340 tc1 137.157.201.86 4002 "\r" 5.0 5.0 -# add_lh45 tc2 137.157.201.86 4003 1 + add_qlink qlink 137.157.201.86 4004 5 + add_sct_ls340 tc1 137.157.201.86 4001 "\r" 5.0 5.0 + add_lh45 tc2 137.157.201.86 4003 1 # ::environment::temperature::add_west400 137.157.201.88 server_init