BLISS: Spec Tutorial CH1 First Steps
In this chapter you will get familiar with SPEC. The text will guide you through. You will learn that SPEC appears to you as a command line interface
. But you will see that under this interface there is a lot of different functionalities.
You will go through a series of commands that will present you the basics of hardware control, data handling, programming, specific commands for diffraction experiments, access to your local UNIX system and online help
.
All of this subjects will be treated in depth in other chapters, here you can already take the taste of it.
[ start | hardware | diffract. | programming | unix | help | batch
]
Start Spec
To start SPEC you just need to type the name of the application at the command line. It is probably not called spec, but something else, like fourc, optics... What is written below is valid for all of them unless specified otherwise. In particular, to get access to diffractometer functionalities, the SPEC application has to be given a well defined name. But this point will be explained in detail later.
Each SPEC application will differ from each other in the hardware configuration. Some commands can be loaded in one application and perhaps not in another one. The commands presented below should be available in all applications.
When SPEC is started a number of messages will scroll on your screen.
expgi.klora<34> optics Welcome to "optics" Release 4.03.07 Copyright (c) 1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998 by Certified Scientific Software. All rights reserved. (Portions derived from a program developed at Harvard University.) (Linked with GNU Readline and History libraries for command line editing.) Using "/users/a/specadm/spec.d" for auxiliary file directory (SPECD). Faking a state named "esrf". Using your state file from /dev/esrf. Getting configuration parameters from "SPECD/optics/config". Can't import "expg/c106specmaxe/1". Cannot create RPC client handle to database server (30/192/59:108). MAXE controller unit 0 (expg/c106specmaxe/1) is unusable. = spec Hot Line: (617) 576-1610. Type h changes for info on latest changes. Browse to http://www.certif.com for complete documentation. = Opening "SPECD/site.mac" at input nest level 1. Opening "SPECD/../jmacros/expgsetup.mac" at input nest level 2. Starting Optics SPEC application **** Setting up plot options .... Doing SETUP. Opening "SPECD/setup" at input nest level 1. Opening "SPECD/optics/setup" at input nest level 1. 31.OPTICS>
Welcome and general info are followed by loading of config and macros. In the example above you can see an error coming from a remote process that cannot be accessed.
Can't import "expg/c106specmaxe/1". Cannot create RPC client handle to database server (30/192/59:108). MAXE controller unit 0 (expg/c106specmaxe/1) is unusable.
This will make the motors on that controller unusable. The problem have to be fixed before continuing.
You should always checked for error messages at startup. If you find a problem that you cannot solve, try to collect the maximum of information and then contact your beamline correspondant of software contact for help.
After those messages you will get the prompt from which you will send the commands to SPEC:
31.OPTICS>
You can talk to most of the hardware in your beamline from SPEC. Many of the hardware capabilities are integrated with SPEC itself, others have been introduced at ESRF by using macros. Users can combine commands to the different hardware elements to create sophisticated sequences.
Talking to Hardware
The way to configure your hardware is not explained here. This field requires a very large explanation and several chapters of the SPEC Tutorial are devoted to that. But probably your SPEC administrator has already configured some motors and other hardware.
Motors
You can take a look to see where every motor is by typing wa at the prompt. wa stands for where all. ( Often in SPEC command names are short words indicating the action they are supposed to do. )
34.OPTICS> wa
Current Positions (user, dial)
Mono X Tilt Y Tilt Height
mono m1 m2 hgt
6.0000 57.9410 4.1850 0.0000
6.0000 57.9410 4.1850 0.0000
If you are not sure if you can move a motor or not you better go in simulation mode before continuing:
35.OPTICS> onsim Simulate was off, is now ON.
In simulation mode there will be no access to hardware. The command offsim will get back to normal mode.
You can move a motor to an absolute position with the command mv. In simulation mode the motor will get there inmediately. In normal mode, SPEC will wait until the motor is stopped before giving you the prompt back.
36.OPTICS> mv mono 10
Then you can verify the actual position of the motor with wa. There is a whole collection of commands to move motors, read positions, change parameters, set software limits for movements... For example, the command umvr. umvr will move the motor to a relative position from where it is now and will show the position while moving.
37.OPTICS> umvr mono -2
Mono
8
Counters
Maybe you have also some counters configured. Start a counting to verify it.
38.OPTICS> ct 2
Mon Apr 20 14:38:58 1998
Seconds = 2
Monitor = 0 (0/s)
Detector = 0 (0/s)
Adc1 = 31.141 (15.5705/s)
With this command you have triggered a counting on a timer channel, and when the timer finished counting SPEC has read the value accumulated in each counter channel.
Scans
A typical experiment combines motors and counters in a so-called scan: The user enters a start and end position for one or several motors and defines a number of intervals and a counting time. SPEC will move the motor, or motors, between those two positions stopping after each interval where it will count for the counting time before continuing with the next interval. SPEC gives a report on what is happening and makes a plot out of it. The data so obtained can be automatically saved into a file.
First you should choose a file where to save data to. Use the command newsession or newfile if you are not using ESRF macros.
39.OPTICS> newsession Working directory (./data)? "./data/" is not an existing directory, create (YES)? Now in "/disks/a/rey/data". Current files in directory: -------------------------- Data file (/dev/null)? tutor.dat Last scan number (0)? Using "/disks/a/rey/data/tutor.dat". Next scan is number 1.
Then the data from your scan will be saved into disk.
40.OPTICS> ascan hgt 3.2 13.65 30 1 Total 31 points, 31 seconds Scan 1 Mon Apr 20 14:55:29 1998 file = /disks/a/rey/data/tutor.dat vicente user = rey ascan hgt 3.2 13.65 30 1 # Height Detector Monitor Seconds 0 3.2000 22 0 1 6.355 1 3.5485 28 0 1 0.465 2 3.8965 9 0 1 17.78 3 4.2450 15 0 1 22.41 [...] 29 13.3015 30 0 1 6.555 30 13.6500 10 0 1 3.586
And you should get a plot window like:
There are a lot of commands to work with motors and counters. some of the things you can use:
- all kind of different scan commands ( ascan, dscan, timescan....)
- setplot to select options for your plot
- newsession to select the file in which to save your data
- cpsetup and cplot/pplot to send the plot to a printer.
for a full list.
I/O interfaces
SPEC knows how to talk to several GPIB and RS232 interfaces. SPEC supports also VME bus, CAMAC interfaces and I/O ports. If you have a paritcular device you want to talk to from SPEC you can use it directly with generic functions. For instance if you have a multimeter with a GPIB interface, you could use the functions gpib_put() and gpib_get(), to send commands or to read the answer back.
40.OPTICS> gpib_put(8,":READ:CURRENT\r\n") 41.OPTICS> print gpib_get(8) 23.45
Multichannel analysers, CCD cameras
With simple commands you can as well control MCA and CCD cameras. You could for example trigger a 10 second counting on your MCA.
42.OPTICS> mcaacq 10
At this point SPEC will know how to start the MCA, get the data, open a display application for it, and depending on the options you selected save the spectrum so-obtained into a file.
Another example if you type:
43.OPTICS> ccdon
a CCD acquistion will be done at each scan point, including trigger, data read and file saving.
ESRF device servers
SPEC was modified to include direct access to ESRF device servers. You could get a list of commands available for a device, send a given command or access the ESRF dynamic database: data collector.
44.OPTICS> esrf_io("id2/valve/1","?")
Input Output Command
void void DevOpen
void void DevClose
void short DevReadCommand
void short DevState
void string DevStatus
45.OPTICS> esrf_io("id2/valve/1","DevOpen")
46.OPTICS> print esrf_io("id2/valve/1","DevStatus")
Open
Other devices
Many other devices have been included in the ESRF SPEC macro distribution. In this way you can see adc's or Keithley multimeters as counters; or you may use a channel of an ICV712 (DAC) on your VME as a motor. Other macros exist to control attenuators, safety shutter, powersupplies or temperature controllers.
47.OPTICS> shopen
Beam shutter exp was CLOSED, is now OPEN.
48.OPTICS> attemenu
*********** ATTE Attenuator MENU ***********
Axis 1 Axis 2 Axis 3
101 Open 201 Open 301 Open
102 C-1 202 C-2 302 C-4
103 Free 203 Free 303 Free
104 Free 204 W-0.125 304 W-0.125
Axis 4 Axis 5 Axis 6
401 Open 501 Open 601 Open
402 Mn_400 502 Zn_10 602 Ag_25
403 Cr_5 503 Cu_7.8 603 Mo_15
404 V_5 504 Co_7 604 Pb_10
405 Ti_7 505 Fe_7 605 Au_5
On On On
Choose filter number or 0 to exit
Diffractometers
SPEC was initially written to control diffractometers. Today 12 different diffractometer geometries are known to SPEC. From SPEC you can align your sample, work with the orientation matrix of your crystal, scan around the miller indexes, select sectors or operation mode.
Every diffractometer geometry has a well defined name in SPEC. So, if your beamlines is equiped with a six-cercle diffractometer you will probably find a SPEC version called sixc dedicated to it.
A version of SPEC that controls a diffractometer has some specific macros for it. And, because the equations are specific to each geometry the macros and the internal code of SPEC are adapted for that. Diffractometer macros have the same name in all geometries but the calculations underneath will be different. The way the information is presented depends on the application.
For example the macro ci calculates the Miller indexes (H,K,L) that corresponds to a set of motor positions. In a six-cercle geometry that macro will get six parameters as input, because six motors are needed. In a fourc-cercle geometry only four motors are used and so only four values are required by the macro.
Some of the commands used to work with a diffractometer are:
To enter parameters of your crystal:
11.FOURC> setlat Enter real space lattice parameters: Lattice a (1.54)? Lattice b (1.54)? Lattice c (1.54)? Lattice alpha (90)? Lattice beta (90)? Lattice gamma (90)? (UB recalculated from orientation reflections and lattice.)
to enter the orientation matrix from two known reflections:
12.FOURC> setor0 Enter primary-reflection angles: Two Theta (60)? Theta (30)? Chi (0)? Phi (0)? Enter primary-reflection HKL coordinates: H (1)? K (0)? L (0)? (UB recalculated from orientation reflections and lattice.) 13.FOURC> setor1 Enter secondary-reflection angles: Two Theta (60)? Theta (30)? Chi (0)? Phi (-90)? Enter secondary-reflection HKL coordinates: H (0)? K (1)? L (0)? (UB recalculated from orientation reflections and lattice.)
to move the motors to find a crystal position: and then know where the diffractometer is:
14.FOURC> br 1 1 0 15.FOURC> wh H K L = 1 1 0 Alpha = 0 Beta = 0 Azimuth = 90 Omega = 0 Lambda = 1.54 Two Theta Theta Chi Phi 90.0000 45.0000 0.0000 -45.0000
to do a scan in the K coordinate
19.FOURC> kscan 0 1 10 1 Total 11 points, 11 seconds Scan 1 Wed Apr 22 11:36:59 1998 file = /dev/null fourc user = rey hklscan 1 1 0 1 0 0 10 1 # H K L Detector Monitor Seconds 0 1 0 0 0 0 1 0 1 1 0.1 0 0 0 1 0 2 1 0.2 0 0 0 1 0 [...]
In the official spec manual you can get a full overview.
Programming
You are now getting familiar with the command line interface in SPEC. New commands can be added to it by using the SPEC language to create macros. They will look as any of the commands you have used up to now.
To create a new macro you have to use the def command.
The following example defines a macro called avg that calculates average speed from data.
155.OPTICS> def avg '{
156.quot> local average dist hour minutes seconds total_time
157.quot>
157.quot> printf("Hello. This macro calculates average speed\n")
158.quot>
158.quot> dist = getval("Distance (km)",0)
159.quot> hour = getval("Hours",0)
160.quot> minutes = getval("Minutes",0)
161.quot> seconds = getval("Seconds",0)
162.quot>
162.quot> total_time = hour + minutes/60 + seconds/3600
163.quot>
163.quot> average = dist/total_time
164.quot>
164.quot> printf("Average speed: %3.2f km/h\n",average)
165.quot> }'
You can then run this macro as a normal SPEC command.
171.OPTICS> avg Hello. This macro calculates average speed Distance (km) (0)? 890 Hours (0)? 8 Minutes (0)? 34 Seconds (0)? Average speed: 103.89 km/h
As you have perhaps noticed the language used to define macros is quite similar to "C". Two of the tutorials are specially devoted to this subject, macros tutorial and SPEC language.
Access to Unix Commands
Without getting out of SPEC you can access any UNIX command with the macro u.
172.OPTICS> u hostname expgi
Some of the UNIX commands have been already defined as macros in SPEC and so ls, pwd, cd or vi are commands in SPEC.
173.OPTICS> pwd /users/a/klora/data 174.OPTICS> ls /tmp geos nhinfo tt llbdbase.dat nscomm40-lagier x login.output nscomm40-peters xx20222 lpq.000a4fe4 nscomm40-rey xx28060
Online Help
Online help is available in SPEC through the command help
173.OPTICS>help
[...]
NAME
data - built-in functions for handling internal data
DESCRIPTION
spec stores data in up to 256 independent data arrays called groups.
Each group is configured (see below) to have a particular number of
data elements per point. For example, each point in a group could
have elements for H, K, L, and detector counts. Alternatively, each
point could have just one element and be used to hold data obtained
from an MCA.
Groups are configured using the data_grp() function. A group can
have up to 2048 elements per point. The maximum number of points in
a group is determined by the product of the number of elements per
point and the number of points. That product can be no more than
65,536, and may be slightly less depending on how the number of
elements divides into 2048. The maximum number of points for all
groups is 262,144. (These limits are arbitrary and are set to
Next page (YES)?
if you select local as subject in the help menus you will get a new menu with ESRF specific documentation. All this help is available also via the web, both for general help and for ESRF specific macros.
Executing a Sequence of Commands
If you want to execute a sequence of SPEC commands automatically you can write them into a file and then, from SPEC, you can trigger that sequence with the command "do" followed by the name of the file.
Edit your file with your favourite editor. It will look something like
# # File: Sc455.do # # This file will do a series of scans for Sc455 experiment # ascan mot1 30 50 10 1 mv mot1 CEN ascan mot2 12.34 -3.45 32 1 mv mot2 CEN dscan mot3 0 3 100 0.1
Then if you type do Sc455.do the commands in the file will be executed in order.