The program MAD (Multidetector Acquisition of Data) controls the data acquisition and other tasks (see topics) of the instrument D22. This manual describes the UNIX version of MAD installed on D22 since June 1998.

Please, send your comments and suggestions concerning this document to Roland May.

Normally, MAD is activated on the monitor of the acquisition work station d22 by the user "d22". Only a privileged user may bypass this rule.

Inside the ILL, an up-to-date version of this help file is available on the instrument computer.

Information about D22 can be found on the D22 page in ILL's WWW server.

Contents of the online MAD manual

Back to index


Equivalent with RUN (see MAD topic).


   MAD:  ACQ [Preset value] [Preset type] [Ntimes] [Save/Nosave] [cr]


After the system login messages, type MAD after the prompt ">" in the directory /users/d22.

MAD starts by typing the date, the time, and a list of control messages and shows that it is ready for input with the prompt "MAD: ".

MAD commands can also be used remotely, see MAD subtopic "remote_use".


ADC reads a value from a analog-to-digital converter (two channels).

      MAD:  ADC  [cr]        default, reads channel 1
      MAD:  ADC1 [cr]        reads channel 1
      MAD:  ADC2 [cr]        reads channel 2


ADJUST aligns the sample changer horizontally with respect to the beam aperture, using an attenuated beam. n is the position number on which the command is executed The default is 1 and should not be used for mechanical reasons.


   MAD:  ADJUST 11 [cr] 


ATTENUATOR activates (IN) or desactivates (OUT) the instrument attenuator and choses (CHANGE) the attenuator to be used (number 1, 2 or 3).


   MAD:  ATT IN [cr]       puts the attenuator in the beam
   MAD:  ATT OUT [cr]      removes the attenuator from the beam
   MAD:  ATT [cr]          reads the attenuator number in use
   MAD:  ATT C n [cr]      sets attenuator n 
Back to index


This program (MAD version for D22) was written by Michel Roure, ILL, March to August 1994. UNIX version May 1998.

Help file by Michel Roure and Roland May, September 1994. Last update: see end of this file


Sets the circulating bath temperature. Uses the parameters defined with the BATH option in PARAMETER.


   MAD:  BATH 25.3[cr]             sets bath temperature to 25.3 deg. C 


Checks the number of/changes the beamstop in use.


   MAD:  BEAM [cr]                   reads current beamstop number
   MAD:  beamstop 4 [cr]             change to beamstop 4 
For manually changing the beamstop, see here. The beamstop can be moved in absolute values with respect to the detector centre with the commands BX and BY.


   MAD:  BY -10 [cr]          moves beam stop vertically to -10 mm


Checks/defines the sample changer position. Uses the parameters defined with the CHANGER option in PARAMETER.


   MAD:  CHANGER [cr]           reads current position
   MAD:  cha 5 [cr]             move to position 5


CHECK verifies the syntax of an edited command file, without execution. (see also MAD topic "command_file").


   MAD:  CHECK toto.cmd [cr]
This command reads the file toto.cmd and checks whether all commands contained in it respect the syntax of MAD, without executing them.

Back to index




COLLIMATION controls the collimation length (free neutron flight path).

Allowed values for D22 are: 1.4; 2; 2.8; 4; 5.6; 8; 11.2; 14.4; 17.6 m.

These values are listed in a MAD error message in case of an erraneous entry (e.g. COLL 99). Note: 5, 11, 14 and 17 are sufficient for 5.6, 11.2, 14.4 and 17.6.


     MAD:  COLL [cr]      reads the current collimation setting (in m).
     MAD:  COLL n [cr]    sets the collimation length to n meters.
DET can be used (as first command) together with COLL.

     MAD:  det 3 coll 5.6 [cr]


MAD command files are ASCII files containing a sequence of valid MAD commands. The default extension of command files is .cmd. Command files are executed by the commands START (or XBU) and CIS (see corresponding topics). Their syntax can be checked with the CHECK command. The length of the whole command-file name (including its extension, in general .cmd) must not exceed 16 characters.

Be careful with characters that mean conditional_commands, i.e. < and >.


   WAIT 600
   RUN   30
   WAIT 600
   RUN   30


You are invited to contribute to improving this document. Please, direct your comments to your local contact or the instrument responsible.

Back to index


Control keys are no longer used in MAD for interrupting counting and for leaving a program level.

See commands STOP, PAUSE, RESUME instead.


see MAD topic RUN


By default, each acquisition creates an ASCII data file (of standard ILL format) with a six-digit name 000xxx, where xxx is the run number, on the instrument workstation ("D22A").

The data is regularly transferred to the central data base. Data files 000001 to 000099 are temporary data files that are not transferred. The frequency of updating data files and measurement states on the instrument computer hard disk is controlled via the TIMER parameter values.


DAC writes a request in Volt units to the digital-to-analogue converter (two channels). The precision is 65536 steps for +/- 10 V.

The Haake bath that has a conversion of 10 mV for 1 deg can therefore be regulated with a precision of about 0.1 deg. Example: An input tension of 0.4 V corresponds to 40 deg.


   MAD:  DAC  4.7  [cr]          default, channel 1
   MAD:  DAC1  3  [cr]           channel 1
   MAD:  DAC2 -4.9  [cr]         channel 2
Back to index


DATE types the current date and time (if you want to take your tea, for example). Equivalence: TIME.


     MAD:  DAT [cr]


DET checks and changes the detector position (values in meters).


     MAD:  DET [cr]
     MAD:  det 15 [cr]
DET can be used (as first command) together with COLL.

     MAD:  det 3 coll 5.6 [cr]


EUDEV sends a command followed by a value to a Eurotherm controller.


     MAD:  EUDEV SL 12345 [cr]
Note: requires communication set-up (line-speed etc.) different from DTI.


EXIT (QUIT, FIN) exits from MAD.


     MAD:  EXI [cr]


see QUIT.


The HELP command provides on-line information on the use of MAD.


     MAD:  HEL [cr]
Back to index


Executes a kinetic measurement. The command kin[etic] starts the acquisition; an external TTL trigger signal is needed ("top" on the acquisition card).

After the end of the run, all frames are automatically stored in standard format. In the case of a "STOP", only those frames that have been measured at the time of the STOP are stored.

The presets (max 450) for the different frames in a run are stored in a text file . The number of frames corresponds to the number of lines in the file.

The files can be produced either by the program time.exe on the data acquisition computer or by the Appleworks spreadsheet "slices_generator". The maximal preset is 390.4 sec (2^32 = 4.29 10^9 ticks)

Example of a file:

The numbers represent the time in ticks, 1 tick = 90.9 ns 1st run time = 11001100 * 90.9 ns = 1 sec (max. = 390.4 sec)


     MAD:  KINETIC [filename] [cr]
     MAD:  KIN [filename] [cr] 

ex.  MAD:  KIN slices.txt [cr] 
Back to index


Reads Keithley voltmeters. They have to be parametrized with a MAD PAR IEEE command or by using the PARAME program.


     MAD:  IEEE [cr]        reads device address=7
     MAD:  IEEE1 [cr]       reads device address=7
     MAD:  IEEE2 [cr]       reads device address=8



All MAD input is in free format, with parameters separated by spaces or commas. Small and capital letters are accepted. Three letters are usually sufficient for the commands (exception: STATE; 4 letters).

The program will generally prompt for the next input; there are messages in the case of insufficient/incorrect input. MAD often defaults to predefined parameter values, example:

RUN 60 [cr] is interpreted as RUN 60 m(onitor), if m was the previous selection.

Normally, there is one line per command, yet the DET command can be combined with the COLL command in one line.


To interrupt a run before the preset is reached, type STOP on the instrument control terminal, eventually with the option SAVE or NOSAVE.

Back to index


MAD works in two different modes:

1) the interactive mode, the user enters each command from the terminal,

2) the use of command files. They contain lists of commands which are obtained by using an editor (e.g. nedit) and are executed by the command START (or XBU).


The positions of all encoded movements are set and read via mnemonic names.

Mnemonic names:


   MAD:  Mall               read all motor positions
   MAD:  Bx By              read beam stop positions X and Y
   MAD:  Bx 55              set beam stop horizontally to 55 mm
   MAD:  Bx 55 By 72.5      set beam stop horizontally and vertically
   MAD:  Det 5.5 Dan 12.50  set the detector distance and angle
Back to index


Besides MAD, other tasks are used on D22 which can be activated in all windows of the data acquisition computer but the one that is running MAD.


DTI is a package to drive and control the 'illptc' temperature controller.


LIS gives the state of the transfer of data files to the central data base.


msp displays the status of the measurement. It requires a video terminal.


NSW controls the output of the MAD log file to a printer and the way log files are started using the nswitch daemon nswd.

The nswd daemon takes output from mad, dti and various other programs and dispatches it to log files found in the $HOME/logfiles directory. nswd can also copy to up to 5 terminal devices and to a hardcopy device connected to a serial port of the computer.

New log files are created every day (assuming something is written to them). Their filename is madyymmdd.log - ex: mad000411.log to enable the directory command (ls) to sort them easily according to date.

Various nswd messages (error/information) are written to console and to file $HOME/nswitch.log.

nsw commands:

nsw status
    shows when nswd was started
    shows any hardcopy device (status/name/speed)
    shows active terminal copy devices

nsw start
    start copying mad and dti output to current window
nsw stop
    stop copying mad and dti output to current window

nsw start hard
    (re) enable hardcopy device

nsw stop hard
    turn off hardcopy device

nsw hard  
    set parameters for and turn on hard copy device
    ex: nsw hard /dev/tty00 19200 (dec)
        nsw hard /dev/ttyd1 19200 (sgi)

        nsw hard /dev/ttya01s 9600  for D11

nsw new 
    request new log files
    existing log files for the day are renaimed with the extension .n
    ex: mad000411.log becomes mad000411.log.1 
                      or      mad000411.log.2 if ".1" already exists

nsw off
    requests nswd to shutdown
    note nswd starts automatically when requested
Back to index


transfert is a task that sends data files "manually" to the ILL data server (serdon).


PARAMETER subcommands define instrument and control parameters. Only the first three characters of parameter names are necessary.


BATH sets offset and slope values for setting the circulating bath temperature via DAC. usage:
     MAD: PAR  BATH [cr]               List bath offset and slope
     MAD: PAR  BATH 0.2 100. [cr]      sets values for BATH:
                                               offset 0.2 deg. C, 
                                               slope 100 (1 deg. =10 mV)


The number of the beamstop in use is defined as parameter beam. If the command BEAM indicates a wrong number PAR BEAM n n allows one to set it to the correct value (note the repetition of value n!). usage:
     MAD: PAR BEAM [cr]           List beamstop number in use
     MAD: PAR  BEAM 4 4 [cr]      sets value for beamstop in use to 4




CHANGER checks and sets parameters for the different sample changers/ rack plates and selects one changer/rack with the SET command.


     MAD: PAR  CHANGER [cr]               List all caracteristics
     MAD: PAR  CHANGER 3 12.5 10. [cr]    sets values for changer 3:
                                               first position 12.50, 
                                               increment 10.0
     MAD: PAR  CHA SET 2 [cr]             Use changer/rack 2


CENTRE checks and sets values for the beam centre.


     MAD: PAR  CENTRE [cr]             List X0, Y0 values (in pixels from 0:127)
     MAD: PAR  CENTRE 12.5 63.2 [cr]   sets values for X0 and Y0


(not yet used on D22).

Certain parameter values may be linked (e.g. detector angle and offset). The parameter COMPUTE (options : ON or OFF) controls whether MAD calculates these links between values or not.


     MAD: PAR  COMPUTE ON [cr]      values are calculated.
     MAD: PAR  COMPUTE OFF [cr]     no parameter locked; no calculation.
Back to index


options: ON or OFF. If ON, and a cryostat is present, temperatures are read.


     MAD: PAR  CRYO ON [cr]


DATE defines/checks the experiment starting date.


     MAD: PAR  DATE 14-Jul-1994 [cr]
     MAD: PAR  dat [cr]


Checks/defines the multidetector resolution in pixels. You can give the size values for X and Y separately. (Normal values on D22 are 128, 128).


     MAD: PAR  DET 64 64 [cr]
     MAD: PAR  DET 32 32 [cr]
     MAD: PAR  DET  X 64 Y 32 [cr]


Checks/defines the default sample-to-detector distance (SD) in meters.


     MAD: PAR  DIS 11.250 [cr]


Checks/defines the minimum and maximum detector counting rates for verifying if the beam is open or if a reasonable count rate is exceeded. If a value is zero, there is no verification for it.


     MAD: PAR  FLU 5 0 [cr]
Back to index


Checks/defines the (MAD internal) software limits, offset and precision for encoded movements. See also MAD PARAMETER topics "movements", ZERO and PRECISION. The values entered are:

lower and upper end switch, offset to be a d d e d to read "zero" and the "precision" value defining a range within which there is no warning upon termination of a command for moving a motor.


     MAD: PAR  LIMITS Bx -20 180.0 [cr]   sets limit values for Bx
     MAD: PAR  LIM [cr]                   types all values


Lists all parameters (not yet implemented).


     MAD: PAR  LIST [cr]


LOGBOOK checks/defines the number of the current logbook in which details of the experiment are to be found.


     MAD: PAR  LOGBOOK 54 [cr]
     MAD: PAR  log [cr]


see TITLE.

Back to index


MOT checks defines the names, output coefficients (divider for integer scaler values), VME unit, timeout (s), physical unit of movement, and VME control type (0: QCL, 1:VPAP control) of the motor units. usage:
     MAD: PAR  MOT  [cr]
     MAD: PAR  MOT  1  DET 1000 1 120 m 0[cr]


NUMOR (numero d'ordre) is the current data-set identification number (run number).

ATTENTION! Users are not allowed to change NUMOR (a special procedure is required for modification).


     MAD: PAR  NUM [cr]


(parameter decription) Switches on/off the optional description header in the data parameter block.


     MAD: PAR  pardes on [cr]
     MAD: PAR  pardes off [cr]


Checks/defines the "soft" (MAD internal) motor precision. Same syntax as LIMITS.


     MAD: PAR  precision By 550 [cr]
     MAD: PAR  precision Bx [cr]
     MAD: PAR  precision [cr]
Back to index


Checks/defines the proposal number (10 characters) to be stored in the data file header.

ATTENTION : the first letter must not be a number!


     MAD: PAR  PROPOSAL n01-08-127 [cr]
     MAD: PAR  PRO [cr]


Checks/defines the parameters for the RS232 line


     MAD: PAR  RS232 [cr]
     MAD: PAR  RS232 4800 [cr]


Checks/defines the relative wavelength resolution (also stored as parameter 54 in the raw data file if parameter PARDES is set).


     MAD: PAR  RES 0.1 [cr]


Checks/defines the area (X1, X2, Y1, Y2, 0:127) used for calculating the detector sum in a SCAN


     MAD: PAR  SCANAREA 45 51 32 110 [cr]
     MAD: PAR  SCANAREA [cr]


Checks/defines the selector constants.


     MAD: PAR  sel ANATOLE 142950 0.1339 0       set constants
     MAD: PAR  SEL 


Checks/defines a 20-character string serving as a description of the sample; it is stored in the data-file header.

NB: The first word must not be a number. Use spaces for erasing residual characters, if there are any.


     MAD: PAR  SUB Sample 12           [cr]
Back to index


Checks/defines the interval times for intermediate storage (in minutes) of the raw data file (parameter UPDATE) and for alarms (in seconds) (parameter ALARM).


     MAD: PAR  TIM A 3 [cr]
     MAD: PAR  TIM U 20 A 2 [cr]
     MAD: PAR  TIM 30 4 [cr]            (update=30 min, alarm=4 sec)


Checks/defines a 60-character string serving as a description of the experiment; it is stored in the data-file header. (Equivalence MCO).

ATTENTION : the first word must not be a number.


     MAD: PAR  TITLE Metallopolymers and other materials [cr]
Back to index


Checks/defines parameters for time of flight (or kinetic) values: Usage:
     MAD: PAR  TOF 0 1 16384 [cr]               normal D22 mode (no TOF)
     MAD: PAR  TOF nomask  [cr]                 mask off
     MAD: PAR  TOF 1 1 256 100 1 [cr]           TOF mode (256 channels of 100 microsec, delay 1 us)
     MAD: PAR  TOF mask 0 127 0 127 sum [cr]    sum all intensities on the whole detector
     MAD: PAR  TOF 1 16384 128 200 1 [cr]       TOF mode (one TOF spectrum for every detector cell)
Runs are started with the normal RUN/COUNT commands. In the case of the last example, detector images (as many as there are time channels, here 128) can be read using the MAD command TOFIMAGE after the end of acquisition. Parameter 96 then contains the number of the frame corresponding to each image.

The longest available time (channel number times channel width) in TOF mode is 98 ms.


Checks/defines the user's name (10 characters) to be stored in the data file header.

ATTENTION: the first word must not be a number.


     MAD: PAR  USERNAME Max Frisch [cr]
     MAD: PAR  use [cr]


IEEE, IEEE1, IEEE2 check/define parameters for voltmeter reading (IEEE).


           MAD: PAR  IEEE   1   2   2     reads unit 1, ohm, range 10ohms
           MAD: PAR  IEEE1  1   2   2       "       "     "     "
           MAD: PAR  IEEE2  1   0   1     reads unit 2, DC , range 1V
           MAD: PAR  IEEE2  0             IEEE2 off
           MAD: PAR  IEEE1 CMDS FOR0X     sends command FOR0X to IEEE1
           MAD: PAR  IEEE1 CMDS           eliminates previous command line
           NB:  IEEE1 is address 7, IEEE2 is address 8
Back to index


Checks/defines the wavelength tolerance.


     MAD: PAR  WAVE 0.10
     MAD: PAR  WAVE              types current values


Checks/defines the "soft" (MAD internal) motor offsets. Same syntax as LIMITS.


     MAD: PAR  ZERO Changer 12.5 [cr]
     MAD: PAR  zer [cr]


PAUSE interrupts a run, eg. for sample inspection. The run can be resumed with a RESUME command.


   MAD:  PAUSE [cr]


The MAD command for getting rid of "Vax control" in "InTouch" is PCCONTROL.


Equivalent to TEMPERATURE. (Only for input: see MAD topic TEMPERATURE).


QUIT (equivalence EXIT, FIN) exits from MAD.

Back to index


RS232 sends a string to the communication line. The line parameters are defined by a PAR RS232 command.


   MAD:  RS232 [string] [cr]
Back to index


The privileged user (instrument responsible) can start MAD from any terminal and make it write to a terminal defined by the parameter OUTPUT.


1) Get the terminal name for the process REQMAD, by the command:

   D22 > SH USER D22/FU
2) Before starting a remote run, cancel MAD by the command "PCP 4" or "PCP K", verify that MAD is not active and then execute a new command file or single command.

3) If the terminal name defined in OUTPUT is different from the control terminal name, it should be modified so that the instrument user is informed about the remote process.


   D22 > SH USER D22/FU
               '                        (get terminal for REQMAD)
   D22 > PCP K                          (kills MAD on control terminal)
   D22 > MAD
   MAD:  PAR OUTPUT                     (verify terminal name)
   MAD:  PAR OUTPUT control__terminal   (if different)
   D22 > MAD START filename             (start in remote mode)
   D22 >


RESUME resumes a run after a PAUSE command.


   MAD:  RESUME [cr]


Equivalent to command TEMPERATURE, but read only (see MAD topic TEMPERATURE).

Back to index


RUN (= ACQ, COUNT) starts counting with the current instrument setting.

RUN takes 0-4 parameters [defaults]

  1. Preset value [previous] - Requested duration in monitor or time units.
  2. Preset type [previous] - M : monitor, T (startup default) : time (sec).
  3. NTIMES [1] - Number of repetitions.
  4. SAVE/NOSAVE [S] - Storage/no storage of data on disk file.
   MAD:  RU[N] [Preset value] [Preset type] [Ntimes] [S[ave]/N[osave]] [cr]


   MAD:  RUN 1200 m 2 N [cr]
   MAD:  RUN [cr]                  repeat the same run


Performs simple scan on motor or attenuators (0 to 7). Used, for example, to search a peak in the detector intensity as function of sample position.

When used with the option ALIGN, the runs are not stored, and a line printer plot is created. When used without the option A, the runs are stored, and there is no line printer plot.


  MAD> SCAN motor_name start_value end_value step  COUNT parameters...  [align]

  MAD:  SCAN SAN 75.25 77 0.1 COUNT 1000 M NOSAVE
             scan on san from 75.25 to 77.00, increment of 0.1 for 1000/Monitor & no save

  MAD:  SCAN att 0 7 1 co 150 t nos align
                          attenuators 0 to 7
Back to index


Checks/defines the selector speed value.


   MAD:  SELECTOR SETPAR [cr]  set speed to default parameter values
   MAD:  SEL 2700 [cr]         set speed to 2700 rpm
   MAD:  SEL 2700 2 [cr]                "           with tolerance 2 rpm


Before starting an acquisition (with RUN) the instrument is set up by entering parameters with the PARAMETER command or by the PARAME task (see corresponding MAD topics).

Back to index


The START command (equivalence XBU) allows one to run a sequence of MAD commands in the form of an ASCII command file (see topic). The START command nests, i.e. it accepts START commands up to a depth of 9 levels.

The CIS command is identical to START, except that it does not nest, i.e. a new CIS command aborts the previous buffer file.

MAD echoes the command line, thus in

   MAD [ XBU1 ] (5) > COMMAND
"1" indicates the repetition level, and "5" indicates the line number in the command file.

Note that you can restart at a different line number after an interrupt.


   START [file.ext (default command.cmd)] [number_of_repetitions (1)]

Conditional commands

Some simple conditional functions exist under START.

If a command is preceded by the character '>', it will not be executed if the previous command was unsuccessful.

If a command is preceded by the character '<', it will be executed only if the previous command was unsuccessful.

"No success" is defined as angles outside limits, bad selector speed, etc. or any 'VME' error, including 'KILL' in PCP.


    commands:   det 15.50
    > det 15.50      no success, 2nd tentative
    < quit           no success, exit of the command file
    co 3000 m s      success, continue
                     ........ etc.
Back to index


Displays the instrument state: attenuators, collimation, selector, etc.


   MAD:  STATE [cr]    - four letters (STAT) are required


Cancels MAD commands (motor movements, acquisition, etc.). In the case of an acquisition, the data is stored if the acquisition was started with the "SAVE" option. A "NOSAVE" run can be saved with the SAVE option. usage:
   MAD:  STOP [cr]
   MAD:  STOP S[AVE] [cr]
   MAD:  STOP N[OSAVE] [cr]


Checks/defines the temperature value and tolerance (unit: Kelvin), via the ILLPTc controller. (equivalence: RTE, PTE).


   MAD:  TEMP [cr]
   MAD:  RTE [cr]
   MAD:  PTE  100.25 [cr]       set temperature to 100.25 K
   MAD:  PTE  100.25 600 [cr]   set temperature to 100.25 K;
                                wait for addidional 600 s.
Note: requires communication set-up (line-speed etc.) different from Eurotherm.

Back to index


see DATE


The WAIT command instructs the routines to pause a certain time (in sec).


   MAD:  WAIT 5        pauses 5 seconds
Note: Any PCP command interrupts a pause started with the WAIT command.


Allows one to execute commands at the system level


  MAD:  UNIX DTI [cr]       reads the temperature settings
  MAD:  unix ls *.cmd [cr]  directory of all command files
Back to index.


Checks/defines the wavelength value and tolerance. Choose the selector type and constants with the option SELECTOR of PARAMETER.


  MAD:  WAVE SETPAR [cr]      takes wavelength and tolerance as
                              defined by PARAMETER (option WAVELENGTH).
  MAD:  WAVE 6.32 0.001 [cr]  wavelength = 6.32 A, tolerance = 0.001
  MAD:  WAVE 6.32 [cr]        wavelength = 6.32 A, tolerance as defined
                              by PARAMETER (option WAVELENGTH).


equivalence: START

Back to index.

Back to the D22 home page.

Web document produced by Roland May, ILL Grenoble (last update: 03-Oct-2003)