# -------------------------------------------------------------------------- # Initialization script for the instrument SANSII at SINQ # # Dr. Mark Koennecke, January - March 2003 # # Changes: # Pavel Strunz, 15.04.2003: - changed backlash dz (0.15 --> 0.005) # Pavel Strunz, 16.04.2003: - changed NVS forbiden gaps according to the actual NVS037 # Pavel Strunz, 23.04.2003: - changed backlash for all ecb motors # Pavel Strunz, 29.04.2003: - hakle.tcl sourced # Pavel Strunz, 20.11.2003: - source sans2geometry, sans2measurement # Pavel Strunz, 03.12.2003: - source scan_a, sans2wavelength, nvs interrupt changed from 3 to 0 #--------------------------------------------------------------------------- # O P T I O N S set root "/home/SANS2" set scriptroot $root/sans2_sics # first all the server options are set ServerOption statusfile $root/data/2003/sans2stat.tcl # File to save the status of the instrument too ServerOption ReadTimeOut 5 # timeout when checking for commands. In the main loop SICS checks for # pending commands on each connection with the above timeout, has # PERFORMANCE impact! ServerOption AcceptTimeOut 5 # timeout when checking for connection req. # Similar to above, but for connections ServerOption ReadUserPasswdTimeout 500000 # time to wait for a user/passwd to be sent from a client. Increase this # if there is a problem connecting to a server due to network overload\ ServerOption LogFileBaseName $root/log/sans2log # the path and base name of the internal server logfile to which all # activity will be logged. ServerOption LogFileDir $root/log # This is where log files from command log go ServerOption ServerPort 2911 # the port number the server is going to listen at. The client MUST know # this number in order to connect. It is in client.ini ServerOption InterruptPort 2917 # The UDP port where the server will wait for Interrupts from clients. # Obviously, clients wishing to interrupt need to know this number. # Telnet Options ServerOption TelnetPort 1301 ServerOption TelWord sicslogin # The token system TokenInit connan #--------------------------------------------------------------------------- # U S E R S # than the SICS users are specified # Syntax: SicsUser name password userRightsCode SicsUser Manager Manager 1 SicsUser lnsmanager lnsSICSlns 1 SicsUser User Looser 2 SicsUser sans2user 04lns1 2 SicsUser Spy 007 3 #-------------------------------------------------------------------------- # S I M P L E V A R I A B L E S # now a few general variables are created # Syntax: VarMake name type access # type can be one of: Text, Int, Float #access can be one of: Internal, Mugger, user, Spy VarMake Instrument Text Internal Instrument "SANS-II at SINQ,PSI" #initialisation Instrument lock VarMake title Text User VarMake User Text User VarMake SubTitle Text User VarMake environment Text User VarMake comment Text User #VarMake samplename Text User VarMake email Text User VarMake fax Text User VarMake phone Text User VarMake adress Text User VarMake sample Text User VarMake BatchRoot Text User VarMake starttime Text User BatchRoot $root #BatchRoot $root/command VarMake sampletable Text User #----------- Initialize data storage stuff VarMake SicsDataPath Text Mugger SicsDataPath $root/data/2004/ SicsDataPath lock VarMake SicsDataPrefix Text Mugger SicsDataPrefix sans2 SicsDataPrefix lock VarMake SicsDataPostFix Text Mugger SicsDataPostFix ".hdf" SicsDataPostFix lock MakeDataNumber SicsDataNumber $root/data/2004/DataNumber #========================================================================= # Initialize ECB system #======================================================================== #--------- GPIB Controller with National Instruments driver MakeGPIB gpib ni #-------- MakeECB name gpib-controller board-number gpib-address MakeECB ecb1 gpib 0 5 #--------- Function to switch ecb to automatic control proc ecbauto {} { ecb1 func 162 1 0 0 0 } Publish ecbauto User ecbauto #-------------- ECB Motors # Motor name ecb ecb-controller ecb-motor-index hardlowerlimit hardupperlimit Motor sr ecb ecb1 1 -17500. 17500. sr encoder 0 sr control 0 sr range 1 sr multi 0 sr multchan 0 sr acceleration 1000 sr rotation_dir -1 sr startspeed 330 sr maxspeed 1000 sr auto 330 sr manuell 50 sr delay 50 sr offset 0 sr dtolerance .01 sr step2deg 1 sr step2dig 0 sr backlash 500 Motor stx ecb ecb1 2 -16000. 16000. stx encoder 0 stx control 0 stx range 1 stx multi 0 stx multchan 0 stx acceleration 500 stx rotation_dir -1 stx startspeed 330 stx maxspeed 1000 stx auto 500 stx manuell 50 stx delay 50 stx offset 0 stx dtolerance .01 stx step2deg 1 stx step2dig 0 stx backlash 500 Motor stz ecb ecb1 3 6500. 20000. stz encoder 0 stz control 0 stz range 1 stz multi 0 stz multchan 0 stz acceleration 500 stz rotation_dir -1 stz startspeed 330 stz maxspeed 1000 stz auto 500 stz manuell 50 stz delay 50 stz offset 0 stz dtolerance .01 stz step2deg 1 stz step2dig 0 stz backlash 500 Motor sc ecb ecb1 4 -2000. 70000. sc encoder 0 sc control 0 sc range 1 sc multi 0 sc multchan 0 sc acceleration 500 sc rotation_dir -1 sc startspeed 330 sc maxspeed 1000 sc auto 500 sc manuell 50 sc delay 50 sc offset 0 sc dtolerance .01 sc step2deg 1 sc step2dig 0 sc backlash 1000 Motor gu ecb ecb1 5 -10000. 10000. gu encoder 0 gu control 0 gu range 1 gu multi 0 gu multchan 0 gu acceleration 500 gu rotation_dir -1 gu startspeed 330 gu maxspeed 1000 gu auto 500 gu manuell 40 gu delay 50 gu offset 0 gu dtolerance .02 gu step2deg 1 gu step2dig 0 gu backlash 100 Motor gl ecb ecb1 6 -10000. 10000. gl encoder 0 gl control 0 gl range 1 gl multi 0 gl multchan 0 gl acceleration 500 gl rotation_dir -1 gl startspeed 330 gl maxspeed 1000 gl auto 500 gl manuell 40 gl delay 50 gl offset 0 gl dtolerance .02 gl step2deg 1 gl step2dig 0 gl backlash 100 Motor tu ecb ecb1 7 -10000. 10000. tu encoder 0 tu control 0 tu range 1 tu multi 0 tu multchan 0 tu acceleration 500 tu rotation_dir 1 tu startspeed 330 tu maxspeed 1000 tu auto 330 tu manuell 40 tu delay 50 tu offset 0 tu dtolerance .01 tu step2deg 1 tu step2dig 0 tu backlash 100 Motor tl ecb ecb1 8 -10000. 10000. tl encoder 0 tl control 0 tl range 1 tl multi 0 tl multchan 0 tl acceleration 500 tl rotation_dir 1 tl startspeed 330 tl maxspeed 1000 tl auto 330 tl manuell 40 tl delay 50 tl offset 0 tl dtolerance .01 tl step2deg 1 tl step2dig 0 tl backlash 100 Motor om ecb ecb1 9 -10000. 10000. om encoder 1 om control 1 om range 1 om multi 0 om multchan 0 om acceleration 500 om rotation_dir 1 om startspeed 330 om maxspeed 1000 om auto 100 om manuell 40 om delay 50 om offset 0 om dtolerance .01 om step2deg 1 om step2dig 10 om backlash 100 Motor sz ecb ecb1 10 -10000. 10000. sz encoder 0 sz control 0 sz range 1 sz multi 0 sz multchan 0 sz acceleration 500 sz rotation_dir 1 sz startspeed 330 sz maxspeed 1000 sz auto 500 sz manuell 40 sz delay 50 sz offset 0 sz dtolerance .001 sz step2deg 1 sz step2dig 0 sz backlash 100 Motor sx ecb ecb1 11 -10000. 10000. sx encoder 0 sx control 0 sx range 1 sx multi 0 sx multchan 0 sx acceleration 500 sx rotation_dir 1 sx startspeed 330 sx maxspeed 1000 sx auto 500 sx manuell 40 sx delay 50 sx offset 0 sx dtolerance .01 sx step2deg 1 sx step2dig 0 sx backlash 100 Motor sy ecb ecb1 12 -10000. 10000. sy encoder 0 sy control 0 sy range 1 sy multi 0 sy multchan 0 sy acceleration 500 sy rotation_dir 1 sy startspeed 330 sy maxspeed 1000 sy auto 500 sy manuell 50 sy delay 50 sy offset 0 sy dtolerance .001 sy step2deg 1 sy step2dig 0 sy backlash 100 Motor dz ecb ecb1 13 0.905 6.015 dz encoder 0 dz control 0 dz range 1 dz multi 0 dz multchan 0 dz acceleration 2000 dz rotation_dir -1 dz startspeed 330 dz maxspeed 1000 dz auto 500 dz manuell 40 dz delay 1000 dz offset 0 dz dtolerance .001 dz step2deg 53076 dz step2dig 0 dz backlash .005 Motor dh ecb ecb1 14 -10100. 16400. dh encoder 0 dh control 0 dh range 1 dh multi 0 dh multchan 0 dh acceleration 1000 dh rotation_dir -1 dh startspeed 330 dh maxspeed 1000 dh auto 500 dh manuell 40 dh delay 50 dh offset 0 dh dtolerance .001 dh step2deg 1 dh step2dig 0 dh backlash 100 Motor dv ecb ecb1 15 -14600. 25400. dv encoder 0 dv control 0 dv range 1 dv multi 0 dv multchan 0 dv acceleration 2000 dv rotation_dir -1 dv startspeed 330 dv maxspeed 1000 dv auto 500 dv manuell 40 dv delay 50 dv offset 0 dv dtolerance .001 dv step2deg 1 dv step2dig 0 dv backlash 100 Motor az1 ecb ecb1 16 -3900. 0. az1 encoder 0 az1 control 0 az1 range 1 az1 multi 0 az1 multchan 0 az1 acceleration 1000 az1 rotation_dir -1 az1 startspeed 330 az1 maxspeed 1000 az1 auto 330 az1 manuell 40 az1 delay 50 az1 offset 0 az1 dtolerance .001 az1 step2deg 1 az1 step2dig 0 az1 backlash 200 Motor atz ecb ecb1 17 -3900. 0. atz encoder 0 atz control 0 atz range 1 atz multi 0 atz multchan 0 atz acceleration 1000 atz rotation_dir -1 atz startspeed 330 atz maxspeed 1000 atz auto 330 atz manuell 40 atz delay 50 atz offset 0 atz dtolerance .001 atz step2deg 1 atz step2dig 0 atz backlash 200 #=========================================================================== # The ECB system has the drawback that only one out of 8 motors in a rack # can run at any given time. Access to such motors has to be serialized. # This is done through the anticollision system originally developed for # TRICS. This system registers requests from motors to run and then calls # a script which serializes the running of motors. This system is used at # SANS to deal with the rack logic. This section installs the necessary # scripts and configures the system. #=========================================================================== AntiCollisionInstall anticollision register sr anticollision register stx anticollision register stz anticollision register sc anticollision register gu anticollision register gl anticollision register tu anticollision register tl anticollision register om anticollision register sz anticollision register sx anticollision register sy anticollision register dz anticollision register dh anticollision register dv anticollision register az1 anticollision register atz #------------ assignment which motors belong into which rack set rack1 [list sr stx sty sc gu gl tu tl] set rack2 [list om sz sx dz dh dv az1 atz] set rack3 [list sy] proc sans2rack args { global rack1 rack2 rack3 set length [ expr [llength $args]/2.] #-------- make list which motors have to be run in each rack for { set i 0} { $i < $length} {incr i} { set mot [lindex $args [expr $i * 2]] set target [lindex $args [expr ($i *2) + 1]] if { [lsearch $rack1 $mot] >= 0} { lappend rack1mot $mot lappend rack1target $target } if { [lsearch $rack2 $mot] >= 0} { lappend rack2mot $mot lappend rack2target $target } if { [lsearch $rack3 $mot] >= 0} { lappend rack3mot $mot lappend rack3target $target } } #------- append a dummy to each in order to ensure existence lappend rack1mot dummy lappend rack1target 0.0 lappend rack2mot dummy lappend rack2target 0.0 lappend rack3mot dummy lappend rack3target 0.0 #-------- how many levels do we have? set level -1 if { [llength $rack1mot] > $level} { set level [llength $rack1mot] } if { [llength $rack2mot] > $level} { set level [llength $rack2mot] } if { [llength $rack3mot] > $level} { set level [llength $rack3mot] } if { $level <= 1} { error "Nothing to do" } #------------ we are set to serialize anticollision clear for {set i 0} {$i < $level} {incr i} { set tst [expr $i + 1] if { [llength $rack1mot] > $tst} { anticollision add $i [lindex $rack1mot $i] \ [lindex $rack1target $i] } if { [llength $rack2mot] > $tst } { anticollision add $i [lindex $rack2mot $i] \ [lindex $rack2target $i] } if { [llength $rack3mot] > $tst } { anticollision add $i [lindex $rack3mot $i] \ [lindex $rack3target $i] } } return } Publish sans2rack User anticollision script sans2rack #====================== PSI Motoren =================================== Motor ome EL734 sans2 4000 3 1 Motor chi EL734 sans2 4000 3 2 Motor phi EL734 sans2 4000 3 3 Motor tilt EL734 sans2 4000 2 1 SicsAlias ome traz "These motors are used to drive SANS I translation table" SicsAlias chi trax "while ome is sample z and chi is sample x (TG070704)" #====================== Multi Motor Setup ============================== MakeMulti detector detector alias dz x detector endconfig SicsAlias detector dt MakeMulti bs bs alias dh x bs alias dv y bs endconfig MakeMulti chamber chamber alias sr omega chamber alias stx x chamber alias sty y chamber alias sc c chamber endconfig MakeMulti gonio gonio alias gu chi gonio alias gl phi gonio alias tu xu gonio alias tl yu gonio endconfig MakeMulti table table alias om om table alias sz z table alias sx x table alias sy y table endconfig# #====================== HISTOGRAM MEMORY ================================ MakeCounter counter ecb ecb1 MakeECB tdc gpib 0 7 MakeHM banana tdc banana configure dim0 128 banana configure dim1 128 banana configure rank 2 banana configure Counter counter banana configure bank 0 banana configure map 9 banana configure range 0 banana configure n 0 banana configure ecb tdc banana configure fill 0 banana configure mode HMXY banana init banana exponent 6 banana CountMode timer banana preset 100 =========================== velocity selector ======================== set dorn(Host) psts233 set dorn(Port) 3004 set dorn(Channel) 4 set dorn(Timeout) 20000 set dorn(MinControl) 6500 VelocitySelector nvs tilt dornier2003 dorn #VelocitySelector nvs tilt SIM nvs add -20 28800 nvs add 3600 4500 nvs add 7800 10500 nvs add 21500 23500 nvs status nvs interrupt 0 MakeSANSWave lambda nvs emon unregister nvswatch #===================================== auxiliary hardware ============== set distoCON [gpib attach 0 14 0 13 0 1] #--------- for the Hakle Feucht MakeRS232Controller h50 psts233 3005 #===================================== data file writing ================ MakeNXScript #===================================== install commands ================== MakeDrive MakeRuenBuffer commandlog auto MakePSDFrame SerialInit #--------- drive command MakeDrive SicsAlias drive dr #----------- for adding scripted content to the status file MakeTclInt bckintern #----- alias for temperature DefineAlias tt temperature #=================================== load specific command files =========== source $scriptroot/sans2com.tcl source $scriptroot/hakle.tcl source $scriptroot/hakle50.tcl source $scriptroot/HaakeSetup.tcl source $scriptroot/A1931Setup.tcl source $scriptroot/sans2geometry.tcl source $scriptroot/sans2measurement.tcl source $scriptroot/sans2wavelength.tcl source $scriptroot/scan_a.tcl # initialisation for IPS-120 superconducting magnet power supply # this definition does not harm other devices used through the same channel ips init localhost 4000 7 #=================================== load display definition ============= #source $scriptroot/sans2dis.tcl #======================================================================= disto