spec

Software for Diffraction

flyscan

Continuous Scans with Multichannel Scalers

DESCRIPTION

The fly-scan macros are similar to the cscan (continuous scan) macros in that counts are accumulated while a motor is in motion. With the continuous scans, the motor position is read on the fly, but is not strictly correlated with the counter reading. With the fly scans, counts are accumulated in an MCS (multi-channel scaler) device with the MCS channel advance controlled by pulses from the motor being swept. It is thus possible to associate the counts collected from each MCS channel with an accurate motor position.

There are macros for single-pass fly scans, mesh scans with one sweep motor and one motor that is stepped through a range, and 3D mesh scans where two motors are stepped through a mesh with the fly motor swept at each position:

flyscan mot start end intervals time
flymesh m0 s0 f0 intervals time m1 s1 f1 ints1
flymesh3d m0 s0 f0 intervals time m1 s1 f1 ints1 m2 s2 f2 ints2

flydscan mot relative_start relative_end intervals time
flydmesh m0 s0 f0 intervals time m1 s1 f1 ints1
flydmesh3d m0 s0 f0 intervals time m1 s1 f1 ints1 m2 s2 f2 ints2

The first three are absolute position scans. The second three are delta scans. The position arguments for the delta scans are relative positions The motors are returned to their starting positions at the end of the scan or if the scan is interrupted.

The first argument in each case is the fast motor followed by start and end positions, either absolute or relative. The intervals argument determines the number of channels allocated in the MCS (but is only relevant if the motor pulses can be prescaled). The time argument is either the time per channel or the elapsed time for the entire sweep, depending on a configuration option. The time is used to set the speed of the fly motor during the sweep.

The mesh and mesh3D scans step one or two other motors. The fly motor is swept at each step. By default, the fly motor will alternate sweep directions at each step, but a flag is available to make the sweeps all in the same direction.

The motor speed will be adjusted to accommodate the time argument, but no higher than the steady-state rate in the config file. If the sweep speed is higher than the base rate, the base rate will be set to half the sweep speed. Backlash is set to zero for the sweep motor during the scans. The speeds and backlash are restored at the end of the scan or if the scan is interrupted. However, there is no backlash correction done on the fly motor after the final sweep for absolute position scans.

The macros adjust the start and end positions of the swept motor to extend one half the distance of a single channel in order to center each motor position in the center of the MCS count bins.

In addition, a motorless loopscan-like flyscan can be invoked using:

flyscan intervals time

where, again, the time argument is either the time per channel or the elapsed time for the entire sweep, depending on a configuration option. This version of the scan uses the internal time base of the MCS to generate the calculated dwell time and simply accumulates counts over the specified time period.

The current macros are designed around the Measurement Computing USB-CTR4/USB-CTR8 counter/timers modules, originally supported by spec only as a counter/timer, but now also as an MCS device. The same module can be used as a counter/timer and as an MCS in the same spec session, but only in one mode at a time. The same counters and hardware configuration can be maintained for both regular counting and fly scans.

The fly_setup macro configures the acquisition parameters for all the scans. Some of the options reflect the particular capabilities and limitations of the USB-CTR. Data can be collected from multiple counters on the USB-CTR, but the counter channels must be consecutive. Conventionally, the first channel (channel 0) will be connected to the output of timer 0, which is programmed by spec to generate a 1 MHz signal.

The last channel (channel 7 on the 8-channel device) is conveniently used as the prescale counter and is not included in the data collection. The motor pulses connect to the counter input (C7IN) and the counter output (C7O) is connected to the CLKI pin, which is the MCS mode external channel advance. Hardware limitations require a minimum prescale value of two. If the scan range and configured motor pulse value results in too small a needed prescale, the macros either adjust the number of intervals to accommodate that minimum or abort the scan altogether, depending on a configuration option.

The macros include a fly_chk_beam macro, which can be used along the lines of the standard chk_beam macro to pause the scan if the source is down. The provided macro tests the state of a DIO bit on the USB-CTR to see if the source is down. The check is performed after an MCS sweep. If the DIO bit is set at the end of the sweep, the scan pauses until the bit is clear, at which point the sweep is repeated.

The fly scan macros invoke the standard scan_head and scan_loop macros, which default to the standard _head and _loop definitions. The standard _head and _loop macros now include special code to write to the data file for fly scans. After each sweep, the MCS data is read directly into the SCAN_D data array, which has been allocated to accommodate the motors and counters involved in the scan. Unlike the rest of the standard scans, the fly scans do not include the value of EPOCH in the data rows of the data file.

The fly scans redefine scan_count to put average values of the MCS counters into the S[] scaler array for the screen display.

Additional counters in a list FLY_other_counters will be included in the data file and screen display. These counters are read after a complete sweep is made. Each row of the data file will contain the same value for such counters for a particular sweep. One might define a macro hardware counter to be included that contains the number of intervals in the sweep as read from the MCS at the end of the sweep.

The macros disable all counters not included in the fly scan or the "other counters" list for the duration of the scan.

The fly setup macro includes an option to select a channel to use for normalization of the counts in the other channels. Conventionally, the 1 MHz signal from timer 0 is connected to one of the counter inputs and that channel can be used. Normalization can correct for uneven count times due to motor acceleration and deceleration at the start and end of the sweeps.

INTERNAL MACROS

fly_setup prompts user for various configurable parameters using spec_menu().

The macro automatically detects the unit number for the USB-CTR and finds the matching counters assigned to USB-CTR by using the "controller" ID string and the USB-CTR serial number.

_fly_prep parses and expands arguments for all the fly scans. By using a regular macro rather than a macro function, local variables used in the arguments will retain their values. All arguments are evaluated with eval().

Local variables in _fly_prep have a prepended underscore in at attempt to avoid conflict with more naturally named variables in the calling code.

Once arguments are expanded and global variables set, the _flyscan() macro function does the work.

fly_normalize() is called if FLY_normalize_chan is set. It is assumed that is a channel of the USB-CTR connected to a clock. To avoid a divide by zero, the macro eliminates zeroes at the beginning and end of the data array, but will still fail if there are zeroes in the middle.

These global variables used by the fly-scan macros preserve state to allow cleanup macros to restore motor parameters and the enabled status of counters. The variables also enable one to use the resume macro to restart aborted scans.

_fly_scan_loop() and _fly_scan_on() are macro functions that contain the scan_loop and _scan_on macros in in order for the updated definitions of those macro to be parsed. (Macro functions are parsed when invoked.)

_fly_count assigns values to scalers in S[]. Currently using the average value normalized by the elapsed channels in the MCS. The scan_count macro gets redefined to _fly_count for the fly scans.

_fly_set_cleanup() installs cleanup macro. The argument is 1 on the first call when the scan initializes. The argument is 0 if called during a resume to restart an aborted macro.

_fly_start_position() moves motors to start position. It is a separate macro so that it can be called on resume to restart scans.

_flyscan() does the scanning.

flyscan_cleanup() clears the trigger bit (if used), re-enables any counters disabled for the scan, and restores the motor parameters. A separate dscan_cleanup() will move motors to starting positions if it was a delta scan. If not a dscan, a message reminds the user that the fly motor hasn't had a backlash correction.

GLOBALS

FLY_unit - MCA unit number

FLY_first_chan - First USB-CTR channel (0-7)

FLY_last_chan - Last USB-CTR channel (0-7)

FLY_prescale_chan - Prescaler channel (0-7 or -1)

FLY_normalize_chan - Prescaler channel (0-7 or -1)

FLY_motor - Motor mnemonic to sweep

FLY_mot_steps_per - Motor steps per degree of fly motor

FLY_trigger_bit - Optional DIO bit for triggering (-1 to disable)

FLY_check_bit - Optional DIO bit for checkbeam signal (-1 to disable)

FLY_counter_list - String list of counter mnemonics on USB-CTR

FLY_other_counters - String list of non USB-CTR counters to enable

FLY_unidirectional - If nonzero, sweep in same direction during mesh

FLY_use_scan_time - If set, time argument is for whole sweep

FLY_adjust_bins - If set, adjust number of bins if impossible prescale

FLY_use_intervals - If set, use intervals, otherwise use pitch

_fly_speed_save - Fly motor speed to restore on cleanup

_fly_speed_use - Fly motor speed to use during sweep

_fly_base_save - Fly motor base rate to restore on cleanup

_fly_base_use - Fly motor base rate to use during sweep

_fly_backlash_save - Fly motor backlash to restore on cleanup

_fly_scan_count_save - Saved definition of scan_count to restore on cleanup

_fly_ticker - Ticker for bidirectional mesh moves

_fly_intervals - Number of intervals in sweep

_fly_pitch - Size of each sweep interval

_fly_cleanup_save - Saved definition of cleanup macro

_fly_disable_save[] - Saved enabled motor list to restore on cleanup

_fly_is_dscan - Flag set if a delta scan

_fly_SCAN_D_cols[] - Column numbers in SCAN_D indexed by USB-CTR counter number

MACROS

fly_setup

fly_chan_config(mne, type, unit, module, chan)

fly_chan_cmd(mne, key, p1, p2)

flyscan

flydscan

flymesh

flydmesh

_fly_prep

fly_normalize()

fly_chk_beam

_fly_scan_loop()

_fly_scan_on()

_fly_count

_fly_setup_cleanup(how)

_fly_start_position()

_flyscan()

flyscan_cleanup()



Warning: Undefined array key "related" in /home1/josetxoc/public_html/certif/functions.php on line 298