This macro package is to use Mark Rivers' EPICS trajectory scan support for Newport MM4000/XPS controllers. It supports kappa and psic geometries. There is a spec interface by CARS, which is made specifically for their spec configurations and not easy portable. This package is based on the CARS macro(Thanks to Peter Eng who kindly provided the CARS macro), but it is extensively revised for general purpose usage.

Once a trajectory scan starts, the synchronization of motion and counting is all hardware controlled by using the motion controllers' sync pulses as the multichannel scaler's external channel advance signal. The macros defined in this package are only to calculate the complex trajectories( especially for these reciprocal space scans) using spec's built-in algorithm, load the calculated positions to the EPICS database. During the scan, spec can update and plot the on-going MCS counts from the array type EPICS records.  When the scan is completed (or aborted), spec saves the actual motor positions and MCS counts data in standard format the same as the a step scan does.

The hardware (Newport MM4005/XPS and SIS380x  MCS)  has to be properly configured and one need have the low level EPICS interface (trajectory SNL program and related database) working properly on an EPIC IOC  before you can use this macro. Details on trajectory scan EPICS support at here.


The motors for trajectory scans have to been configured in spec and they should be indicated as a trajectory scan motor. Included in the file are two examples made for 33-ID, i.e in EPICS the trajectory scan sequencer program is loaded as:

strcpy str, "P=nwp:,R=ts:,NAXES=6,NELM=1000,NPULSE=1000"
strcat str, ",DONPV=jfk:3820:EraseStart,DONV=1,DOFFPV=jfk:3820:StopAll,DOFFV=1"
dbLoadRecords("$(MOTOR)/motorApp/Db/trajectoryScan.db", str)

strcpy str, "P=nwp:,R=ts:"
strcat str, ",M1=m4k:c0:m1,M2=m4k:c0:m2,M3=m4k:c0:m3,M4=m4k:c0:m4"
strcat str, ",M5=m4k:c0:m5,M6=m4k:c0:m6,PORT=gpib1"
seq &MM4005_trajectoryScan, str

In spec (kappa geometry), these six motors are configured as  kphi, kap,kth,mu,tth and nu respectively.  So they should have the following in this macro file:

  TRAJ_MOTOR["kphi"] = TRAJ_PV "M1"
  TRAJ_MOTOR["kap"] = TRAJ_PV "M2"
  TRAJ_MOTOR["kth"] = TRAJ_PV "M3"
  TRAJ_MOTOR["mu"] = TRAJ_PV "M4"
  TRAJ_MOTOR["tth"] = TRAJ_PV "M5"
  TRAJ_MOTOR["nu"] = TRAJ_PV "M6"

  # geometry pseudo motors
  TRAJ_MOTOR["th"]  = "PSEUDO"
  TRAJ_MOTOR["chi"]  = "PSEUDO"
  TRAJ_MOTOR["phi"]  = "PSEUDO"

The last three are pseudo motors instead of real motors, but their values solely depend on one or several trajectory motors. Then they also need to be defined but assigning as "PSEUDO".

For EPICS support of the Struck SIS3820 MCS, it can be used either as regular scaler or MCS. In this case, if the scaler record for the MCS is configured as counter and timer in spec.  The macro "mcs_cntr_map" can automatically map the MCS channels PV to the scaler channels. You just need to assign the global variable TRAJ_MCS_PV to the PV prefix of the MCS scaler , i.e. for the above 33ID settings, it is "jfk:3820:".

If spec uses a different scaler (instead of the MCS) as the timer and counter devices, and the counting signals are "T"ed  into  the  MCS and the scaler, one has to manually match the the MCS channels and scaler channels. Here is  an example:

      MCS_CNTRS["sec"] =  "jfk:3820:mca1"
      MCS_CNTRS["I0"] =   "jfk:3820:mca2"
      TRAJ_MCS_CLOCK = 5.0e7  # set to the clock rate of the MCS not the regular scaler

By doing the counters/MCS channels mapping, the data columns in spec file will have the same meaning in both the trajectory scans and  the regular step scans.

When this file is loaded, it clones the original "_ascan", "mesh","hklscan","_hklmesh" and "_hklline" to "_ascan_step", "mesh_step","hklscan_step","_hklmesh_step" and "_hklline_step", so one can switch back to them when trajectory scan is turned off.

User Macros


          Defines _ascan mesh hklscan _hklmesh _hklline to use the trajectory mode.


          Defines _ascan mesh hklscan _hklmesh _hklline to use the spec standard definitions.


  Sets the trajectory scan switches:
        1) whether use the actual motor positions (for NM4005 controller, it uses relative longer time to transfer the actual positions)
    2) the update rate to plot the current data in spec.


         Lists all the trajectory scan related user macros. 


 Prints the trajectory motor mapping associative array TRAJ_MOTORS and the MCS-scaler mapping associative array MCS_CNTRS.

Internal Macros


A macro that is redefined inside _ascan_trj mesh_traj hklscan_traj _hklmesh_traj and _hklline_traj. See the following traj_savedata_xxxxx below.


        When traj_on is called, this replaces the standard _ascan. For all trajectory motors, the trajectory scan will be executed if possible. All other motors still use  step scan  mode "_ascan_step"( a clone of the standard _ascan)


        traj_savedata is defined with macro in _ascan_traj. traj_abort also calls this when the scan is aborted, to save the partly  data.


        When traj_on is called, this replaces the standard mesh.        


traj_savedata is defined with macro in mesh_traj.


        When traj_on is called, this replaces the standard hklscan.


        traj_savedata is defined with macro in hklscan_traj.


        When traj_on is called, this replaces the standard _hklmesh( called by hklmesh).


        traj_savedata is defined with macro in _hklmesh_traj.



       When traj_on is called, this replaces the standard _hklline( called by hkcircle klcirce hkradial etc).


       traj_savedata is defined with macro in _hklmesh_traj.


      Builds the trajectory  based on the calculated value. A empty hook macro "traj_build_extra" is provided where one can setting up extra stuff (i.e. the pilatus detector) here.


      Executes the trajectory scan, updates the spec plot during the scan. "pre_traj_exec" and "post_traj_exec" hooks are provided for use defined actions if needed.

For more information please contact Xuesong Jiao.