CCDScan.mac

Description

This package contains macros that allow spec to trigger a CCD detector and save the images during spec scans. The CCD must be controlled  by Brian Tieman's CCD Image Server Program, and spec talks to the  CCD through this Portable Channel Access Server. See Brian Tieman's  documentation for details on the Image Server Program.

If this package is freshly loaded in spec, it asks some questions on how the detector is triggered. The user is responsible to select the trigger mode. The default mode is internal trigger (or Image On Demand as shown in the CCD Image Server console). If an external shutter is used,  for example, a delay generator to synchronize the shutter open/close and the acquisition,  the user need to give the PVs that controls the shutter and the delay generator. Should you use a different external shutter machanism, please modify the preliminary setup code and the ccdset_shutter macro accordingly.

This package allows the user to select an CCD ROI as a spec pseudo counter, so the ROI's average value can be monitored from the scan plot during  a scan.  If the user wants to use this feature, a pseudo counter named "ccdc" has to be configured priorly with the  config command.  The device type must be NONE. Please refer to the spec help page for details on the pseudo counters. 

The user is also responsible to implement two macros: "ccd_blockbeam" that prevents x-rays from hitting the camera and "ccd_showbeam" that allows x-ray to reach the camera during acquisition, which are required if one needs to take dark images. These two macros could vary at different experimental stations. Thus they are left blank and should be assigned by the user.

User Macros

ccdsetup

          ccdsetup lets users to input the EPICS PV prefix of the Image Server, the data directory on the Windows machine, the saved ROI number and the counter ROI number.

ccdinfo

          ccdinfo displays the CCD Image Server  configurations.

setccdc

          SYNOPSIS
    setccdc RXX  (RXX is the ROI number,  i.e. R02)

   
setccdc sets which ROI will be the pseudo counter ccdc.

ccdset_saved_roi

          SYNOPSIS
    ccdset_saved_roi RXX  (RXX is the ROI number,  i.e. R01)

   
ccdset_saved_roi sets which ROI will be saved as the image files.
  

ccd_addcolumn

        SYNOPSIS
        ccd_addcolumn RXX
        
        ccd_addcolumn adds RXX as a data column in the spec file.

ccd_rmcolum

        SYNOPSIS
        ccd_rmcolum RXX (or all)
       
        ccd_rmcolumn removes RXX from the spec data columns. If the parameter is all,  all ccd ROI columns are removed.

ccdscan_setup

        SYNOPSIS
        ccdscan_setup  (interactive mode)
   ccdscan_setup save_flag #throws #darks #repeats_per_point (quiet mode)

  
        ccdscan_setup lets the user to set four parameters that define to the ccdscan: 1) save images to disk or not; 2)  how many images to throw away before the scan starts ; 3) how many dark images to take at the begining; 4) how many images to take at each scan point.   Interactive mode and quite mode are supported.


ccdscan

       SYNOPSIS
   ccdscan  any_spec_scan_macro and its parametes  ( i..e ccdscan ascan th -1 1 20 1 0.1)


       ccdscan trigger the camera at each scan point, wait the ccd aquisition until it's finished, and move to the next point, The name of the saved images are based on the spec data file name, the scan number and the number of the repeats at each scan point. Please see the examples below.

ccdhelp

     ccdhelp displays all user macros of this package and the URL to the BCDA spec support page.   

Examples

The following examples are using the Software Emulator Camera on the CCD Image Server program, and 3 ROIs are created.

On startup:


1.SPEC> qdo ccdscan_1.0.mac
Reading file "/home/oxygen9/JIAOX/BCDA/macros/generic/ccdscan_1.0.mac".
Reading file "/home/oxygen9/JIAOX/BCDA/macros/generic/uspec_column.mac" (level 2).
 
This BCDA package allows spec to control the CCD Image Server!
 
You need to answer some questions first.
Do you use the exteral trigger from a delay generator to control the CCD? (NO)?
 
Setup a pseudo counter(ccdc) to monitor some ROIS (its average value) from spec? (YES)?
Found a counter named ccdc.
Seems that you have already configured a pseudo counter(None type).
 
Please use ccdsetup to configure the image server settings.
You need define ccd_blockbeam ccd_showbeam macro if you need to take dark images.
For more help on this package, please use ccdhelp.

Connect to the CCD Image Server

2.SPEC> ccdsetup
The EPICS prefix of the CCD device: (TST:CCD)? jiao:ccd
The windows directory where the Image Server saves the data: (C:\data\)?
Use IMM file format (NO)?
Saved ROI#(1-50) i.e. R01 (R01)?
ROI# for the counter ("none" to not use) (R02)?
 
jiao:ccd is configured
================================================================
CCDManufacturer: Brian Tieman
CCDModel: Software Emulator
CCDChip Temperature: 0C
ADCSpeed: Slow ADC
BinX: 1
BinY: 1
CameraMode: Normal
Data home: C:\data\
Saved ROI: jiao:ccd.R01
CCD pseudo counter: jiao:ccd.R02
================================================================


Change the  saved ROI and the counter ROI

3.SPEC> ccdset_saved_roi R02
 
4.SPEC> setccdc R01


Show Current configuration

5.SPEC> ccdinfo
================================================================
CCDManufacturer: Brian Tieman
CCDModel: Software Emulator
CCDChip Temperature: 0C
ADCSpeed: Slow ADC
BinX: 1
BinY: 1
CameraMode: Normal
Data home: C:\data\
Saved ROI: jiao:ccd.R02
CCD pseudo counter: jiao:ccd.R01
================================================================
 

Show help information

6.SPEC> ccdhelp
 
User macros for the BCDA ccd package
        ccdsetup
        ccdinfo
        ccdset_saved_roi
        setccdc
        ccd_addcolumn
        ccd_rmcolumn
        ccdscan_setup
        ccdscan
See "http://www.aps.anl.gov/APS_Engineering_Support_Division/Beamline_Controls_and_Data_Acquisition/spec/APSMacros.php" for more help


Add two ROIs to the data column

7.SPEC> ccd_addcolumn R02
R02 will be saved to the data file
 
Columns defined as pieces of identifier:ccdroi
R02 :  epics_get("jiao:ccd.R02.Average")  :  %.8g
 
8.SPEC> ccd_addcolumn R03
R03 will be saved to the data file
 
Columns defined as pieces of identifier:ccdroi
R03 :  epics_get("jiao:ccd.R03.Average")  :  %.8g
R02 :  epics_get("jiao:ccd.R02.Average")  :  %.8g


Remove one ROI from the data column

9.SPEC> ccd_rmcolumn R02
R02 is  not saved to the data file anymore



Set up the ccdscan 

10.SPEC> ccdscan_setup
Save images during scan? (YES)?
Number of images to throw at the begining: (0)? 2
Number of darks to take at the begining: (0)? 5
Number of imgages per scan point: (1)?
 

Do a ccdscan

34.SPEC> plotselect
Select from following list:
    sec:D     mon:M    ccdc
Counters to plot (det)? ccdc
 
35.SPEC> counters
 
Current counter configuration:
 
Num           Name  Mnemonic
 0         Seconds  sec     <- Assigned to DET
 1         Monitor  mon     <- Assigned to MON
 2            ccdc  ccdc
 
Counter number for monitor, -1 disables (1)? -1
Counter number for detector (0)? 2
 
Note:  Use "plotselect" to choose which counters to plot.
 
36.SPEC> ccdscan ascan th 0 1 10 1
 
Now the beam is blocked or attenuated, so no x-ray hits the camera during acquisition
You need to implement this for your specific setup
 
The CCD is taking 2 images and throw them away.
 
Writing CCD infomation to spec data file
 
Now the beam is blocked or attenuated, so no x-ray hits the camera during acquisition
You need to implement this for your specific setup
 
Taking 5 darks
 
Now the beam is allowed to hit the camera during acquisition
You need to implement this for your specific setup
Total 11 points, 11 seconds
 
Scan   2   Mon Jan 30 14:02:29 2006   file = test  spec  user = jiaox
ascan  th 0 1  10 1
 
  #        th     ccdc    Seconds  Monitor
  0    0.0000  1411.98          1        0
  1    0.1000  2845.57          1        0
  2    0.2000  3460.99          1        0
  3    0.3000  4014.03          1        0
  4    0.4000  5510.38          1        0
  5    0.5000  7014.62          1        0
  6    0.6000   7555.6          1        0
  7    0.7000  8051.39          1        0
  8    0.8000  9444.74          1        0
  9    0.9000  9102.64          1        0
 10    1.0000  9612.93          1        0

 

The image files  are in C:\data\test_2, and the names are

test_2_dark00001
...
test_2_dark00005
test_2_0000_00001
...
test_2_0010_00001

The spec data file


#C Mon Jan 30 14:02:17 2006 ccdscan is turned on
 
#CCD ccdscan 2
#CCD save_flag 1
#CCD image_dir C:\data\test_2
#CCD repeats_per_point 1
#CCD dark 5
#CCD saved_roi jiao:ccd.R02 50 50 2 3
#CCD counter_roi jiao:ccd.R01 1 1 1024 1024
#S 2  ascan  th 0 1  10 1
#D Mon Jan 30 14:02:29 2006
#T 1  (Seconds)
#G0 0
#G1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#G3 0 0 0 0 0 0 0 0 0
#G4 0
#Q
#P0 1
#N 6
#L th    R03  Epoch  Seconds  Monitor  ccdc
0  26624 434 1 0 1411.9824
0.1  27648 437 1 0 2845.5703
0.2  28672 440 1 0 3460.9883
0.3  29696 443 1 0 4014.0312
0.4  30720 446 1 0 5510.377
0.5  31744 449 1 0 7014.625
0.6  32768 452 1 0 7555.6016
0.7  33792 455 1 0 8051.3945
0.8  34816 458 1 0 9444.7383
0.9  35840 461 1 0 9102.6367
1  36864 464 1 0 9612.9258
 
#C Mon Jan 30 14:03:02 2006 ccdscan is turned off