Spice_icon SPICE
Spectrometer Instrument Control Environment


INTRODUCTION

The introduction to SPICE is split into 3 sections:
1. General Information
2. Core Components
3. Triple-Axis Specific Features

GENERAL INFORMATION
The Spectrometer Instrument Control Environment (SPICE) is a LabVIEW based program written at ORNL for control of neutron scattering instruments.  The core components of the program (outlined below) are written to be independent of the type of instrument allowing the software to be expanded to different instrument types.  LabVIEW was chosen as the language for development for a number of reasons:

1. The most compeling reason to choose LabVIEW is the ease with which hardware can be interfaced.  Almost all modern hardware comes shipped with LabVIEW drivers or (at least) drivers which are easily accessed from LabVIEW.  This greatly simplifies the process of hardware integration in SPICE.

2. As LabVIEW's programming language, G, is a graphical programming language, a graphical user interface (GUI) is easily generated.  The presence of a GUI greatly improves user friendliness.

3. LabVIEW supports a large number of communications protocols including TCP/IP, UDP, ActiveX and DataSockets (most of these protocols are used quite extensively in SPICE - for instance, the Status Display program is totally driven by LabVIEW DataSockets).

4. There are numerous mathematical functions and analysis tools incorporated directly into LabVIEW.  This includes linear algebra, basic calculus (integration, differentiation, etc.), basic statistics, and curve fitting routines including Levenburg Marquardt algorithms.

5. Finally LabVIEW is largely platform independent allowing the code to be written and executed on several operating systems including Windows, Mac OS, and several Unix platforms.

CORE COMPONENTS


The core of SPICE consists of 2 components, a command line interpreter and a hardware interface layer.  These 2 components are completely independent of the type of instrument being controlled.

1. Command Line Interpreter


The command line interpreter sequentially executes commands from a first-in-first-out (FIFO) stack.  This command stack takes the form of a simple ascii file on the control computer which means that any process which is capable of writing to this ascii file is able to issue commands.  Currently, commands can be issued through a provided command-line of the main program window or from the graphical user interface (see Information about the Graphical User Interface for more information).  

The commands are all executed dynamically.  This means that none of the commands are hard-wired into the program and commands can be added, removed, or modified without restarting the program.  The available commands are specified in a top-level configuration file.

The command interpreter includes an integrated alias structure which is similar to the alias capabilities of UNIX.  This allows users to rename commands or combine a frequently used command sequence into a single, simple command.  There are 3 levels of alias definitions included in SPICE:
1. System - alias definitions specific to a specific class of instrument
2. Instrument - alias definitions specific to a specific instrument
3. User - alias definitions which which the user can specify

Another feature of the command line interpreter is a structure which allows access to any variable stored in LabVIEW global variable space from the command line.  These variables are accessed using a syntax @(name) where name and its definition is stored in a variables configuration file.  Detailed information about the use of this structure is given in the How to use command-line variables guide.

2. Hardware Interface Layer

The hardware interface layer consists of a series of classes and methods following the example of standard object-oriented programming languages.  Any SPICE hardware driver must contain all the methods required for the specific class of hardware.  For instance, to add a new motor controller and its included motor axes, 2 drivers are required, one for the controller class and one for the motor class (which will call the methods present on the controller driver).  Provided that both drivers have the methods required for their respective classes, entries are added in the proper configuration files, the main program is re-initialized, and the new hardware is ready to be used.  In this scheme, hardware can be added and removed dynamically without requiring a restart of the main program.  

The currently implemented classes in SPICE are: controller, motor, counter (includes ratemeters), interfaces (gpib, rs232, etc.), and pseudomotors (not physical motors but quantities which can be derived from physical motors).

More detailed information about device drivers in SPICE can be found in the How to write a device driver guide.

TRIPLE-AXIS SPECIFIC FEATURES

The triple-axis implementation of SPICE contains several advanced features designed largely to expand flexibility.  These include:

1. UB matrix: The conversion of angles to and from reciprocal space coordinates uses a UB matrix formalism.  The UB matrix is typically used in a 4-circle diffractometer but has been modified in SPICE to work with the standard triple-axis geometry where one usually has 2 perpendicular arcs and a sample rotation axis to define the sample orientation.  In addition, the formalism has been generalized to allow inelastic scans to be performed.  The advantages of this formalism are:
    (a) The arcs can now be used to make movements in reciprocal space
    (b) Any crystal symmetry (including tricilinc) can be used within the program

2. Tabbed Graphical User Interface - see the Introduction to the GUI guide for more information.

3. Scanon - the scanon structure allows any combination of drives and counts to be converted into a properly formatted scan.  For more information, see the How to create a custom scan guide.

4. Countfiles - Generally a scan consists of drives followed by counts to some specified preset (for instance, 30 seconds).  The usual count in a scan can be replaced by a series of commands specified in a countfile.  See the How to use a countfile for more information.

5. Status Display - A stand-alone program has been written to monitor the state of the triple-axis spectrometer.  This program is written using LabVIEW DataSockets and, consequently, can be operated from any computer with a valid internet connection.  More detailed information about the Status Display can be found in the Introduction to Status Display guide.

6. Drive, Scan, and Count - We have implemented a scheme where all changeable quantities (including physical motors, pseudomotors, sample enviroment quantities, flipper voltages, etc.) are all treated as motors.  This means that the command to change the magnetic field strength is the same as the command to drive a physical motor which is the same as the command which changes the energy value.  A consequence of this is that the majority of experiments can be performed with a knowledge of 3 basic commands: drive,scan, and count.  This means that users only need to learn these 3 basic command to be able to perform many experiments and helps with user friendliness.